Stage 1 of the GIS Analytical Tools concept — client-side spatial analysis: - src/analysis/overlay.js: vector overlays (intersect / clip / difference / union-dissolve) on Turf.js, reprojecting to WGS84 and merging attributes (intersect keeps both layers', clip keeps only A's). - src/analysis/zonal.js: vector-in-vector zonal statistics — count / sum / mean / min / max / total area per zone, with centroid-in-zone (default) or any-overlap membership. - Bounding-box pre-filtering in both: only genuinely overlapping pairs reach the expensive geometry test. 43 zones x 25,004 parcels now completes in ~106 ms; previously it was refused as too large. - src/analysis-modal.js + markup: Analysis panel with "Apply to" scoping — whole layer, current map view, selected features, or the catch of a drawn Circle/Area. Reached from a new "Analyse" dock button. - MapView.addCOGLayer() for Cloud-Optimized GeoTIFF display (WebGLTile + GeoTIFF source, imported lazily); listVectorLayers(); getSelectedFeatures(). - Circle/Area analysis popup: one "Export" button (PDF folded into the export modal as a fourth format, field-rename table hidden for it) plus an "Analyse" button that opens the panel pre-scoped to the intersecting features. - vite.config.js: code-split turf, geotiff and pako so the eager bundle is unchanged (~283 kB). Giving pako its own chunk also fixes a circular chunk between jspdf and geotiff, which share it via fast-png. Drawing-tool fixes carried in the same working tree: - Delete/Backspace key deletes the selection via the EditBar's Delete interaction (same undoable block as the button). - Multi-select: shift-click toggles, Ctrl/Cmd-drag box-selects; helper layers (vertex overlay, GPS) excluded. - Undo: split/merge/divide wrapped in undo blocks so one press reverses the whole operation; vertex-overlay churn no longer pollutes the undo stack; sources are re-scanned and the stack cleared when edit mode is entered, so deletes on sub-grouped layers are undoable. NOTE: the undo behaviour is not yet confirmed on-device. - ol-ext TouchCursor gated to touch-only devices, so hybrid touchscreen laptops keep the normal cursor. Service worker v12 -> v13. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
646 lines
550 KiB
JavaScript
646 lines
550 KiB
JavaScript
const Le={ADD:"add",REMOVE:"remove"},jn={PROPERTYCHANGE:"propertychange"},Z={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class Ks{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function If(n,e,t){let i,s;t=t||Gt;let r=0,o=n.length,a=!1;for(;r<o;)i=r+(o-r>>1),s=+t(n[i],e),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function Gt(n,e){return n>e?1:n<e?-1:0}function ru(n,e){return n<e?1:n>e?-1:0}function dl(n,e,t){if(n[0]<=e)return 0;const i=n.length;if(e<=n[i-1])return i-1;if(typeof t=="function"){for(let s=1;s<i;++s){const r=n[s];if(r===e)return s;if(r<e)return t(e,n[s-1],r)>0?s-1:s}return i-1}if(t>0){for(let s=1;s<i;++s)if(n[s]<e)return s-1;return i-1}if(t<0){for(let s=1;s<i;++s)if(n[s]<=e)return s;return i-1}for(let s=1;s<i;++s){if(n[s]==e)return s;if(n[s]<e)return n[s-1]-e<e-n[s]?s-1:s}return i-1}function Af(n,e,t){for(;e<t;){const i=n[e];n[e]=n[t],n[t]=i,++e,--t}}function oe(n,e){const t=Array.isArray(e)?e:[e],i=t.length;for(let s=0;s<i;s++)n[n.length]=t[s]}function jt(n,e){const t=n.length;if(t!==e.length)return!1;for(let i=0;i<t;i++)if(n[i]!==e[i])return!1;return!0}function Lf(n,e,t){const i=e||Gt;return n.every(function(s,r){if(r===0)return!0;const o=i(n[r-1],s);return!(o>0||o===0)})}function Li(){return!0}function Jn(){return!1}function Ds(){}function ou(n){let e,t,i;return function(){const s=Array.prototype.slice.call(arguments);return(!t||this!==i||!jt(s,t))&&(i=this,t=s,e=n.apply(this,arguments)),e}}function fl(n){function e(){let t;try{t=n()}catch(i){return Promise.reject(i)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function tn(n){for(const e in n)delete n[e]}function Ki(n){let e;for(e in n)return!1;return!e}class Pt{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Qn extends Ks{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const i=this.listeners_||(this.listeners_={}),s=i[e]||(i[e]=[]);s.includes(t)||s.push(t)}dispatchEvent(e){const t=typeof e=="string",i=t?e:e.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=t?new Pt(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=s.length;h<c;++h)if("handleEvent"in s[h]?l=s[h].handleEvent(r):l=s[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Ds);delete o[i]}return l}disposeInternal(){this.listeners_&&tn(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,t){if(!this.listeners_)return;const i=this.listeners_[e];if(!i)return;const s=i.indexOf(t);s!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(i[s]=Ds,++this.pendingRemovals_[e]):(i.splice(s,1),i.length===0&&delete this.listeners_[e]))}}function ee(n,e,t,i,s){if(s){const o=t;t=function(a){return n.removeEventListener(e,t),o.call(i??this,a)}}else i&&i!==n&&(t=t.bind(i));const r={target:n,type:e,listener:t};return n.addEventListener(e,t),r}function Ur(n,e,t,i){return ee(n,e,t,i,!0)}function ue(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),tn(n))}class Hs extends Qn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(Z.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const i=e.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=ee(this,e[r],t);return s}return ee(this,e,t)}onceInternal(e,t){let i;if(Array.isArray(e)){const s=e.length;i=new Array(s);for(let r=0;r<s;++r)i[r]=Ur(this,e[r],t)}else i=Ur(this,e,t);return t.ol_key=i,i}unInternal(e,t){const i=t.ol_key;if(i)Ff(i);else if(Array.isArray(e))for(let s=0,r=e.length;s<r;++s)this.removeEventListener(e[s],t);else this.removeEventListener(e,t)}}Hs.prototype.on;Hs.prototype.once;Hs.prototype.un;function Ff(n){if(Array.isArray(n))for(let e=0,t=n.length;e<t;++e)ue(n[e]);else ue(n)}function W(){throw new Error("Unimplemented abstract method.")}let bf=0;function O(n){return n.ol_uid||(n.ol_uid=String(++bf))}class kh extends Pt{constructor(e,t,i){super(e),this.key=t,this.oldValue=i}}class bt extends Hs{constructor(e){super(),this.on,this.once,this.un,O(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,t){let i;i=`change:${e}`,this.hasListener(i)&&this.dispatchEvent(new kh(i,e,t)),i=jn.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new kh(i,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,i){const s=this.values_||(this.values_={});if(i)s[e]=t;else{const r=s[e];s[e]=t,r!==t&&this.notify(e,r)}}setProperties(e,t){for(const i in e)this.set(i,e[i],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){const i=this.values_[e];delete this.values_[e],Ki(this.values_)&&(this.values_=null),t||this.notify(e,i)}}}const Uh={LENGTH:"length"};class cr extends Pt{constructor(e,t,i){super(e),this.element=t,this.index=i}}class qe extends bt{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e??[],this.unique_)for(let i=1,s=this.array_.length;i<s;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,i=e.length;t<i;++t)this.push(e[t]);return this}forEach(e){const t=this.array_;for(let i=0,s=t.length;i<s;++i)e(t[i],i,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(Uh.LENGTH)}insertAt(e,t){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new cr(Le.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let i=0,s=t.length;i<s;++i)if(t[i]===e)return this.removeAt(i)}removeAt(e){if(e<0||e>=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new cr(Le.REMOVE,t,e)),t}setAt(e,t){const i=this.getLength();if(e>=i){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const s=this.array_[e];this.array_[e]=t,this.dispatchEvent(new cr(Le.REMOVE,s,e)),this.dispatchEvent(new cr(Le.ADD,t,e))}updateLength_(){this.set(Uh.LENGTH,this.array_.length)}assertUnique_(e,t){const i=this.array_;for(let s=0,r=i.length;s<r;++s)if(i[s]===e&&s!==t)throw new Error("Duplicate item added to a unique collection")}}class vn extends Pt{constructor(e,t,i){super(e),this.map=t,this.frameState=i!==void 0?i:null}}class Jt extends vn{constructor(e,t,i,s,r,o){super(e,t,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(e){this.pixel_=e}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(e){this.coordinate_=e}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ne={SINGLECLICK:"singleclick",CLICK:Z.CLICK,DBLCLICK:Z.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Hi=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Mf=Hi.includes("safari")&&!Hi.includes("chrom"),Df=Mf&&(Hi.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Hi)),Of=Hi.includes("webkit")&&!Hi.includes("edge"),gl=Hi.includes("macintosh"),Nf=typeof devicePixelRatio<"u"?devicePixelRatio:1,st=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,au=typeof Image<"u"&&Image.prototype.decode,Gf=typeof createImageBitmap=="function",lu=(function(){let n=!1;try{const e=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return n})(),Aa={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class kf extends Qn{constructor(e,t){super(e),this.map_=e,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=t===void 0?1:t,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=ee(i,Aa.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=ee(i,Aa.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(Z.TOUCHMOVE,this.boundHandleTouchMove_,lu?{passive:!1}:!1)}emulateClick_(e){let t=new Jt(ne.CLICK,this.map_,e);this.dispatchEvent(t),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,t=new Jt(ne.DBLCLICK,this.map_,e),this.dispatchEvent(t)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new Jt(ne.SINGLECLICK,this.map_,e);this.dispatchEvent(i)},250)}updateActivePointers_(e){const t=e,i=t.pointerId;if(t.type==ne.POINTERUP||t.type==ne.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==t.target){delete this.trackedTouches_[s];break}}else(t.type==ne.POINTERDOWN||t.type==ne.POINTERMOVE)&&(this.trackedTouches_[i]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new Jt(ne.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new Jt(ne.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(ee(i,ne.POINTERMOVE,this.handlePointerMove_,this),ee(i,ne.POINTERUP,this.handlePointerUp_,this),ee(this.element_,ne.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(ee(this.element_.getRootNode(),ne.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new Jt(ne.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Jt(ne.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(ue(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(Z.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ue(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Qt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},je={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},D={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function se(n,e){if(!n)throw new Error(e)}const Br=1/0;class Uf{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,tn(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,i=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(e){se(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=Br?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,i=this.priorities_,s=t.length,r=t[e],o=i[e],a=e;for(;e<s>>1;){const l=this.getLeftChildIndex_(e),h=this.getRightChildIndex_(e),c=h<s&&i[h]<i[l]?h:l;t[e]=t[c],i[e]=i[c],e=c}t[e]=r,i[e]=o,this.siftDown_(a,e)}siftDown_(e,t){const i=this.elements_,s=this.priorities_,r=i[t],o=s[t];for(;t>e;){const a=this.getParentIndex_(t);if(s[a]>o)i[t]=i[a],s[t]=s[a],t=a;else break}i[t]=r,s[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,i=this.priorities_;let s=0;const r=t.length;let o,a,l;for(a=0;a<r;++a)o=t[a],l=e(o),l==Br?delete this.queuedElements_[this.keyFunction_(o)]:(i[s]=l,t[s++]=o);t.length=s,i.length=s,this.heapify_()}}class Bf extends Uf{constructor(e,t){super(i=>e.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){const t=super.enqueue(e);return t&&e[0].addEventListener(Z.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){const t=e.target,i=t.getState();if(i===D.LOADED||i===D.ERROR||i===D.EMPTY){i!==D.ERROR&&t.removeEventListener(Z.CHANGE,this.boundHandleTileChange_);const s=t.getKey();s in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[s],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let i=0;for(;this.tilesLoading_<e&&i<t&&this.getCount()>0;){const s=this.dequeue()[0],r=s.getKey();s.getState()===D.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,s.load())}}}function zf(n,e,t,i,s){if(!n||!(t in n.wantedTiles)||!n.wantedTiles[t][e.getKey()])return Br;const r=n.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(s)+Math.sqrt(o*o+a*a)/s}const de={ANIMATING:0,INTERACTING:1},It={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function _e(n,e,t){return Math.min(Math.max(n,e),t)}function Xf(n,e,t,i,s,r){const o=s-t,a=r-i;if(o!==0||a!==0){const l=((n-t)*o+(e-i)*a)/(o*o+a*a);l>1?(t=s,i=r):l>0&&(t+=o*l,i+=a*l)}return ni(n,e,t,i)}function ni(n,e,t,i){const s=t-n,r=i-e;return s*s+r*r}function jf(n){const e=n.length;for(let i=0;i<e;i++){let s=i,r=Math.abs(n[i][i]);for(let a=i+1;a<e;a++){const l=Math.abs(n[a][i]);l>r&&(r=l,s=a)}if(r===0)return null;const o=n[s];n[s]=n[i],n[i]=o;for(let a=i+1;a<e;a++){const l=-n[a][i]/n[i][i];for(let h=i;h<e+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}const t=new Array(e);for(let i=e-1;i>=0;i--){t[i]=n[i][e]/n[i][i];for(let s=i-1;s>=0;s--)n[s][e]-=n[s][i]*t[i]}return t}function Bh(n){return n*180/Math.PI}function Ct(n){return n*Math.PI/180}function si(n,e){const t=n%e;return t*e<0?t+e:t}function lt(n,e,t){return n+t*(e-n)}function es(n,e){const t=Math.pow(10,e);return Math.round(n*t)/t}function zh(n,e){return Math.round(es(n,e))}function ur(n,e){return Math.floor(es(n,e))}function dr(n,e){return Math.ceil(es(n,e))}function La(n,e,t){if(n>=e&&n<t)return n;const i=t-e;return((n-e)%i+i)%i+e}function Xh(n,e,t){return(function(i,s,r,o,a){if(!i)return;if(!s&&!e)return i;const l=e?0:r[0]*s,h=e?0:r[1]*s,c=a?a[0]:0,u=a?a[1]:0;let d=n[0]+l/2+c,f=n[2]-l/2+c,g=n[1]+h/2+u,_=n[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>_&&(g=(_+g)/2,_=g);let m=_e(i[0],d,f),y=_e(i[1],g,_);if(o&&t&&s){const p=30*s;m+=-p*Math.log(1+Math.max(0,d-i[0])/p)+p*Math.log(1+Math.max(0,i[0]-f)/p),y+=-p*Math.log(1+Math.max(0,g-i[1])/p)+p*Math.log(1+Math.max(0,i[1]-_)/p)}return[m,y]})}function $f(n){return n}const Ge={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Be(n){const e=Qe();for(let t=0,i=n.length;t<i;++t)Ss(e,n[t]);return e}function Wf(n,e,t){const i=Math.min.apply(null,n),s=Math.min.apply(null,e),r=Math.max.apply(null,n),o=Math.max.apply(null,e);return zt(i,s,r,o,t)}function ai(n,e,t){return t?(t[0]=n[0]-e,t[1]=n[1]-e,t[2]=n[2]+e,t[3]=n[3]+e,t):[n[0]-e,n[1]-e,n[2]+e,n[3]+e]}function hu(n,e){return e?(e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e):n.slice()}function nn(n,e,t){let i,s;return e<n[0]?i=n[0]-e:n[2]<e?i=e-n[2]:i=0,t<n[1]?s=n[1]-t:n[3]<t?s=t-n[3]:s=0,i*i+s*s}function li(n,e){return _l(n,e[0],e[1])}function Ti(n,e){return n[0]<=e[0]&&e[2]<=n[2]&&n[1]<=e[1]&&e[3]<=n[3]}function _l(n,e,t){return n[0]<=e&&e<=n[2]&&n[1]<=t&&t<=n[3]}function Fa(n,e){const t=n[0],i=n[1],s=n[2],r=n[3],o=e[0],a=e[1];let l=Ge.UNKNOWN;return o<t?l=l|Ge.LEFT:o>s&&(l=l|Ge.RIGHT),a<i?l=l|Ge.BELOW:a>r&&(l=l|Ge.ABOVE),l===Ge.UNKNOWN&&(l=Ge.INTERSECTING),l}function Qe(){return[1/0,1/0,-1/0,-1/0]}function zt(n,e,t,i,s){return s?(s[0]=n,s[1]=e,s[2]=t,s[3]=i,s):[n,e,t,i]}function ts(n){return zt(1/0,1/0,-1/0,-1/0,n)}function Cs(n,e){const t=n[0],i=n[1];return zt(t,i,t,i,e)}function ml(n,e,t,i,s){const r=ts(s);return cu(r,n,e,t,i)}function qi(n,e){return n[0]==e[0]&&n[2]==e[2]&&n[1]==e[1]&&n[3]==e[3]}function pl(n,e){return e[0]<n[0]&&(n[0]=e[0]),e[2]>n[2]&&(n[2]=e[2]),e[1]<n[1]&&(n[1]=e[1]),e[3]>n[3]&&(n[3]=e[3]),n}function Ss(n,e){e[0]<n[0]&&(n[0]=e[0]),e[0]>n[2]&&(n[2]=e[0]),e[1]<n[1]&&(n[1]=e[1]),e[1]>n[3]&&(n[3]=e[1])}function cu(n,e,t,i,s){for(;t<i;t+=s)Yf(n,e[t],e[t+1]);return n}function Yf(n,e,t){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}function yl(n,e){let t;return t=e(ho(n)),t||(t=e(co(n)),t)||(t=e(uo(n)),t)||(t=e(Xt(n)),t)?t:!1}function Os(n){let e=0;return Di(n)||(e=te(n)*Ie(n)),e}function ho(n){return[n[0],n[1]]}function co(n){return[n[2],n[1]]}function Fi(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function Vf(n,e){let t;if(e==="bottom-left")t=ho(n);else if(e==="bottom-right")t=co(n);else if(e==="top-left")t=Xt(n);else if(e==="top-right")t=uo(n);else throw new Error("Invalid corner");return t}function ba(n,e,t,i,s){const[r,o,a,l,h,c,u,d]=xl(n,e,t,i);return zt(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),s)}function xl(n,e,t,i){const s=e*i[0]/2,r=e*i[1]/2,o=Math.cos(t),a=Math.sin(t),l=s*o,h=s*a,c=r*o,u=r*a,d=n[0],f=n[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function Ie(n){return n[3]-n[1]}function We(n,e,t){const i=t||Qe();return Pe(n,e)?(n[0]>e[0]?i[0]=n[0]:i[0]=e[0],n[1]>e[1]?i[1]=n[1]:i[1]=e[1],n[2]<e[2]?i[2]=n[2]:i[2]=e[2],n[3]<e[3]?i[3]=n[3]:i[3]=e[3]):ts(i),i}function Xt(n){return[n[0],n[3]]}function uo(n){return[n[2],n[3]]}function te(n){return n[2]-n[0]}function Pe(n,e){return n[0]<=e[2]&&n[2]>=e[0]&&n[1]<=e[3]&&n[3]>=e[1]}function Di(n){return n[2]<n[0]||n[3]<n[1]}function Zf(n,e){return e?(e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e):n}function Kf(n,e){const t=(n[2]-n[0])/2*(e-1),i=(n[3]-n[1])/2*(e-1);n[0]-=t,n[2]+=t,n[1]-=i,n[3]+=i}function Hf(n,e,t){let i=!1;const s=Fa(n,e),r=Fa(n,t);if(s===Ge.INTERSECTING||r===Ge.INTERSECTING)i=!0;else{const o=n[0],a=n[1],l=n[2],h=n[3],c=e[0],u=e[1],d=t[0],f=t[1],g=(f-u)/(d-c);let _,m;r&Ge.ABOVE&&!(s&Ge.ABOVE)&&(_=d-(f-h)/g,i=_>=o&&_<=l),!i&&r&Ge.RIGHT&&!(s&Ge.RIGHT)&&(m=f-(d-l)*g,i=m>=a&&m<=h),!i&&r&Ge.BELOW&&!(s&Ge.BELOW)&&(_=d-(f-a)/g,i=_>=o&&_<=l),!i&&r&Ge.LEFT&&!(s&Ge.LEFT)&&(m=f-(d-o)*g,i=m>=a&&m<=h)}return i}function qf(n,e,t,i){if(Di(n))return ts(t);let s=[];if(i>1){const a=n[2]-n[0],l=n[3]-n[1];for(let h=0;h<i;++h)s.push(n[0]+a*h/i,n[1],n[2],n[1]+l*h/i,n[2]-a*h/i,n[3],n[0],n[3]-l*h/i)}else s=[n[0],n[1],n[2],n[1],n[2],n[3],n[0],n[3]];e(s,s,2);const r=[],o=[];for(let a=0,l=s.length;a<l;a+=2)r.push(s[a]),o.push(s[a+1]);return Wf(r,o,t)}function uu(n,e){const t=e.getExtent(),i=Fi(n);if(e.canWrapX()&&(i[0]<t[0]||i[0]>=t[2])){const s=te(t),o=Math.floor((i[0]-t[0])/s)*s;n[0]-=o,n[2]-=o}return n}function El(n,e,t){if(e.canWrapX()){const i=e.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];uu(n,e);const s=te(i);if(te(n)>s&&!t)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+s,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}function du(n,e){const t=(""+n).split("."),i=(""+e).split(".");for(let s=0;s<Math.max(t.length,i.length);s++){const r=parseInt(t[s]||"0",10),o=parseInt(i[s]||"0",10);if(r>o)return 1;if(o>r)return-1}return 0}function Jf(n,e){return n[0]+=+e[0],n[1]+=+e[1],n}function Tl(n,e){const t=n[0],i=n[1],s=e[0],r=e[1],o=s[0],a=s[1],l=r[0],h=r[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(t-o)+u*(i-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function He(n,e){let t=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=e[i]){t=!1;break}return t}function Rl(n,e){const t=Math.cos(e),i=Math.sin(e),s=n[0]*t-n[1]*i,r=n[1]*t+n[0]*i;return n[0]=s,n[1]=r,n}function Qf(n,e){return n[0]*=e,n[1]*=e,n}function $n(n,e){const t=n[0]-e[0],i=n[1]-e[1];return t*t+i*i}function Fn(n,e){return Math.sqrt($n(n,e))}function eg(n,e){return $n(n,Tl(n,e))}function Cl(n,e){if(e.canWrapX()){const t=te(e.getExtent()),i=tg(n,e,t);i&&(n[0]-=i*t)}return n}function tg(n,e,t){const i=e.getExtent();let s=0;return e.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(t=t||te(i),s=Math.floor((n[0]-i[0])/t)),s}function fu(n){return Math.pow(n,3)}function is(n){return 1-fu(1-n)}function ig(n){return 3*n*n-2*n*n*n}function ng(n){return n}const Sl=63710088e-1;function Ma(n,e,t){t=t||Sl;const i=Ct(n[1]),s=Ct(e[1]),r=(s-i)/2,o=Ct(e[0]-n[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(s);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function jo(n,e){let t=0;for(let i=0,s=n.length;i<s-1;++i)t+=Ma(n[i],n[i+1],e);return t}function sg(n,e){e=e||{};const t=e.radius||Sl,i=e.projection||"EPSG:3857",s=n.getType();s!=="GeometryCollection"&&(n=n.clone().transform(i,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(s){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=n.getCoordinates(),r=jo(o,t);break}case"MultiLineString":case"Polygon":{for(o=n.getCoordinates(),l=0,h=o.length;l<h;++l)r+=jo(o[l],t);break}case"MultiPolygon":{for(o=n.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)r+=jo(a[c],t);break}case"GeometryCollection":{const d=n.getGeometries();for(l=0,h=d.length;l<h;++l)r+=sg(d[l],e);break}default:throw new Error("Unsupported geometry type: "+s)}return r}function fr(n,e){let t=0;const i=n.length;let s=n[i-1][0],r=n[i-1][1];for(let o=0;o<i;o++){const a=n[o][0],l=n[o][1];t+=Ct(a-s)*(2+Math.sin(Ct(r))+Math.sin(Ct(l))),s=a,r=l}return t*e*e/2}function rg(n,e){e=e||{};const t=e.radius||Sl,i=e.projection||"EPSG:3857",s=n.getType();s!=="GeometryCollection"&&(n=n.clone().transform(i,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(s){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=n.getCoordinates(),r=Math.abs(fr(o[0],t)),l=1,h=o.length;l<h;++l)r-=Math.abs(fr(o[l],t));break}case"MultiPolygon":{for(o=n.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],r+=Math.abs(fr(a[0],t)),c=1,u=a.length;c<u;++c)r-=Math.abs(fr(a[c],t));break}case"GeometryCollection":{const d=n.getGeometries();for(l=0,h=d.length;l<h;++l)r+=rg(d[l],e);break}default:throw new Error("Unsupported geometry type: "+s)}return r}function gu(...n){console.warn(...n)}function sT(...n){console.error(...n)}const og={9001:"m",9002:"ft",9003:"us-ft",9101:"radians",9102:"degrees"};function rT(n){return og[n]}const Wn={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class vl{constructor(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}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Wn[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const qs=6378137,bn=Math.PI*qs,ag=[-bn,-bn,bn,bn],lg=[-180,-85,180,85],gr=qs*Math.log(Math.tan(Math.PI/2));class gn extends vl{constructor(e){super({code:e,units:"m",extent:ag,global:!0,worldExtent:lg,getPointResolution:function(t,i){return t/Math.cosh(i[1]/qs)}})}}const jh=[new gn("EPSG:3857"),new gn("EPSG:102100"),new gn("EPSG:102113"),new gn("EPSG:900913"),new gn("http://www.opengis.net/def/crs/EPSG/0/3857"),new gn("http://www.opengis.net/gml/srs/epsg.xml#3857")];function hg(n,e,t,i){const s=n.length;t=t>1?t:2,i=i??t,e===void 0&&(t>2?e=n.slice():e=new Array(s));for(let r=0;r<s;r+=i){e[r]=bn*n[r]/180;let o=qs*Math.log(Math.tan(Math.PI*(+n[r+1]+90)/360));o>gr?o=gr:o<-gr&&(o=-gr),e[r+1]=o}return e}function cg(n,e,t,i){const s=n.length;t=t>1?t:2,i=i??t,e===void 0&&(t>2?e=n.slice():e=new Array(s));for(let r=0;r<s;r+=i)e[r]=180*n[r]/bn,e[r+1]=360*Math.atan(Math.exp(n[r+1]/qs))/Math.PI-90;return e}const ug=6378137,$h=[-180,-90,180,90],dg=Math.PI*ug/180;class Ui extends vl{constructor(e,t){super({code:e,units:"degrees",extent:$h,axisOrientation:t,global:!0,metersPerUnit:dg,worldExtent:$h})}}const Wh=[new Ui("CRS:84"),new Ui("EPSG:4326","neu"),new Ui("urn:ogc:def:crs:OGC:1.3:CRS84"),new Ui("urn:ogc:def:crs:OGC:2:84"),new Ui("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Ui("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Ui("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Da={};function fg(n){return Da[n]||Da[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function gg(n,e){Da[n]=e}let On={};function Ns(n,e,t){const i=n.getCode(),s=e.getCode();i in On||(On[i]={}),On[i][s]=t}function $o(n,e){return n in On&&e in On[n]?On[n][e]:null}const zr=.9996,St=.00669438,fo=St*St,go=fo*St,ji=St/(1-St),Yh=Math.sqrt(1-St),Yn=(1-Yh)/(1+Yh),_u=Yn*Yn,wl=_u*Yn,Pl=wl*Yn,mu=Pl*Yn,pu=1-St/4-3*fo/64-5*go/256,_g=3*St/8+3*fo/32+45*go/1024,mg=15*fo/256+45*go/1024,pg=35*go/3072,yg=3/2*Yn-27/32*wl+269/512*mu,xg=21/16*_u-55/32*Pl,Eg=151/96*wl-417/128*mu,Tg=1097/512*Pl,Xr=6378137;function Rg(n,e,t){const i=n-5e5,o=(t.north?e:e-1e7)/zr/(Xr*pu),a=o+yg*Math.sin(2*o)+xg*Math.sin(4*o)+Eg*Math.sin(6*o)+Tg*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-St*h,_=Math.sqrt(1-St*h),m=Xr/_,y=(1-St)/g,p=ji*c**2,T=p*p,x=i/(m*zr),E=x*x,R=E*x,C=R*x,v=C*x,w=v*x,P=a-u/y*(E/2-C/24*(5+3*d+10*p-4*T-9*ji))+w/720*(61+90*d+298*p+45*f-252*ji-3*T);let A=(x-R/6*(1+2*d+p)+v/120*(5-2*p+28*d-3*T+8*ji+24*f))/c;return A=La(A+Ct(yu(t.number)),-Math.PI,Math.PI),[Bh(A),Bh(P)]}const Vh=-80,Zh=84,Cg=-180,Sg=180;function vg(n,e,t){n=La(n,Cg,Sg),e<Vh?e=Vh:e>Zh&&(e=Zh);const i=Ct(e),s=Math.sin(i),r=Math.cos(i),o=s/r,a=o*o,l=a*a,h=Ct(n),c=yu(t.number),u=Ct(c),d=Xr/Math.sqrt(1-St*s**2),f=ji*r**2,g=r*La(h-u,-Math.PI,Math.PI),_=g*g,m=_*g,y=m*g,p=y*g,T=p*g,x=Xr*(pu*i-_g*Math.sin(2*i)+mg*Math.sin(4*i)-pg*Math.sin(6*i)),E=zr*d*(g+m/6*(1-a+f)+p/120*(5-18*a+l+72*f-58*ji))+5e5;let R=zr*(x+d*o*(_/2+y/24*(5-a+9*f+4*f**2)+T/720*(61-58*a+l+600*f-330*ji)));return t.north||(R+=1e7),[E,R]}function yu(n){return(n-1)*6-180+3}const wg=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function xu(n){let e=0;for(const s of wg){const r=n.match(s);if(r){e=parseInt(r[1]);break}}if(!e)return null;let t=0,i=!1;return e>32700&&e<32761?t=e-32700:e>32600&&e<32661&&(i=!0,t=e-32600),t?{number:t,north:i}:null}function Kh(n,e){return function(t,i,s,r){const o=t.length;s=s>1?s:2,r=r??s,i||(s>2?i=t.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=t[a],h=t[a+1],c=n(l,h,e);i[a]=c[0],i[a+1]=c[1]}return i}}function Pg(n){return xu(n)?new vl({code:n,units:"m"}):null}function Ig(n){const e=xu(n.getCode());return e?{forward:Kh(vg,e),inverse:Kh(Rg,e)}:null}const Ag=[Ig],Lg=[Pg];let Oa=!0;function Eu(n){Oa=!1}function Il(n,e){if(e!==void 0){for(let t=0,i=n.length;t<i;++t)e[t]=n[t];e=e}else e=n.slice();return e}function Na(n){gg(n.getCode(),n),Ns(n,n,Il)}function Fg(n){n.forEach(Na)}function pe(n){if(typeof n!="string")return n;const e=fg(n);if(e)return e;for(const t of Lg){const i=t(n);if(i)return i}return null}function jr(n,e,t,i){n=pe(n);let s;const r=n.getPointResolutionFunc();if(r){if(s=r(e,t),i&&i!==n.getUnits()){const o=n.getMetersPerUnit();o&&(s=s*o/Wn[i])}}else{const o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")s=e;else{const a=_o(n,pe("EPSG:4326"));if(!a&&o!=="degrees")s=e*n.getMetersPerUnit();else{let h=[t[0]-e/2,t[1],t[0]+e/2,t[1],t[0],t[1]-e/2,t[0],t[1]+e/2];h=a(h,h,2);const c=Ma(h.slice(0,2),h.slice(2,4)),u=Ma(h.slice(4,6),h.slice(6,8));s=(c+u)/2}const l=i?Wn[i]:n.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function Hh(n){Fg(n),n.forEach(function(e){n.forEach(function(t){e!==t&&Ns(e,t,Il)})})}function bg(n,e,t,i){n.forEach(function(s){e.forEach(function(r){Ns(s,r,t),Ns(r,s,i)})})}function Al(n,e){return n?typeof n=="string"?pe(n):n:pe(e)}function Mg(n){return(function(e,t,i,s){const r=e.length;i=i!==void 0?i:2,s=s??i,t=t!==void 0?t:new Array(r);for(let o=0;o<r;o+=s){const a=n(e.slice(o,o+i)),l=a.length;for(let h=0,c=s;h<c;++h)t[o+h]=h>=l?e[o+h]:a[h]}return t})}function oT(n,e){return Eu(),Js(n,"EPSG:4326","EPSG:3857")}function aT(n,e){const t=Js(n,"EPSG:3857","EPSG:4326"),i=t[0];return(i<-180||i>180)&&(t[0]=si(i+180,360)-180),t}function kt(n,e){if(n===e)return!0;const t=n.getUnits()===e.getUnits();return(n.getCode()===e.getCode()||_o(n,e)===Il)&&t}function _o(n,e){const t=n.getCode(),i=e.getCode();let s=$o(t,i);if(s)return s;let r=null,o=null;for(const l of Ag)r||(r=l(n)),o||(o=l(e));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)s=Wo(r.inverse,o.forward);else{const l=$o(t,a);l&&(s=Wo(l,o.forward))}else{const l=$o(a,i);l&&(s=Wo(r.inverse,l))}return s&&(Na(n),Na(e),Ns(n,e,s)),s}function Wo(n,e){return function(t,i,s,r){return i=n(t,i,s,r),e(i,i,s,r)}}function Ji(n,e){const t=pe(n),i=pe(e);return _o(t,i)}function Js(n,e,t){const i=Ji(e,t);if(!i){const s=pe(e).getCode(),r=pe(t).getCode();throw new Error(`No transform available between ${s} and ${r}`)}return i(n,void 0,n.length)}function Dg(n,e,t,i){const s=Ji(e,t);return qf(n,s,void 0,i)}let Og=null;function Ng(){return Og}function Qi(n,e){return n}function xe(n,e){return Oa&&!He(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Oa=!1,gu("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function mo(n,e){return n}function ct(n,e){return n}function Gg(){Hh(jh),Hh(Wh),bg(Wh,jh,hg,cg)}Gg();const Ll=new Array(6);function Ce(){return[1,0,0,1,0,0]}function Ga(n){return po(n,1,0,0,1,0,0)}function Qs(n,e){const t=n[0],i=n[1],s=n[2],r=n[3],o=n[4],a=n[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],f=e[5];return n[0]=t*l+s*h,n[1]=i*l+r*h,n[2]=t*c+s*u,n[3]=i*c+r*u,n[4]=t*d+s*f+o,n[5]=i*d+r*f+a,n}function po(n,e,t,i,s,r,o){return n[0]=e,n[1]=t,n[2]=i,n[3]=s,n[4]=r,n[5]=o,n}function Tu(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n}function me(n,e){const t=e[0],i=e[1];return e[0]=n[0]*t+n[2]*i+n[4],e[1]=n[1]*t+n[3]*i+n[5],e}function kg(n,e){const t=Math.cos(e),i=Math.sin(e);return Qs(n,po(Ll,t,i,-i,t,0,0))}function vs(n,e,t){return Qs(n,po(Ll,e,0,0,t,0,0))}function Fl(n,e,t){return Qs(n,po(Ll,1,0,0,1,e,t))}function ft(n,e,t,i,s,r,o,a){const l=Math.sin(r),h=Math.cos(r);return n[0]=i*h,n[1]=s*l,n[2]=-i*l,n[3]=s*h,n[4]=o*i*h-a*i*l+e,n[5]=o*s*l+a*s*h+t,n}function Gs(n,e){const t=Ug(e);se(t!==0,"Transformation matrix cannot be inverted");const i=e[0],s=e[1],r=e[2],o=e[3],a=e[4],l=e[5];return n[0]=o/t,n[1]=-s/t,n[2]=-r/t,n[3]=i/t,n[4]=(r*l-o*a)/t,n[5]=-(i*l-s*a)/t,n}function Ug(n){return n[0]*n[3]-n[1]*n[2]}const Bg=[1e5,1e5,1e5,1e5,2,2];function zg(n){return"matrix("+n.join(", ")+")"}function ka(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function Xg(n,e){const t=ka(n),i=ka(e);for(let s=0;s<6;++s)if(Math.round((t[s]-i[s])*Bg[s])!==0)return!1;return!0}function Ut(n,e,t,i,s,r,o){r=r||[],o=o||2;let a=0;for(let l=e;l<t;l+=i){const h=n[l],c=n[l+1];r[a++]=s[0]*h+s[2]*c+s[4],r[a++]=s[1]*h+s[3]*c+s[5];for(let u=2;u<o;u++)r[a++]=n[l+u]}return r&&r.length!=a&&(r.length=a),r}function bl(n,e,t,i,s,r,o){o=o||[];const a=Math.cos(s),l=Math.sin(s),h=r[0],c=r[1];let u=0;for(let d=e;d<t;d+=i){const f=n[d]-h,g=n[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let _=d+2;_<d+i;++_)o[u++]=n[_]}return o&&o.length!=u&&(o.length=u),o}function jg(n,e,t,i,s,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=e;u<t;u+=i){const d=n[u]-l,f=n[u+1]-h;a[c++]=l+s*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=n[g]}return a&&a.length!=c&&(a.length=c),a}function $g(n,e,t,i,s,r,o){o=o||[];let a=0;for(let l=e;l<t;l+=i){o[a++]=n[l]+s,o[a++]=n[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}const qh=Ce(),Wg=[NaN,NaN];class Ru extends bt{constructor(){super(),this.extent_=Qe(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=ou((e,t,i)=>{if(!i)return this.getSimplifiedGeometry(t);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return W()}closestPointXY(e,t,i,s){return W()}containsXY(e,t){return this.closestPointXY(e,t,Wg,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return W()}getExtent(e){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&ts(t),this.extentRevision_=this.getRevision()}return Zf(this.extent_,e)}rotate(e,t){W()}scale(e,t,i){W()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return W()}getType(){return W()}applyTransform(e){W()}intersectsExtent(e){return W()}translate(e,t){W()}transform(e,t){const i=pe(e),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=Ie(h)/Ie(l);ft(qh,h[0],h[3],c,-c,0,0,0);const u=Ut(r,0,r.length,a,qh,o),d=Ji(i,t);return d?d(u,u,a):u}:Ji(i,t);return this.applyTransform(s),this}}class Oi extends Ru{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return ml(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return W()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length<this.flatCoordinates.length?t:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,t){this.stride=$r(e),this.layout=e,this.flatCoordinates=t}setCoordinates(e,t){W()}setLayout(e,t,i){let s;if(e)s=$r(e);else{for(let r=0;r<i;++r){if(t.length===0){this.layout="XY",this.stride=2;return}t=t[0]}s=t.length,e=sn(s)}this.layout=e,this.stride=s}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,t){const i=this.getFlatCoordinates();if(i){const s=this.getStride();bl(i,0,i.length,s,e,t,i),this.changed()}}scale(e,t,i){t===void 0&&(t=e),i||(i=Fi(this.getExtent()));const s=this.getFlatCoordinates();if(s){const r=this.getStride();jg(s,0,s.length,r,e,t,i,s),this.changed()}}translate(e,t){const i=this.getFlatCoordinates();if(i){const s=this.getStride();$g(i,0,i.length,s,e,t,i),this.changed()}}}function sn(n){let e;return n==2?e="XY":n==3?e="XYZ":n==4&&(e="XYZM"),e}function $r(n){let e;return n=="XY"?e=2:n=="XYZ"||n=="XYM"?e=3:n=="XYZM"&&(e=4),e}function Yg(n,e,t){const i=n.getFlatCoordinates();if(!i)return null;const s=n.getStride();return Ut(i,0,i.length,s,e,t)}function Cu(n,e,t,i){let s=0;const r=n[t-i],o=n[t-i+1];let a=0,l=0;for(;e<t;e+=i){const h=n[e]-r,c=n[e+1]-o;s+=l*h-a*c,a=h,l=c}return s/2}function Su(n,e,t,i){let s=0;for(let r=0,o=t.length;r<o;++r){const a=t[r];s+=Cu(n,e,a,i),e=a}return s}function Vg(n,e,t,i){let s=0;for(let r=0,o=t.length;r<o;++r){const a=t[r];s+=Su(n,e,a,i),e=a[a.length-1]}return s}function Jh(n,e,t,i,s,r,o){const a=n[e],l=n[e+1],h=n[t]-a,c=n[t+1]-l;let u;if(h===0&&c===0)u=e;else{const d=((s-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=t;else if(d>0){for(let f=0;f<i;++f)o[f]=lt(n[e+f],n[t+f],d);o.length=i;return}else u=e}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function Ml(n,e,t,i,s){let r=n[e],o=n[e+1];for(e+=i;e<t;e+=i){const a=n[e],l=n[e+1],h=ni(r,o,a,l);h>s&&(s=h),r=a,o=l}return s}function Dl(n,e,t,i,s){for(let r=0,o=t.length;r<o;++r){const a=t[r];s=Ml(n,e,a,i,s),e=a}return s}function Zg(n,e,t,i,s){for(let r=0,o=t.length;r<o;++r){const a=t[r];s=Dl(n,e,a,i,s),e=a[a.length-1]}return s}function Ol(n,e,t,i,s,r,o,a,l,h,c){if(e==t)return h;let u,d;if(s===0){if(d=ni(o,a,n[e],n[e+1]),d<h){for(u=0;u<i;++u)l[u]=n[e+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=e+i;for(;f<t;)if(Jh(n,f-i,f,i,o,a,c),d=ni(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/s|0,1);if(r&&(Jh(n,t-i,e,i,o,a,c),d=ni(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function Nl(n,e,t,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){const f=t[u];h=Ol(n,e,f,i,s,r,o,a,l,h,c),e=f}return h}function Kg(n,e,t,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){const f=t[u];h=Nl(n,e,f,i,s,r,o,a,l,h,c),e=f[f.length-1]}return h}function vu(n,e,t,i){for(let s=0,r=t.length;s<r;++s)n[e++]=t[s];return e}function yo(n,e,t,i){for(let s=0,r=t.length;s<r;++s){const o=t[s];for(let a=0;a<i;++a)n[e++]=o[a]}return e}function er(n,e,t,i,s){s=s||[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=yo(n,e,t[o],i);s[r++]=l,e=l}return s.length=r,s}function wu(n,e,t,i,s){s=s||[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=er(n,e,t[o],i,s[r]);l.length===0&&(l[0]=e),s[r++]=l,e=l[l.length-1]}return s.length=r,s}function Ri(n,e,t,i,s){s=s!==void 0?s:[];let r=0;for(let o=e;o<t;o+=i)s[r++]=n.slice(o,o+i);return s.length=r,s}function ks(n,e,t,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o];s[r++]=Ri(n,e,l,i,s[r]),e=l}return s.length=r,s}function Ua(n,e,t,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o];s[r++]=l.length===1&&l[0]===e?[]:ks(n,e,l,i,s[r]),e=l[l.length-1]}return s.length=r,s}function xo(n,e,t,i,s,r,o){const a=(t-e)/i;if(a<3){for(;e<t;e+=i)r[o++]=n[e],r[o++]=n[e+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,t-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=n[d],_=n[d+1],m=n[u],y=n[u+1];for(let p=d+i;p<u;p+=i){const T=n[p],x=n[p+1],E=Xf(T,x,g,_,m,y);E>f&&(c=p,f=E)}f>s&&(l[(c-e)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=n[e+u*i],r[o++]=n[e+u*i+1]);return o}function Pu(n,e,t,i,s,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l];o=xo(n,e,c,i,s,r,o),a.push(o),e=c}return o}function zi(n,e){return e*Math.round(n/e)}function Hg(n,e,t,i,s,r,o){if(e==t)return o;let a=zi(n[e],s),l=zi(n[e+1],s);e+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=zi(n[e],s),c=zi(n[e+1],s),e+=i,e==t)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;e<t;){const u=zi(n[e],s),d=zi(n[e+1],s);if(e+=i,u==h&&d==c)continue;const f=h-a,g=c-l,_=u-a,m=d-l;if(f*m==g*_&&(f<0&&_<f||f==_||f>0&&_>f)&&(g<0&&m<g||g==m||g>0&&m>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function Gl(n,e,t,i,s,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l];o=Hg(n,e,c,i,s,r,o),a.push(o),e=c}return o}function qg(n,e,t,i,s,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l],u=[];o=Gl(n,e,c,i,s,r,o,u),a.push(u),e=c[c.length-1]}return o}class Us extends Oi{constructor(e,t){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}clone(){return new Us(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,t,i,s){return s<nn(this.getExtent(),e,t)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ml(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ol(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,t,i,s))}getArea(){return Cu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ri(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){const t=[];return t.length=xo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new Us(t,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=yo(this.flatCoordinates,0,e,this.stride),this.changed()}}class ut extends Oi{constructor(e,t){super(),this.setCoordinates(e,t)}clone(){const e=new ut(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,s){const r=this.flatCoordinates,o=ni(e,t,r[0],r[1]);if(o<s){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return Cs(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return _l(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,t){this.setLayout(t,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=vu(this.flatCoordinates,0,e,this.stride),this.changed()}}function Jg(n,e,t,i,s){return!yl(s,function(o){return!$i(n,e,t,i,o[0],o[1])})}function $i(n,e,t,i,s,r){let o=0,a=n[t-i],l=n[t-i+1];for(;e<t;e+=i){const h=n[e],c=n[e+1];l<=r?c>r&&(h-a)*(r-l)-(s-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(s-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function kl(n,e,t,i,s,r){if(t.length===0||!$i(n,e,t[0],i,s,r))return!1;for(let o=1,a=t.length;o<a;++o)if($i(n,t[o-1],t[o],i,s,r))return!1;return!0}function Qg(n,e,t,i,s,r){if(t.length===0)return!1;for(let o=0,a=t.length;o<a;++o){const l=t[o];if(kl(n,e,l,i,s,r))return!0;e=l[l.length-1]}return!1}function Ul(n,e,t,i,s,r,o){let a,l,h,c,u,d,f;const g=s[r+1],_=[];for(let p=0,T=t.length;p<T;++p){const x=t[p];for(c=n[x-i],d=n[x-i+1],a=e;a<x;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,_.push(h)),c=u,d=f}let m=NaN,y=-1/0;for(_.sort(Gt),c=_[0],a=1,l=_.length;a<l;++a){u=_[a];const p=Math.abs(u-c);p>y&&(h=(c+u)/2,kl(n,e,t,i,h,g)&&(m=h,y=p)),c=u}return isNaN(m)&&(m=s[r]),o?(o.push(m,g,y),o):[m,g,y]}function Iu(n,e,t,i,s){let r=[];for(let o=0,a=t.length;o<a;++o){const l=t[o];r=Ul(n,e,l,i,s,2*o,r),e=l[l.length-1]}return r}function Au(n,e,t,i,s){let r;for(e+=i;e<t;e+=i)if(r=s(n.slice(e-i,e),n.slice(e,e+i)),r)return r;return!1}function Eo(n,e,t,i,s,r){return r=r??cu(Qe(),n,e,t,i),Pe(s,r)?r[0]>=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Au(n,e,t,i,function(o,a){return Hf(s,o,a)}):!1}function e_(n,e,t,i,s){for(let r=0,o=t.length;r<o;++r){if(Eo(n,e,t[r],i,s))return!0;e=t[r]}return!1}function Lu(n,e,t,i,s){return!!(Eo(n,e,t,i,s)||$i(n,e,t,i,s[0],s[1])||$i(n,e,t,i,s[0],s[3])||$i(n,e,t,i,s[2],s[1])||$i(n,e,t,i,s[2],s[3]))}function Fu(n,e,t,i,s){if(!Lu(n,e,t[0],i,s))return!1;if(t.length===1)return!0;for(let r=1,o=t.length;r<o;++r)if(Jg(n,t[r-1],t[r],i,s)&&!Eo(n,t[r-1],t[r],i,s))return!1;return!0}function t_(n,e,t,i,s){for(let r=0,o=t.length;r<o;++r){const a=t[r];if(Fu(n,e,a,i,s))return!0;e=a[a.length-1]}return!1}function i_(n,e,t,i){for(;e<t-i;){for(let s=0;s<i;++s){const r=n[e+s];n[e+s]=n[t-i+s],n[t-i+s]=r}e+=i,t-=i}}function Bl(n,e,t,i){let s=0,r=n[t-i],o=n[t-i+1];for(;e<t;e+=i){const a=n[e],l=n[e+1];s+=(a-r)*(l+o),r=a,o=l}return s===0?void 0:s>0}function zl(n,e,t,i,s){s=s!==void 0?s:!1;for(let r=0,o=t.length;r<o;++r){const a=t[r],l=Bl(n,e,a,i);if(r===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;e=a}return!0}function bu(n,e,t,i,s){for(let r=0,o=t.length;r<o;++r){const a=t[r];if(!zl(n,e,a,i,s))return!1;a.length&&(e=a[a.length-1])}return!0}function Wr(n,e,t,i,s){s=s!==void 0?s:!1;for(let r=0,o=t.length;r<o;++r){const a=t[r],l=Bl(n,e,a,i);(r===0?s&&l||!s&&!l:s&&!l||!s&&l)&&i_(n,e,a,i),e=a}return e}function Ba(n,e,t,i,s){for(let r=0,o=t.length;r<o;++r)e=Wr(n,e,t[r],i,s);return e}function Mu(n,e){const t=[];let i=0,s=0,r;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=Bl(n,i,l,2);if(r===void 0&&(r=h),h===r)t.push(e.slice(s,o+1));else{if(t.length===0)continue;t[t.length-1].push(e[s])}s=o+1,i=l}return t}class rt extends Oi{constructor(e,t,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,t!==void 0&&i?(this.setFlatCoordinates(t,e),this.ends_=i):this.setCoordinates(e,t)}appendLinearRing(e){this.flatCoordinates?oe(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const e=new rt(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,i,s){return s<nn(this.getExtent(),e,t)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Dl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Nl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,t,i,s))}containsXY(e,t){return kl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,t)}getArea(){return Su(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),Wr(t,0,this.ends_,this.stride,e)):t=this.flatCoordinates,ks(t,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const e=Fi(this.getExtent());this.flatInteriorPoint_=Ul(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new ut(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new Us(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){const e=this.layout,t=this.flatCoordinates,i=this.ends_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new Us(t.slice(r,l),e);s.push(h),r=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const e=this.flatCoordinates;zl(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Wr(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){const t=[],i=[];return t.length=Gl(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),t,0,i),new rt(t,"XY",i)}getType(){return"Polygon"}intersectsExtent(e){return Fu(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=er(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function Qh(n){if(Di(n))throw new Error("Cannot create polygon from empty extent");const e=n[0],t=n[1],i=n[2],s=n[3],r=[e,t,e,s,i,s,i,t,e,t];return new rt(r,"XY",[r.length])}function lT(n,e,t){e=e||32;const i=n.getStride(),s=n.getLayout(),r=n.getCenter(),o=i*(e+1),a=new Array(o);for(let c=0;c<o;c+=i){a[c]=0,a[c+1]=0;for(let u=2;u<i;u++)a[c+u]=r[u]}const l=[a.length],h=new rt(a,s,l);return n_(h,r,n.getRadius(),t),h}function n_(n,e,t,i){const s=n.getFlatCoordinates(),r=n.getStride(),o=s.length/r-1,a=i||0;for(let l=0;l<=o;++l){const h=l*r,c=a+si(l,o)*2*Math.PI/o;s[h]=e[0]+t*Math.cos(c),s[h+1]=e[1]+t*Math.sin(c)}n.changed()}function Xl(n,e,t,i){const s=te(e)/t[0],r=Ie(e)/t[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function jl(n,e,t){let i=Math.min(n,e);const s=50;return i*=Math.log(1+s*Math.max(0,n/e-1))/s+1,t&&(i=Math.max(i,t),i/=Math.log(1+s*Math.max(0,t/n-1))/s+1),_e(i,t/2,e*2)}function s_(n,e,t,i){return e=e!==void 0?e:!0,(function(s,r,o,a){if(s!==void 0){const l=n[0],h=n[n.length-1],c=t?Xl(l,t,o,i):l;if(a)return e?jl(s,c,h):_e(s,h,c);const u=Math.min(c,s),d=Math.floor(dl(n,u,r));return n[d]>c&&d<n.length-1?n[d+1]:n[d]}})}function r_(n,e,t,i,s,r){return i=i!==void 0?i:!0,t=t!==void 0?t:0,(function(o,a,l,h){if(o!==void 0){const c=s?Xl(e,s,l,r):e;if(h)return i?jl(o,c,t):_e(o,t,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),_=Math.floor(Math.log(e/g)/Math.log(n)+f),m=Math.max(d,_),y=e/Math.pow(n,m);return _e(y,t,c)}})}function ec(n,e,t,i,s){return t=t!==void 0?t:!0,(function(r,o,a,l){if(r!==void 0){const h=i?Xl(n,i,a,s):n;return!t||!l?_e(r,e,h):jl(r,h,e)}})}function $l(n){if(n!==void 0)return 0}function tc(n){if(n!==void 0)return n}function o_(n){const e=2*Math.PI/n;return(function(t,i){if(i)return t;if(t!==void 0)return t=Math.floor(t/e+.5)*e,t})}function a_(n){const e=Ct(5);return(function(t,i){return i||t===void 0?t:Math.abs(t)<=e?0:t})}const l_=42,Wl=256,Yo=0;class ii extends bt{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Al(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&Eu(),e.center&&(e.center=xe(e.center,this.projection_)),e.extent&&(e.extent=ct(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){const t=Object.assign({},e);for(const a in It)delete t[a];this.setProperties(t,!0);const i=c_(e);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=i.minZoom;const s=h_(e),r=i.constraint,o=u_(e);this.constraints_={center:s,resolution:r,rotation:o},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let t=this.padding_;this.padding_=e;const i=this.getCenterInternal();if(i){const s=e||[0,0,0,0];t=t||[0,0,0,0];const r=this.getResolution(),o=r/2*(s[3]-t[3]+t[1]-s[1]),a=r/2*(s[0]-t[0]+t[2]-s[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(e){const t=this.getProperties();return t.resolution!==void 0?t.resolution=this.getResolution():t.zoom=this.getZoom(),t.center=this.getCenterInternal(),t.rotation=this.getRotation(),Object.assign({},t,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const t=new Array(arguments.length);for(let i=0;i<t.length;++i){let s=arguments[i];s.center&&(s=Object.assign({},s),s.center=xe(s.center,this.getProjection())),s.anchor&&(s=Object.assign({},s),s.anchor=xe(s.anchor,this.getProjection())),t[i]=s}this.animateInternal.apply(this,t)}animateInternal(e){let t=arguments.length,i;t>1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let s=0;for(;s<t&&!this.isDef();++s){const c=arguments[s];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(s===t){i&&_r(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;s<t;++s){const c=arguments[s],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||ig,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=si(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}d_(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(de.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[de.ANIMATING]>0}getInteracting(){return this.hints_[de.INTERACTING]>0}cancelAnimations(){this.setHint(de.ANIMATING,-this.hints_[de.ANIMATING]);let e;for(let t=0,i=this.animations_.length;t<i;++t){const s=this.animations_[t];if(s[0].callback&&_r(s[0].callback,!1),!e)for(let r=0,o=s.length;r<o;++r){const a=s[r];if(!a.complete){e=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const e=Date.now();let t=!1;for(let i=this.animations_.length-1;i>=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o<a;++o){const l=s[o];if(l.complete)continue;const h=e-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=d+u*(g-d),y=f+u*(_-f);this.targetCenter_=[m,y]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?si(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(de.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&_r(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-t[0],s[1]-t[1]],Rl(i,e-this.getRotation()),Jf(i,t)),i}calculateCenterZoom(e,t){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=t[0]-e*(t[0]-s[0])/r,a=t[1]-e*(t[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(e){const t=this.viewportSize_;if(e){const i=t[0],s=t[1];return[Math.abs(i*Math.cos(e))+Math.abs(s*Math.sin(e)),Math.abs(i*Math.sin(e))+Math.abs(s*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&Qi(e,this.getProjection())}getCenterInternal(){return this.get(It.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return mo(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();se(t,"The view center is not defined");const i=this.getResolution();se(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return se(s!==void 0,"The view rotation is not defined"),ba(t,i,s,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(It.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(ct(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const i=te(e)/t[0],s=Ie(e)/t[1];return Math.max(i,s)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(t/i)/Math.log(e);return(function(r){return t/Math.pow(e,r*s)})}getRotation(){return this.get(It.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/t;return(function(o){return Math.log(i/o)/t/r})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const i=this.padding_;return i&&(t=[t[0]-i[1]-i[3],t[1]-i[0]-i[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=Vo(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],t,i)}return{center:s.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,i,s;if(this.resolutions_){const r=dl(this.resolutions_,e,1);t=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return t+Math.log(i/e)/Math.log(s)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const t=_e(Math.floor(e),0,this.resolutions_.length-2),i=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(i,_e(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let i;if(se(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){se(!Di(e),"Cannot fit empty extent provided as `geometry`");const s=ct(e,this.getProjection());i=Qh(s)}else if(e.getType()==="Circle"){const s=ct(e.getExtent(),this.getProjection());i=Qh(s),i.rotate(this.getRotation(),Fi(s))}else i=e;this.fitInternal(i,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),i=Math.cos(t),s=Math.sin(-t),r=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*s,g=r[u]*s+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(e,t){t=t||{};let i=t.size;i||(i=this.getViewportSizeMinusPadding_());const s=t.padding!==void 0?t.padding:[0,0,0,0],r=t.nearest!==void 0?t.nearest:!1;let o;t.minResolution!==void 0?o=t.minResolution:t.maxZoom!==void 0?o=this.getResolutionForZoom(t.maxZoom):o=0;const a=this.rotatedExtentForGeometry(e);let l=this.getResolutionForExtentInternal(a,[i[0]-s[1]-s[3],i[1]-s[0]-s[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=Fi(a);d[0]+=(s[1]-s[3])/2*l,d[1]+=(s[0]-s[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,_=this.getConstrainedCenter([f,g],l),m=t.callback?t.callback:Ds;t.duration!==void 0?this.animateInternal({resolution:l,center:_,duration:t.duration,easing:t.easing},m):(this.targetResolution_=l,this.targetCenter_=_,this.applyTargetState_(!1,!0),_r(m,!0))}centerOn(e,t,i){this.centerOnInternal(xe(e,this.getProjection()),t,i)}centerOnInternal(e,t,i){this.setCenterInternal(Vo(e,t,i,this.getResolution(),this.getRotation()))}calculateCenterShift(e,t,i,s){let r;const o=this.padding_;if(o&&e){const a=this.getViewportSizeMinusPadding_(-i),l=Vo(e,s,[a[0]/2+o[3],a[1]/2+o[0]],t,i);r=[e[0]-l[0],e[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){const t=Qi(this.targetCenter_,this.getProjection());this.setCenter([t[0]+e[0],t[1]+e[1]])}adjustCenterInternal(e){const t=this.targetCenter_;this.setCenterInternal([t[0]+e[0],t[1]+e[1]])}adjustResolution(e,t){t=t&&xe(t,this.getProjection()),this.adjustResolutionInternal(e,t)}adjustResolutionInternal(e,t){const i=this.getAnimating()||this.getInteracting(),s=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*e,0,s,i);t&&(this.targetCenter_=this.calculateCenterZoom(r,t)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,t){this.adjustResolution(Math.pow(this.zoomFactor_,-e),t)}adjustRotation(e,t){t&&(t=xe(t,this.getProjection())),this.adjustRotationInternal(e,t)}adjustRotationInternal(e,t){const i=this.getAnimating()||this.getInteracting(),s=this.constraints_.rotation(this.targetRotation_+e,i);t&&(this.targetCenter_=this.calculateCenterRotate(s,t)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&xe(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,t){return this.hints_[e]+=t,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,t){const i=this.getAnimating()||this.getInteracting()||t,s=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(s),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,s,r));this.get(It.ROTATION)!==s&&this.set(It.ROTATION,s),this.get(It.RESOLUTION)!==o&&(this.set(It.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(It.CENTER)||!He(this.get(It.CENTER),a))&&this.set(It.CENTER,a),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,t,i){e=e!==void 0?e:200;const s=t||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,s,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(e===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!He(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:e,easing:is,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(de.INTERACTING,1)}endInteraction(e,t,i){i=i&&xe(i,this.getProjection()),this.endInteractionInternal(e,t,i)}endInteractionInternal(e,t,i){this.getInteracting()&&(this.setHint(de.INTERACTING,-1),this.resolveConstraints(e,t,i))}getConstrainedCenter(e,t){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,t||this.getResolution(),i)}getConstrainedZoom(e,t){const i=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(i,t))}getConstrainedResolution(e,t){t=t||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,t,i)}}function _r(n,e){setTimeout(function(){n(e)},0)}function h_(n){if(n.extent!==void 0){const t=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return Xh(n.extent,n.constrainOnlyCenter,t)}const e=Al(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Xh(t,!1,!1)}return $f}function c_(n){let e,t,i,o=n.minZoom!==void 0?n.minZoom:Yo,a=n.maxZoom!==void 0?n.maxZoom:28;const l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=Al(n.projection,"EPSG:3857"),f=d.getExtent();let g=n.constrainOnlyCenter,_=n.extent;if(!h&&!_&&d.isGlobal()&&(g=!1,_=f),n.resolutions!==void 0){const m=n.resolutions;t=m[o],i=m[a]!==void 0?m[a]:m[m.length-1],n.constrainResolution?e=s_(m,c,!g&&_,u):e=ec(t,i,c,!g&&_,u)}else{const y=(f?Math.max(te(f),Ie(f)):360*Wn.degrees/d.getMetersPerUnit())/Wl/Math.pow(2,Yo),p=y/Math.pow(2,28-Yo);t=n.maxResolution,t!==void 0?o=0:t=y/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=t/Math.pow(l,a):i=y/Math.pow(l,a):i=p),a=o+Math.floor(Math.log(t/i)/Math.log(l)),i=t/Math.pow(l,a-o),n.constrainResolution?e=r_(l,t,i,c,!g&&_,u):e=ec(t,i,c,!g&&_,u)}return{constraint:e,maxResolution:t,minResolution:i,minZoom:o,zoomFactor:l}}function u_(n){if(n.enableRotation!==void 0?n.enableRotation:!0){const t=n.constrainRotation;return t===void 0||t===!0?a_():t===!1?tc:typeof t=="number"?o_(t):tc}return $l}function d_(n){return!(n.sourceCenter&&n.targetCenter&&!He(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function Vo(n,e,t,i,s){const r=Math.cos(-s);let o=Math.sin(-s),a=n[0]*r-n[1]*o,l=n[1]*r+n[0]*o;a+=(e[0]/2-t[0])*i,l+=(t[1]-e[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const mr="ol-hidden",f_="ol-selectable",tr="ol-unselectable",Yl="ol-control",ic="ol-collapsed",g_=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),nc=["style","variant","weight","size","lineHeight","family"],za={normal:400,bold:700},Xa=function(n){const e=n.match(g_);if(!e)return null;const t={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,s=nc.length;i<s;++i){const r=e[i+1];r!==void 0&&(t[nc[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(t.weight))&&t.weight in za&&(t.weight=za[t.weight]),t.families=t.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),t};function Te(n,e,t,i){let s;return t&&t.length?s=t.shift():st?s=new class extends OffscreenCanvas{style={}}(n??300,e??150):s=document.createElement("canvas"),n&&(s.width=n),e&&(s.height=e),s.getContext("2d",i)}let Zo;function Yr(){return Zo||(Zo=Te(1,1)),Zo}function To(n){const e=n.canvas;e.width=1,e.height=1,n.clearRect(0,0,1,1)}function __(n){let e=n.offsetWidth;const t=getComputedStyle(n);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function m_(n){let e=n.offsetHeight;const t=getComputedStyle(n);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function sc(n,e){const t=e.parentNode;t&&t.replaceChild(n,e)}function Du(n){for(;n.lastChild;)n.lastChild.remove()}function p_(n,e){const t=n.childNodes;for(let i=0;;++i){const s=t[i],r=e[i];if(!s&&!r)break;if(s!==r){if(!s){n.appendChild(r);continue}if(!r){n.removeChild(s),--i;continue}n.insertBefore(r,s)}}}function Ou(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){const t=this.childNodes.indexOf(e);if(t===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(t,1),e},insertBefore:function(e,t){const i=this.childNodes.indexOf(t);if(i===-1)throw new Error("Reference node not found");return this.childNodes.splice(i,0,e),e},style:{}},{get(e,t,i){return t==="firstElementChild"?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,i)}})}function Ci(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}class Ro extends bt{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let t=0,i=this.listenerKeys.length;t<i;++t)ue(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=e,e){const t=this.target_??e.getOverlayContainerStopEvent();this.element&&t.appendChild(this.element),this.render!==Ds&&this.listenerKeys.push(ee(e,Qt.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}}class y_ extends Ro{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=e.collapsed!==void 0?e.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=e.collapsible!==void 0,this.collapsible_=e.collapsible!==void 0?e.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=e.attributions;const t=e.className!==void 0?e.className:"ol-attribution",i=e.tipLabel!==void 0?e.tipLabel:"Attributions",s=e.expandClassName!==void 0?e.expandClassName:t+"-expand",r=e.collapseLabel!==void 0?e.collapseLabel:"›",o=e.collapseClassName!==void 0?e.collapseClassName:t+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=e.label!==void 0?e.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=s):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(Z.CLICK,this.handleClick_.bind(this),!1);const h=t+" "+tr+" "+Yl+(this.collapsed_&&this.collapsible_?" "+ic:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(e){const t=this.getMap().getAllLayers(),i=new Set(t.flatMap(s=>s.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(s=>i.add(s)):i.add(this.attributions_)),!this.overrideCollapsible_){const s=!t.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(s)}return Array.from(i)}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=await Promise.all(this.collectSourceAttributions_(e).map(s=>fl(()=>s))),i=t.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!jt(t,this.renderedAttributions_)){Du(this.ulElement_);for(let s=0,r=t.length;s<r;++s){const o=document.createElement("li");o.innerHTML=t[s],this.ulElement_.appendChild(o)}this.renderedAttributions_=t}}handleClick_(e){e.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(ic),this.collapsed_?sc(this.collapseLabel_,this.label_):sc(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(e){this.collapsible_!==e&&(this.collapsible_=e,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(e){this.userCollapsed_=e,!(!this.collapsible_||this.collapsed_===e)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(e){this.updateElement_(e.frameState)}}class x_ extends Ro{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target});const t=e.className!==void 0?e.className:"ol-rotate",i=e.label!==void 0?e.label:"⇧",s=e.compassClassName!==void 0?e.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=s,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(s));const r=e.tipLabel?e.tipLabel:"Reset rotation",o=document.createElement("button");o.className=t+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(Z.CLICK,this.handleClick_.bind(this),!1);const a=t+" "+tr+" "+Yl,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=e.resetNorth?e.resetNorth:void 0,this.duration_=e.duration!==void 0?e.duration:250,this.autoHide_=e.autoHide!==void 0?e.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(mr)}handleClick_(e){e.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const t=this.getMap().getView();if(!t)return;const i=t.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:is}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const i=t.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(mr);!r&&i===0?this.element.classList.add(mr):r&&i!==0&&this.element.classList.remove(mr)}this.label_.style.transform=s}this.rotation_=i}}class E_ extends Ro{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",i=e.delta!==void 0?e.delta:1,s=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",r=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",h=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=s,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(Z.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(Z.CLICK,this.handleClick_.bind(this,-i),!1);const d=t+" "+tr+" "+Yl,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+e);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:is})):i.setZoom(r)}}}function T_(n){n=n||{};const e=new qe;return(n.zoom!==void 0?n.zoom:!0)&&e.push(new E_(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&e.push(new x_(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&e.push(new y_(n.attributionOptions)),e}class R_{constructor(e,t,i){this.decay_=e,this.minVelocity_=t,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]<e)return!1;let i=t-3;for(;i>0&&this.points_[i+2]>e;)i-=3;const s=this.points_[t+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[t]-this.points_[i],o=this.points_[t+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/s,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const ja={ACTIVE:"active"};class ns extends bt{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(ja.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(ja.ACTIVE,e)}setMap(e){this.map_=e}}function C_(n,e,t){const i=n.getCenterInternal();if(i){const s=[i[0]+e[0],i[1]+e[1]];n.animateInternal({duration:t!==void 0?t:250,easing:ng,center:n.getConstrainedCenter(s)})}}function Vl(n,e,t,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+e),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:t,duration:i!==void 0?i:250,easing:is})}class S_ extends ns{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==ne.DBLCLICK){const i=e.originalEvent,s=e.map,r=e.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Vl(a,o,r,this.duration_),i.preventDefault(),t=!0}return!t}}function $a(n){const e=arguments;return function(t){let i=!0;for(let s=0,r=e.length;s<r&&(i=i&&e[s](t),!!i);++s);return i}}const v_=function(n){const e=n.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},w_=function(n){const e=n.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},P_=function(n){const e=n.map.getTargetElement(),t=e.getRootNode(),i=n.map.getOwnerDocument().activeElement;return t instanceof ShadowRoot?t.host.contains(i):e.contains(i)},Nu=function(n){const e=n.map.getTargetElement(),t=e.getRootNode();return(t instanceof ShadowRoot?t.host:e).hasAttribute("tabindex")?P_(n):!0},Nn=Li,hT=function(n){return n.type==ne.CLICK},Gu=function(n){const e=n.originalEvent;return"pointerId"in e&&e.button==0&&!(Of&&gl&&e.ctrlKey)},Vr=Jn,ku=function(n){return n.type==ne.SINGLECLICK},Zl=function(n){const e=n.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},cT=function(n){const e=n.originalEvent;return!e.altKey&&(gl?e.metaKey:e.ctrlKey)&&!e.shiftKey},I_=function(n){const e=n.originalEvent;return gl?e.metaKey:e.ctrlKey},Zr=function(n){const e=n.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Uu=function(n){const e=n.originalEvent,t=e.target.tagName;return t!=="INPUT"&&t!=="SELECT"&&t!=="TEXTAREA"&&!e.target.isContentEditable},Ko=function(n){const e=n.originalEvent;return"pointerId"in e&&e.pointerType=="mouse"},Bu=function(n){const e=n.originalEvent;return"pointerId"in e&&e.isPrimary&&e.button===0};class rn extends ns{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==ne.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==ne.POINTERUP){const i=this.handleUpEvent(e);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(e.type==ne.POINTERDOWN){const i=this.handleDownEvent(e);this.handlingDownUpSequence=i,t=this.stopDown(i)}else e.type==ne.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function Kl(n){const e=n.length;let t=0,i=0;for(let s=0;s<e;s++)t+=n[s].clientX,i+=n[s].clientY;return{clientX:t/e,clientY:i/e}}class A_ extends rn{constructor(e){super({stopDown:Jn}),e=e||{},this.kinetic_=e.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const t=e.condition?e.condition:$a(Zl,Bu);this.condition_=e.onFocusOnly?$a(Nu,t):t,this.noKinetic_=!1}handleDragEvent(e){const t=e.map;this.panning_||(this.panning_=!0,t.getView().beginInteraction());const i=this.targetPointers,s=t.getEventPixel(Kl(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(s[0],s[1]),this.lastCentroid){const r=[this.lastCentroid[0]-s[0],s[1]-this.lastCentroid[1]],a=e.map.getView();Qf(r,a.getResolution()),Rl(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=s,this.lastPointersCount_=i.length,e.originalEvent.preventDefault()}handleUpEvent(e){const t=e.map,i=t.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const s=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=t.getPixelFromCoordinateInternal(o),l=t.getCoordinateFromPixelInternal([a[0]-s*Math.cos(r),a[1]-s*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:is})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(e){if(this.targetPointers.length>0&&this.condition_(e)){const i=e.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class L_ extends rn{constructor(e){e=e||{},super({stopDown:Jn}),this.condition_=e.condition?e.condition:w_,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!Ko(e))return;const t=e.map,i=t.getView();if(i.getConstraints().rotation===$l)return;const s=t.getSize(),r=e.pixel,o=Math.atan2(s[1]/2-r[1],r[0]-s[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return Ko(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return Ko(e)&&Gu(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class F_ extends Ks{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(e[0],t[0])+i,s.top=Math.min(e[1],t[1])+i,s.width=Math.abs(t[0]-e[0])+i,s.height=Math.abs(t[1]-e[1])+i}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const e=this.startPixel_,t=this.endPixel_,s=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new rt([s])}getGeometry(){return this.geometry_}}const _n={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class fs extends Pt{constructor(e,t,i){super(e),this.coordinate=t,this.mapBrowserEvent=i}}class b_ extends rn{constructor(e){super(),this.on,this.once,this.un,e=e??{},this.box_=new F_(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??Gu,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,i){const s=i[0]-t[0],r=i[1]-t[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new fs(_n.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new fs(t?_n.BOXEND:_n.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new fs(_n.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new fs(_n.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new fs(_n.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(e)}}class M_ extends b_{constructor(e){e=e||{};const t=e.condition?e.condition:Zr;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const i=this.getMap().getView();let s=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(s),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;s=s.clone(),s.scale(a*a)}i.fitInternal(s,{duration:this.duration_,easing:is})}}const Bi={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class D_ extends ns{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return Zl(t)&&Uu(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==Z.KEYDOWN){const i=e.originalEvent,s=i.key;if(this.condition_(e)&&(s==Bi.DOWN||s==Bi.LEFT||s==Bi.RIGHT||s==Bi.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;s==Bi.DOWN?h=-a:s==Bi.LEFT?l=-a:s==Bi.RIGHT?l=a:h=a;const c=[l,h];Rl(c,o.getRotation()),C_(o,c,this.duration_),i.preventDefault(),t=!0}}return!t}}class O_ extends ns{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!I_(t)&&Uu(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==Z.KEYDOWN||e.type==Z.KEYPRESS){const i=e.originalEvent,s=i.key;if(this.condition_(e)&&(s==="+"||s==="-")){const r=e.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Vl(a,o,void 0,this.duration_),i.preventDefault(),t=!0}}return!t}}const N_=40,G_=300;class k_ extends ns{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:Nn;this.condition_=e.onFocusOnly?$a(Nu,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==Z.WHEEL)return!0;const i=e.map,s=e.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.pixel);let r=s.deltaY;switch(s.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=N_;break;case WheelEvent.DOM_DELTA_PAGE:r*=G_;break}if(r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let i=-_e(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Vl(t,i,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}class U_ extends rn{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Jn),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const i=this.targetPointers[0],s=this.targetPointers[1],r=Math.atan2(s.clientY-i.clientY,s.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=r;const o=e.map,a=o.getView();a.getConstraints().rotation!==$l&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Kl(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class B_ extends rn{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Jn),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const i=this.targetPointers[0],s=this.targetPointers[1],r=i.clientX-s.clientX,o=i.clientY-s.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,h=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Kl(this.targetPointers))),l.render(),h.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const i=e.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}function z_(n){n=n||{};const e=new qe,t=new R_(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&e.push(new L_),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&e.push(new S_({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&e.push(new A_({onFocusOnly:n.onFocusOnly,kinetic:t})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&e.push(new U_),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&e.push(new B_({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(e.push(new D_),e.push(new O_({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&e.push(new k_({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&e.push(new M_({duration:n.zoomDuration})),e}const ce={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class zu extends bt{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;const t=Object.assign({},e);typeof e.properties=="object"&&(delete t.properties,Object.assign(t,e.properties)),t[ce.OPACITY]=e.opacity!==void 0?e.opacity:1,se(typeof t[ce.OPACITY]=="number","Layer opacity must be a number"),t[ce.VISIBLE]=e.visible!==void 0?e.visible:!0,t[ce.Z_INDEX]=e.zIndex,t[ce.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,t[ce.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,t[ce.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,t[ce.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=t.className!==void 0?t.className:"ol-layer",delete t.className,this.setProperties(t),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){const t=this.state_||{layer:this,managed:e===void 0?!0:e},i=this.getZIndex();return t.opacity=_e(Math.round(this.getOpacity()*100)/100,0,1),t.visible=this.getVisible(),t.extent=this.getExtent(),t.zIndex=i===void 0&&!t.managed?1/0:i,t.maxResolution=this.getMaxResolution(),t.minResolution=Math.max(this.getMinResolution(),0),t.minZoom=this.getMinZoom(),t.maxZoom=this.getMaxZoom(),this.state_=t,t}getLayersArray(e){return W()}getLayerStatesArray(e){return W()}getExtent(){return this.get(ce.EXTENT)}getMaxResolution(){return this.get(ce.MAX_RESOLUTION)}getMinResolution(){return this.get(ce.MIN_RESOLUTION)}getMinZoom(){return this.get(ce.MIN_ZOOM)}getMaxZoom(){return this.get(ce.MAX_ZOOM)}getOpacity(){return this.get(ce.OPACITY)}getSourceState(){return W()}getVisible(){return this.get(ce.VISIBLE)}getZIndex(){return this.get(ce.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(ce.EXTENT,e)}setMaxResolution(e){this.set(ce.MAX_RESOLUTION,e)}setMinResolution(e){this.set(ce.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(ce.MAX_ZOOM,e)}setMinZoom(e){this.set(ce.MIN_ZOOM,e)}setOpacity(e){se(typeof e=="number","Layer opacity must be a number"),this.set(ce.OPACITY,e)}setVisible(e){this.set(ce.VISIBLE,e)}setZIndex(e){this.set(ce.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const gi={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class xi extends Pt{constructor(e,t){super(e),this.layer=t}}const Ho={LAYERS:"layers"};class ss extends zu{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let i=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Ho.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new qe(i.slice(),{unique:!0}):se(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new qe(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ue),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(ee(e,Le.ADD,this.handleLayersAdd_,this),ee(e,Le.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(ue);tn(this.listenerKeys_);const t=e.getArray();for(let i=0,s=t.length;i<s;i++){const r=t[i];this.registerLayerListeners_(r),this.dispatchEvent(new xi(gi.ADDLAYER,r))}this.changed()}registerLayerListeners_(e){const t=[ee(e,jn.PROPERTYCHANGE,this.handleLayerChange_,this),ee(e,Z.CHANGE,this.handleLayerChange_,this)];e instanceof ss&&t.push(ee(e,gi.ADDLAYER,this.handleLayerGroupAdd_,this),ee(e,gi.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[O(e)]=t}handleLayerGroupAdd_(e){this.dispatchEvent(new xi(gi.ADDLAYER,e.layer))}handleLayerGroupRemove_(e){this.dispatchEvent(new xi(gi.REMOVELAYER,e.layer))}handleLayersAdd_(e){const t=e.element;this.registerLayerListeners_(t),this.dispatchEvent(new xi(gi.ADDLAYER,t)),this.changed()}handleLayersRemove_(e){const t=e.element,i=O(t);this.listenerKeys_[i].forEach(ue),delete this.listenerKeys_[i],this.dispatchEvent(new xi(gi.REMOVELAYER,t)),this.changed()}getLayers(){return this.get(Ho.LAYERS)}setLayers(e){const t=this.getLayers();if(t){const i=t.getArray();for(let s=0,r=i.length;s<r;++s)this.dispatchEvent(new xi(gi.REMOVELAYER,i[s]))}this.set(Ho.LAYERS,e)}getLayersArray(e){return e=e!==void 0?e:[],this.getLayers().forEach(function(t){t.getLayersArray(e)}),e}getLayerStatesArray(e){const t=e!==void 0?e:[],i=t.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(t)});const s=this.getLayerState();let r=s.zIndex;!e&&s.zIndex===void 0&&(r=0);for(let o=i,a=t.length;o<a;o++){const l=t[o];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent!==void 0?l.extent=We(l.extent,s.extent):l.extent=s.extent),l.zIndex===void 0&&(l.zIndex=r)}return t}getSourceState(){return"ready"}}const ke={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};class ir extends zu{constructor(e){const t=Object.assign({},e);delete t.source,super(t),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(ce.SOURCE,this.handleSourcePropertyChange_);const i=e.source?e.source:null;this.setSource(i)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(ce.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(ue(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const e=this.getSource();e&&(this.sourceChangeKey_=ee(e,Z.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const i=this.getMapInternal();!e&&i&&(e=i.getView()),e instanceof ii?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&i&&(t.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;if(t.layerStatesArray){if(s=t.layerStatesArray.find(o=>o.layer===this),!s)return!1}else s=this.getLayerState();const r=this.getExtent();return Hl(s,t.viewState)&&(!r||Pe(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];const t=this.getSource()?.getAttributions();if(!t)return[];const i=e instanceof ii?e.getViewStateAndExtent():e;let s=t(i);return Array.isArray(s)||(s=[s]),s}render(e,t){const i=this.getRenderer();return i.prepareFrame(e)?(this.rendered=!0,i.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){const t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(ce.MAP,e)}getMapInternal(){return this.get(ce.MAP)}setMap(e){this.mapPrecomposeKey_&&(ue(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(ue(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=ee(e,ke.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=ee(this,Z.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){const t=e.frameState.layerStatesArray,i=this.getLayerState(!1);se(!t.some(s=>s.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(i)}setSource(e){this.set(ce.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Hl(n,e){if(!n.visible)return!1;const t=e.resolution;if(t<n.minResolution||t>=n.maxResolution)return!1;const i=e.zoom;return i>n.minZoom&&i<=n.maxZoom}function Xu(n,e,t=0,i=n.length-1,s=X_){for(;i>t;){if(i-t>600){const l=i-t+1,h=e-t+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*u/l+d)),g=Math.min(i,Math.floor(e+(l-h)*u/l+d));Xu(n,e,f,g,s)}const r=n[e];let o=t,a=i;for(gs(n,t,e),s(n[i],r)>0&&gs(n,t,i);o<a;){for(gs(n,o,a),o++,a--;s(n[o],r)<0;)o++;for(;s(n[a],r)>0;)a--}s(n[t],r)===0?gs(n,t,a):(a++,gs(n,a,i)),a<=e&&(t=a+1),e<=a&&(i=a-1)}}function gs(n,e,t){const i=n[e];n[e]=n[t],n[t]=i}function X_(n,e){return n<e?-1:n>e?1:0}let ql=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!yr(e,t))return i;const s=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?s(a):a;yr(e,l)&&(t.leaf?i.push(a):Jo(e,l)?this._all(a,i):r.push(a))}t=r.pop()}return i}collides(e){let t=this.data;if(!yr(e,t))return!1;const i=[];for(;t;){for(let s=0;s<t.children.length;s++){const r=t.children[s],o=t.leaf?this.toBBox(r):r;if(yr(e,o)){if(t.leaf||Jo(e,o))return!0;i.push(r)}}t=i.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let i=0;i<e.length;i++)this.insert(e[i]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const i=this.data;this.data=t,t=i}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=wn([]),this}remove(e,t){if(!e)return this;let i=this.data;const s=this.toBBox(e),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=j_(e,i.children,t);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Jo(i,s)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,s){const r=i-t+1;let o=this._maxEntries,a;if(r<=o)return a=wn(e.slice(t,i+1)),mn(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=wn([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));rc(e,t,i,h,this.compareMinX);for(let c=t;c<=i;c+=h){const u=Math.min(c+h-1,i);rc(e,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(e,d,f,s-1))}}return mn(a,this.toBBox),a}_chooseSubtree(e,t,i,s){for(;s.push(t),!(t.leaf||s.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],c=qo(h),u=Y_(e,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}t=a||t.children[0]}return t}_insert(e,t,i){const s=i?e:this.toBBox(e),r=[],o=this._chooseSubtree(s,this.data,t,r);for(o.children.push(e),Es(o,s);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(s,r,t)}_split(e,t){const i=e[t],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=wn(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,mn(i,this.toBBox),mn(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=wn([e,t]),this.data.height=e.height+1,this.data.leaf=!1,mn(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let s,r=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=xs(e,0,a,this.toBBox),h=xs(e,a,i,this.toBBox),c=V_(l,h),u=qo(l)+qo(h);c<r?(r=c,s=a,o=u<o?u:o):c===r&&u<o&&(o=u,s=a)}return s||i-t}_chooseSplitAxis(e,t,i){const s=e.leaf?this.compareMinX:$_,r=e.leaf?this.compareMinY:W_,o=this._allDistMargin(e,t,i,s),a=this._allDistMargin(e,t,i,r);o<a&&e.children.sort(s)}_allDistMargin(e,t,i,s){e.children.sort(s);const r=this.toBBox,o=xs(e,0,t,r),a=xs(e,i-t,i,r);let l=pr(o)+pr(a);for(let h=t;h<i-t;h++){const c=e.children[h];Es(o,e.leaf?r(c):c),l+=pr(o)}for(let h=i-t-1;h>=t;h--){const c=e.children[h];Es(a,e.leaf?r(c):c),l+=pr(a)}return l}_adjustParentBBoxes(e,t,i){for(let s=i;s>=0;s--)Es(t[s],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():mn(e[t],this.toBBox)}};function j_(n,e,t){if(!t)return e.indexOf(n);for(let i=0;i<e.length;i++)if(t(n,e[i]))return i;return-1}function mn(n,e){xs(n,0,n.children.length,e,n)}function xs(n,e,t,i,s){s||(s=wn(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=e;r<t;r++){const o=n.children[r];Es(s,n.leaf?i(o):o)}return s}function Es(n,e){return n.minX=Math.min(n.minX,e.minX),n.minY=Math.min(n.minY,e.minY),n.maxX=Math.max(n.maxX,e.maxX),n.maxY=Math.max(n.maxY,e.maxY),n}function $_(n,e){return n.minX-e.minX}function W_(n,e){return n.minY-e.minY}function qo(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function pr(n){return n.maxX-n.minX+(n.maxY-n.minY)}function Y_(n,e){return(Math.max(e.maxX,n.maxX)-Math.min(e.minX,n.minX))*(Math.max(e.maxY,n.maxY)-Math.min(e.minY,n.minY))}function V_(n,e){const t=Math.max(n.minX,e.minX),i=Math.max(n.minY,e.minY),s=Math.min(n.maxX,e.maxX),r=Math.min(n.maxY,e.maxY);return Math.max(0,s-t)*Math.max(0,r-i)}function Jo(n,e){return n.minX<=e.minX&&n.minY<=e.minY&&e.maxX<=n.maxX&&e.maxY<=n.maxY}function yr(n,e){return e.minX<=n.maxX&&e.minY<=n.maxY&&e.maxX>=n.minX&&e.maxY>=n.minY}function wn(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function rc(n,e,t,i,s){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;Xu(n,o,e,t,s),r.push(e,o,o,t)}}const Jl=[NaN,NaN,NaN,0];let Qo;function Z_(){return Qo||(Qo=Te(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Qo}const K_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,H_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,q_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,J_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function xr(n,e){return n.endsWith("%")?Number(n.substring(0,n.length-1))/e:Number(n)}function ws(n){throw new Error('failed to parse "'+n+'" as color')}function ju(n){if(n.toLowerCase().startsWith("rgb")){const r=n.match(H_)||n.match(K_)||n.match(q_);if(r){const o=r[4],a=100/255;return[_e(xr(r[1],a)+.5|0,0,255),_e(xr(r[2],a)+.5|0,0,255),_e(xr(r[3],a)+.5|0,0,255),o!==void 0?_e(xr(o,100),0,1):1]}ws(n)}if(n.startsWith("#")){if(J_.test(n)){const r=n.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}ws(n)}const e=Z_();e.fillStyle="#abcdef";let t=e.fillStyle;e.fillStyle=n,e.fillStyle===t&&(e.fillStyle="#fedcba",t=e.fillStyle,e.fillStyle=n,e.fillStyle===t&&ws(n));const i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return ju(i);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);const s=Array.from(e.getImageData(0,0,1,1).data);return s[3]=es(s[3]/255,3),s}function Q_(n){return typeof n=="string"?n:eh(n)}const em=1024,_s={};let ea=0;function tm(n){if(n.length===4)return n;const e=n.slice();return e[3]=1,e}function ta(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function ia(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function na(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function sa(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function oc(n){const e=na(n[0]),t=na(n[1]),i=na(n[2]),s=sa(e*.222488403+t*.716873169+i*.06060791),r=500*(sa(e*.452247074+t*.399439023+i*.148375274)-s),o=200*(s-sa(e*.016863605+t*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*s-16,Math.sqrt(r*r+o*o),a<0?a+360:a,n[3]]}function im(n){const e=(n[0]+16)/116,t=n[1],i=n[2]*Math.PI/180,s=ia(e),r=ia(e+t/500*Math.cos(i)),o=ia(e-t/200*Math.sin(i)),a=ta(r*3.021973625-s*1.617392459-o*.404875592),l=ta(r*-.943766287+s*1.916279586+o*.027607165),h=ta(r*.069407491-s*.22898585+o*1.159737864);return[_e(a+.5|0,0,255),_e(l+.5|0,0,255),_e(h+.5|0,0,255),n[3]]}function Ql(n){if(n==="none")return Jl;if(_s.hasOwnProperty(n))return _s[n];if(ea>=em){let t=0;for(const i in _s)(t++&3)===0&&(delete _s[i],--ea)}const e=ju(n);e.length!==4&&ws(n);for(const t of e)isNaN(t)&&ws(n);return _s[n]=e,++ea,e}function wt(n){return Array.isArray(n)?n:Ql(n)}function eh(n){let e=n[0];e!=(e|0)&&(e=e+.5|0);let t=n[1];t!=(t|0)&&(t=t+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+e+","+t+","+i+","+s+")"}function ac(n){return n[0]>0&&n[1]>0}function nm(n,e,t){return t===void 0&&(t=[0,0]),t[0]=n[0]*e+.5|0,t[1]=n[1]*e+.5|0,t}function Se(n,e){return Array.isArray(n)?n:(e===void 0?e=[n,n]:(e[0]=n,e[1]=n),e)}let on=0;const Fe=1<<on++,B=1<<on++,Me=1<<on++,ye=1<<on++,ot=1<<on++,Tt=1<<on++,Er=Math.pow(2,on)-1,th={[Fe]:"boolean",[B]:"number",[Me]:"string",[ye]:"color",[ot]:"number[]",[Tt]:"size"},sm=Object.keys(th).map(Number).sort(Gt);function rm(n){return n in th}function Mn(n){const e=[];for(const t of sm)Ts(n,t)&&e.push(th[t]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Ts(n,e){return(n&e)===e}function Ot(n,e){return n===e}class be{constructor(e,t){if(!rm(e))throw new Error(`literal expressions must have a specific type, got ${Mn(e)}`);this.type=e,this.value=t}}class $u{constructor(e,t,...i){this.type=e,this.operator=t,this.args=i}}function ih(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function Ue(n,e,t){switch(typeof n){case"boolean":{if(Ot(e,Me))return new be(Me,n?"true":"false");if(!Ts(e,Fe))throw new Error(`got a boolean, but expected ${Mn(e)}`);return new be(Fe,n)}case"number":{if(Ot(e,Tt))return new be(Tt,Se(n));if(Ot(e,Fe))return new be(Fe,!!n);if(Ot(e,Me))return new be(Me,n.toString());if(!Ts(e,B))throw new Error(`got a number, but expected ${Mn(e)}`);return new be(B,n)}case"string":{if(Ot(e,ye))return new be(ye,Ql(n));if(Ot(e,Fe))return new be(Fe,!!n);if(!Ts(e,Me))throw new Error(`got a string, but expected ${Mn(e)}`);return new be(Me,n)}}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return mm(n,e,t);for(const i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ot(e,Tt)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new be(Tt,n)}if(Ot(e,ye)){if(n.length===3)return new be(ye,[...n,1]);if(n.length===4)return new be(ye,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!Ts(e,ot))throw new Error(`got an array of numbers, but expected ${Mn(e)}`);return new be(ot,n)}const S={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},om={[S.Get]:H(Q(1,1/0),lc),[S.Var]:H(Q(1,1),am),[S.Has]:H(Q(1,1/0),lc),[S.Id]:H(lm,pn),[S.Concat]:H(Q(2,1/0),le(Me)),[S.GeometryType]:H(hm,pn),[S.LineMetric]:H(pn),[S.Resolution]:H(ra,pn),[S.Zoom]:H(ra,pn),[S.Time]:H(ra,pn),[S.Any]:H(Q(2,1/0),le(Fe)),[S.All]:H(Q(2,1/0),le(Fe)),[S.Not]:H(Q(1,1),le(Fe)),[S.Equal]:H(Q(2,2),le(Er)),[S.NotEqual]:H(Q(2,2),le(Er)),[S.GreaterThan]:H(Q(2,2),le(B)),[S.GreaterThanOrEqualTo]:H(Q(2,2),le(B)),[S.LessThan]:H(Q(2,2),le(B)),[S.LessThanOrEqualTo]:H(Q(2,2),le(B)),[S.Multiply]:H(Q(2,1/0),hc),[S.Coalesce]:H(Q(2,1/0),hc),[S.Divide]:H(Q(2,2),le(B)),[S.Add]:H(Q(2,1/0),le(B)),[S.Subtract]:H(Q(2,2),le(B)),[S.Clamp]:H(Q(3,3),le(B)),[S.Mod]:H(Q(2,2),le(B)),[S.Pow]:H(Q(2,2),le(B)),[S.Abs]:H(Q(1,1),le(B)),[S.Floor]:H(Q(1,1),le(B)),[S.Ceil]:H(Q(1,1),le(B)),[S.Round]:H(Q(1,1),le(B)),[S.Sin]:H(Q(1,1),le(B)),[S.Cos]:H(Q(1,1),le(B)),[S.Atan]:H(Q(1,2),le(B)),[S.Sqrt]:H(Q(1,1),le(B)),[S.Match]:H(Q(4,1/0),cc,um),[S.Between]:H(Q(3,3),le(B)),[S.Interpolate]:H(Q(6,1/0),cc,dm),[S.Case]:H(Q(3,1/0),cm,fm),[S.In]:H(Q(2,2),gm),[S.Number]:H(Q(1,1/0),le(Er)),[S.String]:H(Q(1,1/0),le(Er)),[S.Array]:H(Q(1,1/0),le(B)),[S.Color]:H(Q(1,4),le(B)),[S.Band]:H(Q(1,3),le(B)),[S.Palette]:H(Q(2,2),_m),[S.ToString]:H(Q(1,1),le(Fe|B|Me|ye))};function lc(n,e,t){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=n[r+1];switch(typeof o){case"number":{s[r]=new be(B,o);break}case"string":{s[r]=new be(Me,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&t.properties.add(String(o))}return s}function am(n,e,t){const i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return t.variables.add(i),[new be(Me,i)]}function lm(n,e,t){t.featureId=!0}function hm(n,e,t){t.geometryType=!0}function ra(n,e,t){t.mapState=!0}function pn(n,e,t){const i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function Q(n,e){return function(t,i,s){const r=t[0],o=t.length-1;if(n===e){if(o!==n){const a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${r}, got ${o}`)}}else if(o<n||o>e){const a=e===1/0?`${n} or more`:`${n} to ${e}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function hc(n,e,t){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=Ue(n[r+1],e,t);s[r]=o}return s}function le(n){return function(e,t,i){const s=e.length-1,r=new Array(s);for(let o=0;o<s;++o){const a=Ue(e[o+1],n,i);r[o]=a}return r}}function cm(n,e,t){const i=n[0],s=n.length-1;if(s%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${s} instead`)}function cc(n,e,t){const i=n[0],s=n.length-1;if(s%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${s} instead`)}function um(n,e,t){const i=n.length-1,s=Me|B|Fe,r=Ue(n[1],s,t),o=Ue(n[n.length-1],e,t),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=Ue(n[l+2],r.type,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=Ue(n[l+3],o.type,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function dm(n,e,t){const i=n[1];let s;switch(i[0]){case"linear":s=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new be(B,s);let o;try{o=Ue(n[2],B,t)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{const h=Ue(n[l+3],B,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Ue(n[l+4],e,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function fm(n,e,t){const i=Ue(n[n.length-1],e,t),s=new Array(n.length-1);for(let r=0;r<s.length-1;r+=2){try{const o=Ue(n[r+1],Fe,t);s[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Ue(n[r+2],i.type,t);s[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return s[s.length-1]=i,s}function gm(n,e,t){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let s;if(typeof i[0]=="string"){if(i[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],s=Me}else s=B;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=Ue(i[a],s,t);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Ue(n[1],s,t),...r]}function _m(n,e,t){let i;try{i=Ue(n[1],B,t)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const s=n[2];if(!Array.isArray(s))throw new Error("the second argument of palette must be an array");const r=new Array(s.length);for(let o=0;o<r.length;o++){let a;try{a=Ue(s[o],ye,t)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof be))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function H(...n){return function(e,t,i){const s=e[0];let r;for(let o=0;o<n.length;o++){const a=n[o](e,t,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new $u(t,s,...r)}}function mm(n,e,t){const i=n[0],s=om[i];if(!s)throw new Error(`unknown operator: ${i}`);return s(n,e,t)}function nh(n){if(!n)return"";const e=n.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return nh(n.getGeometries()[0]);default:return""}}function Wu(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function ci(n,e,t){const i=Ue(n,e,t);return At(i)}function At(n,e){if(n instanceof be){if(n.type===ye&&typeof n.value=="string"){const i=Ql(n.value);return function(){return i}}return function(){return n.value}}const t=n.operator;switch(t){case S.Number:case S.String:case S.Coalesce:return pm(n);case S.Get:case S.Var:case S.Has:return ym(n);case S.Id:return i=>i.featureId;case S.GeometryType:return i=>i.geometryType;case S.Concat:{const i=n.args.map(s=>At(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case S.Resolution:return i=>i.resolution;case S.Any:case S.All:case S.Between:case S.In:case S.Not:return Em(n);case S.Equal:case S.NotEqual:case S.LessThan:case S.LessThanOrEqualTo:case S.GreaterThan:case S.GreaterThanOrEqualTo:return xm(n);case S.Multiply:case S.Divide:case S.Add:case S.Subtract:case S.Clamp:case S.Mod:case S.Pow:case S.Abs:case S.Floor:case S.Ceil:case S.Round:case S.Sin:case S.Cos:case S.Atan:case S.Sqrt:return Tm(n);case S.Case:return Rm(n);case S.Match:return Cm(n);case S.Interpolate:return Sm(n);case S.ToString:return vm(n);default:throw new Error(`Unsupported operator ${t}`)}}function pm(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=At(n.args[r]);switch(t){case S.Coalesce:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case S.Number:case S.String:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a===t)return a}throw new Error(`Expected one of the values to be a ${t}`)};default:throw new Error(`Unsupported assertion operator ${t}`)}}function ym(n,e){const i=n.args[0].value;switch(n.operator){case S.Get:return s=>{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case S.Var:return s=>s.variables[i];case S.Has:return s=>{const r=n.args;if(!(i in s.properties))return!1;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function xm(n,e){const t=n.operator,i=At(n.args[0]),s=At(n.args[1]);switch(t){case S.Equal:return r=>i(r)===s(r);case S.NotEqual:return r=>i(r)!==s(r);case S.LessThan:return r=>i(r)<s(r);case S.LessThanOrEqualTo:return r=>i(r)<=s(r);case S.GreaterThan:return r=>i(r)>s(r);case S.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${t}`)}}function Em(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=At(n.args[r]);switch(t){case S.Any:return r=>{for(let o=0;o<i;++o)if(s[o](r))return!0;return!1};case S.All:return r=>{for(let o=0;o<i;++o)if(!s[o](r))return!1;return!0};case S.Between:return r=>{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case S.In:return r=>{const o=s[0](r);for(let a=1;a<i;++a)if(o===s[a](r))return!0;return!1};case S.Not:return r=>!s[0](r);default:throw new Error(`Unsupported logical operator ${t}`)}}function Tm(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=At(n.args[r]);switch(t){case S.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=s[a](r);return o};case S.Divide:return r=>s[0](r)/s[1](r);case S.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=s[a](r);return o};case S.Subtract:return r=>s[0](r)-s[1](r);case S.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(o<a)return a;const l=s[2](r);return o>l?l:o};case S.Mod:return r=>s[0](r)%s[1](r);case S.Pow:return r=>Math.pow(s[0](r),s[1](r));case S.Abs:return r=>Math.abs(s[0](r));case S.Floor:return r=>Math.floor(s[0](r));case S.Ceil:return r=>Math.ceil(s[0](r));case S.Round:return r=>Math.round(s[0](r));case S.Sin:return r=>Math.sin(s[0](r));case S.Cos:return r=>Math.cos(s[0](r));case S.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case S.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Rm(n,e){const t=n.args.length,i=new Array(t);for(let s=0;s<t;++s)i[s]=At(n.args[s]);return s=>{for(let r=0;r<t-1;r+=2)if(i[r](s))return i[r+1](s);return i[t-1](s)}}function Cm(n,e){const t=n.args.length,i=new Array(t);for(let s=0;s<t;++s)i[s]=At(n.args[s]);return s=>{const r=i[0](s);for(let o=1;o<t-1;o+=2)if(r===i[o](s))return i[o+1](s);return i[t-1](s)}}function Sm(n,e){const t=n.args.length,i=new Array(t);for(let s=0;s<t;++s)i[s]=At(n.args[s]);return s=>{const r=i[0](s),o=i[1](s);let a,l;for(let h=2;h<t;h+=2){const c=i[h](s);let u=i[h+1](s);const d=Array.isArray(u);if(d&&(u=tm(u)),c>=o)return h===2?u:d?wm(r,o,a,l,c,u):Rs(r,o,a,l,c,u);a=c,l=u}return l}}function vm(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=At(n.args[r]);switch(t){case S.ToString:return r=>{const o=s[0](r);return n.args[0].type===ye?eh(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function Rs(n,e,t,i,s,r){const o=s-t;if(o===0)return i;const a=e-t,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function wm(n,e,t,i,s,r){if(s-t===0)return i;const a=oc(i),l=oc(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[Rs(n,e,t,a[0],s,l[0]),Rs(n,e,t,a[1],s,l[1]),a[2]+Rs(n,e,t,0,s,h),Rs(n,e,t,i[3],s,r[3])];return im(c)}const X={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class Pm extends Qn{constructor(e,t,i,s){super(),this.extent=e,this.pixelRatio_=i,this.resolution=t,this.state=typeof s=="function"?X.IDLE:s,this.image_=null,this.loader=typeof s=="function"?s:null}changed(){this.dispatchEvent(Z.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==X.IDLE&&this.loader){this.state=X.LOADING,this.changed();const e=this.getResolution(),t=Array.isArray(e)?e[0]:e;fl(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(i=>{"image"in i&&(this.image_=i.image),"extent"in i&&(this.extent=i.extent),"resolution"in i&&(this.resolution=i.resolution),"pixelRatio"in i&&(this.pixelRatio_=i.pixelRatio),(i instanceof HTMLImageElement||Gf&&i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=X.LOADED}).catch(i=>{this.state=X.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}}function Im(n,e,t){const i=n;let s=!0,r=!1,o=!1;const a=[Ur(i,Z.LOAD,function(){o=!0,r||e()})];return i.src&&au?(r=!0,i.decode().then(function(){s&&e()}).catch(function(l){s&&(o?e():t())})):a.push(Ur(i,Z.ERROR,t)),function(){s=!1,a.forEach(ue)}}function Am(n,e){return new Promise((t,i)=>{function s(){o(),t(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r)})}function Lm(n,e){return e&&(n.src=e),n.src&&au?new Promise((t,i)=>n.decode().then(()=>t(n)).catch(s=>n.complete&&n.width?t(n):i(s))):Am(n)}class Fm{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const i=this.cache_[t];(e++&3)===0&&!i.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t,i){const s=oa(e,t,i);return s in this.cache_?this.cache_[s]:null}getPattern(e,t,i){const s=oa(e,t,i);return s in this.patternCache_?this.patternCache_[s]:null}set(e,t,i,s,r){const o=oa(e,t,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===X.IDLE&&s.load(),s.getImageState()===X.LOADING?s.ready().then(()=>{this.patternCache_[o]=Yr().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=Yr().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function oa(n,e,t){const i=t?wt(t):"null";return e+":"+n+":"+i}const Rt=new Fm;let ms=null;class Yu extends Qn{constructor(e,t,i,s,r){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?X.IDLE:s,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===X.LOADED){ms||(ms=Te(1,1,void 0,{willReadFrequently:!0})),ms.drawImage(this.image_,0,0);try{ms.getImageData(0,0,1,1),this.tainted_=!1}catch{ms=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(Z.CHANGE)}handleImageError_(){this.imageState_=X.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=X.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],i=Te(e,t);i.fillRect(0,0,e,t),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===X.IDLE){this.image_||this.initializeImage_(),this.imageState_=X.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Lm(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==X.LOADED)return;const t=this.image_,i=Te(Math.ceil(t.width*e),Math.ceil(t.height*e)),s=i.canvas;i.scale(e,e),i.drawImage(t,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Q_(this.color_),i.fillRect(0,0,s.width/e,s.height/e),i.globalCompositeOperation="destination-in",i.drawImage(t,0,0),this.canvas_[e]=s}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===X.LOADED||this.imageState_===X.ERROR)e();else{const t=()=>{(this.imageState_===X.LOADED||this.imageState_===X.ERROR)&&(this.removeEventListener(Z.CHANGE,t),e())};this.addEventListener(Z.CHANGE,t)}})),this.ready_}}function Kr(n,e,t,i,s,r){let o=e===void 0?void 0:Rt.get(e,t,s);return o||(o=new Yu(n,n&&"src"in n?n.src||void 0:e,t,i,s),Rt.set(e,t,s,o,r)),r&&o&&!Rt.getPattern(e,t,s)&&Rt.set(e,t,s,o,r),o}function Nt(n){return n?Array.isArray(n)?eh(n):typeof n=="object"&&"src"in n?bm(n):n:null}function bm(n){if(!n.offset||!n.size)return Rt.getPattern(n.src,"anonymous",n.color);const e=n.src+":"+n.offset,t=Rt.getPattern(e,void 0,n.color);if(t)return t;const i=Rt.get(n.src,"anonymous",null);if(i.getImageState()!==X.LOADED)return null;const s=Te(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Kr(s.canvas,e,void 0,X.LOADED,n.color,!0),Rt.getPattern(e,void 0,n.color)}const Vu="10px sans-serif",tt="#000",Vn="round",ri=[],oi=0,Zn="round",Bs=10,zs="#000",Xs="center",Hr="middle",Wi=[0,0,0,0],js=1,Pn=new bt;let ps=null,uc;const Wa={},Mm=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Dm(n,e,t){return`${n} ${e} 16px "${t}"`}const Om=(function(){let e,t;async function i(r){await t.ready;const o=await t.load(r);if(o.length===0)return!1;const a=Xa(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=za[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function s(){await t.ready;let r=!0;const o=Pn.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(tn(Wa),Pn.set(h,100)):(c+=10,Pn.set(h,c,!0),c<100&&(r=!1)))}e=void 0,r||(e=setTimeout(s,100))}return async function(r){t||(t=st?self.fonts:document.fonts);const o=Xa(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Mm.has(h))continue;const c=Dm(o.style,o.weight,h);Pn.get(c)===void 0&&(Pn.set(c,0,!0),l=!0)}l&&(clearTimeout(e),e=setTimeout(s,100))}})(),Nm=(function(){let n;return function(e){let t=Wa[e];if(t==null){if(st){const i=Xa(e),s=Zu(e,"Žg");t=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=e,document.body.appendChild(n),t=n.offsetHeight,document.body.removeChild(n);Wa[e]=t}return t}})();function Zu(n,e){return ps||(ps=Te(1,1)),n!=uc&&(ps.font=n,uc=ps.font),ps.measureText(e)}function Ku(n,e){return Zu(n,e).width}function dc(n,e,t){if(e in t)return t[e];const i=e.split(`
|
||
`).reduce((s,r)=>Math.max(s,Ku(n,r)),0);return t[e]=i,i}function Gm(n,e){const t=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if(u===`
|
||
`||h===c){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||n.font,f=Ku(d,u);t.push(f),o+=f;const g=Nm(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:i,lineWidths:s}}function km(n,e,t,i,s,r,o,a,l,h,c){n.save(),t!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=t:n.globalAlpha*=t),e&&n.transform.apply(n,e),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),Um(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,h,o*c[0],a*c[1]),n.restore()}function Um(n,e){const t=n.contextInstructions;for(let i=0,s=t.length;i<s;i+=2)Array.isArray(t[i+1])?e[t[i]].apply(e,t[i+1]):e[t[i]]=t[i+1]}class Co{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Se(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new Co({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return W()}getImage(e){return W()}getHitDetectionImage(){return W()}getPixelRatio(e){return 1}getImageState(){return W()}getImageSize(){return W()}getOrigin(){return W()}getSize(){return W()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Se(e)}listenImageChange(e){W()}load(){W()}unlistenImageChange(e){W()}ready(){return Promise.resolve()}}class So extends Co{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,rotation:e.rotation!==void 0?e.rotation:0,scale:e.scale!==void 0?e.scale:1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=e.fill!==void 0?e.fill:null,this.origin_=[0,0],this.points_=e.points,this.radius=e.radius,this.radius2_=e.radius2,this.angle_=e.angle!==void 0?e.angle:0,this.stroke_=e.stroke!==void 0?e.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?X.LOADING:X.LOADED,this.imageState_===X.LOADING&&this.ready().then(()=>this.imageState_=X.LOADED),this.render()}clone(){const e=this.getScale(),t=new So({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}getAnchor(){const e=this.size_,t=this.getDisplacement(),i=this.getScaleArray();return[e[0]/2-t[0]/i[0],e[1]/2+t[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){const t=this.fill_?.getKey(),i=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${t}`+Object.values(this.renderOptions_).join(",");let s=Rt.get(i,null,null)?.getImage(1);if(!s){const r=this.renderOptions_,o=Math.ceil(r.size*e),a=Te(o,o);this.draw_(r,a,e),s=a.canvas,Rt.set(i,null,null,new Yu(s,void 0,null,X.LOADED,null))}return s}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,i){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let s=this.radius,r=this.radius2_===void 0?s:this.radius2_;if(s<r){const R=s;s=r,r=R}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=s-h,u=Math.sqrt(l*l+c*c),d=u/l;if(e==="miter"&&d<=i)return d*t;const f=t/2/d,g=t/2*(c/u),m=Math.sqrt((s+f)*(s+f)+g*g)-s;if(this.radius2_===void 0||e==="bevel")return m*2;const y=s*Math.sin(a),p=Math.sqrt(s*s-y*y),T=r-p,E=Math.sqrt(y*y+T*T)/y;if(E<=i){const R=E*t/2-r-s;return 2*Math.max(m,R)}return m*2}createRenderOptions(){let e=Vn,t=Zn,i=0,s=null,r=0,o,a=0;this.stroke_&&(o=Nt(this.stroke_.getColor()??zs),a=this.stroke_.getWidth()??js,s=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,t=this.stroke_.getLineJoin()??Zn,e=this.stroke_.getLineCap()??Vn,i=this.stroke_.getMiterLimit()??Bs);const l=this.calculateLineJoinSize_(t,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:e,lineDash:s,lineDashOffset:r,lineJoin:t,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const e=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,t,i){if(t.scale(i,i),t.translate(e.size/2,e.size/2),this.createPath_(t),this.fill_){let s=this.fill_.getColor();s===null&&(s=tt),t.fillStyle=Nt(s),t.fill()}e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}createHitDetectionCanvas_(e){let t;if(this.fill_){let i=this.fill_.getColor(),s=0;typeof i=="string"&&(i=wt(i)),i===null?s=1:Array.isArray(i)&&(s=i.length===4?i[3]:1),s===0&&(t=Te(e.size,e.size),this.drawHitDetectionCanvas_(e,t))}return t?t.canvas:this.getImage(1)}createPath_(e){let t=this.points_;const i=this.radius;if(t===1/0)e.arc(0,0,i,0,2*Math.PI);else{const s=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(t*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/t;for(let a=0;a<t;a++){const l=r+a*o,h=a%2===0?i:s;e.lineTo(h*Math.cos(l),h*Math.sin(l))}e.closePath()}}drawHitDetectionCanvas_(e,t){t.translate(e.size/2,e.size/2),this.createPath_(t),t.fillStyle=tt,t.fill(),e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class nr extends So{constructor(e){e=e||{radius:5},super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:e.scale!==void 0?e.scale:1,rotation:e.rotation!==void 0?e.rotation:0,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode})}clone(){const e=this.getScale(),t=new nr({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}setRadius(e){this.radius=e,this.render()}}class Lt{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){const e=this.getColor();return new Lt({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){const t=Kr(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));t.ready().then(()=>{this.patternImage_=null}),t.getImageState()===X.IDLE&&t.load(),t.getImageState()===X.LOADING&&(this.patternImage_=t)}this.color_=e}getKey(){const e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?O(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:wt(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function fc(n,e,t,i){return t!==void 0&&i!==void 0?[t/n,i/e]:t!==void 0?t/n:i!==void 0?i/e:1}class rs extends Co{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,i=e.rotation!==void 0?e.rotation:0,s=e.scale!==void 0?e.scale:1,r=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:i,scale:s,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:r,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;se(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||O(o)),se(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),se(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=X.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?X.LOADED:X.IDLE:l=X.LOADING:l=X.LOADED),this.color_=e.color!==void 0?wt(e.color):null,this.iconImage_=Kr(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let h,c;if(e.size)[h,c]=e.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(fc(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(fc(h,c,e.width,e.height))}}clone(){let e,t,i;return this.initialOptions_?(t=this.initialOptions_.width,i=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new rs({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:t,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=s[0]),this.anchorYUnits_=="fraction"&&(e[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+s[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),i=this.getScaleArray();return[e[0]-t[0]/i[0],e[1]+t[1]/i[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),i=this.iconImage_.getSize();if(!t||!i)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=i[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=i[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(e){this.iconImage_=Kr(null,e,this.crossOrigin_,X.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==X.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==X.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(Z.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(Z.CHANGE,e)}ready(){return this.iconImage_.ready()}}class Bt{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){const e=this.getColor();return new Bt({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}}class ze{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=gc,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new ze({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(t){return t.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=gc,this.geometry_=e}setZIndex(e){this.zIndex_=e}}function Bm(n){let e;if(typeof n=="function")e=n;else{let t;Array.isArray(n)?t=n:(se(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[n]),e=function(){return t}}return e}let aa=null;function Hu(n,e){if(!aa){const t=new Lt({color:"rgba(255,255,255,0.4)"}),i=new Bt({color:"#3399CC",width:1.25});aa=[new ze({image:new nr({fill:t,stroke:i,radius:5}),fill:t,stroke:i})]}return aa}function sh(){const n={},e=[255,255,255,1],t=[0,153,255,1],i=3;return n.Polygon=[new ze({fill:new Lt({color:[255,255,255,.5]})})],n.MultiPolygon=n.Polygon,n.LineString=[new ze({stroke:new Bt({color:e,width:i+2})}),new ze({stroke:new Bt({color:t,width:i})})],n.MultiLineString=n.LineString,n.Circle=n.Polygon.concat(n.LineString),n.Point=[new ze({image:new nr({radius:i*2,fill:new Lt({color:t}),stroke:new Bt({color:e,width:i/2})}),zIndex:1/0})],n.MultiPoint=n.Point,n.GeometryCollection=n.Polygon.concat(n.LineString,n.Point),n}function gc(n){return n.getGeometry()}const zm="#333";class sr{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.keepUpright_=e.keepUpright,this.scale_=e.scale,this.scaleArray_=Se(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new Lt({color:zm}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new sr({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof Lt?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setKeepUpright(e){this.keepUpright_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Se(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}}function Xm(n){return!0}function jm(n){const e=ih(),t=$m(n,e),i=Wu();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,e.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return e.geometryType&&(i.geometryType=nh(s.getGeometry())),t(i)}}function _c(n){const e=ih(),t=n.length,i=new Array(t);for(let o=0;o<t;++o)i[o]=Ya(n[o],e);const s=Wu(),r=new Array(t);return function(o,a){if(s.properties=o.getPropertiesInternal(),s.resolution=a,e.featureId){const h=o.getId();h!==void 0?s.featureId=h:s.featureId=null}let l=0;for(let h=0;h<t;++h){const c=i[h](s);c&&(r[l]=c,l+=1)}return r.length=l,r}}function $m(n,e){const t=n.length,i=new Array(t);for(let s=0;s<t;++s){const r=n[s],o="filter"in r?ci(r.filter,Fe,e):Xm;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=Ya(r.style[h],e)}else a=[Ya(r.style,e)];i[s]={filter:o,styles:a}}return function(s){const r=[];let o=!1;for(let a=0;a<t;++a){const l=i[a].filter;if(l(s)&&!(n[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(s);c&&r.push(c)}}}return r}}function Ya(n,e){const t=$s(n,"",e),i=Ws(n,"",e),s=Wm(n,e),r=Ym(n,e),o=nt(n,"z-index",e);if(!t&&!i&&!s&&!r&&!Ki(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));const a=new ze;return function(l){let h=!0;if(t){const c=t(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(s){const c=s(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function $s(n,e,t){let i;if(e+"fill-pattern-src"in n)i=Hm(n,e+"fill-",t);else{if(n[e+"fill-color"]==="none")return r=>null;i=rh(n,e+"fill-color",t)}if(!i)return null;const s=new Lt;return function(r){const o=i(r);return o===Jl?null:(s.setColor(o),s)}}function Ws(n,e,t){const i=nt(n,e+"stroke-width",t),s=rh(n,e+"stroke-color",t);if(!i&&!s)return null;const r=ei(n,e+"stroke-line-cap",t),o=ei(n,e+"stroke-line-join",t),a=qu(n,e+"stroke-line-dash",t),l=nt(n,e+"stroke-line-dash-offset",t),h=nt(n,e+"stroke-miter-limit",t),c=new Bt;return function(u){if(s){const d=s(u);if(d===Jl)return null;c.setColor(d)}if(i&&c.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function Wm(n,e){const t="text-",i=ei(n,t+"value",e);if(!i)return null;const s=$s(n,t,e),r=$s(n,t+"background-",e),o=Ws(n,t,e),a=Ws(n,t+"background-",e),l=ei(n,t+"font",e),h=nt(n,t+"max-angle",e),c=nt(n,t+"offset-x",e),u=nt(n,t+"offset-y",e),d=Gn(n,t+"overflow",e),f=ei(n,t+"placement",e),g=nt(n,t+"repeat",e),_=vo(n,t+"scale",e),m=Gn(n,t+"rotate-with-view",e),y=nt(n,t+"rotation",e),p=ei(n,t+"align",e),T=ei(n,t+"justify",e),x=ei(n,t+"baseline",e),E=Gn(n,t+"keep-upright",e),R=qu(n,t+"padding",e),C=wo(n,t+"declutter-mode"),v=new sr({declutterMode:C});return function(w){if(v.setText(i(w)),s&&v.setFill(s(w)),r&&v.setBackgroundFill(r(w)),o&&v.setStroke(o(w)),a&&v.setBackgroundStroke(a(w)),l&&v.setFont(l(w)),h&&v.setMaxAngle(h(w)),c&&v.setOffsetX(c(w)),u&&v.setOffsetY(u(w)),d&&v.setOverflow(d(w)),f){const P=f(w);if(P!=="point"&&P!=="line")throw new Error("Expected point or line for text-placement");v.setPlacement(P)}if(g&&v.setRepeat(g(w)),_&&v.setScale(_(w)),m&&v.setRotateWithView(m(w)),y&&v.setRotation(y(w)),p){const P=p(w);if(P!=="left"&&P!=="center"&&P!=="right"&&P!=="end"&&P!=="start")throw new Error("Expected left, right, center, start, or end for text-align");v.setTextAlign(P)}if(T){const P=T(w);if(P!=="left"&&P!=="right"&&P!=="center")throw new Error("Expected left, right, or center for text-justify");v.setJustify(P)}if(x){const P=x(w);if(P!=="bottom"&&P!=="top"&&P!=="middle"&&P!=="alphabetic"&&P!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");v.setTextBaseline(P)}return R&&v.setPadding(R(w)),E&&v.setKeepUpright(E(w)),v}}function Ym(n,e){return"icon-src"in n?Vm(n,e):"shape-points"in n?Zm(n,e):"circle-radius"in n?Km(n,e):null}function Vm(n,e){const t="icon-",i=t+"src",s=Ju(n[i],i),r=qr(n,t+"anchor",e),o=vo(n,t+"scale",e),a=nt(n,t+"opacity",e),l=qr(n,t+"displacement",e),h=nt(n,t+"rotation",e),c=Gn(n,t+"rotate-with-view",e),u=pc(n,t+"anchor-origin"),d=yc(n,t+"anchor-x-units"),f=yc(n,t+"anchor-y-units"),g=ep(n,t+"color"),_=Jm(n,t+"cross-origin"),m=Qm(n,t+"offset"),y=pc(n,t+"offset-origin"),p=Jr(n,t+"width"),T=Jr(n,t+"height"),x=qm(n,t+"size"),E=wo(n,t+"declutter-mode"),R=new rs({src:s,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:_,offset:m,offsetOrigin:y,height:T,width:p,size:x,declutterMode:E});return function(C){return a&&R.setOpacity(a(C)),l&&R.setDisplacement(l(C)),h&&R.setRotation(h(C)),c&&R.setRotateWithView(c(C)),o&&R.setScale(o(C)),r&&R.setAnchor(r(C)),R}}function Zm(n,e){const t="shape-",i=t+"points",s=t+"radius",r=Va(n[i],i),o=Va(n[s],s),a=$s(n,t,e),l=Ws(n,t,e),h=vo(n,t+"scale",e),c=qr(n,t+"displacement",e),u=nt(n,t+"rotation",e),d=Gn(n,t+"rotate-with-view",e),f=Jr(n,t+"radius2"),g=Jr(n,t+"angle"),_=wo(n,t+"declutter-mode"),m=new So({points:r,radius:o,radius2:f,angle:g,declutterMode:_});return function(y){return a&&m.setFill(a(y)),l&&m.setStroke(l(y)),c&&m.setDisplacement(c(y)),u&&m.setRotation(u(y)),d&&m.setRotateWithView(d(y)),h&&m.setScale(h(y)),m}}function Km(n,e){const t="circle-",i=$s(n,t,e),s=Ws(n,t,e),r=nt(n,t+"radius",e),o=vo(n,t+"scale",e),a=qr(n,t+"displacement",e),l=nt(n,t+"rotation",e),h=Gn(n,t+"rotate-with-view",e),c=wo(n,t+"declutter-mode"),u=new nr({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),s&&u.setStroke(s(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function nt(n,e,t){if(!(e in n))return;const i=ci(n[e],B,t);return function(s){return Va(i(s),e)}}function ei(n,e,t){if(!(e in n))return null;const i=ci(n[e],Me,t);return function(s){return Ju(i(s),e)}}function Hm(n,e,t){const i=ei(n,e+"pattern-src",t),s=mc(n,e+"pattern-offset",t),r=mc(n,e+"pattern-size",t),o=rh(n,e+"color",t);return function(a){return{src:i(a),offset:s&&s(a),size:r&&r(a),color:o&&o(a)}}}function Gn(n,e,t){if(!(e in n))return null;const i=ci(n[e],Fe,t);return function(s){const r=i(s);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${e}`);return r}}function rh(n,e,t){if(!(e in n))return null;const i=ci(n[e],ye,t);return function(s){return Qu(i(s),e)}}function qu(n,e,t){if(!(e in n))return null;const i=ci(n[e],ot,t);return function(s){return rr(i(s),e)}}function qr(n,e,t){if(!(e in n))return null;const i=ci(n[e],ot,t);return function(s){const r=rr(i(s),e);if(r.length!==2)throw new Error(`Expected two numbers for ${e}`);return r}}function mc(n,e,t){if(!(e in n))return null;const i=ci(n[e],ot,t);return function(s){return ed(i(s),e)}}function vo(n,e,t){if(!(e in n))return null;const i=ci(n[e],ot|B,t);return function(s){return tp(i(s),e)}}function Jr(n,e){const t=n[e];if(t!==void 0){if(typeof t!="number")throw new Error(`Expected a number for ${e}`);return t}}function qm(n,e){const t=n[e];if(t!==void 0){if(typeof t=="number")return Se(t);if(!Array.isArray(t))throw new Error(`Expected a number or size array for ${e}`);if(t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return t}}function Jm(n,e){const t=n[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);return t}}function pc(n,e){const t=n[e];if(t!==void 0){if(t!=="bottom-left"&&t!=="bottom-right"&&t!=="top-left"&&t!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return t}}function yc(n,e){const t=n[e];if(t!==void 0){if(t!=="pixels"&&t!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return t}}function Qm(n,e){const t=n[e];if(t!==void 0)return rr(t,e)}function wo(n,e){const t=n[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);if(t!=="declutter"&&t!=="obstacle"&&t!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return t}}function ep(n,e){const t=n[e];if(t!==void 0)return Qu(t,e)}function rr(n,e){if(!Array.isArray(n))throw new Error(`Expected an array for ${e}`);const t=n.length;for(let i=0;i<t;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${e}`);return n}function Ju(n,e){if(typeof n!="string")throw new Error(`Expected a string for ${e}`);return n}function Va(n,e){if(typeof n!="number")throw new Error(`Expected a number for ${e}`);return n}function Qu(n,e){if(typeof n=="string")return n;const t=rr(n,e),i=t.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function ed(n,e){const t=rr(n,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function tp(n,e){return typeof n=="number"?n:ed(n,e)}const xc={RENDER_ORDER:"renderOrder"};class os extends ir{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(xc.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){const i=this.getDeclutter();i in e.declutter||(e.declutter[i]=new ql(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(xc.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Hu:e;const t=ip(e);this.styleFunction_=e===null?void 0:Bm(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}}function ip(n){if(n===void 0)return Hu;if(!n)return null;if(typeof n=="function"||n instanceof ze)return n;if(!Array.isArray(n))return _c([n]);if(n.length===0)return[];const e=n.length,t=n[0];if(t instanceof ze){const s=new Array(e);for(let r=0;r<e;++r){const o=n[r];if(!(o instanceof ze))throw new Error("Expected a list of style instances");s[r]=o}return s}if("style"in t){const s=new Array(e);for(let r=0;r<e;++r){const o=n[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");s[r]=o}return jm(s)}return _c(n)}class Ps extends Pt{constructor(e,t,i,s){super(e),this.inversePixelTransform=t,this.frameState=i,this.context=s}}class np extends Ks{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){W()}calculateMatrices2D(e){const t=e.viewState,i=e.coordinateToPixelTransform,s=e.pixelToCoordinateTransform;ft(i,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),Gs(s,i)}forEachFeatureAtCoordinate(e,t,i,s,r,o,a,l){let h;const c=t.viewState;function u(x,E,R,C){return r.call(o,E,x?R:null,C)}const d=c.projection,f=Cl(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const x=d.getExtent(),E=te(x);g.push([-E,0],[E,0])}const _=t.layerStatesArray,m=_.length,y=[],p=[];for(let x=0;x<g.length;x++)for(let E=m-1;E>=0;--E){const R=_[E],C=R.layer;if(C.hasRenderer()&&Hl(R,c)&&a.call(l,C)){const v=C.getRenderer(),w=C.getSource();if(v&&w){const P=w.getWrapX()?f:e,A=u.bind(null,R.managed);p[0]=P[0]+g[x][0],p[1]=P[1]+g[x][1],h=v.forEachFeatureAtCoordinate(p,t,i,A,y)}if(h)return h}}if(y.length===0)return;const T=1/y.length;return y.forEach((x,E)=>x.distanceSq+=E*T),y.sort((x,E)=>x.distanceSq-E.distanceSq),y.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(e,t,i,s,r,o){return this.forEachFeatureAtCoordinate(e,t,i,s,Li,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){W()}scheduleExpireIconCache(e){Rt.canExpireCache()&&e.postRenderFunctions.push(sp)}}function sp(n,e){Rt.expire()}class rp extends np{constructor(e){super(e),this.fontChangeListenerKey_=ee(Pn,jn.PROPERTYCHANGE,e.redrawText,e),this.element_=st?Ou():document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=tr+" ol-layers";const i=e.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){const i=this.getMap();if(i.hasListener(e)){const s=new Ps(e,void 0,t);i.dispatchEvent(s)}}disposeInternal(){ue(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(ke.PRECOMPOSE,e);const t=e.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);t.some(h=>h.layer instanceof os&&h.layer.getDeclutter())&&(e.declutter={});const s=e.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=t.length;h<c;++h){const u=t[h];e.layerIndex=h;const d=u.layer,f=d.getSourceState();if(!Hl(u,s)||f!="ready"&&f!="undefined"){d.unrender();continue}const g=d.render(e,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(u))}this.declutter(e,r),p_(this.element_,this.children_);const l=this.getMap().getTargetElement();if(Ci(l)){const h=l.getContext("2d");for(const c of this.children_){const u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!Ci(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),Ci(u)&&u.width>0){const f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=u.style.transform;if(g)h.setTransform(...ka(g));else{const _=parseFloat(u.style.width)/u.width,m=parseFloat(u.style.height)/u.height;h.setTransform(_,0,0,m,0,0)}h.drawImage(u,0,0)}}h.globalAlpha=1,h.setTransform(1,0,0,1,0,0)}this.dispatchRenderEvent(ke.POSTCOMPOSE,e),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let i=t.length-1;i>=0;--i){const s=t[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(e,s)}t.forEach(i=>i.layer.renderDeferred(e))}}}function td(n){if(n instanceof ir){n.setMapInternal(null);return}n instanceof ss&&n.getLayers().forEach(td)}function id(n,e){if(n instanceof ir){n.setMapInternal(e);return}if(n instanceof ss){const t=n.getLayers().getArray();for(let i=0,s=t.length;i<s;++i)id(t[i],e)}}let dT=class extends bt{constructor(e){super(),e=e||{},this.on,this.once,this.un;const t=op(e);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=e.maxTilesLoading!==void 0?e.maxTilesLoading:16,this.pixelRatio_=e.pixelRatio!==void 0?e.pixelRatio:Nf,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Ce(),this.pixelToCoordinateTransform_=Ce(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,st||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=e.moveTolerance,this.keyboardEventTarget_=t.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,st||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=t.controls||(st?new qe:T_()),this.interactions=t.interactions||(st?new qe:z_({onFocusOnly:!0})),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Bf(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(je.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(je.VIEW,this.handleViewChanged_),this.addChangeListener(je.SIZE,this.handleSizeChanged_),this.addChangeListener(je.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const i=this;e.view&&!(e.view instanceof ii)&&e.view.then(function(s){i.setView(new ii(s))}),this.controls.addEventListener(Le.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(Le.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(Le.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(Le.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(Le.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(Le.REMOVE,s=>{const r=s.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],s.element.setMap(null)}),this.controls.forEach(s=>{s.setMap(this)}),this.interactions.forEach(s=>{s.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){id(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(e);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Li,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,t,null,o,null)}getFeaturesAtPixel(e,t){const i=[];return this.forEachFeatureAtPixel(e,function(s){i.push(s)},t),i}getAllLayers(){const e=[];function t(i){i.forEach(function(s){s instanceof ss?t(s.getLayers()):e.push(s)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const s=t.layerFilter!==void 0?t.layerFilter:Li,r=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(je.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return Qi(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?me(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(je.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof qe){t.setLayers(e);return}const i=t.getLayers();i.clear(),i.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,i=e.length;t<i;++t){const s=e[t];if(!s.visible)continue;const r=s.layer.getRenderer();if(r&&!r.ready)return!0;const o=s.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(e){const t=xe(e,this.getView().getProjection());return this.getPixelFromCoordinateInternal(t)}getPixelFromCoordinateInternal(e){const t=this.frameState_;return t?me(t.coordinateToPixelTransform,e.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(je.SIZE)}getView(){return this.get(je.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const e=this.getTargetElement();return e?e.ownerDocument:document}getTilePriority(e,t,i,s){return zf(this.frameState_,e,t,i,s)}handleBrowserEvent(e,t){t=t||e.type;const i=new Jt(t,this,e);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(e){if(!this.frameState_)return;const t=e.originalEvent,i=t.type;if(i===Aa.POINTERDOWN||i===Z.WHEEL||i===Z.KEYDOWN){const s=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():s,o=t.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===s?s.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(e.frameState=this.frameState_,this.dispatchEvent(e)!==!1){const s=this.getInteractions().getArray().slice();for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let s=this.maxTilesLoading_,r=s;if(e){const o=e.viewHints;if(o[de.ANIMATING]||o[de.INTERACTING]){const a=Date.now()-e.time>8;s=a?0:8,r=a?0:2}}t.getTilesLoading()<s&&(t.reprioritize(),t.loadMoreTiles(s,r))}e&&this.renderer_&&!e.animate&&(this.renderComplete_?(this.hasListener(ke.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(ke.RENDERCOMPLETE,e),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new vn(Qt.LOADEND,this,e)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new vn(Qt.LOADSTART,this,e))));const i=this.postRenderFunctions_;if(e)for(let s=0,r=i.length;s<r;++s)i[s](this,e);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,s=this.targetChangeHandlerKeys_.length;i<s;++i)ue(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(Z.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(Z.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!Ci(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const e=this.getTarget(),t=typeof e=="string"?document.getElementById(e):e;if(this.targetElement_=t,!t)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(Ci(t)||t.appendChild(this.viewport_),this.renderer_||(this.renderer_=new rp(this)),!Ci(t)){this.mapBrowserEventHandler_=new kf(this,this.moveTolerance_);for(const s in ne)this.mapBrowserEventHandler_.addEventListener(ne[s],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(Z.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(Z.WHEEL,this.boundHandleBrowserEvent_,lu?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const s=t.getRootNode();i=s instanceof ShadowRoot?s.host:t}if(this.targetChangeHandlerKeys_=[ee(i,Z.KEYDOWN,this.handleBrowserEvent,this),ee(i,Z.KEYPRESS,this.handleBrowserEvent,this)],t instanceof HTMLElement){const s=t.getRootNode();s instanceof ShadowRoot&&this.resizeObserver_.observe(s.host),this.resizeObserver_?.observe(t)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(ue(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(ue(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const e=this.getView();e&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=ee(e,jn.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=ee(e,Z.CHANGE,this.handleViewPropertyChanged_,this),e.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(ue),this.layerGroupPropertyListenerKeys_=null);const e=this.getLayerGroup();e&&(this.handleLayerAdd_(new xi("addlayer",e)),this.layerGroupPropertyListenerKeys_=[ee(e,jn.PROPERTYCHANGE,this.render,this),ee(e,Z.CHANGE,this.render,this),ee(e,"addlayer",this.handleLayerAdd_,this),ee(e,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const e=this.frameState_.layerStatesArray;for(let t=0,i=e.length;t<i;++t){const s=e[t].layer;s.hasRenderer()&&s.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(e){return this.getControls().remove(e)}removeInteraction(e){return this.getInteractions().remove(e)}removeLayer(e){return this.getLayerGroup().getLayers().remove(e)}handleLayerRemove_(e){td(e.layer)}removeOverlay(e){return this.getOverlays().remove(e)}renderFrame_(e){const t=this.getSize(),i=this.getView(),s=this.frameState_;let r=null;if(t!==void 0&&ac(t)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:ba(a.center,a.resolution,a.rotation,t),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:t,tileQueue:this.tileQueue_,time:e,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:O(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=ba(a.nextCenter,a.nextResolution,l,t)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),s&&(!this.previousExtent_||!Di(this.previousExtent_)&&!qi(r.extent,this.previousExtent_))&&(this.dispatchEvent(new vn(Qt.MOVESTART,this,s)),this.previousExtent_=ts(this.previousExtent_)),this.previousExtent_&&!r.viewHints[de.ANIMATING]&&!r.viewHints[de.INTERACTING]&&!qi(r.extent,this.previousExtent_)&&(this.dispatchEvent(new vn(Qt.MOVEEND,this,r)),hu(r.extent,this.previousExtent_))),this.dispatchEvent(new vn(Qt.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Qt.LOADSTART)||this.hasListener(Qt.LOADEND)||this.hasListener(ke.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new xi("removelayer",t)),this.set(je.LAYERGROUP,e)}setSize(e){this.set(je.SIZE,e)}setTarget(e){this.set(je.TARGET,e)}setView(e){if(!e||e instanceof ii){this.set(je.VIEW,e);return}this.set(je.VIEW,new ii);const t=this;e.then(function(i){t.setView(new ii(i))})}updateSize(){const e=this.getTargetElement();let t;if(e){let s,r;if(Ci(e))s=e.width,r=e.height;else{const o=getComputedStyle(e);s=e.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=e.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(s)&&!isNaN(r)&&(t=[Math.max(0,s),Math.max(0,r)],!ac(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&gu("No map visible because the map container's width or height are 0."))}const i=this.getSize();t&&(!i||!jt(t,i))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}};function op(n){let e=null;n.keyboardEventTarget!==void 0&&(e=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const t={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new ss({layers:n.layers});t[je.LAYERGROUP]=i,t[je.TARGET]=n.target,t[je.VIEW]=n.view instanceof ii?n.view:new ii;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new qe(n.controls.slice()):(se(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=n.controls));let r;n.interactions!==void 0&&(Array.isArray(n.interactions)?r=new qe(n.interactions.slice()):(se(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new qe(n.overlays.slice()):(se(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new qe,{controls:s,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const Xe={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class gT extends bt{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+f_,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Xe.ELEMENT,this.handleElementChanged),this.addChangeListener(Xe.MAP,this.handleMapChanged),this.addChangeListener(Xe.OFFSET,this.handleOffsetChanged),this.addChangeListener(Xe.POSITION,this.handlePositionChanged),this.addChangeListener(Xe.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(Xe.ELEMENT)}getId(){return this.id}getMap(){return this.get(Xe.MAP)||null}getOffset(){return this.get(Xe.OFFSET)}getPosition(){return this.get(Xe.POSITION)}getPositioning(){return this.get(Xe.POSITIONING)}handleElementChanged(){Du(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),ue(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=ee(e,Qt.POSTRENDER,this.render,this),this.updatePixelPosition();const t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(Xe.ELEMENT,e)}setMap(e){this.set(Xe.MAP,e)}setOffset(e){this.set(Xe.OFFSET,e)}setPosition(e){this.set(Xe.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(Xe.POSITION))return;const i=this.getRect(t.getTargetElement(),t.getSize()),s=this.getElement(),r=this.getRect(s,[__(s),m_(s)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!Ti(i,r)){const a=r[0]-i[0],l=i[2]-r[2],h=r[1]-i[1],c=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),h<0?u[1]=h-o:c<0&&(u[1]=Math.abs(c)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],_=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:_.duration,easing:_.easing})}}}getRect(e,t){const i=e.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+t[0],r+t[1]]}setPositioning(e){this.set(Xe.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const i=e.getPixelFromCoordinate(t),s=e.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(e,t){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${e[0]+s[0]}px`,a=`${e[1]+s[1]}px`;let l="0%",h="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?h="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(h="-50%");const c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,i.transform=c)}getOptions(){return this.options}}class oh extends Qn{constructor(e,t,i){super(),i=i||{},this.tileCoord=e,this.state=t,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(Z.CHANGE)}release(){this.setState(D.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==D.EMPTY){if(this.state!==D.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}}load(){W()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;const s=t-i+1e3/60;return s>=this.transition_?1:fu(s/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function Kn(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}function Za(n){return n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Float32Array||n instanceof DataView?n:null}const ap=new Error("disposed");let yn=null;function lp(n){yn||(yn=Te(n.width,n.height,void 0,{willReadFrequently:!0}));const e=yn.canvas,t=n.width;e.width!==t&&(e.width=t);const i=n.height;return e.height!==i&&(e.height=i),yn.clearRect(0,0,t,i),yn.drawImage(n,0,0),yn.getImageData(0,0,t,i).data}const hp=[256,256];class Ys extends oh{constructor(e){const t=D.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;const e=Kn(this.data_);return e?[e.width,e.height]:hp}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==D.IDLE&&this.state!==D.ERROR)return;this.state=D.LOADING,this.changed();const e=this;this.loader_().then(function(t){e.data_=t,e.state=D.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=D.ERROR,e.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(ap),this.controller_=null),super.disposeInternal()}}class Po extends oh{constructor(e,t,i,s,r,o){super(e,t,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_,st?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,s!==null&&(this.image_.crossOrigin=s)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=D.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}handleImageError_(){this.state=D.ERROR,this.unlistenImage_(),this.image_=cp(),this.changed()}handleImageLoad_(){if(st)this.state=D.LOADED;else{const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=D.LOADED:this.state=D.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==D.ERROR&&(this.state=D.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==D.IDLE&&(this.state=D.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Im(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}function cp(){const n=Te(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}class Io{constructor(e,t,i,s){this.minX=e,this.maxX=t,this.minY=i,this.maxY=s}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minX<this.minX&&(this.minX=e.minX),e.maxX>this.maxX&&(this.maxX=e.maxX),e.minY<this.minY&&(this.minY=e.minY),e.maxY>this.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function xn(n,e,t,i,s){return s!==void 0?(s.minX=n,s.maxX=e,s.minY=t,s.maxY=i,s):new Io(n,e,t,i)}let la;const kn=[];function Ec(n,e,t,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(e,t),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(e,i)+1,Math.max(t,s)),n.restore()}function ha(n,e){return Math.abs(n[e*4]-210)>2||Math.abs(n[e*4+3]-.75*255)>2}function up(){if(la===void 0){const n=Te(6,6,kn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",Ec(n,4,5,4,0),Ec(n,4,5,0,5);const e=n.getImageData(0,0,3,3).data;la=ha(e,0)||ha(e,4)||ha(e,8),To(n),kn.push(n.canvas)}return la}function Ka(n,e,t,i){const s=Js(t,e,n);let r=jr(e,i,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||li(l,s)){const h=jr(n,r,s)/r;isFinite(h)&&h>0&&(r/=h)}return r}function nd(n,e,t,i){const s=Fi(t);let r=Ka(n,e,s,i);return(!isFinite(r)||r<=0)&&yl(t,function(o){return r=Ka(n,e,o,i),isFinite(r)&&r>0}),r}function dp(n,e,t,i,s,r,o,a,l,h,c,u,d,f){const g=Te(Math.round(t*n),Math.round(t*e),kn);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function _(E){return Math.round(E*t)/t}g.globalCompositeOperation="lighter";const m=Qe();l.forEach(function(E,R,C){pl(m,E.extent)});let y;const p=t/i,T=(u?1:1+Math.pow(2,-24))/p;y=Te(Math.round(te(m)*p),Math.round(Ie(m)*p),kn),u||(y.imageSmoothingEnabled=!1),l.forEach(function(E,R,C){if(E.image.width>0&&E.image.height>0){if(E.clipExtent){y.save();const I=(E.clipExtent[0]-m[0])*p,F=-(E.clipExtent[3]-m[3])*p,b=te(E.clipExtent)*p,k=Ie(E.clipExtent)*p;y.rect(u?I:Math.round(I),u?F:Math.round(F),u?b:Math.round(I+b)-Math.round(I),u?k:Math.round(F+k)-Math.round(F)),y.clip()}const v=(E.extent[0]-m[0])*p,w=-(E.extent[3]-m[3])*p,P=te(E.extent)*p,A=Ie(E.extent)*p;y.drawImage(E.image,h,h,E.image.width-2*h,E.image.height-2*h,u?v:Math.round(v),u?w:Math.round(w),u?P:Math.round(v+P)-Math.round(v),u?A:Math.round(w+A)-Math.round(w)),E.clipExtent&&y.restore()}});const x=Xt(o);return a.getTriangles().forEach(function(E,R,C){const v=E.source,w=E.target;let P=v[0][0],A=v[0][1],I=v[1][0],F=v[1][1],b=v[2][0],k=v[2][1];const M=_((w[0][0]-x[0])/r),G=_(-(w[0][1]-x[1])/r),N=_((w[1][0]-x[0])/r),j=_(-(w[1][1]-x[1])/r),$=_((w[2][0]-x[0])/r),J=_(-(w[2][1]-x[1])/r),L=P,ie=A;P=0,A=0,I-=L,F-=ie,b-=L,k-=ie;const fe=[[I,F,0,0,N-M],[b,k,0,0,$-M],[0,0,I,F,j-G],[0,0,b,k,J-G]],ae=jf(fe);if(!ae)return;if(g.save(),g.beginPath(),up()||!u){g.moveTo(N,j);const we=4,gt=M-N,at=G-j;for(let Ve=0;Ve<we;Ve++)g.lineTo(N+_((Ve+1)*gt/we),j+_(Ve*at/(we-1))),Ve!=we-1&&g.lineTo(N+_((Ve+1)*gt/we),j+_((Ve+1)*at/(we-1)));g.lineTo($,J)}else g.moveTo(N,j),g.lineTo(M,G),g.lineTo($,J);g.clip(),g.transform(ae[0],ae[2],ae[1],ae[3],M,G),g.translate(m[0]-L,m[3]-ie);let ve;if(y)ve=y.canvas,g.scale(T,-T);else{const we=l[0],gt=we.extent;ve=we.image,g.scale(te(gt)/ve.width,-Ie(gt)/ve.height)}g.drawImage(ve,0,0),g.restore()}),y&&(To(y),kn.push(y.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(E,R,C){const v=E.target,w=(v[0][0]-x[0])/r,P=-(v[0][1]-x[1])/r,A=(v[1][0]-x[0])/r,I=-(v[1][1]-x[1])/r,F=(v[2][0]-x[0])/r,b=-(v[2][1]-x[1])/r;g.beginPath(),g.moveTo(A,I),g.lineTo(w,P),g.lineTo(F,b),g.closePath(),g.stroke()}),g.restore()),g.canvas}const fp=10,Tc=.25;class sd{constructor(e,t,i,s,r,o,a){this.sourceProj_=e,this.targetProj_=t;let l={};const h=a?Mg(T=>me(a,Js(T,this.targetProj_,this.sourceProj_))):Ji(this.targetProj_,this.sourceProj_);this.transformInv_=function(T){const x=T[0]+"/"+T[1];return l[x]||(l[x]=h(T)),l[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&te(s)>=te(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?te(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?te(this.targetProj_.getExtent()):null;const c=Xt(i),u=uo(i),d=co(i),f=ho(i),g=this.transformInv_(c),_=this.transformInv_(u),m=this.transformInv_(d),y=this.transformInv_(f),p=fp+(o?Math.max(0,Math.ceil(Math.log2(Os(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,_,m,y,p),this.wrapsXInSource_){let T=1/0;this.triangles_.forEach(function(x,E,R){T=Math.min(T,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-T>this.sourceWorldWidth_/2){const E=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];E[0][0]-T>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-T>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-T>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);const R=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-R<this.sourceWorldWidth_/2&&(x.source=E)}})}l={}}addTriangle_(e,t,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[e,t,i]})}addQuad_(e,t,i,s,r,o,a,l,h){const c=Be([r,o,a,l]),u=this.sourceWorldWidth_?te(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const m=Be([e,t,i,s]);g=te(m)/this.targetWorldWidth_>Tc||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>Tc||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Pe(c,this.maxSourceExtent_))return;let _=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(_=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),_!=1&&_!=2&&_!=4&&_!=8)return}if(h>0){if(!g){const m=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(m);let p;f?p=(si(r[0],d)+si(a[0],d))/2-si(y[0],d):p=(r[0]+a[0])/2-y[0];const T=(r[1]+a[1])/2-y[1];g=p*p+T*T>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){const m=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(m),p=[(s[0]+e[0])/2,(s[1]+e[1])/2],T=this.transformInv_(p);this.addQuad_(e,t,m,p,r,o,y,T,h-1),this.addQuad_(p,m,i,s,T,y,a,l,h-1)}else{const m=[(e[0]+t[0])/2,(e[1]+t[1])/2],y=this.transformInv_(m),p=[(i[0]+s[0])/2,(i[1]+s[1])/2],T=this.transformInv_(p);this.addQuad_(e,m,p,s,r,y,T,l,h-1),this.addQuad_(m,t,i,p,y,o,a,T,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(_&11)==0&&this.addTriangle_(e,i,s,r,a,l),(_&14)==0&&this.addTriangle_(e,i,t,r,a,o),_&&((_&13)==0&&this.addTriangle_(t,s,e,o,l,r),(_&7)==0&&this.addTriangle_(t,s,i,o,l,a))}calculateSourceExtent(){const e=Qe();return this.triangles_.forEach(function(t,i,s){const r=t.source;Ss(e,r[0]),Ss(e,r[1]),Ss(e,r[2])}),e}getTriangles(){return this.triangles_}}const rd=.5;class ah extends oh{constructor(e,t,i,s,r,o,a,l,h,c,u,d){super(r,D.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=s,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;const f=s.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let _=this.sourceTileGrid_.getExtent();const m=g?We(f,g):f;if(Os(m)===0){this.state=D.EMPTY;return}const y=e.getExtent();y&&(_?_=We(_,y):_=y);const p=s.getResolution(this.wrappedTileCoord_[0]),T=nd(e,i,m,p);if(!isFinite(T)||T<=0){this.state=D.EMPTY;return}const x=c!==void 0?c:rd;if(this.triangulation_=new sd(e,i,m,_,T*x,p),this.triangulation_.getTriangles().length===0){this.state=D.EMPTY;return}this.sourceZ_=t.getZForResolution(T);let E=this.triangulation_.calculateSourceExtent();if(_&&(e.canWrapX()?(E[1]=_e(E[1],_[1],_[3]),E[3]=_e(E[3],_[1],_[3])):E=We(E,_)),!Os(E))this.state=D.EMPTY;else{let R=0,C=0;e.canWrapX()&&(R=te(y),C=Math.floor((E[0]-y[0])/R)),El(E.slice(),e,!0).forEach(w=>{const P=t.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let A=P.minX;A<=P.maxX;A++)for(let I=P.minY;I<=P.maxY;I++){const F=h(this.sourceZ_,A,I,a);if(F){const b=C*R;this.sourceTiles_.push({tile:F,offset:b})}}++C}),this.sourceTiles_.length===0&&(this.state=D.EMPTY)}}getImage(){return this.canvas_}reproject_(){const e=[];if(this.sourceTiles_.forEach(t=>{const i=t.tile;if(i&&i.getState()==D.LOADED){const s=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);s[0]+=t.offset,s[2]+=t.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=t.offset,r[2]+=t.offset),e.push({extent:s,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=D.ERROR;else{const t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=dp(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=D.LOADED}this.changed()}load(){if(this.state==D.IDLE){this.state=D.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{const i=t.getState();if(i==D.IDLE||i==D.LOADING){e++;const s=ee(t,Z.CHANGE,r=>{const o=t.getState();(o==D.LOADED||o==D.ERROR||o==D.EMPTY)&&(ue(s),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},i,s){t.getState()==D.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ue),this.sourcesListenerKeys_=null}release(){this.canvas_&&(To(this.canvas_.getContext("2d")),kn.push(this.canvas_),this.canvas_=null),super.release()}}class Ha{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const e=this.pop();e instanceof Ks&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const i=this.entries_[e];return se(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(e){const t=this.entries_[e];return se(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){se(!(e in this.entries_),"Tried to set a value for a key that is used already");const i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}}function Hn(n,e,t,i){return i!==void 0?(i[0]=n,i[1]=e,i[2]=t,i):[n,e,t]}function od(n,e,t){return n+"/"+e+"/"+t}function In(n){return od(n[0],n[1],n[2])}function Is(n,e,t,i,s){return`${O(n)},${e},${od(t,i,s)}`}function ad(n){return gp(n[0],n[1],n[2])}function gp(n,e,t){return(e<<n)+t}function _p(n,e){const t=n[0],i=n[1],s=n[2];if(e.getMinZoom()>t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(i,s):!0}class lh{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Yr(),{get:(e,t)=>{if(typeof Yr()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,i)=>(this.push_(t,i),!0)})}push_(...e){const t=this.instructions_,i=this.zIndex+this.offset_;t[i]||(t[i]=[]),t[i].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let i=0,s=t.length;i<s;++i){const r=t[i];if(typeof r=="function"){r(e);continue}const o=t[++i];if(typeof e[r]=="function")e[r](...o);else{if(typeof o=="function"){e[r]=o(e);continue}e[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const mp=5;class ld extends Hs{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=mp}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return W()}getData(e){return null}prepareFrame(e){return W()}renderFrame(e,t){return W()}forEachFeatureAtCoordinate(e,t,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===X.LOADED||t.getState()===X.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=X.LOADED&&t!=X.ERROR&&e.addEventListener(Z.CHANGE,this.boundHandleImageChange_),t==X.IDLE&&(e.load(),t=e.getState()),t==X.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Rc=[];let An=null;function pp(){An=Te(1,1,void 0,{willReadFrequently:!0})}class hh extends ld{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Ce(),this.pixelTransform=Ce(),this.inversePixelTransform=Ce(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,i){An||pp(),An.clearRect(0,0,1,1);let s;try{An.drawImage(e,t,i,1,1,0,0,1,1),s=An.getImageData(0,0,1,1).data}catch{return An=null,null}return s}getBackground(e){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(e.viewState.resolution)),i||void 0}useContainer(e,t,i){const s=this.getLayer().getClassName();let r,o;if(e&&e.className===s&&(!i||e&&e.style.backgroundColor&&jt(wt(e.style.backgroundColor),wt(i)))){const a=e.firstElementChild;Ci(a)&&(o=a.getContext("2d"))}if(o&&Xg(o.canvas.style.transform,t)?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=st?Ou():document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=Te();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(e,t,i){const s=Xt(i),r=uo(i),o=co(i),a=ho(i);me(t.coordinateToPixelTransform,s),me(t.coordinateToPixelTransform,r),me(t.coordinateToPixelTransform,o),me(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;me(l,s),me(l,r),me(l,o),me(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(s[0]),Math.round(s[1])),e.lineTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){const i=e.extent,s=e.viewState.resolution,r=e.viewState.rotation,o=e.pixelRatio,a=Math.round(te(i)/s*o),l=Math.round(Ie(i)/s*o);ft(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,r,-a/2,-l/2),Gs(this.inversePixelTransform,this.pixelTransform);const h=zg(this.pixelTransform);if(this.useContainer(t,h,this.getBackground(e)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(e,t,i){const s=this.getLayer();if(s.hasListener(e)){const r=new Ps(e,this.inversePixelTransform,i,t);s.dispatchEvent(r)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(ke.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(ke.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new lh),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(ke.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(ke.POSTRENDER,this.context,e))}getRenderTransform(e,t,i,s,r,o,a){const l=r/2,h=o/2,c=s/t,u=-c,d=-e[0]+a,f=-e[1];return ft(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function ca(n,e,t){if(!(t in n))return n[t]=new Set([e]),!0;const i=n[t],s=i.has(e);return s||i.add(e),!s}function yp(n,e,t){const i=n[t];return i?i.delete(e):!1}function Cc(n,e){const t=n.layerStatesArray[n.layerIndex];t.extent&&(e=We(e,ct(t.extent,n.viewState.projection)));const i=t.layer.getRenderSource();if(!i.getWrapX()){const s=i.getTileGridForProjection(n.viewState.projection).getExtent();s&&(e=We(e,s))}return e}class hd extends hh{constructor(e,t){super(e),t=t||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Qe(),this.tempTileRange_=new Io(0,0,0,0),this.tempTileCoord_=Hn(0,0,0);const i=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new Ha(i),this.sourceTileCache_=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new Ha(512)),this.sourceTileCache_}getOrCreateTile(e,t,i,s){const r=this.tileCache_,a=this.getLayer().getSource(),l=Is(a,a.getKey(),e,t,i);let h;if(r.containsKey(l))h=r.get(l);else{const c=s.viewState.projection,u=a.getProjection();if(h=a.getTile(e,t,i,s.pixelRatio,c,!u||kt(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(e,t,i,s){const r=this.getOrCreateTile(e,t,i,s);return r||null}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=me(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!li(r,s))return null;const o=t.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(t.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(s,c),d=this.getTile(c,u[1],u[2],t);if(!d||d.getState()!==D.LOADED)continue;const f=l.getOrigin(c),g=Se(l.getTileSize(c)),_=l.getResolution(c);let m;if(d instanceof Po||d instanceof ah)m=d.getImage();else if(d instanceof Ys){if(m=Kn(d.getData()),!m)continue}else continue;const y=Math.floor(h*((s[0]-f[0])/_-u[1]*g[0])),p=Math.floor(h*((f[1]-s[1])/_-u[2]*g[1])),T=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(m,y+T,p+T)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;const t=this.getLayer().getSource();if(!t)return!1;const i=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,i,s,r){const o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=O(l);c in e.wantedTiles||(e.wantedTiles[c]={});const u=e.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,_=g?xl(o.center,o.resolution,g,e.size):void 0;for(let m=i;m>=f;--m){const y=h.getTileRangeForExtentAndZ(t,m,this.tempTileRange_),p=h.getResolution(m);for(let T=y.minX;T<=y.maxX;++T)for(let x=y.minY;x<=y.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([m,T,x],_))continue;const E=this.getTile(m,T,x,e);if(!E||!ca(s,E,m))continue;const C=E.getKey();if(u[C]=!0,E.getState()===D.IDLE&&!e.tileQueue.isKeyQueued(C)){const v=Hn(m,T,x,this.tempTileCoord_);e.tileQueue.enqueue([E,c,h.getTileCoordCenter(v),p])}}}}findStaleTile_(e,t){const i=this.tileCache_,s=e[0],r=e[1],o=e[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=Is(this.getLayer().getSource(),a[l],s,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===D.LOADED)return c.endTransition(O(this)),ca(t,c,s),!0}}return!1}findAltTiles_(e,t,i,s){const r=e.getTileRangeForTileCoordAndZ(t,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=Is(l,h,i,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===D.LOADED&&(ca(s,g,i),f=!0)}f||(o=!1)}return o}renderFrame(e,t){this.renderComplete=!0;const i=e.layerStatesArray[e.layerIndex],s=e.viewState,r=s.projection,o=s.resolution,a=s.center,l=e.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let _=e.extent;const m=c.getTilePixelRatio(l);this.prepareContainer(e,t);const y=this.context.canvas.width,p=this.context.canvas.height,T=i.extent&&ct(i.extent);T&&(_=We(_,ct(i.extent)));const x=f*y/2/m,E=f*p/2/m,R=[a[0]-x,a[1]-E,a[0]+x,a[1]+E],C={};this.renderedTiles.length=0;const v=h.getPreload();if(e.nextExtent&&this.enqueueTilesForNextExtent()){const N=u.getZForResolution(s.nextResolution,c.zDirection),j=Cc(e,e.nextExtent);this.enqueueTiles(e,j,N,C,v)}const w=Cc(e,_);if(this.enqueueTiles(e,w,d,C,0),v>0&&setTimeout(()=>{this.enqueueTiles(e,w,d-1,C,v-1)},0),!(d in C))return this.container;const P=O(this),A=e.time;for(const N of C[d]){const j=N.getState();if(j===D.EMPTY)continue;const $=N.tileCoord;if(j===D.LOADED&&N.getAlpha(P,A)===1){N.endTransition(P);continue}if(j!==D.ERROR&&(this.renderComplete=!1),this.findStaleTile_($,C)){yp(C,N,d),e.animate=!0;continue}if(this.findAltTiles_(u,$,d+1,C))continue;const ie=u.getMinZoom();for(let fe=d-1;fe>=ie&&!this.findAltTiles_(u,$,fe,C);--fe);}const I=f/o*l/m,F=this.getRenderContext(e);ft(this.tempTransform,y/2,p/2,I,I,0,-y/2,-p/2),i.extent&&this.clipUnrotated(F,e,T),c.getInterpolate()||(F.imageSmoothingEnabled=!1),this.preRender(F,e);const b=Object.keys(C).map(Number);b.sort(Gt);let k;const M=[],G=[];for(let N=b.length-1;N>=0;--N){const j=b[N],$=c.getTilePixelSize(j,l,r),L=u.getResolution(j)/f,ie=$[0]*L*I,fe=$[1]*L*I,ae=u.getTileCoordForCoordAndZ(Xt(R),j),ve=u.getTileCoordExtent(ae),we=me(this.tempTransform,[m*(ve[0]-R[0])/f,m*(R[3]-ve[3])/f]),gt=m*c.getGutterForProjection(r);for(const at of C[j]){if(at.getState()!==D.LOADED)continue;const Ve=at.tileCoord,hn=ae[1]-Ve[1],ls=Math.round(we[0]-(hn-1)*ie),Ni=ae[2]-Ve[2],$t=Math.round(we[1]-(Ni-1)*fe),et=Math.round(we[0]-hn*ie),_t=Math.round(we[1]-Ni*fe),cn=ls-et,un=$t-_t,hs=b.length===1;let Gi=!1;k=[et,_t,et+cn,_t,et+cn,_t+un,et,_t+un];for(let dn=0,fn=M.length;dn<fn;++dn)if(!hs&&j<G[dn]){const De=M[dn];Pe([et,_t,et+cn,_t+un],[De[0],De[3],De[4],De[7]])&&(Gi||(F.save(),Gi=!0),F.beginPath(),F.moveTo(k[0],k[1]),F.lineTo(k[2],k[3]),F.lineTo(k[4],k[5]),F.lineTo(k[6],k[7]),F.moveTo(De[6],De[7]),F.lineTo(De[4],De[5]),F.lineTo(De[2],De[3]),F.lineTo(De[0],De[1]),F.clip())}M.push(k),G.push(j),this.drawTile(at,e,et,_t,cn,un,gt,hs),Gi&&F.restore(),this.renderedTiles.unshift(at),this.updateUsedTiles(e.usedTiles,c,at)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!qi(this.renderedExtent_,R),this.renderedExtent_=R,this.renderedPixelRatio=l,this.postRender(this.context,e),i.extent&&F.restore(),F.imageSmoothingEnabled=!0,this.renderComplete){const N=(j,$)=>{const J=O(c),L=$.wantedTiles[J],ie=L?Object.keys(L).length:0;this.updateCacheSize(ie),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};e.postRenderFunctions.push(N)}return this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,i,s,r,o,a,l){let h;if(e instanceof Ys){if(h=Kn(e.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(e);if(!h)return;const c=this.getRenderContext(t),u=O(this),d=t.layerStatesArray[t.layerIndex],f=d.opacity*(l?e.getAlpha(u,t.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,s,r,o),g&&c.restore(),f!==d.opacity?t.animate=!0:l&&e.endTransition(u)}getImage(){const e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,i){const s=O(t);s in e||(e[s]={}),e[s][i.getKey()]=!0}}const Si={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class xp extends ir{constructor(e){e=e||{};const t=Object.assign({},e),i=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Si.PRELOAD)}setPreload(e){this.set(Si.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Si.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Si.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class _T extends xp{constructor(e){super(e)}createRenderer(){return new hd(this,{cacheSize:this.getCacheSize()})}}class cd extends hh{constructor(e){super(e),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],i=e.pixelRatio,s=e.viewState,r=s.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=We(l,ct(t.extent,s.projection))),!a[de.ANIMATING]&&!a[de.INTERACTING]&&!Di(l))if(o){const h=s.projection,c=o.getImage(l,r,i,h);c&&(this.loadImage(c)?this.image=c:c.getState()===X.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=me(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!li(r,s))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=te(o),h=Math.floor(a.width*((s[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=Ie(o),u=Math.floor(a.height*((o[3]-s[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(e,t){const i=this.image,s=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=i.getPixelRatio(),h=e.layerStatesArray[e.layerIndex],c=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),_=c*a/(f*l);this.prepareContainer(e,t);const m=this.context.canvas.width,y=this.context.canvas.height,p=this.getRenderContext(e);let T=!1,x=!0;if(h.extent){const w=ct(h.extent,u.projection);x=Pe(w,e.extent),T=x&&!Ti(w,e.extent),T&&this.clipUnrotated(p,e,w)}const E=i.getImage(),R=ft(this.tempTransform,m/2,y/2,g,_,0,l*(s[0]-d[0])/o,l*(d[1]-s[3])/a);this.renderedResolution=a*c/l;const C=E.width*R[0],v=E.height*R[3];if(this.getLayer().getSource().getInterpolate()||(p.imageSmoothingEnabled=!1),this.preRender(p,e),x&&C>=.5&&v>=.5){const w=R[4],P=R[5],A=h.opacity;A!==1&&(p.save(),p.globalAlpha=A),p.drawImage(E,0,0,+E.width,+E.height,w,P,C,v),A!==1&&p.restore()}return this.postRender(this.context,e),T&&p.restore(),p.imageSmoothingEnabled=!0,this.container}}class Ep extends ir{constructor(e){e=e||{},super(e)}}class mT extends Ep{constructor(e){super(e)}createRenderer(){return new cd(this)}getData(e){return super.getData(e)}}class ud{drawCustom(e,t,i,s,r){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,i){}drawFeature(e,t,i){}drawGeometryCollection(e,t,i){}drawLineString(e,t,i){}drawMultiLineString(e,t,i){}drawMultiPoint(e,t,i){}drawMultiPolygon(e,t,i){}drawPoint(e,t,i){}drawPolygon(e,t,i){}drawText(e,t,i){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}}const V={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Tr=[V.FILL],vi=[V.STROKE],Yi=[V.BEGIN_PATH],Sc=[V.CLOSE_PATH];class or extends ud{constructor(e,t,i,s){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){const t=this.pixelRatio;return t==1?e:e.map(function(i){return i*t})}appendFlatPointCoordinates(e,t){const i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=e.length;a<l;a+=t)s[0]=e[a],s[1]=e[a+1],li(i,s)&&(r[o++]=s[0],r[o++]=s[1]);return o}appendFlatLineCoordinates(e,t,i,s,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(t+=s);let c=e[t],u=e[t+1];const d=this.tmpCoordinate_;let f=!0,g,_,m;for(g=t+s;g<i;g+=s)d[0]=e[g],d[1]=e[g+1],m=Fa(h,d),m!==_?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):m===Ge.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],_=m;return(r&&f||g===t+s)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(e,t,i,s,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(e,t,l,s,!1,!1);r.push(h),t=l}return t}drawCustom(e,t,i,s,r){this.beginGeometry(e,t,r);const o=e.getType(),a=e.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=e.getOrientedFlatCoordinates(),d=[];const g=e.getEndss();f=0;for(let _=0,m=g.length;_<m;++_){const y=[];f=this.drawCustomCoordinates_(h,f,g[_],a,y),d.push(y)}this.instructions.push([V.CUSTOM,l,d,e,i,Ua,r]),this.hitDetectionInstructions.push([V.CUSTOM,l,d,e,s||i,Ua,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,e.getEnds(),a,u),this.instructions.push([V.CUSTOM,l,u,e,i,ks,r]),this.hitDetectionInstructions.push([V.CUSTOM,l,u,e,s||i,ks,r]);break;case"LineString":case"Circle":h=e.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([V.CUSTOM,l,c,e,i,Ri,r]),this.hitDetectionInstructions.push([V.CUSTOM,l,c,e,s||i,Ri,r]);break;case"MultiPoint":h=e.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([V.CUSTOM,l,c,e,i,Ri,r]),this.hitDetectionInstructions.push([V.CUSTOM,l,c,e,s||i,Ri,r]));break;case"Point":h=e.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([V.CUSTOM,l,c,e,i,void 0,r]),this.hitDetectionInstructions.push([V.CUSTOM,l,c,e,s||i,void 0,r]);break}this.endGeometry(t)}beginGeometry(e,t,i){this.beginGeometryInstruction1_=[V.BEGIN_GEOMETRY,t,0,e,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[V.BEGIN_GEOMETRY,t,0,e,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const i=e.length;let s,r,o=-1;for(t=0;t<i;++t)s=e[t],r=s[0],r==V.END_GEOMETRY?o=t:r==V.BEGIN_GEOMETRY&&(s[2]=t,Af(this.hitDetectionInstructions,o,t),o=-1)}fillStyleToState(e,t={}){if(e){const i=e.getColor();t.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,t.fillStyle=Nt(i||tt)}else t.fillStyle=void 0;return t}strokeStyleToState(e,t={}){if(e){const i=e.getColor();t.strokeStyle=Nt(i||zs);const s=e.getLineCap();t.lineCap=s!==void 0?s:Vn;const r=e.getLineDash();t.lineDash=r?r.slice():ri;const o=e.getLineDashOffset();t.lineDashOffset=o||oi;const a=e.getLineJoin();t.lineJoin=a!==void 0?a:Zn;const l=e.getWidth();t.lineWidth=l!==void 0?l:js;const h=e.getMiterLimit();t.miterLimit=h!==void 0?h:Bs,t.lineWidth>this.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0;return t}setFillStrokeStyle(e,t){const i=this.state;this.fillStyleToState(e,i),this.strokeStyleToState(t,i)}createFill(e){const t=e.fillStyle,i=[V.SET_FILL_STYLE,t];return typeof t!="string"&&i.push(e.fillPatternScale),i}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[V.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const i=e.fillStyle;(typeof i!="string"||e.currentFillStyle!=i)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=i)}updateStrokeStyle(e,t){const i=e.strokeStyle,s=e.lineCap,r=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,h=e.miterLimit;(e.currentStrokeStyle!=i||e.currentLineCap!=s||r!=e.currentLineDash&&!jt(e.currentLineDash,r)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=h)&&(t.call(this,e),e.currentStrokeStyle=i,e.currentLineCap=s,e.currentLineDash=r,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=h)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[V.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=hu(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;ai(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Tp extends or{constructor(e,t,i,s){super(e,t,i,s),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t,i){if(!this.image_||this.maxExtent&&!li(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,i);const s=e.getFlatCoordinates(),r=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([V.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([V.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t,i){if(!this.image_)return;this.beginGeometry(e,t,i);const s=e.getFlatCoordinates(),r=[];for(let l=0,h=s.length;l<h;l+=e.getStride())(!this.maxExtent||li(this.maxExtent,s.slice(l,l+2)))&&r.push(s[l],s[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([V.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([V.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,t){const i=e.getAnchor(),s=e.getSize(),r=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=s[1],this.opacity_=e.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=s[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}class Rp extends or{constructor(e,t,i,s){super(e,t,i,s)}drawFlatCoordinates_(e,t,i,s){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(e,t,i,s,!1,!1),a=[V.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(e,t,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(e,t,i),this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ri,oi],Yi);const a=e.getFlatCoordinates(),l=e.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(vi),this.endGeometry(t)}drawMultiLineString(e,t,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(e,t,i),this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ri,oi],Yi);const a=e.getEnds(),l=e.getFlatCoordinates(),h=e.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(vi),this.endGeometry(t)}finish(){const e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(vi),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(vi),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(Yi)}}class vc extends or{constructor(e,t,i,s){super(e,t,i,s)}drawFlatCoordinatess_(e,t,i,s){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(Yi),this.hitDetectionInstructions.push(Yi);for(let h=0;h<l;++h){const c=i[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(e,t,c,s,!0,!a),f=[V.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(Sc),this.hitDetectionInstructions.push(Sc)),t=c}return o&&(this.instructions.push(Tr),this.hitDetectionInstructions.push(Tr)),a&&(this.instructions.push(vi),this.hitDetectionInstructions.push(vi)),t}drawCircle(e,t,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_FILL_STYLE,tt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ri,oi]);const a=e.getFlatCoordinates(),l=e.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[V.CIRCLE,h];this.instructions.push(Yi,c),this.hitDetectionInstructions.push(Yi,c),s.fillStyle!==void 0&&(this.instructions.push(Tr),this.hitDetectionInstructions.push(Tr)),s.strokeStyle!==void 0&&(this.instructions.push(vi),this.hitDetectionInstructions.push(vi)),this.endGeometry(t)}drawPolygon(e,t,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_FILL_STYLE,tt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ri,oi]);const a=e.getEnds(),l=e.getOrientedFlatCoordinates(),h=e.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(t)}drawMultiPolygon(e,t,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_FILL_STYLE,tt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ri,oi]);const a=e.getEndss(),l=e.getOrientedFlatCoordinates(),h=e.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(t)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const e=this.tolerance;if(e!==0){const t=this.coordinates;for(let i=0,s=t.length;i<s;++i)t[i]=zi(t[i],e)}return super.finish()}setFillStrokeStyles_(){const e=this.state;this.updateFillStyle(e,this.createFill),this.updateStrokeStyle(e,this.applyStroke)}}function Cp(n,e,t,i,s){const r=[];let o=t,a=0,l=e.slice(t,2);for(;a<n&&o+s<i;){const[h,c]=l.slice(-2),u=e[o+s],d=e[o+s+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=n){const g=(n-a+f)/f,_=lt(h,u,g),m=lt(c,d,g);l.push(_,m),r.push(l),l=[_,m],a==n&&(o+=s),a=0}else if(a<n)l.push(e[o+s],e[o+s+1]),o+=s;else{const g=f-a,_=lt(h,u,g/f),m=lt(c,d,g/f);l.push(_,m),r.push(l),l=[_,m],a=0,o+=s}}return a>0&&r.push(l),r}function Sp(n,e,t,i,s){let r=t,o=t,a=0,l=0,h=t,c,u,d,f,g,_,m,y,p,T;for(u=t;u<i;u+=s){const x=e[u],E=e[u+1];g!==void 0&&(p=x-g,T=E-_,f=Math.sqrt(p*p+T*T),m!==void 0&&(l+=d,c=Math.acos((m*p+y*T)/(d*f)),c>n&&(l>a&&(a=l,r=h,o=u),l=0,h=u-s)),d=f,m=p,y=T),g=x,_=E}return l+=f,l>a?[h,u]:[r,o]}const Qr={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class vp extends or{constructor(e,t,i,s){super(e,t,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[tt]={fillStyle:tt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const h=e.getType();let c=null,u=e.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Pe(this.maxExtent,e.getExtent()))return;let d;if(c=e.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=e.getEnds();else if(h=="Polygon")d=e.getEnds().slice(0,1);else if(h=="MultiPolygon"){const m=e.getEndss();d=[];for(let y=0,p=m.length;y<p;++y)d.push(m[y][0])}this.beginGeometry(e,t,i);const f=o.repeat,g=f?void 0:o.textAlign;let _=0;for(let m=0,y=d.length;m<y;++m){let p;f?p=Cp(f*this.resolution,c,_,d[m],u):p=[c.slice(_,d[m])];for(let T=0,x=p.length;T<x;++T){const E=p[T];let R=0,C=E.length;if(g==null){const w=Sp(o.maxAngle,E,0,E.length,2);R=w[0],C=w[1]}for(let w=R;w<C;w+=u)a.push(E[w],E[w+1]);const v=a.length;_=d[m],this.drawChars_(l,v),l=v}}this.endGeometry(t)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=e.getFlatCoordinates();break;case"LineString":c=e.getFlatMidpoint();break;case"Circle":c=e.getCenter();break;case"MultiLineString":c=e.getFlatMidpoints(),u=2;break;case"Polygon":c=e.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=e.getFlatInteriorPoints();c=[];for(let E=0,R=x.length;E<R;E+=3)o.overflow||d.push(x[E+2]/this.resolution),c.push(x[E],x[E+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((E,R)=>{const C=a[(x+R)*2]===c[R*u]&&a[(x+R)*2+1]===c[R*u+1];return C||--x,C})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,_=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(e,t,i);let m=o.padding;if(m!=Wi&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],E=o.padding[1],R=o.padding[2],C=o.padding[3];o.scale[0]<0&&(E=-E,C=-C),o.scale[1]<0&&(x=-x,R=-R),m=[x,E,R,C]}const y=this.pixelRatio;this.instructions.push([V.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,m==Wi?Wi:m.map(function(x){return x*y}),g,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const p=1/y,T=g?g.slice(0):null;T&&(T[1]=tt),this.hitDetectionInstructions.push([V.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,m,T,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?tt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,i=this.textFillState_,s=this.strokeKey_;e&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:t.font,textAlign:t.textAlign||Xs,justify:t.justify,textBaseline:t.textBaseline||Hr,scale:t.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(e,t){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=Qr[s.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([V.DRAW_CHARS,e,t,h,s.overflow,a,s.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([V.DRAW_CHARS,e,t,h,s.overflow,a&&tt,s.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let i,s,r;if(!e)this.text_="";else{const o=e.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=Nt(o.getColor()||tt)):(s=null,this.textFillState_=s);const a=e.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const _=a.getLineDash(),m=a.getLineDashOffset(),y=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||Vn,r.lineDash=_?_.slice():ri,r.lineDashOffset=m===void 0?oi:m,r.lineJoin=a.getLineJoin()||Zn,r.lineWidth=y===void 0?js:y,r.miterLimit=p===void 0?Bs:p,r.strokeStyle=Nt(a.getColor()||zs)}i=this.textState_;const l=e.getFont()||Vu;Om(l);const h=e.getScaleArray();i.overflow=e.getOverflow(),i.font=l,i.maxAngle=e.getMaxAngle(),i.placement=e.getPlacement(),i.textAlign=e.getTextAlign(),i.repeat=e.getRepeat(),i.justify=e.getJustify(),i.textBaseline=e.getTextBaseline()||Hr,i.backgroundFill=e.getBackgroundFill(),i.backgroundStroke=e.getBackgroundStroke(),i.padding=e.getPadding()||Wi,i.scale=h===void 0?[1,1]:h;const c=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getKeepUpright(),g=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:O(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+O(s.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const wp={Circle:vc,Default:or,Image:Tp,LineString:Rp,Polygon:vc,Text:vp};class dd{constructor(e,t,i,s){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const i=this.buildersByZIndex_[t];for(const s in i){const r=i[s].finish();e[t][s]=r}}return e}getBuilder(e,t){const i=e!==void 0?e.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[t];if(r===void 0){const o=wp[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[t]=r}return r}}function ch(n,e,t,i){let s=n[e],r=n[e+1],o=0;for(let a=e+i;a<t;a+=i){const l=n[a],h=n[a+1];o+=Math.sqrt((l-s)*(l-s)+(h-r)*(h-r)),s=l,r=h}return o}function Pp(n,e,t,i,s,r,o,a,l,h,c,u,d=!0){let f=n[e],g=n[e+1],_=0,m=0,y=0,p=0;function T(){_=f,m=g,e+=i,f=n[e],g=n[e+1],p+=y,y=Math.sqrt((f-_)*(f-_)+(g-m)*(g-m))}do T();while(e<t-i&&p+y<r);let x=y===0?0:(r-p)/y;const E=lt(_,f,x),R=lt(m,g,x),C=e-i,v=p,w=r+a*l(h,s,c);for(;e<t-i&&p+y<w;)T();x=y===0?0:(w-p)/y;const P=lt(_,f,x),A=lt(m,g,x);let I=!1;if(d)if(u){const G=[E,R,P,A];bl(G,0,4,2,u,G,G),I=G[0]>G[2]}else I=E>P;const F=Math.PI,b=[],k=C+i===e;e=C,y=0,p=v,f=n[e],g=n[e+1];let M;if(k){T(),M=Math.atan2(g-m,f-_),I&&(M+=M>0?-F:F);const G=(P+E)/2,N=(A+R)/2;return b[0]=[G,N,(w-r)/2,M,s],b}s=s.replace(/\n/g," ");for(let G=0,N=s.length;G<N;){T();let j=Math.atan2(g-m,f-_);if(I&&(j+=j>0?-F:F),M!==void 0){let ae=j-M;if(ae+=ae>F?-2*F:ae<-F?2*F:0,Math.abs(ae)>o)return null}M=j;const $=G;let J=0;for(;G<N;++G){const ae=I?N-G-1:G,ve=a*l(h,s[ae],c);if(e+i<t&&p+y<r+J+ve/2)break;J+=ve}if(G===$)continue;const L=I?s.substring(N-$,N-G):s.substring($,G);x=y===0?0:(r+J/2-p)/y;const ie=lt(_,f,x),fe=lt(m,g,x);b.push([ie,fe,J/2,j,L]),r+=J}return b}const En=Qe(),_i=[],Zt=[],Kt=[],mi=[];function wc(n){return n[3].declutterBox}const Pc=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function ua(n,e){return e==="start"?e=Pc.test(n)?"right":"left":e==="end"&&(e=Pc.test(n)?"left":"right"),Qr[e]}function Ip(n,e,t){return t>0&&n.push(`
|
||
`,""),n.push(e,""),n}function Ap(n,e,t){return t%2===0&&(n+=e),n}class Lp{constructor(e,t,i,s,r){this.overlaps=i,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=Ce(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new lh:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,i,s){const r=e+t+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[t],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Qr[l.justify]:ua(Array.isArray(e)?e[0]:e,l.textAlign||Xs),d=s&&o.lineWidth?o.lineWidth:0,f=Array.isArray(e)?e:String(e).split(`
|
||
`).reduce(Ip,[]),{width:g,height:_,widths:m,heights:y,lineWidths:p}=Gm(l,f),T=g+d,x=[],E=(T+2)*c[0],R=(_+d)*c[1],C={width:E<0?Math.floor(E):Math.ceil(E),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),s&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const v=.5-u;let w=u*T+v*d;const P=[],A=[];let I=0,F=0,b=0,k=0,M;for(let G=0,N=f.length;G<N;G+=2){const j=f[G];if(j===`
|
||
`){F+=I,I=0,w=u*T+v*d,++k;continue}const $=f[G+1]||l.font;$!==M&&(s&&P.push("font",$),i&&A.push("font",$),M=$),I=Math.max(I,y[b]);const J=[j,w+v*m[b]+u*(m[b]-p[k]),.5*(d+I)+F];w+=m[b],s&&P.push("strokeText",J),i&&A.push("fillText",J),++b}return Array.prototype.push.apply(x,P),Array.prototype.push.apply(x,A),this.labels_[r]=C,C}replayTextBackground_(e,t,i,s,r,o,a){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,i),e.lineTo.apply(e,s),e.lineTo.apply(e,r),e.lineTo.apply(e,t),o&&(this.alignAndScaleFill_=o[2],e.fillStyle=o[1],this.fill_(e)),a&&(this.setStrokeStyle_(e,a),e.stroke())}calculateImageOrLabelDimensions_(e,t,i,s,r,o,a,l,h,c,u,d,f,g,_,m){a*=d[0],l*=d[1];let y=i-a,p=s-l;const T=r+h>e?e-h:r,x=o+c>t?t-c:o,E=g[3]+T*d[0]+g[1],R=g[0]+x*d[1]+g[2],C=y-g[3],v=p-g[0];(_||u!==0)&&(_i[0]=C,mi[0]=C,_i[1]=v,Zt[1]=v,Zt[0]=C+E,Kt[0]=Zt[0],Kt[1]=v+R,mi[1]=Kt[1]);let w;return u!==0?(w=ft(Ce(),i,s,1,1,u,-i,-s),me(w,_i),me(w,Zt),me(w,Kt),me(w,mi),zt(Math.min(_i[0],Zt[0],Kt[0],mi[0]),Math.min(_i[1],Zt[1],Kt[1],mi[1]),Math.max(_i[0],Zt[0],Kt[0],mi[0]),Math.max(_i[1],Zt[1],Kt[1],mi[1]),En)):zt(Math.min(C,C+E),Math.min(v,v+R),Math.max(C,C+E),Math.max(v,v+R),En),f&&(y=Math.round(y),p=Math.round(p)),{drawImageX:y,drawImageY:p,drawImageW:T,drawImageH:x,originX:h,originY:c,declutterBox:{minX:En[0],minY:En[1],maxX:En[2],maxY:En[3],value:m},canvasTransform:w,scale:d}}replayImageOrLabel_(e,t,i,s,r,o,a){const l=!!(o||a),h=s.declutterBox,c=a?a[2]*s.scale[0]/2:0;return h.minX-c<=t[0]&&h.maxX+c>=0&&h.minY-c<=t[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(e,_i,Zt,Kt,mi,o,a),km(e,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const i=me(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;e.save(),e.translate(i[0]%s,i[1]%s),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,i,s){const r=this.textStates[t],o=this.createLabel(e,t,s,i),a=this.strokeStates[i],l=this.pixelRatio,h=ua(Array.isArray(e)?e[0]:e,r.textAlign||Xs),c=Qr[r.textBaseline||Hr],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,i,s,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&jt(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Ut(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Tu(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,_,m,y,p,T,x,E,R,C,v,w,P,A=0,I=0;const F=this.coordinateCache_,b=this.viewRotation_,k=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,M={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:b},G=this.instructions!=s||this.overlaps?0:200;let N,j,$,J;for(;u<d;){const L=s[u];switch(L[0]){case V.BEGIN_GEOMETRY:N=L[1],J=L[3],N.getGeometry()?a!==void 0&&!Pe(a,J.getExtent())?u=L[2]+1:++u:u=L[2],h&&(h.zIndex=L[4]);break;case V.BEGIN_PATH:A>G&&(this.fill_(e),A=0),I>G&&(e.stroke(),I=0),!A&&!I&&(e.beginPath(),p=NaN,T=NaN),++u;break;case V.CIRCLE:f=L[1];const fe=c[f],ae=c[f+1],ve=c[f+2],we=c[f+3],gt=ve-fe,at=we-ae,Ve=Math.sqrt(gt*gt+at*at);e.moveTo(fe+Ve,ae),e.arc(fe,ae,Ve,0,2*Math.PI,!0),++u;break;case V.CLOSE_PATH:e.closePath(),++u;break;case V.CUSTOM:f=L[1],g=L[2];const hn=L[3],ls=L[4],Ni=L[5];M.geometry=hn,M.feature=N,u in F||(F[u]=[]);const $t=F[u];Ni?Ni(c,f,g,2,$t):($t[0]=c[f],$t[1]=c[f+1],$t.length=2),h&&(h.zIndex=L[6]),ls($t,M),++u;break;case V.DRAW_IMAGE:f=L[1],g=L[2],R=L[3],_=L[4],m=L[5];let et=L[6];const _t=L[7],cn=L[8],un=L[9],hs=L[10];let Gi=L[11];const dn=L[12];let fn=L[13];y=L[14]||"declutter";const De=L[15];if(!R&&L.length>=20){C=L[19],v=L[20],w=L[21],P=L[22];const mt=this.drawLabelWithPointPlacement_(C,v,w,P);R=mt.label,L[3]=R;const ki=L[23];_=(mt.anchorX-ki)*this.pixelRatio,L[4]=_;const pt=L[24];m=(mt.anchorY-pt)*this.pixelRatio,L[5]=m,et=R.height,L[6]=et,fn=R.width,L[13]=fn}let ko;L.length>25&&(ko=L[25]);let Uo,lr,hr;L.length>17?(Uo=L[16],lr=L[17],hr=L[18]):(Uo=Wi,lr=null,hr=null),hs&&k?Gi+=b:!hs&&!k&&(Gi-=b);let Cf=0;for(;f<g;f+=2){if(ko&&ko[Cf++]<fn/this.pixelRatio)continue;const mt=this.calculateImageOrLabelDimensions_(R.width,R.height,c[f],c[f+1],fn,et,_,m,cn,un,Gi,dn,r,Uo,!!lr||!!hr,N),ki=[e,t,R,mt,_t,lr,hr];if(l){let pt,Mt,yt;if(De){const Re=g-f;if(!De[Re]){De[Re]={args:ki,declutterMode:y};continue}const Ze=De[Re];pt=Ze.args,Mt=Ze.declutterMode,delete De[Re],yt=wc(pt)}let Wt,Yt;if(pt&&(Mt!=="declutter"||!l.collides(yt))&&(Wt=!0),(y!=="declutter"||!l.collides(mt.declutterBox))&&(Yt=!0),Mt==="declutter"&&y==="declutter"){const Re=Wt&&Yt;Wt=Re,Yt=Re}Wt&&(Mt!=="none"&&l.insert(yt),this.replayImageOrLabel_.apply(this,pt)),Yt&&(y!=="none"&&l.insert(mt.declutterBox),this.replayImageOrLabel_.apply(this,ki))}else this.replayImageOrLabel_.apply(this,ki)}++u;break;case V.DRAW_CHARS:const Fh=L[1],bh=L[2],Bo=L[3],Sf=L[4];P=L[5];const vf=L[6],Mh=L[7],Dh=L[8];w=L[9];const zo=L[10];C=L[11],Array.isArray(C)&&(C=C.reduce(Ap,"")),v=L[12];const Oh=[L[13],L[13]];y=L[14]||"declutter";const wf=L[15],Xo=this.textStates[v],cs=Xo.font,us=[Xo.scale[0]*Mh,Xo.scale[1]*Mh];let ds;cs in this.widths_?ds=this.widths_[cs]:(ds={},this.widths_[cs]=ds);const Nh=ch(c,Fh,bh,2),Gh=Math.abs(us[0])*dc(cs,C,ds);if(Sf||Gh<=Nh){const mt=this.textStates[v].textAlign,ki=(Nh-Gh)*ua(C,mt),pt=Pp(c,Fh,bh,2,C,ki,vf,Math.abs(us[0]),dc,cs,ds,k?0:this.viewRotation_,wf);e:if(pt){const Mt=[];let yt,Wt,Yt,Re,Ze;if(w)for(yt=0,Wt=pt.length;yt<Wt;++yt){Ze=pt[yt],Yt=Ze[4],Re=this.createLabel(Yt,v,"",w),_=Ze[2]+(us[0]<0?-zo:zo),m=Bo*Re.height+(.5-Bo)*2*zo*us[1]/us[0]-Dh;const Vt=this.calculateImageOrLabelDimensions_(Re.width,Re.height,Ze[0],Ze[1],Re.width,Re.height,_,m,0,0,Ze[3],Oh,!1,Wi,!1,N);if(l&&y==="declutter"&&l.collides(Vt.declutterBox))break e;Mt.push([e,t,Re,Vt,1,null,null])}if(P)for(yt=0,Wt=pt.length;yt<Wt;++yt){Ze=pt[yt],Yt=Ze[4],Re=this.createLabel(Yt,v,P,""),_=Ze[2],m=Bo*Re.height-Dh;const Vt=this.calculateImageOrLabelDimensions_(Re.width,Re.height,Ze[0],Ze[1],Re.width,Re.height,_,m,0,0,Ze[3],Oh,!1,Wi,!1,N);if(l&&y==="declutter"&&l.collides(Vt.declutterBox))break e;Mt.push([e,t,Re,Vt,1,null,null])}l&&y!=="none"&&l.load(Mt.map(wc));for(let Vt=0,Pf=Mt.length;Vt<Pf;++Vt)this.replayImageOrLabel_.apply(this,Mt[Vt])}}++u;break;case V.END_GEOMETRY:if(o!==void 0){N=L[1];const mt=o(N,J,y);if(mt)return mt}++u;break;case V.FILL:G?A++:this.fill_(e),++u;break;case V.MOVE_TO_LINE_TO:for(f=L[1],g=L[2],j=c[f],$=c[f+1],e.moveTo(j,$),p=j+.5|0,T=$+.5|0,f+=2;f<g;f+=2)j=c[f],$=c[f+1],x=j+.5|0,E=$+.5|0,(f==g-2||x!==p||E!==T)&&(e.lineTo(j,$),p=x,T=E);++u;break;case V.SET_FILL_STYLE:this.alignAndScaleFill_=L[2],A&&(this.fill_(e),A=0,I&&(e.stroke(),I=0)),e.fillStyle=L[1],++u;break;case V.SET_STROKE_STYLE:I&&(e.stroke(),I=0),this.setStrokeStyle_(e,L),++u;break;case V.STROKE:G?I++:e.stroke(),++u;break;default:++u;break}}A&&this.fill_(e),I&&e.stroke()}execute(e,t,i,s,r,o){this.viewRotation_=s,this.execute_(e,t,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(e,t,i,s,r){return this.viewRotation_=i,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,s,r)}}const Xi=["Polygon","Circle","LineString","Image","Text","Default"],eo=["Image","Text"],Fp=Xi.filter(n=>!eo.includes(n));class fd{constructor(e,t,i,s,r,o,a){this.maxExtent_=e,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Ce(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const i=this.getClipCoords(t);e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(i[2],i[3]),e.lineTo(i[4],i[5]),e.lineTo(i[6],i[7]),e.clip()}createExecutors_(e,t){for(const i in e){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=e[i];for(const o in r){const a=r[o];s[o]=new Lp(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const i=this.executorsByZIndex_[t];for(let s=0,r=e.length;s<r;++s)if(e[s]in i)return!0}return!1}forEachFeatureAtCoordinate(e,t,i,s,r,o){s=Math.round(s);const a=s*2+1,l=ft(this.hitDetectionTransform_,s+.5,s+.5,1/t,-1/t,-i,-e[0],-e[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=Te(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=Qe(),Ss(u,e),ai(u,t*(this.renderBuffer_+s),u));const d=bp(s);let f;function g(E,R,C){const v=c.getImageData(0,0,a,a).data;for(let w=0,P=d.length;w<P;w++)if(v[d[w]]>0){if(!o||C==="none"||f!=="Image"&&f!=="Text"||o.includes(E)){const A=(d[w]-3)/4,I=s-A%a,F=s-(A/a|0),b=r(E,R,I*I+F*F);if(b)return b}c.clearRect(0,0,a,a);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Gt);let m,y,p,T,x;for(m=_.length-1;m>=0;--m){const E=_[m].toString();for(p=this.executorsByZIndex_[E],y=Xi.length-1;y>=0;--y)if(f=Xi[y],T=p[f],T!==void 0&&(x=T.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const i=t[0],s=t[1],r=t[2],o=t[3],a=[i,s,i,o,r,o,r,s];return Ut(a,0,8,2,e,a),a}isEmpty(){return Ki(this.executorsByZIndex_)}execute(e,t,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?ru:Gt),o=o||Xi;const h=Xi.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,_=o.length;g<_;++g){const m=o[g],y=f[m];if(y!==void 0){const p=a===null?void 0:y.getZIndexContext(),T=p?p.getContext():e,x=this.maxExtent_&&m!=="Image"&&m!=="Text";if(x&&(T.save(),this.clip(T,i)),!p||m==="Text"||m==="Image"?y.execute(T,t,i,s,r,a):p.pushFunction(E=>y.execute(E,t,i,s,r,a)),x&&T.restore(),p){p.offset();const E=l[c]*h+Xi.indexOf(m);this.deferredZIndexContexts_[E]||(this.deferredZIndexContexts_[E]=[]),this.deferredZIndexContexts_[E].push(p)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Gt);for(let i=0,s=t.length;i<s;++i)e[t[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),e[t[i]].length=0}}const da={};function bp(n){if(da[n]!==void 0)return da[n];const e=n*2+1,t=n*n,i=new Array(t+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>t)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*e+(n+o))*4+3),r>0&&l.push(((n-r)*e+(n+o))*4+3),o>0&&(l.push(((n+r)*e+(n-o))*4+3),r>0&&l.push(((n-r)*e+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return da[n]=s,s}class Mp extends ud{constructor(e,t,i,s,r,o,a){super(),this.context_=e,this.pixelRatio_=t,this.extent_=i,this.transform_=s,this.transformRotation_=s?es(Math.atan2(s[1],s[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Ce()}drawImages_(e,t,i,s){if(!this.image_)return;const r=Ut(e,t,i,s,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,_=f+this.imageAnchorY_;ft(a,g,_,1,1,h,-g,-_),o.save(),o.transform.apply(o,a),o.translate(g,_),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(e,t,i,s){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Ut(e,t,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);t<i;t+=s){const l=r[t]+this.textOffsetX_,h=r[t+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(e,t,i,s,r){const o=this.context_,a=Ut(e,t,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),i}drawRings_(e,t,i,s){for(let r=0,o=i.length;r<o;++r)t=this.moveToLineTo_(e,t,i[r],s,!0);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pe(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=Yg(e,this.transform_,this.pixelCoordinates_),i=t[2]-t[0],s=t[3]-t[1],r=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(t[0],t[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break}}drawFeature(e,t){const i=t.getGeometryFunction()(e);i&&(this.setStyle(t),this.drawGeometry(i))}drawGeometryCollection(e){const t=e.getGeometriesArray();for(let i=0,s=t.length;i<s;++i)this.drawGeometry(t[i])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getFlatCoordinates(),i=e.getStride();this.image_&&this.drawImages_(t,0,t.length,i),this.text_!==""&&this.drawText_(t,0,t.length,i)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getFlatCoordinates(),i=e.getStride();this.image_&&this.drawImages_(t,0,t.length,i),this.text_!==""&&this.drawText_(t,0,t.length,i)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pe(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const t=this.context_,i=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(i,0,i.length,e.getStride(),!1),t.stroke()}if(this.text_!==""){const t=e.getFlatMidpoint();this.drawText_(t,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getExtent();if(Pe(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,s=e.getFlatCoordinates();let r=0;const o=e.getEnds(),a=e.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(s,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=e.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pe(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=this.context_;t.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){const t=e.getFlatInteriorPoint();this.drawText_(t,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pe(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=this.context_,i=e.getOrientedFlatCoordinates();let s=0;const r=e.getEndss(),o=e.getStride();t.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];s=this.drawRings_(i,s,h,o)}this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){const t=e.getFlatInteriorPoints();this.drawText_(t,0,t.length,2)}}}setContextFillState_(e){const t=this.context_,i=this.contextFillState_;i?i.fillStyle!=e.fillStyle&&(i.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){const t=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=e.lineCap&&(i.lineCap=e.lineCap,t.lineCap=e.lineCap),jt(i.lineDash,e.lineDash)||t.setLineDash(i.lineDash=e.lineDash),i.lineDashOffset!=e.lineDashOffset&&(i.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),i.lineJoin!=e.lineJoin&&(i.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),i.lineWidth!=e.lineWidth&&(i.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),i.miterLimit!=e.miterLimit&&(i.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),i.strokeStyle!=e.strokeStyle&&(i.strokeStyle=e.strokeStyle,t.strokeStyle=e.strokeStyle)):(t.lineCap=e.lineCap,t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){const t=this.context_,i=this.contextTextState_,s=e.textAlign?e.textAlign:Xs;i?(i.font!=e.font&&(i.font=e.font,t.font=e.font),i.textAlign!=s&&(i.textAlign=s,t.textAlign=s),i.textBaseline!=e.textBaseline&&(i.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=s,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:s,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{const i=e.getColor();this.fillState_={fillStyle:Nt(i||tt)}}if(!t)this.strokeState_=null;else{const i=t.getColor(),s=t.getLineCap(),r=t.getLineDash(),o=t.getLineDashOffset(),a=t.getLineJoin(),l=t.getWidth(),h=t.getMiterLimit(),c=r||ri;this.strokeState_={lineCap:s!==void 0?s:Vn,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||oi)*this.pixelRatio_,lineJoin:a!==void 0?a:Zn,lineWidth:(l!==void 0?l:js)*this.pixelRatio_,miterLimit:h!==void 0?h:Bs,strokeStyle:Nt(i||zs)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const i=e.getPixelRatio(this.pixelRatio_),s=e.getAnchor(),r=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=t[1]*i,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=t[0]*i}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:Nt(f||tt)}}const i=e.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),_=i.getLineDash(),m=i.getLineDashOffset(),y=i.getLineJoin(),p=i.getWidth(),T=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Vn,lineDash:_||ri,lineDashOffset:m||oi,lineJoin:y!==void 0?y:Zn,lineWidth:p!==void 0?p:js,miterLimit:T!==void 0?T:Bs,strokeStyle:Nt(f||zs)}}const s=e.getFont(),r=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),h=e.getScaleArray(),c=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:s!==void 0?s:Vu,textAlign:u!==void 0?u:Xs,textBaseline:d!==void 0?d:Hr},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,_)=>f+=_%2?" ":g,""):c:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}}const ht=.5;function gd(n,e,t,i,s,r,o,a,l){const h=l?mo(s):s,c=n[0]*ht,u=n[1]*ht,d=Te(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Mp(d,ht,s,null,o,a,l?_o(Ng(),l):null),_=t.length,m=Math.floor((256*256*256-1)/_),y={};for(let T=1;T<=_;++T){const x=t[T-1],E=x.getStyleFunction()||i;if(!E)continue;let R=E(x,r);if(!R)continue;Array.isArray(R)||(R=[R]);const v=(T*m).toString(16).padStart(7,"#00000");for(let w=0,P=R.length;w<P;++w){const A=R[w],I=A.getGeometryFunction()(x);if(!I||!Pe(h,I.getExtent()))continue;const F=A.clone(),b=F.getFill();b&&b.setColor(v);const k=F.getStroke();k&&(k.setColor(v),k.setLineDash(null)),F.setText(void 0);const M=A.getImage();if(M){const $=M.getImageSize();if(!$)continue;const J=Te($[0],$[1],void 0,{alpha:!1}),L=J.canvas;J.fillStyle=v,J.fillRect(0,0,L.width,L.height),F.setImage(new rs({img:L,anchor:M.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:M.getOrigin(),opacity:1,size:M.getSize(),scale:M.getScale(),rotation:M.getRotation(),rotateWithView:M.getRotateWithView()}))}const G=F.getZIndex()||0;let N=y[G];N||(N={},y[G]=N,N.Polygon=[],N.Circle=[],N.LineString=[],N.Point=[]);const j=I.getType();if(j==="GeometryCollection"){const $=I.getGeometriesArrayRecursive();for(let J=0,L=$.length;J<L;++J){const ie=$[J];N[ie.getType().replace("Multi","")].push(ie,F)}}else N[j.replace("Multi","")].push(I,F)}}const p=Object.keys(y).map(Number).sort(Gt);for(let T=0,x=p.length;T<x;++T){const E=y[p[T]];for(const R in E){const C=E[R];for(let v=0,w=C.length;v<w;v+=2){g.setStyle(C[v+1]);for(let P=0,A=e.length;P<A;++P)g.setTransform(e[P]),g.drawGeometry(C[v])}}}return d.getImageData(0,0,f.width,f.height)}function _d(n,e,t){const i=[];if(t){const s=Math.floor(Math.round(n[0])*ht),r=Math.floor(Math.round(n[1])*ht),o=(_e(s,0,t.width-1)+_e(r,0,t.height-1)*t.width)*4,a=t.data[o],l=t.data[o+1],c=t.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/e.length);c&&c%u===0&&i.push(e[c/u-1])}return i}const Dp=.5,md={Point:Xp,LineString:Up,Polygon:$p,MultiPoint:jp,MultiLineString:Bp,MultiPolygon:zp,GeometryCollection:kp,Circle:Np};function Op(n,e){return parseInt(O(n),10)-parseInt(O(e),10)}function qa(n,e){const t=pd(n,e);return t*t}function pd(n,e){return Dp*n/e}function Np(n,e,t,i,s){const r=t.getFill(),o=t.getStroke();if(r||o){const l=n.getBuilder(t.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(e,i,s)}const a=t.getText();if(a&&a.getText()){const l=n.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i)}}function to(n,e,t,i,s,r,o,a){const l=[],h=t.getImage();if(h){let d=!0;const f=h.getImageState();f==X.LOADED||f==X.ERROR?d=!1:f==X.IDLE&&h.load(),d&&l.push(h.ready())}const c=t.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>s(null)),Gp(n,e,t,i,r,o,a),u}function Gp(n,e,t,i,s,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(i,s);if(t.getRenderer())yd(n,l,t,e,o);else{const c=md[l.getType()];c(n,l,t,e,o,r)}}function yd(n,e,t,i,s){if(e.getType()=="GeometryCollection"){const o=e.getGeometries();for(let a=0,l=o.length;a<l;++a)yd(n,o[a],t,i,s);return}n.getBuilder(t.getZIndex(),"Default").drawCustom(e,i,t.getRenderer(),t.getHitDetectionRenderer(),s)}function kp(n,e,t,i,s,r){const o=e.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=md[o[a].getType()];h(n,o[a],t,i,s,r)}}function Up(n,e,t,i,s){const r=t.getStroke();if(r){const a=n.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(e,i,s)}const o=t.getText();if(o&&o.getText()){const a=n.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,i,s)}}function Bp(n,e,t,i,s){const r=t.getStroke();if(r){const a=n.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(e,i,s)}const o=t.getText();if(o&&o.getText()){const a=n.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,i,s)}}function zp(n,e,t,i,s){const r=t.getFill(),o=t.getStroke();if(o||r){const l=n.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(e,i,s)}const a=t.getText();if(a&&a.getText()){const l=n.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i,s)}}function Xp(n,e,t,i,s,r){const o=t.getImage(),a=t.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=X.LOADED)return;const c=n.getBuilder(t.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(e,i,s)}if(l){const c=n.getBuilder(t.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(e,i,s)}}function jp(n,e,t,i,s,r){const o=t.getImage(),a=o&&o.getOpacity()!==0,l=t.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=X.LOADED)return;const u=n.getBuilder(t.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(e,i,s)}if(h){const u=n.getBuilder(t.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(e,i,s)}}function $p(n,e,t,i,s){const r=t.getFill(),o=t.getStroke();if(r||o){const l=n.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(e,i,s)}const a=t.getText();if(a&&a.getText()){const l=n.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i,s)}}class xd extends hh{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Qe(),this.wrappedRenderedExtent_=Qe(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,t,i){const s=t.extent,r=t.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=t.pixelRatio,g=t.viewHints,_=!(g[de.ANIMATING]||g[de.INTERACTING]),m=this.context,y=Math.round(te(s)/a*f),p=Math.round(Ie(s)/a*f),T=u.getWrapX()&&l.canWrapX(),x=T?te(c):null,E=T?Math.ceil((s[2]-c[2])/x)+1:1;let R=T?Math.floor((s[0]-c[0])/x):0;do{let C=this.getRenderTransform(o,a,0,f,y,p,R*x);t.declutter&&(C=C.slice(0)),e.execute(m,[m.canvas.width,m.canvas.height],C,h,_,i===void 0?Xi:i?eo:Fp,i?d&&t.declutter[d]:void 0)}while(++R<E)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Te(this.context.canvas.width,this.context.canvas.height,Rc))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,To(this.context),Rc.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,t){const i=e.layerStatesArray[e.layerIndex];this.opacity_=i.opacity;const s=e.viewState;this.prepareContainer(e,t);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(ke.PRERENDER)||this.getLayer().hasListener(ke.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,e),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=ct(i.extent);a=Pe(l,e.extent),this.clipped_=a&&!Ti(l,e.extent),this.clipped_&&this.clipUnrotated(r,e,l)}return a&&this.renderWorlds(o,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&r.restore(),this.postRender(r,e),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*ht,d=i[1]*ht;c.push(this.getRenderTransform(s,r,o,ht,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Ti(g,l)){let _=l[0];const m=te(g);let y=0,p;for(;_<g[0];)--y,p=m*y,c.push(this.getRenderTransform(s,r,o,ht,u,d,p).slice()),_+=m;for(y=0,_=l[2];_>g[2];)++y,p=m*y,c.push(this.getRenderTransform(s,r,o,ht,u,d,p).slice()),_-=m}this.hitDetectionImageData_=gd(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,qa(r,this.renderedPixelRatio_),null)}t(_d(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,i,s,r){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const _=O(d),m=h[_];if(m){if(m!==!0&&g<m.distanceSq){if(g===0)return h[_]=!0,r.splice(r.lastIndexOf(m),1),s(d,l,f);m.geometry=f,m.distanceSq=g}}else{if(g===0)return h[_]=!0,s(d,l,f);r.push(h[_]={feature:d,layer:l,geometry:f,distanceSq:g,callback:s})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,o,a,i,c,u?t.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),i=t.getSource();if(!i)return!1;const s=e.viewHints[de.ANIMATING],r=e.viewHints[de.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,h=e.viewState,c=h.projection,u=h.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let _=t.getRenderOrder();_===void 0&&(_=Op);const m=h.center.slice(),y=ai(l,g*u),p=y.slice(),T=[y.slice()],x=c.getExtent();if(i.getWrapX()&&c.canWrapX()&&!Ti(x,e.extent)){const b=te(x),k=Math.max(te(y)/2,b);y[0]=x[0]-k,y[2]=x[2]+k,Cl(m,c);const M=uu(T[0],c);M[0]<x[0]&&M[2]<x[2]?T.push([M[0]+b,M[1],M[2]+b,M[3]]):M[0]>x[0]&&M[2]>x[2]&&T.push([M[0]-b,M[1],M[2]-b,M[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!e.declutter&&Ti(this.wrappedRenderedExtent_,y))return jt(this.renderedExtent_,p)||(this.hitDetectionImageData_=null,this.renderedExtent_=p),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const E=new dd(pd(u,d),y,u,d);let R;for(let b=0,k=T.length;b<k;++b)i.loadFeatures(T[b],u,c);const C=qa(u,d);let v=!0;const w=(b,k)=>{let M;const G=b.getStyleFunction()||t.getStyleFunction();if(G&&(M=G(b,u)),M){const N=this.renderFeature(b,C,M,E,R,this.getLayer().getDeclutter(),k);v=v&&!N}},P=mo(y),A=i.getFeaturesInExtent(P);_&&A.sort(_);for(let b=0,k=A.length;b<k;++b)w(A[b],b);this.renderedFeatures_=A,this.ready=v;const I=E.finish(),F=new fd(y,u,d,i.getOverlaps(),I,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=_,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=p,this.wrappedRenderedExtent_=y,this.renderedCenter_=m,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=F,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=to(s,e,i[h],t,this.boundHandleStyleImageChange_,r,o,a)||l;else l=to(s,e,i,t,this.boundHandleStyleImageChange_,r,o,a);return l}}class uh extends os{constructor(e){super(e)}createRenderer(){return new xd(this)}}class Wp extends Pm{constructor(e,t,i,s,r){const o=r!==void 0?X.IDLE:X.LOADED;super(e,t,i,o),this.loader_=r!==void 0?r:null,this.canvas_=s,this.error_=null}getError(){return this.error_}handleLoad_(e){e?(this.error_=e,this.state=X.ERROR):this.state=X.LOADED,this.changed()}load(){this.state==X.IDLE&&(this.state=X.LOADING,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}function Yp(n){return Array.isArray(n)?Math.min(...n):n}class Vp extends cd{constructor(e){super(e),this.vectorRenderer_=new xd(e),this.layerImageRatio_=e.getImageRatio(),this.coordinateToVectorPixelTransform_=Ce(),this.renderedPixelToCoordinateTransform_=null}disposeInternal(){this.vectorRenderer_.dispose(),super.disposeInternal()}getFeatures(e){if(!this.vectorRenderer_)return Promise.resolve([]);const t=me(this.coordinateToVectorPixelTransform_,me(this.renderedPixelToCoordinateTransform_,e.slice()));return this.vectorRenderer_.getFeatures(t)}handleFontsChanged(){this.vectorRenderer_.handleFontsChanged()}prepareFrame(e){const t=e.pixelRatio,i=e.viewState,s=i.resolution,r=e.viewHints,o=this.vectorRenderer_;let a=e.extent;this.layerImageRatio_!==1&&(a=a.slice(0),Kf(a,this.layerImageRatio_));const l=te(a)/s,h=Ie(a)/s;if(!r[de.ANIMATING]&&!r[de.INTERACTING]&&!Di(a)){o.useContainer(null,null);const c=o.context,u=e.layerStatesArray[e.layerIndex],d=Object.assign({},u,{opacity:1}),f=Object.assign({},e,{extent:a,size:[l,h],viewState:Object.assign({},e.viewState,{rotation:0}),layerStatesArray:[d],layerIndex:0,declutter:null}),g=this.getLayer().getDeclutter();g&&(f.declutter={[g]:new ql(9)});const _=new Wp(a,s,t,c.canvas,function(m){o.prepareFrame(f)&&o.replayGroupChanged&&(o.clipping=!1,o.renderFrame(f,null),o.renderDeclutter(f),o.renderDeferred(f),m())});_.addEventListener(Z.CHANGE,()=>{if(_.getState()!==X.LOADED)return;this.image=_;const m=_.getPixelRatio(),y=Yp(_.getResolution())*t/m;this.renderedResolution=y,this.coordinateToVectorPixelTransform_=ft(this.coordinateToVectorPixelTransform_,l/2,h/2,1/y,-1/y,0,-i.center[0],-i.center[1])}),_.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice()),!this.getLayer().getSource()?.loading&&!!this.image}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(e,t,i,s,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(e,t,i,s,r):super.forEachFeatureAtCoordinate(e,t,i,s,r)}}class pT extends os{constructor(e){e=e||{};const t=Object.assign({},e);delete t.imageRatio,super(t),this.imageRatio_=e.imageRatio!==void 0?e.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new Vp(this)}}let Zp=!1;function Kp(n,e,t,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(t,i,s):n,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=Zp,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=e.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(e.readFeatures(c,{extent:t,featureProjection:s}),e.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function Ic(n,e){return function(t,i,s,r,o){Kp(n,e,t,i,s,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Hp(n,e){return[[-1/0,-1/0,1/0,1/0]]}class $e extends bt{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){const t=e;this.setGeometry(t)}else{const t=e;this.setProperties(t)}}clone(){const e=new $e(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());const t=this.getGeometry();t&&e.setGeometry(t.clone());const i=this.getStyle();return i&&e.setStyle(i),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(ue(this.geometryChangeKey_),this.geometryChangeKey_=null);const e=this.getGeometry();e&&(this.geometryChangeKey_=ee(e,Z.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?qp(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function qp(n){if(typeof n=="function")return n;let e;return Array.isArray(n)?e=n:(se(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[n]),function(){return e}}function Ed(n,e,t,i){const s=[];let r=Qe();for(let o=0,a=t.length;o<a;++o){const l=t[o];r=ml(n,e,l[0],i),s.push((r[0]+r[2])/2,(r[1]+r[3])/2),e=l[l.length-1]}return s}function io(n,e,t,i,s,r,o){let a,l;const h=(t-e)/i;if(h===1)a=e;else if(h===2)a=e,l=s;else if(h!==0){let c=n[e],u=n[e+1],d=0;const f=[0];for(let m=e+i;m<t;m+=i){const y=n[m],p=n[m+1];d+=Math.sqrt((y-c)*(y-c)+(p-u)*(p-u)),f.push(d),c=y,u=p}const g=s*d,_=If(f,g);_<0?(l=(g-f[-_-2])/(f[-_-1]-f[-_-2]),a=e+(-_-2)*i):a=e+_*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?n[a+c]:lt(n[a+c],n[a+i+c],l);return r}function Ja(n,e,t,i,s,r){if(t==e)return null;let o;if(s<n[e+i-1])return r?(o=n.slice(e,e+i),o[i-1]=s,o):null;if(n[t-1]<s)return r?(o=n.slice(t-i,t),o[i-1]=s,o):null;if(s==n[e+i-1])return n.slice(e,e+i);let a=e/i,l=t/i;for(;a<l;){const d=a+l>>1;s<n[(d+1)*i-1]?l=d:a=d+1}const h=n[a*i-1];if(s==h)return n.slice((a-1)*i,(a-1)*i+i);const c=n[(a+1)*i-1],u=(s-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(lt(n[(a-1)*i+d],n[a*i+d],u));return o.push(s),o}function Jp(n,e,t,i,s,r,o){if(o)return Ja(n,e,t[t.length-1],i,s,r);let a;if(s<n[i-1])return r?(a=n.slice(0,i),a[i-1]=s,a):null;if(n[n.length-1]<s)return r?(a=n.slice(n.length-i),a[i-1]=s,a):null;for(let l=0,h=t.length;l<h;++l){const c=t[l];if(e!=c){if(s<n[e+i-1])return null;if(s<=n[c-1])return Ja(n,e,c,i,s,!1);e=c}}return null}class Ao extends Oi{constructor(e,t,i){super(),i!==void 0&&t===void 0?this.setFlatCoordinates(i,e):(t=t||0,this.setCenterAndRadius(e,t,i))}clone(){const e=new Ao(this.flatCoordinates.slice(),void 0,this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,s){const r=this.flatCoordinates,o=e-r[0],a=t-r[1],l=o*o+a*a;if(l<s){if(l===0)for(let h=0;h<this.stride;++h)i[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);i[0]=r[0]+h*o,i[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)i[c]=r[c]}return i.length=this.stride,l}return s}containsXY(e,t){const i=this.flatCoordinates,s=e-i[0],r=t-i[1];return s*s+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(e){const t=this.flatCoordinates,i=t[this.stride]-t[0];return zt(t[0]-i,t[1]-i,t[0]+i,t[1]+i,e)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const e=this.flatCoordinates[this.stride]-this.flatCoordinates[0],t=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return e*e+t*t}getType(){return"Circle"}intersectsExtent(e){const t=this.getExtent();if(Pe(e,t)){const i=this.getCenter();return e[0]<=i[0]&&e[2]>=i[0]||e[1]<=i[1]&&e[3]>=i[1]?!0:yl(e,this.intersectsCoordinate.bind(this))}return!1}setCenter(e){const t=this.stride,i=this.flatCoordinates[t]-this.flatCoordinates[0],s=e.slice();s[t]=s[0]+i;for(let r=1;r<t;++r)s[t+r]=e[r];this.setFlatCoordinates(this.layout,s),this.changed()}setCenterAndRadius(e,t,i){this.setLayout(i,e,0),this.flatCoordinates||(this.flatCoordinates=[]);const s=this.flatCoordinates;let r=vu(s,0,e,this.stride);s[r++]=s[0]+t;for(let o=1,a=this.stride;o<a;++o)s[r++]=s[o];s.length=r,this.changed()}getCoordinates(){return null}setCoordinates(e,t){}setRadius(e){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+e,this.changed()}rotate(e,t){const i=this.getCenter(),s=this.getStride();this.setCenter(bl(i,0,i.length,s,e,t,i)),this.changed()}}Ao.prototype.transform;class Je extends Ru{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(ue),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const e=this.geometries_;for(let t=0,i=e.length;t<i;++t)this.changeEventsKeys_.push(ee(e[t],Z.CHANGE,this.changed,this))}clone(){const e=new Je(fa(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,t,i,s){if(s<nn(this.getExtent(),e,t))return s;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)s=r[o].closestPointXY(e,t,i,s);return s}containsXY(e,t){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)if(i[s].containsXY(e,t))return!0;return!1}computeExtent(e){ts(e);const t=this.geometries_;for(let i=0,s=t.length;i<s;++i)pl(e,t[i].getExtent());return e}getGeometries(){return fa(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[];const t=this.geometries_;for(let i=0,s=t.length;i<s;++i)t[i].getType()===this.getType()?e=e.concat(t[i].getGeometriesArrayRecursive()):e.push(t[i]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=[],i=this.geometries_;let s=!1;for(let r=0,o=i.length;r<o;++r){const a=i[r],l=a.getSimplifiedGeometry(e);t.push(l),l!==a&&(s=!0)}return s?new Je(t):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){const t=this.geometries_;for(let i=0,s=t.length;i<s;++i)if(t[i].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,t){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)i[s].rotate(e,t);this.changed()}scale(e,t,i){i||(i=Fi(this.getExtent()));const s=this.geometries_;for(let r=0,o=s.length;r<o;++r)s[r].scale(e,t,i);this.changed()}setGeometries(e){this.setGeometriesArray(fa(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){const t=this.geometries_;for(let i=0,s=t.length;i<s;++i)t[i].applyTransform(e);this.changed()}translate(e,t){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)i[s].translate(e,t);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function fa(n){return n.map(e=>e.clone())}class dt extends Oi{constructor(e,t){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendCoordinate(e){oe(this.flatCoordinates,e),this.changed()}clone(){const e=new dt(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,s){return s<nn(this.getExtent(),e,t)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ml(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ol(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,t,i,s))}forEachSegment(e){return Au(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,t){return this.layout!="XYM"&&this.layout!="XYZM"?null:(t=t!==void 0?t:!1,Ja(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t))}getCoordinates(){return Ri(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,t){return io(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,this.stride)}getLength(){return ch(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){const t=[];return t.length=xo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new dt(t,"XY")}getType(){return"LineString"}intersectsExtent(e){return Eo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,this.getExtent())}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=yo(this.flatCoordinates,0,e,this.stride),this.changed()}}class hi extends Oi{constructor(e,t,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,t);else if(t!==void 0&&i)this.setFlatCoordinates(t,e),this.ends_=i;else{const s=e,r=[],o=[];for(let l=0,h=s.length;l<h;++l){const c=s[l];oe(r,c.getFlatCoordinates()),o.push(r.length)}const a=s.length===0?this.getLayout():s[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(e){oe(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const e=new hi(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,i,s){return s<nn(this.getExtent(),e,t)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Dl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Nl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,t,i,s))}getCoordinateAtM(e,t,i){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(t=t!==void 0?t:!1,i=i!==void 0?i:!1,Jp(this.flatCoordinates,0,this.ends_,this.stride,e,t,i))}getCoordinates(){return ks(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new dt(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){const e=this.flatCoordinates,t=this.ends_,i=this.layout,s=[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=new dt(e.slice(r,l),i);s.push(h),r=l}return s}getLength(){const e=this.ends_;let t=0,i=0;for(let s=0,r=e.length;s<r;++s)i+=ch(this.flatCoordinates,t,e[s],this.stride),t=e[s];return i}getFlatMidpoints(){const e=[],t=this.flatCoordinates;let i=0;const s=this.ends_,r=this.stride;for(let o=0,a=s.length;o<a;++o){const l=s[o],h=io(t,i,l,r,.5);oe(e,h),i=l}return e}getSimplifiedGeometryInternal(e){const t=[],i=[];return t.length=Pu(this.flatCoordinates,0,this.ends_,this.stride,e,t,0,i),new hi(t,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(e){return e_(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=er(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class an extends Oi{constructor(e,t){super(),t&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendPoint(e){oe(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){const e=new an(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,s){if(s<nn(this.getExtent(),e,t))return s;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=ni(e,t,r[a],r[a+1]);if(h<s){s=h;for(let c=0;c<o;++c)i[c]=r[a+c];i.length=o}}return s}getCoordinates(){return Ri(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){const t=this.flatCoordinates.length/this.stride;return e<0||t<=e?null:new ut(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){const e=this.flatCoordinates,t=this.layout,i=this.stride,s=[];for(let r=0,o=e.length;r<o;r+=i){const a=new ut(e.slice(r,r+i),t);s.push(a)}return s}getType(){return"MultiPoint"}intersectsExtent(e){const t=this.flatCoordinates,i=this.stride;for(let s=0,r=t.length;s<r;s+=i){const o=t[s],a=t[s+1];if(_l(e,o,a))return!0}return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=yo(this.flatCoordinates,0,e,this.stride),this.changed()}}class bi extends Oi{constructor(e,t,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(e[0])){const s=e,r=[],o=[];for(let a=0,l=s.length;a<l;++a){const h=s[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;oe(r,h.getFlatCoordinates()),o.push(u)}t=s.length===0?this.getLayout():s[0].getLayout(),e=r,i=o}t!==void 0&&i?(this.setFlatCoordinates(t,e),this.endss_=i):this.setCoordinates(e,t)}appendPolygon(e){let t;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),t=e.getEnds().slice(),this.endss_.push();else{const i=this.flatCoordinates.length;oe(this.flatCoordinates,e.getFlatCoordinates()),t=e.getEnds().slice();for(let s=0,r=t.length;s<r;++s)t[s]+=i}this.endss_.push(t),this.changed()}clone(){const e=this.endss_.length,t=new Array(e);for(let s=0;s<e;++s)t[s]=this.endss_[s].slice();const i=new bi(this.flatCoordinates.slice(),this.layout,t);return i.applyProperties(this),i}closestPointXY(e,t,i,s){return s<nn(this.getExtent(),e,t)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Zg(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Kg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,t,i,s))}containsXY(e,t){return Qg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,t)}getArea(){return Vg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),Ba(t,0,this.endss_,this.stride,e)):t=this.flatCoordinates,Ua(t,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const e=Ed(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Iu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new an(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const e=this.flatCoordinates;bu(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ba(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){const t=[],i=[];return t.length=qg(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),t,0,i),new bi(t,"XY",i)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let t;if(e===0)t=0;else{const r=this.endss_[e-1];t=r[r.length-1]}const i=this.endss_[e].slice(),s=i[i.length-1];if(t!==0)for(let r=0,o=i.length;r<o;++r)i[r]-=t;return new rt(this.flatCoordinates.slice(t,s),this.layout,i)}getPolygons(){const e=this.layout,t=this.flatCoordinates,i=this.endss_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new rt(t.slice(r,h),e,l);s.push(c),r=h}return s}getType(){return"MultiPolygon"}intersectsExtent(e){return t_(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=wu(this.flatCoordinates,0,e,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{const s=i[i.length-1];this.flatCoordinates.length=s.length===0?0:s[s.length-1]}this.changed()}}const Ac=Ce();class it{constructor(e,t,i,s,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=e,this.flatCoordinates_=t,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Cs(this.flatCoordinates_):ml(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const e=Fi(this.getExtent());this.flatInteriorPoints_=Ul(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const e=Mu(this.flatCoordinates_,this.ends_),t=Ed(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Iu(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=io(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const e=this.flatCoordinates_;let t=0;const i=this.ends_;for(let s=0,r=i.length;s<r;++s){const o=i[s],a=io(e,t,o,2,.5);oe(this.flatMidpoints_,a),t=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,t){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=pe(e);const t=e.getExtent(),i=e.getWorldExtent();if(t&&i){const s=Ie(i)/Ie(t);ft(Ac,i[0],i[3],s,-s,0,0,0),Ut(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Ac,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new it(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=ou((e,t)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=xo(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Pu(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,i,0,s);break;case"Polygon":s=[],i.length=Gl(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),i,0,s);break}return s&&(this.simplifiedGeometry_=new it(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}it.prototype.getFlatCoordinates=it.prototype.getOrientedFlatCoordinates;class Qa{constructor(e){this.rbush_=new ql(e),this.items_={}}insert(e,t){const i={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(i),this.items_[O(t)]=i}load(e,t){const i=new Array(t.length);for(let s=0,r=t.length;s<r;s++){const o=e[s],a=t[s],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[s]=l,this.items_[O(a)]=l}this.rbush_.load(i)}remove(e){const t=O(e),i=this.items_[t];return delete this.items_[t],this.rbush_.remove(i)!==null}update(e,t){const i=this.items_[O(t)],s=[i.minX,i.minY,i.maxX,i.maxY];qi(s,e)||(this.remove(t),this.insert(e,t))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(e){const t={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(t).map(function(s){return s.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,t){return this.forEach_(this.getInExtent(e),t)}forEach_(e,t){let i;for(let s=0,r=e.length;s<r;s++)if(i=t(e[s]),i)return i;return i}isEmpty(){return Ki(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){const t=this.rbush_.toJSON();return zt(t.minX,t.minY,t.maxX,t.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(const t in e.items_)this.items_[t]=e.items_[t]}}class Td extends bt{constructor(e){super(),this.projection=pe(e.projection),this.attributions_=Lc(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;const t=this;this.viewPromise_=new Promise(function(i,s){t.viewResolver=i,t.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=Lc(e),this.changed()}setState(e){this.state_=e,this.changed()}}function Lc(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),e=>n):null}const Ne={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class pi extends Pt{constructor(e,t,i){super(e),this.feature=t,this.features=i}}class Rd extends Td{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Ds,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(se(this.format_,"`format` must be set when `url` is set"),this.loader_=Ic(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Hp;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Qa:null,this.loadedExtentsRtree_=new Qa,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(e.features)?s=e.features:e.features&&(i=e.features,s=i.getArray()),!t&&i===void 0&&(i=new qe(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=O(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const i=e.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new pi(Ne.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof it||(this.featureChangeKeys_[e]=[ee(t,Z.CHANGE,this.handleFeatureChange_,this),ee(t,jn.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let i=!0;if(t.getId()!==void 0){const s=String(t.getId());if(!(s in this.idIndex_))this.idIndex_[s]=t;else if(t instanceof it){const r=this.idIndex_[s];r instanceof it?Array.isArray(r)?r.push(t):this.idIndex_[s]=[r,t]:i=!1}else i=!1}return i&&(se(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),i}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],i=[],s=[];for(let r=0,o=e.length;r<o;r++){const a=e[r],l=O(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=O(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();t.push(c),s.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(t,s),this.hasListener(Ne.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new pi(Ne.ADDFEATURE,i[r]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(Ne.ADDFEATURE,function(i){t||(t=!0,e.push(i.feature),t=!1)}),this.addEventListener(Ne.REMOVEFEATURE,function(i){t||(t=!0,e.remove(i.feature),t=!1)}),e.addEventListener(Le.ADD,i=>{t||(t=!0,this.addFeature(i.element),t=!1)}),e.addEventListener(Le.REMOVE,i=>{t||(t=!0,this.removeFeature(i.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(ue);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new pi(Ne.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const i=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof it||r.intersectsCoordinate(e))return t(s)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(i){const s=i.getGeometry();if(s instanceof it||s.intersectsExtent(e)){const r=t(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Ki(this.nullGeometryFeatures_)||oe(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(i){t.push(i)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const s=El(e,t);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const i=e[0],s=e[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||Li,this.featuresRtree_.forEachInExtent(l,function(h){if(t(h)){const c=h.getGeometry(),u=a;if(a=c instanceof it?0:c.closestPointXY(i,s,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=s-d,l[2]=i+d,l[3]=s+d}}}),r}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){const t=this.idIndex_[e.toString()];return t!==void 0?t:null}getFeatureByUid(e){const t=this.uidIndex_[e];return t!==void 0?t:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){const t=e.target,i=O(t),s=t.getGeometry();if(!s)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(t),this.nullGeometryFeatures_[i]=t);else{const o=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,t)):this.featuresRtree_&&this.featuresRtree_.update(o,t)}const r=t.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==t&&(this.removeFromIdIndex_(t),this.idIndex_[o]=t)}else this.removeFromIdIndex_(t),this.uidIndex_[i]=t;this.changed(),this.dispatchEvent(new pi(Ne.CHANGEFEATURE,t))}hasFeature(e){const t=e.getId();return t!==void 0?t in this.idIndex_:O(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Ki(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,t,i){const s=this.loadedExtentsRtree_,r=this.strategy_(e,t,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];s.forEachInExtent(l,function(c){return Ti(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new pi(Ne.FEATURESLOADSTART)),this.loader_.call(this,l,t,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new pi(Ne.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new pi(Ne.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_,i=t.forEachInExtent(e,function(s){if(qi(s.extent,e))return s});i&&t.remove(i)}removeFeatures(e){let t=!1;for(let i=0,s=e.length;i<s;++i)t=this.removeFeatureInternal(e[i])||t;t&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){const t=O(e);if(!(t in this.uidIndex_))return!1;t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[t]?.forEach(ue),delete this.featureChangeKeys_[t];const s=e.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===e?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(e),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[t],this.hasListener(Ne.REMOVEFEATURE)&&this.dispatchEvent(new pi(Ne.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(const t in this.idIndex_)if(this.idIndex_[t]===e){delete this.idIndex_[t];break}}setLoader(e){this.loader_=e}setUrl(e){se(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(Ic(e,this.format_))}setOverlaps(e){this.overlaps_=e,this.changed()}}const Fc=4;function Cd(n,e){const t=[];Object.keys(e).forEach(function(s){e[s]!==null&&e[s]!==void 0&&t.push(s+"="+encodeURIComponent(e[s]))});const i=t.join("&");return n=n.replace(/[?&]$/,""),n+=n.includes("?")?"&":"?",n+i}const Qp=/\{z\}/g,ey=/\{x\}/g,ty=/\{y\}/g,iy=/\{-y\}/g;function ny(n,e,t,i,s){return n.replace(Qp,e.toString()).replace(ey,t.toString()).replace(ty,i.toString()).replace(iy,function(){if(s===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(s-i).toString()})}function sy(n){const e=[];let t=/\{([a-z])-([a-z])\}/.exec(n);if(t){const i=t[1].charCodeAt(0),s=t[2].charCodeAt(0);let r;for(r=i;r<=s;++r)e.push(n.replace(t[0],String.fromCharCode(r)));return e}if(t=/\{(\d+)-(\d+)\}/.exec(n),t){const i=parseInt(t[2],10);for(let s=parseInt(t[1],10);s<=i;s++)e.push(n.replace(t[0],s.toString()));return e}return e.push(n),e}const el="1.3.0";function ry(n,e,t,i,s){s.WIDTH=t[0],s.HEIGHT=t[1];const r=i.getAxisOrientation(),o=du(s.VERSION,"1.3")>=0;s[o?"CRS":"SRS"]=i.getCode();const a=o&&r.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return s.BBOX=a.join(","),Cd(n,s)}function oy(n,e,t,i,s,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[zh(te(n)/a,Fc),zh(Ie(n)/a,Fc)];if(t!=1)switch(o){case"geoserver":const c=90*t+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+c:r.FORMAT_OPTIONS="dpi:"+c;break;case"mapserver":r.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":r.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return ry(s,n,l,i,r)}function bc(n,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:el,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},n)}const Tn=[0,0,0],yi=5;class Sd{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,se(Lf(this.resolutions_,(s,r)=>r-s),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let s=0,r=this.resolutions_.length-1;s<r;++s)if(!t)t=this.resolutions_[s]/this.resolutions_[s+1];else if(this.resolutions_[s]/this.resolutions_[s+1]!==t){t=void 0;break}}this.zoomFactor_=t,this.maxZoom=this.resolutions_.length-1,this.origin_=e.origin!==void 0?e.origin:null,this.origins_=null,e.origins!==void 0&&(this.origins_=e.origins,se(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=e.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Xt(i)),se(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,e.tileSizes!==void 0&&(this.tileSizes_=e.tileSizes,se(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=e.tileSize!==void 0?e.tileSize:this.tileSizes_?null:Wl,se(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],e.sizes!==void 0?this.fullTileRanges_=e.sizes.map((s,r)=>{const o=new Io(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(e,t,i){const s=this.getTileRangeForExtentAndZ(e,t);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([t,r,a])}forEachTileCoordParentTileRange(e,t,i,s){let r,o,a,l=null,h=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,s);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=xn(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,h,i),t(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]<this.maxZoom){if(this.zoomFactor_===2){const r=e[1]*2,o=e[2]*2;return xn(r,r+1,o,o+1,t)}const s=this.getTileCoordExtent(e,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(s,e[0]+1,t)}return null}getTileRangeForTileCoordAndZ(e,t,i){if(t>this.maxZoom||t<this.minZoom)return null;const s=e[0],r=e[1],o=e[2];if(t===s)return xn(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,t-s),h=Math.floor(r*l),c=Math.floor(o*l);if(t<s)return xn(h,h,c,c,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return xn(h,u,c,d,i)}const a=this.getTileCoordExtent(e,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,t,i)}getTileRangeForExtentAndZ(e,t,i){this.getTileCoordForXYAndZ_(e[0],e[3],t,!1,Tn);const s=Tn[1],r=Tn[2];this.getTileCoordForXYAndZ_(e[2],e[1],t,!0,Tn);const o=Tn[1],a=Tn[2];return xn(s,o,r,a,i)}getTileCoordCenter(e){const t=this.getOrigin(e[0]),i=this.getResolution(e[0]),s=Se(this.getTileSize(e[0]),this.tmpSize_);return[t[0]+(e[1]+.5)*s[0]*i,t[1]-(e[2]+.5)*s[1]*i]}getTileCoordExtent(e,t){const i=this.getOrigin(e[0]),s=this.getResolution(e[0]),r=Se(this.getTileSize(e[0]),this.tmpSize_),o=i[0]+e[1]*r[0]*s,a=i[1]-(e[2]+1)*r[1]*s,l=o+r[0]*s,h=a+r[1]*s;return zt(o,a,l,h,t)}getTileCoordForCoordAndResolution(e,t,i){return this.getTileCoordForXYAndResolution_(e[0],e[1],t,!1,i)}getTileCoordForXYAndResolution_(e,t,i,s,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=Se(this.getTileSize(o),this.tmpSize_);let c=a*(e-l[0])/i/h[0],u=a*(l[1]-t)/i/h[1];return s?(c=dr(c,yi)-1,u=dr(u,yi)-1):(c=ur(c,yi),u=ur(u,yi)),Hn(o,c,u,r)}getTileCoordForXYAndZ_(e,t,i,s,r){const o=this.getOrigin(i),a=this.getResolution(i),l=Se(this.getTileSize(i),this.tmpSize_);let h=(e-o[0])/a/l[0],c=(o[1]-t)/a/l[1];return s?(h=dr(h,yi)-1,c=dr(c,yi)-1):(h=ur(h,yi),c=ur(c,yi)),Hn(i,h,c,r)}getTileCoordForCoordAndZ(e,t,i){return this.getTileCoordForXYAndZ_(e[0],e[1],t,!1,i)}getTileCoordResolution(e){return this.resolutions_[e[0]]}getTileSize(e){return this.tileSize_?this.tileSize_:this.tileSizes_[e]}getFullTileRange(e){return this.fullTileRanges_?this.fullTileRanges_[e]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,e):null}getZForResolution(e,t){const i=dl(this.resolutions_,e,t||0);return _e(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(e,t){return Lu(t,0,t.length,2,this.getTileCoordExtent(e))}calculateTileRanges_(e){const t=this.resolutions_.length,i=new Array(t);for(let s=this.minZoom;s<t;++s)i[s]=this.getTileRangeForExtentAndZ(e,s);this.fullTileRanges_=i}}function dh(n){let e=n.getDefaultTileGrid();return e||(e=hy(n),n.setDefaultTileGrid(e)),e}function ay(n,e,t){const i=e[0],s=n.getTileCoordCenter(e),r=Lo(t);if(!li(r,s)){const o=te(r),a=Math.ceil((r[0]-s[0])/o);return s[0]+=o*a,n.getTileCoordForCoordAndZ(s,i)}return e}function ly(n,e,t,i){i=i!==void 0?i:"top-left";const s=wd(n,e,t);return new Sd({extent:n,origin:Vf(n,i),resolutions:s,tileSize:t})}function vd(n){const e=n||{},t=e.extent||pe("EPSG:3857").getExtent(),i={extent:t,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:wd(t,e.maxZoom,e.tileSize,e.maxResolution)};return new Sd(i)}function wd(n,e,t,i){e=e!==void 0?e:l_,t=Se(t!==void 0?t:Wl);const s=Ie(n),r=te(n);i=i>0?i:Math.max(r/t[0],s/t[1]);const o=e+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function hy(n,e,t,i){const s=Lo(n);return ly(s,e,t,i)}function Lo(n){n=pe(n);let e=n.getExtent();if(!e){const t=180*Wn.degrees/n.getMetersPerUnit();e=zt(-t,-t,t,t)}return e}function cy(n,e){return(function(t,i,s){if(!t)return;let r;const o=t[0];if(e){const a=e.getFullTileRange(o);a&&(r=a.getHeight()-1)}return ny(n,o,t[1],t[2],r)})}function uy(n,e){const t=n.length,i=new Array(t);for(let s=0;s<t;++s)i[s]=cy(n[s],e);return dy(i)}function dy(n){return n.length===1?n[0]:(function(e,t,i){if(!e)return;const s=ad(e),r=si(s,n.length);return n[r](e,t,i)})}class Pd extends Td{constructor(e){super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:e.projection,state:e.state,wrapX:e.wrapX,interpolate:e.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=e.tilePixelRatio!==void 0?e.tilePixelRatio:1,this.tileGrid=e.tileGrid!==void 0?e.tileGrid:null;const t=[256,256];this.tileGrid&&Se(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),t),this.tmpSize=[0,0],this.key_=e.key||O(this),this.tileOptions={transition:e.transition,interpolate:e.interpolate},this.zDirection=e.zDirection?e.zDirection:0}getGutterForProjection(e){return 0}getKey(){return this.key_}setKey(e){this.key_!==e&&(this.key_=e,this.changed())}getResolutions(e){const t=e?this.getTileGridForProjection(e):this.tileGrid;return t?t.getResolutions():null}getTile(e,t,i,s,r,o){return W()}getTileGrid(){return this.tileGrid}getTileGridForProjection(e){return this.tileGrid?this.tileGrid:dh(e)}getTilePixelRatio(e){return this.tilePixelRatio_}getTilePixelSize(e,t,i){const s=this.getTileGridForProjection(i),r=this.getTilePixelRatio(t),o=Se(s.getTileSize(e),this.tmpSize);return r==1?o:nm(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(e,t){const i=t!==void 0?t:this.getProjection(),s=t!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(e=ay(s,e,i)),_p(e,s)?e:null}clear(){}refresh(){this.clear(),super.refresh()}}class Id extends Pt{constructor(e,t){super(e),this.tile=t}}const Un={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class fh extends Pd{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===fh.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(e){const t=e.target,i=O(t),s=t.getState();let r;s==D.LOADING?(this.tileLoadingKeys_[i]=!0,r=Un.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=s==D.ERROR?Un.TILELOADERROR:s==D.LOADED?Un.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new Id(r,t))}setTileLoadFunction(e){this.tileLoadFunction=e,this.changed()}setTileUrlFunction(e,t){this.tileUrlFunction=e,typeof t<"u"?this.setKey(t):this.changed()}setUrl(e){const t=sy(e);this.urls=t,this.setUrls(t)}setUrls(e){this.urls=e;const t=e.join(`
|
||
`);this.generateTileUrlFunction_?this.setTileUrlFunction(uy(e,this.tileGrid),t):this.setKey(t)}tileUrlFunction(e,t,i){}}class Ad extends fh{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:Ld,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate!==void 0?e.interpolate:!0,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.crossOrigin=e.crossOrigin!==void 0?e.crossOrigin:null,this.tileClass=e.tileClass!==void 0?e.tileClass:Po,this.tileGridForProjection={},this.reprojectionErrorThreshold_=e.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(e){return this.getProjection()&&e&&!kt(this.getProjection(),e)?0:this.getGutter()}getGutter(){return 0}getKey(){let e=super.getKey();return this.getInterpolate()||(e+=":disable-interpolation"),e}getTileGridForProjection(e){const t=this.getProjection();if(this.tileGrid&&(!t||kt(t,e)))return this.tileGrid;const i=O(e);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=dh(e)),this.tileGridForProjection[i]}createTile_(e,t,i,s,r,o){const a=[e,t,i],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,s,r):void 0,c=new this.tileClass(a,h!==void 0?D.IDLE:D.EMPTY,h!==void 0?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(Z.CHANGE,this.handleTileChange.bind(this)),c}getTile(e,t,i,s,r,o){const a=this.getProjection();if(!a||!r||kt(a,r))return this.getTileInternal(e,t,i,s,a||r);const l=[e,t,i],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(r),d=this.getTileCoordForTileUrlFunction(l,r),f=new ah(a,c,r,u,l,d,this.getTilePixelRatio(s),this.getGutter(),(g,_,m,y)=>this.getTileInternal(g,_,m,y,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(e,t,i,s,r,o){const a=this.getKey(),l=Is(this,a,e,t,i);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(e,t,i,s,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){const i=pe(e);if(i){const s=O(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=t)}}}function Ld(n,e){if(st){const t=n.getCrossOrigin();let i="same-origin",s="same-origin";t==="anonymous"||t===""?(i="cors",s="omit"):t==="use-credentials"&&(i="cors",s="include"),fetch(e,{mode:i,credentials:s}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>createImageBitmap(r)).then(r=>{const o=n.getImage();o.width=r.width,o.height=r.height,o.getContext("2d").drawImage(r,0,0),r.close?.(),o.dispatchEvent(new Event("load"))}).catch(()=>{n.getImage().dispatchEvent(new Event("error"))});return}n.getImage().src=e}class yT extends Ad{constructor(e){e=e||{};const t=Object.assign({},e.params);super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0,this.params_=t,this.v13_=!0,this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.tmpExtent_=Qe(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(e,t,i,s){const r=pe(i),o=this.getProjection()||r;let a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));const l=Js(e,r,o),h=Ka(o,r,e,t),c=a.getZForResolution(h,this.zDirection),u=a.getResolution(c),d=a.getTileCoordForCoordAndZ(l,c);if(a.getResolutions().length<=d[0])return;let f=a.getTileCoordExtent(d,this.tmpExtent_);const g=this.gutter_;g!==0&&(f=ai(f,u*g,f));const _={QUERY_LAYERS:this.params_.LAYERS};Object.assign(_,bc(this.params_,"GetFeatureInfo"),s);const m=Math.floor((l[0]-f[0])/u),y=Math.floor((f[3]-l[1])/u);return _[this.v13_?"I":"X"]=m,_[this.v13_?"J":"Y"]=y,this.getRequestUrl_(d,f,1,o||r,_)}getLegendUrl(e,t){if(this.urls[0]===void 0)return;const i={SERVICE:"WMS",VERSION:el,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(t===void 0||t.LAYER===void 0){const s=this.params_.LAYERS;if(!(!Array.isArray(s)||s.length===1))return;i.LAYER=s}if(e!==void 0){const s=this.getProjection()?this.getProjection().getMetersPerUnit():1,r=28e-5;i.SCALE=e*s/r}return Object.assign(i,t),Cd(this.urls[0],i)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(e,t,i,s,r){const o=this.urls;if(!o)return;let a;if(o.length==1)a=o[0];else{const l=si(ad(e),o.length);a=o[l]}return oy(t,(this.tileGrid||this.getTileGridForProjection(s)).getResolution(e[0]),i,s,a,r,this.serverType_)}getTilePixelRatio(e){return!this.hidpi_||this.serverType_===void 0?1:e}getKeyForParams_(){let e=0;const t=[];for(const i in this.params_)t[e++]=i+"-"+this.params_[i];return t.join("/")}setParams_(e){this.params_=e,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(e){this.setParams_(Object.assign({},e))}updateParams(e){this.setParams_(Object.assign(this.params_,e))}updateV13_(){const e=this.params_.VERSION||el;this.v13_=du(e,"1.3")>=0}tileUrlFunction(e,t,i){let s=this.getTileGrid();if(s||(s=this.getTileGridForProjection(i)),s.getResolutions().length<=e[0])return;t!=1&&(!this.hidpi_||this.serverType_===void 0)&&(t=1);const r=s.getResolution(e[0]);let o=s.getTileCoordExtent(e,this.tmpExtent_);const a=this.gutter_;a!==0&&(o=ai(o,r*a,o));const l=Object.assign({},bc(this.params_,"GetMap"));return this.getRequestUrl_(e,o,t,i,l)}}class fy extends Ad{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",i=e.tileGrid!==void 0?e.tileGrid:vd({extent:Lo(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const gy='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class xT extends fy{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[gy];const i=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",s=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:i,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:(r,o)=>{const a=r.getImage();!st&&a instanceof HTMLImageElement&&(a.referrerPolicy="origin-when-cross-origin"),(e.tileLoadFunction||Ld)(r,o)},transition:e.transition,url:s,wrapX:e.wrapX,zDirection:e.zDirection})}}class gh{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=$e,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let i=t.dataProjection?pe(t.dataProjection):this.readProjection(e);t.extent&&i&&i.getUnits()==="tile-pixels"&&(i=pe(i),i.setWorldExtent(t.extent)),t={dataProjection:i,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return W()}readFeature(e,t){return W()}readFeatures(e,t){return W()}readGeometry(e,t){return W()}readProjection(e){return W()}writeFeature(e,t){return W()}writeFeatures(e,t){return W()}writeGeometry(e,t){return W()}}function en(n,e,t){const i=t?pe(t.featureProjection):null,s=t?pe(t.dataProjection):null;let r=n;if(i&&s&&!kt(i,s)){e&&(r=n.clone());const o=e?i:s,a=e?s:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Ji(o,a))}if(e&&t&&t.decimals!==void 0){const o=Math.pow(10,t.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};r===n&&(r=n.clone()),r.applyTransform(a)}return r}const _y={Point:ut,LineString:dt,Polygon:rt,MultiPoint:an,MultiLineString:hi,MultiPolygon:bi};function my(n,e,t){return Array.isArray(e[0])?(bu(n,0,e,t)||(n=n.slice(),Ba(n,0,e,t)),n):(zl(n,0,e,t)||(n=n.slice(),Wr(n,0,e,t)),n)}function Fd(n,e){const t=n.geometry;if(!t)return[];if(Array.isArray(t))return t.map(r=>Fd({...n,geometry:r})).flat();const i=t.type==="MultiPolygon"?"Polygon":t.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);const s=t.layout.length;return en(new it(i,i==="Polygon"?my(t.flatCoordinates,t.ends,s):t.flatCoordinates,t.ends?.flat(),s,n.properties||{},n.id).enableSimplifyTransformed(),!1,e)}function _h(n,e){if(!n)return null;if(Array.isArray(n)){const i=n.map(s=>_h(s,e));return new Je(i)}const t=_y[n.type];return en(new t(n.flatCoordinates,n.layout||"XY",n.ends),!1,e)}class py extends gh{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(Rr(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(Rr(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return W()}readFeaturesFromObject(e,t){return W()}readGeometry(e,t){return this.readGeometryFromObject(Rr(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return W()}readProjection(e){return this.readProjectionFromObject(Rr(e))}readProjectionFromObject(e){return W()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return W()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return W()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return W()}}function Rr(n){if(typeof n=="string"){const e=JSON.parse(n);return e||null}return n!==null?n:null}class ET extends py{constructor(e){e=e||{},super(),this.dataProjection=pe(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=pe(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,t){let i=null;e.type==="Feature"?i=e:i={type:"Feature",geometry:e,properties:null};const s=mh(i.geometry);if(this.featureClass===it)return Fd({geometry:s,id:i.id,properties:i.properties},t);const r=new $e;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(_h(s,t)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(e,t){const i=e;let s=null;if(i.type==="FeatureCollection"){const r=e;s=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],t);h&&s.push(h)}}else s=[this.readFeatureFromObject(e,t)];return s.flat()}readGeometryFromObject(e,t){return yy(e,t)}readProjectionFromObject(e){const t=e.crs;let i;if(t)if(t.type=="name")i=pe(t.properties.name);else if(t.type==="EPSG")i=pe("EPSG:"+t.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(e,t){t=this.adaptOptions(t);const i={type:"Feature",geometry:null,properties:null},s=e.getId();if(s!==void 0&&(i.id=s),!e.hasProperties())return i;const r=e.getProperties(),o=e.getGeometry();return o&&(i.geometry=tl(o,t),delete r[e.getGeometryName()]),Ki(r)||(i.properties=r),i}writeFeaturesObject(e,t){t=this.adaptOptions(t);const i=[];for(let s=0,r=e.length;s<r;++s)i.push(this.writeFeatureObject(e[s],t));return{type:"FeatureCollection",features:i}}writeGeometryObject(e,t){return tl(e,this.adaptOptions(t))}}function mh(n,e){if(!n)return null;let t;switch(n.type){case"Point":{t=Ey(n);break}case"LineString":{t=Ty(n);break}case"Polygon":{t=vy(n);break}case"MultiPoint":{t=Cy(n);break}case"MultiLineString":{t=Ry(n);break}case"MultiPolygon":{t=Sy(n);break}case"GeometryCollection":{t=xy(n);break}default:throw new Error("Unsupported GeoJSON type: "+n.type)}return t}function yy(n,e){const t=mh(n);return _h(t,e)}function xy(n,e){return n.geometries.map(function(i){return mh(i)})}function Ey(n){const e=n.coordinates;return{type:"Point",flatCoordinates:e,layout:sn(e.length)}}function Ty(n){const e=n.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:sn(e[0]?.length||2)}}function Ry(n){const e=n.coordinates,t=e[0]?.[0]?.length||2,i=[],s=er(i,0,e,t);return{type:"MultiLineString",flatCoordinates:i,ends:s,layout:sn(t)}}function Cy(n){const e=n.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:sn(e[0]?.length||2)}}function Sy(n){const e=n.coordinates,t=[],i=e[0]?.[0]?.[0].length||2,s=wu(t,0,e,i);return{type:"MultiPolygon",flatCoordinates:t,ends:s,layout:sn(i)}}function vy(n){const e=n.coordinates,t=[],i=e[0]?.[0]?.length,s=er(t,0,e,i);return{type:"Polygon",flatCoordinates:t,ends:s,layout:sn(i)}}function tl(n,e){n=en(n,!0,e);const t=n.getType();let i;switch(t){case"Point":{i=Fy(n);break}case"LineString":{i=Py(n);break}case"Polygon":{i=by(n,e);break}case"MultiPoint":{i=Ay(n);break}case"MultiLineString":{i=Iy(n);break}case"MultiPolygon":{i=Ly(n,e);break}case"GeometryCollection":{i=wy(n,e);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return i}function wy(n,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:n.getGeometriesArray().map(function(i){return tl(i,e)})}}function Py(n,e){return{type:"LineString",coordinates:n.getCoordinates()}}function Iy(n,e){return{type:"MultiLineString",coordinates:n.getCoordinates()}}function Ay(n,e){return{type:"MultiPoint",coordinates:n.getCoordinates()}}function Ly(n,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:n.getCoordinates(t)}}function Fy(n,e){return{type:"Point",coordinates:n.getCoordinates()}}function by(n,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:n.getCoordinates(t)}}const ga="units",My=[1,2,5],ys=25.4/.28;class TT extends Ro{constructor(e){e=e||{};const t=document.createElement("div");t.style.pointerEvents="none",super({element:t,render:e.render,target:e.target}),this.on,this.once,this.un;const i=e.className!==void 0?e.className:e.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=i+"-inner",this.element.className=i+" "+tr,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=e.minWidth!==void 0?e.minWidth:64,this.maxWidth_=e.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(ga,this.handleUnitsChanged_),this.setUnits(e.units||"metric"),this.scaleBar_=e.bar||!1,this.scaleBarSteps_=e.steps||4,this.scaleBarText_=e.text||!1,this.dpi_=e.dpi||void 0}getUnits(){return this.get(ga)}handleUnitsChanged_(){this.updateElement_()}setUnits(e){this.set(ga,e)}setDpi(e){this.dpi_=e}updateElement_(){const e=this.viewState_;if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=e.center,i=e.projection,s=this.getUnits(),r=s=="degrees"?"degrees":"m";let o=jr(i,e.resolution,t,r);const a=this.minWidth_*(this.dpi_||ys)/ys,l=this.maxWidth_!==void 0?this.maxWidth_*(this.dpi_||ys)/ys:void 0;let h=a*o,c="";if(s=="degrees"){const T=Wn.degrees;h*=T,h<T/60?(c="″",o*=3600):h<T?(c="′",o*=60):c="°"}else if(s=="imperial")h<.9144?(c="in",o/=.0254):h<1609.344?(c="ft",o/=.3048):(c="mi",o/=1609.344);else if(s=="nautical")o/=1852,c="NM";else if(s=="metric")h<1e-6?(c="nm",o*=1e9):h<.001?(c="μm",o*=1e6):h<1?(c="mm",o*=1e3):h<1e3?c="m":(c="km",o/=1e3);else if(s=="us")h<.9144?(c="in",o*=39.37):h<1609.344?(c="ft",o/=.30480061):(c="mi",o/=1609.3472);else throw new Error("Invalid units");let u=3*Math.floor(Math.log(a*o)/Math.log(10)),d,f,g,_=0,m,y;for(;;){g=Math.floor(u/3);const T=Math.pow(10,g);if(d=My[(u%3+3)%3]*T,f=Math.round(d/o),isNaN(f)){this.element.style.display="none",this.renderedVisible_=!1;return}if(l!==void 0&&f>=l){d=_,f=m,g=y;break}else if(f>=a)break;_=d,m=f,y=g,++u}const p=this.scaleBar_?this.createScaleBar(f,d,c):d.toFixed(g<0?-g:0)+" "+c;this.renderedHTML_!=p&&(this.innerElement_.innerHTML=p,this.renderedHTML_=p),this.renderedWidth_!=f&&(this.innerElement_.style.width=f+"px",this.renderedWidth_=f),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(e,t,i){const s=this.getScaleForResolution(),r=s<1?Math.round(1/s).toLocaleString()+" : 1":"1 : "+Math.round(s).toLocaleString(),o=this.scaleBarSteps_,a=e/o,l=[this.createMarker("absolute")];for(let c=0;c<o;++c){const u=c%2===0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";l.push(`<div><div class="ol-scale-singlebar ${u}" style="width: ${a}px;"></div>`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,e,!1,t,i):"")+"</div>")}return l.push(this.createStepText(o,e,!0,t,i)),(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${e}px;">`+r+"</div>":"")+l.join("")}createMarker(e){return`<div class="ol-scale-step-marker" style="position: ${e}; top: ${e==="absolute"?3:-10}px;"></div>`}createStepText(e,t,i,s,r){const a=(e===0?0:Math.round(s/this.scaleBarSteps_*e*100)/100)+(e===0?"":" "+r),l=e===0?-3:t/this.scaleBarSteps_*-1,h=e===0?0:t/this.scaleBarSteps_*2;return`<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${e===0?"left":"center"};min-width: ${h}px;left: ${i?t+"px":"unset"};">`+a+"</div>"}getScaleForResolution(){const e=jr(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),t=this.dpi_||ys,i=1e3/25.4;return e*i*t}render(e){const t=e.frameState;t?this.viewState_=t.viewState:this.viewState_=null,this.updateElement_()}}const Dy={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},Mc={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class Oy extends hd{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=Ce(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(e,t,i,s,r,o,a,l){this.updateExecutorGroup_(e,t.pixelRatio,t.viewState.projection),this.tileImageNeedsRender_(e)&&this.renderTileImage_(e,t),super.drawTile(e,t,i,s,r,o,a,l)}getTile(e,t,i,s){const r=this.getOrCreateTile(e,t,i,s);if(!r)return null;const o=s.viewState,a=o.resolution,l=s.viewHints,h=this.getLayer().getSource(),c=h.getTileGridForProjection(o.projection),u=!(l[de.ANIMATING]||l[de.INTERACTING]),d=c.getZForResolution(a,h.zDirection)===e;return u&&d?r.wantedResolution=a:r.wantedResolution||(r.wantedResolution=c.getResolution(e)),r}prepareFrame(e){const t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,i){const s=this.getLayer(),r=s.getRevision(),o=s.getRenderOrder()||null,a=e.wantedResolution,l=e.getReplayState(s);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==r&&l.renderedRenderOrder==o)return;const h=s.getSource(),c=!!s.getDeclutter(),u=h.getTileGrid(),f=h.getTileGridForProjection(i).getTileCoordExtent(e.wrappedTileCoord),g=h.getSourceTiles(t,i,e),_=O(s);delete e.hitDetectionImageData[_],e.executorGroups[_]=[],l.dirty=!1;for(let m=0,y=g.length;m<y;++m){const p=g[m];if(p.getState()!=D.LOADED)continue;const T=h.getProjection(),x=p.tileCoord;let E=u.getTileCoordExtent(x);i&&T&&!kt(i,T)&&(E=Dg(E,T,i,32));const R=We(f,E),C=ai(R,s.getRenderBuffer()*a,this.tempExtent),v=qi(E,R)?null:C,w=new dd(0,R,a,t),P=qa(a,t),A=function(M,G){let N;const j=M.getStyleFunction()||s.getStyleFunction();if(j&&(N=j(M,a)),N){const $=this.renderFeature(M,P,N,w,c,G);l.dirty=l.dirty||$}},I=p.getFeatures();o&&o!==l.renderedRenderOrder&&I.sort(o);for(let M=0,G=I.length;M<G;++M){let N=I[M];i&&p.projection&&!kt(i,p.projection)&&(N=N.clone(),N.getGeometry().applyTransform(Ji(p.projection,i))),(!v||Pe(v,N.getGeometry().getExtent()))&&A.call(this,N,M)}const F=w.finish(),b=s.getRenderMode()!=="vector"&&c&&g.length===1?null:R,k=new fd(b,a,t,h.getOverlaps(),F,s.getRenderBuffer(),!0);e.executorGroups[_].push(k)}l.renderedRevision=r,l.renderedRenderOrder=o,l.renderedResolution=a}forEachFeatureAtCoordinate(e,t,i,s,r){const o=t.viewState.resolution,a=t.viewState.rotation;i=i??0;const l=this.getLayer(),c=l.getSource().getTileGridForProjection(t.viewState.projection),u=Be([e]);ai(u,o*i,u);const d={},f=function(T,x,E){let R=T.getId();R===void 0&&(R=O(T));const C=d[R];if(C){if(C!==!0&&E<C.distanceSq){if(E===0)return d[R]=!0,r.splice(r.lastIndexOf(C),1),s(T,l,x);C.geometry=x,C.distanceSq=E}}else{if(E===0)return d[R]=!0,s(T,l,x);r.push(d[R]={feature:T,layer:l,geometry:x,distanceSq:E,callback:s})}},g=this.renderedTiles,_=O(l),m=l.getDeclutter(),y=m?t.declutter?.[m]?.all().map(T=>T.value):null;let p;e:for(let T=0,x=g.length;T<x;++T){const E=g[T],R=c.getTileCoordExtent(E.wrappedTileCoord);if(!Pe(R,u))continue;const C=E.executorGroups[_];for(let v=0,w=C.length;v<w;++v)if(p=C[v].forEachFeatureAtCoordinate(e,o,a,i,f,y),p)break e}return p}getFeatures(e){return this.renderedTiles.length===0?Promise.resolve([]):new Promise((t,i)=>{const s=this.getLayer(),r=s.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=r.getTileGridForProjection(o),c=me(this.renderedPixelToCoordinateTransform_,e.slice()),u=h.getTileCoordForCoordAndResolution(c,l).toString(),d=this.renderedTiles.find(T=>T.tileCoord.toString()===u&&T.getState()===D.LOADED);if(!d||d.loadingSourceTiles>0){t([]);return}r.getWrapX()&&o.canWrapX()&&!Ti(a,h.getTileCoordExtent(d.tileCoord))&&Cl(c,o);const f=O(s),g=h.getTileCoordExtent(d.wrappedTileCoord),_=Xt(g),m=[(c[0]-_[0])/l,(_[1]-c[1])/l],y=d.getSourceTiles().reduce((T,x)=>T.concat(x.getFeatures()),[]);let p=d.hitDetectionImageData[f];if(!p){const T=Se(h.getTileSize(h.getZForResolution(l,r.zDirection))),x=this.renderedRotation_,E=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,ht,T[0]*ht,T[1]*ht,0)];p=gd(T,E,y,s.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(s).renderedResolution,x),d.hitDetectionImageData[f]=p}t(_d(m,y,p))})}getFeaturesInExtent(e){const t=[],i=this.getTileCache();if(i.getCount()===0)return t;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),o=r.getZForResolution(this.renderedResolution),a={};return i.forEach(l=>{if(l.tileCoord[0]!==o||l.getState()!==D.LOADED)return;const h=l.getSourceTiles();for(let c=0,u=h.length;c<u;++c){const d=h[c],f=d.getKey();if(f in a)continue;a[f]=!0;const g=d.tileCoord;if(Pe(e,r.getTileCoordExtent(g))){const _=d.getFeatures();if(_)for(let m=0,y=_.length;m<y;++m){const p=_[m],T=p.getGeometry();Pe(e,T.getExtent())&&t.push(p)}}}}),t}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.renderedLayerRevision_!==void 0&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}renderDeclutter(e,t){const i=this.context,s=i.globalAlpha;i.globalAlpha=t.opacity;const r=e.viewHints,o=!(r[de.ANIMATING]||r[de.INTERACTING]),a=[this.context.canvas.width,this.context.canvas.height],l=this.getLayer().getDeclutter(),h=l?e.declutter?.[l]:void 0,c=O(this.getLayer()),u=this.renderedTiles;for(let d=0,f=u.length;d<f;++d){const g=u[d],_=g.executorGroups[c];if(_)for(let m=_.length-1;m>=0;--m)_[m].execute(this.context,a,this.getTileRenderTransform(g,e),e.viewState.rotation,o,eo,h)}i.globalAlpha=s}renderDeferredInternal(e){const t=this.renderedTiles,i=O(this.getLayer()),s=t.reduce((l,h,c)=>(h.executorGroups[i].forEach(u=>l.push({executorGroup:u,index:c})),l),[]),r=s.map(({executorGroup:l})=>l.getDeferredZIndexContexts()),o={};for(let l=0,h=s.length;l<h;++l){const c=s[l].executorGroup.getDeferredZIndexContexts();for(const u in c)o[u]=!0}Object.keys(o).map(Number).sort(Gt).forEach(l=>{r.forEach((h,c)=>{h[l]&&(h[l].forEach(u=>{const{executorGroup:d,index:f}=s[c],g=d.getRenderedContext(),_=g.globalAlpha;g.globalAlpha=this.renderedOpacity_;const m=this.tileClipContexts_[f];m&&m.draw(g),u.draw(g),m&&g.restore(),g.globalAlpha=_,u.clear()}),h[l].length=0)})})}getTileRenderTransform(e,t){const i=t.pixelRatio,s=t.viewState,r=s.center,o=s.resolution,a=s.rotation,l=t.size,h=Math.round(l[0]*i),c=Math.round(l[1]*i),d=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),f=e.tileCoord,g=d.getTileCoordExtent(e.wrappedTileCoord),_=d.getTileCoordExtent(f,this.tempExtent)[0]-g[0];return Qs(vs(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(r,o,a,i,h,c,_))}postRender(e,t){const i=t.viewHints,s=!(i[de.ANIMATING]||i[de.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation,this.renderedOpacity_=t.layerStatesArray[t.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),a=e.globalAlpha;e.globalAlpha=this.renderedOpacity_;const l=r.getDeclutter(),h=l?Mc[o].filter(E=>!eo.includes(E)):Mc[o],c=t.viewState,u=c.rotation,d=r.getSource(),g=d.getTileGridForProjection(c.projection).getZForResolution(c.resolution,d.zDirection),_=this.renderedTiles,m=[],y=[],p=[],T=O(r);let x=!0;for(let E=_.length-1;E>=0;--E){const R=_[E];x=x&&!R.getReplayState(r).dirty;const C=R.executorGroups[T].filter(b=>b.hasExecutors(h));if(C.length===0)continue;const v=this.getTileRenderTransform(R,t),w=R.tileCoord[0];let P=!1;const A=C[0].getClipCoords(v);let I=e,F;if(A){F=new lh,I=F.getContext();for(let b=0,k=m.length;b<k;++b)if(g!==w&&w<y[b]){const M=m[b];Pe([A[0],A[3],A[4],A[7]],[M[0],M[3],M[4],M[7]])&&(P||(I.save(),P=!0),I.beginPath(),I.moveTo(A[0],A[1]),I.lineTo(A[2],A[3]),I.lineTo(A[4],A[5]),I.lineTo(A[6],A[7]),I.moveTo(M[6],M[7]),I.lineTo(M[4],M[5]),I.lineTo(M[2],M[3]),I.lineTo(M[0],M[1]),I.clip())}m.push(A),y.push(w)}for(let b=0,k=C.length;b<k;++b)C[b].execute(e,[e.canvas.width,e.canvas.height],v,u,s,h,t.declutter?.[l]);P&&(I===e?I.restore():p[E]=F)}e.globalAlpha=a,this.ready=x,this.tileClipContexts_=p,t.declutter||this.renderDeferredInternal(t),super.postRender(e,t)}renderFeature(e,t,i,s,r,o){if(!i)return!1;let a=!1;if(Array.isArray(i))for(let l=0,h=i.length;l<h;++l)a=to(s,e,i[l],t,this.boundHandleStyleImageChange_,void 0,r,o)||a;else a=to(s,e,i,t,this.boundHandleStyleImageChange_,void 0,r,o);return a}tileImageNeedsRender_(e){const t=this.getLayer();if(t.getRenderMode()==="vector")return!1;const i=e.getReplayState(t),s=t.getRevision(),r=e.wantedResolution;return i.renderedTileResolution!==r||i.renderedTileRevision!==s}renderTileImage_(e,t){const i=this.getLayer(),s=e.getReplayState(i),r=i.getRevision(),o=e.executorGroups[O(i)];s.renderedTileRevision=r;const a=e.wrappedTileCoord,l=a[0],h=i.getSource();let c=t.pixelRatio;const d=t.viewState.projection,f=h.getTileGridForProjection(d),g=f.getResolution(e.tileCoord[0]),_=t.pixelRatio/e.wantedResolution*g,m=f.getResolution(l),y=e.getContext();c=Math.round(Math.max(c,_/c));const p=h.getTilePixelSize(l,c,d);y.canvas.width=p[0],y.canvas.height=p[1];const T=c/_;if(T!==1){const C=Ga(this.tmpTransform_);vs(C,T,T),y.setTransform.apply(y,C)}const x=f.getTileCoordExtent(a,this.tempExtent),E=_/m,R=Ga(this.tmpTransform_);vs(R,E,-E),Fl(R,-x[0],-x[3]);for(let C=0,v=o.length;C<v;++C)o[C].execute(y,[y.canvas.width*T,y.canvas.height*T],R,0,!0,Dy[i.getRenderMode()],null);s.renderedTileResolution=e.wantedResolution}}class RT extends os{constructor(e){e=e||{};const t=Object.assign({},e);delete t.preload;const i=e.cacheSize===void 0?0:e.cacheSize;delete e.cacheSize,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i;const s=e.renderMode||"hybrid";se(s=="hybrid"||s=="vector","`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=s,this.setPreload(e.preload?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0),this.getBackground,this.setBackground}createRenderer(){return new Oy(this,{cacheSize:this.cacheSize_})}getFeatures(e){return super.getFeatures(e)}getFeaturesInExtent(e){return this.getRenderer().getFeaturesInExtent(e)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Si.PRELOAD)}getUseInterimTilesOnError(){return this.get(Si.USE_INTERIM_TILES_ON_ERROR)}setPreload(e){this.set(Si.PRELOAD,e)}setUseInterimTilesOnError(e){this.set(Si.USE_INTERIM_TILES_ON_ERROR,e)}}function ln(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function no(n,e){return n[0]=e[0],n[1]=e[1],n[4]=e[2],n[5]=e[3],n[12]=e[4],n[13]=e[5],n}function il(n,e,t,i,s,r,o){o=o??ln();const a=1/(n-e),l=1/(t-i),h=1/(s-r);return o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*l,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*h,o[11]=0,o[12]=(n+e)*a,o[13]=(i+t)*l,o[14]=(r+s)*h,o[15]=1,o}function Dc(n,e,t,i,s){return s=s??ln(),s[0]=n[0]*e,s[1]=n[1]*e,s[2]=n[2]*e,s[3]=n[3]*e,s[4]=n[4]*t,s[5]=n[5]*t,s[6]=n[6]*t,s[7]=n[7]*t,s[8]=n[8]*i,s[9]=n[9]*i,s[10]=n[10]*i,s[11]=n[11]*i,s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],s}function Ny(n,e,t,i,s){s=s??ln();let r,o,a,l,h,c,u,d,f,g,_,m;return n===s?(s[12]=n[0]*e+n[4]*t+n[8]*i+n[12],s[13]=n[1]*e+n[5]*t+n[9]*i+n[13],s[14]=n[2]*e+n[6]*t+n[10]*i+n[14],s[15]=n[3]*e+n[7]*t+n[11]*i+n[15]):(r=n[0],o=n[1],a=n[2],l=n[3],h=n[4],c=n[5],u=n[6],d=n[7],f=n[8],g=n[9],_=n[10],m=n[11],s[0]=r,s[1]=o,s[2]=a,s[3]=l,s[4]=h,s[5]=c,s[6]=u,s[7]=d,s[8]=f,s[9]=g,s[10]=_,s[11]=m,s[12]=r*e+h*t+f*i+n[12],s[13]=o*e+c*t+g*i+n[13],s[14]=a*e+u*t+_*i+n[14],s[15]=l*e+d*t+m*i+n[15]),s}function Gy(n,e,t,i){return i=i??ln(),i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=n,i[13]=e,i[14]=t,i[15]=1,i}const Vs=34962,Fo=34963,ph=35044,_a=35048,ky=5121,Uy=5123,By=5125,bd=5126,Oc=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function zy(n,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!Df},e);const t=Oc.length;for(let i=0;i<t;++i)try{const s=n.getContext(Oc[i],e);if(s)return s}catch{}return null}const Xy={STATIC_DRAW:ph};class As{constructor(e,t){this.array_=null,this.type_=e,se(e===Vs||e===Fo,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=t!==void 0?t:Xy.STATIC_DRAW}ofSize(e){return this.array_=new(Cr(this.type_))(e),this}fromArray(e){return this.array_=Cr(this.type_).from(e),this}fromArrayBuffer(e){return this.array_=new(Cr(this.type_))(e),this}getType(){return this.type_}getArray(){return this.array_}setArray(e){const t=Cr(this.type_);if(!(e instanceof t))throw new Error(`Expected ${t}`);this.array_=e}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}}function Cr(n){switch(n){case Vs:return Float32Array;case Fo:return Uint32Array;default:return Float32Array}}const Sr={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},jy=`
|
||
precision mediump float;
|
||
|
||
attribute vec2 a_position;
|
||
varying vec2 v_texCoord;
|
||
varying vec2 v_screenCoord;
|
||
|
||
uniform vec2 u_screenSize;
|
||
|
||
void main() {
|
||
v_texCoord = a_position * 0.5 + 0.5;
|
||
v_screenCoord = v_texCoord * u_screenSize;
|
||
gl_Position = vec4(a_position, 0.0, 1.0);
|
||
}
|
||
`,$y=`
|
||
precision mediump float;
|
||
|
||
uniform sampler2D u_image;
|
||
uniform float u_opacity;
|
||
|
||
varying vec2 v_texCoord;
|
||
|
||
void main() {
|
||
gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
|
||
}
|
||
`;class Nc{constructor(e){this.gl_=e.webGlContext;const t=this.gl_;this.scaleRatio_=e.scaleRatio||1,this.renderTargetTexture_=t.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=t.createFramebuffer(),this.depthBuffer_=t.createRenderbuffer();const i=t.createShader(t.VERTEX_SHADER);t.shaderSource(i,e.vertexShader||jy),t.compileShader(i);const s=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(s,e.fragmentShader||$y),t.compileShader(s),this.renderTargetProgram_=t.createProgram(),t.attachShader(this.renderTargetProgram_,i),t.attachShader(this.renderTargetProgram_,s),t.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=t.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];t.bindBuffer(t.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),t.bufferData(t.ARRAY_BUFFER,new Float32Array(r),t.STATIC_DRAW),this.renderTargetAttribLocation_=t.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],e.uniforms&&Object.keys(e.uniforms).forEach(o=>{this.uniforms_.push({value:e.uniforms[o],location:t.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(e){const t=this.getGL(),i=[t.drawingBufferWidth*this.scaleRatio_,t.drawingBufferHeight*this.scaleRatio_];if(t.bindFramebuffer(t.FRAMEBUFFER,this.getFrameBuffer()),t.bindRenderbuffer(t.RENDERBUFFER,this.getDepthBuffer()),t.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const s=0,r=t.RGBA,o=0,a=t.RGBA,l=t.UNSIGNED_BYTE,h=null;t.bindTexture(t.TEXTURE_2D,this.renderTargetTexture_),t.texImage2D(t.TEXTURE_2D,s,r,i[0],i[1],o,a,l,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.renderTargetTexture_,0),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,i[0],i[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthBuffer_)}}apply(e,t,i,s){const r=this.getGL(),o=e.size;if(r.bindFramebuffer(r.FRAMEBUFFER,t?t.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!t){const l=O(r.canvas);if(!e.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),e.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=e.layerStatesArray[e.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(e),i&&i(r,e),r.drawArrays(r.TRIANGLES,0,6),s&&s(r,e)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(e){const t=this.getGL();let i,s=1;this.uniforms_.forEach(function(r){if(i=typeof r.value=="function"?r.value(e):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=t.createTexture()),t.activeTexture(t[`TEXTURE${s}`]),t.bindTexture(t.TEXTURE_2D,r.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i instanceof ImageData?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,i.width,i.height,0,t.UNSIGNED_BYTE,new Uint8Array(i.data)):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i),t.uniform1i(r.location,s++);else if(Array.isArray(i))switch(i.length){case 2:t.uniform2f(r.location,i[0],i[1]);return;case 3:t.uniform3f(r.location,i[0],i[1],i[2]);return;case 4:t.uniform4f(r.location,i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&t.uniform1f(r.location,i)})}}const qt={PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",ROTATION:"u_rotation",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},Oe={UNSIGNED_BYTE:ky,UNSIGNED_SHORT:Uy,UNSIGNED_INT:By,FLOAT:bd},so={};function Gc(n){return"shared/"+n}let kc=0;function Wy(){const n="unique/"+kc;return kc+=1,n}function Yy(n){let e=so[n];if(!e){const t=document.createElement("canvas");t.width=1,t.height=1,t.style.position="absolute",t.style.left="0",e={users:0,context:zy(t)},so[n]=e}return e.users+=1,e.context}function Vy(n){const e=so[n];if(!e||(e.users-=1,e.users>0))return;const t=e.context,i=t.getExtension("WEBGL_lose_context");i&&i.loseContext();const s=t.canvas;s.width=1,s.height=1,delete so[n]}class Zy extends Ks{constructor(e){super(),e=e||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=e.canvasCacheKey?Gc(e.canvasCacheKey):Wy(),this.gl_=Yy(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const t=this.gl_.canvas;t.addEventListener(Sr.LOST,this.boundHandleWebGLContextLost_),t.addEventListener(Sr.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Ce(),this.offsetScaleMatrix_=Ce(),this.tmpMat4_=ln(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],e.uniforms&&this.setUniforms(e.uniforms),this.postProcessPasses_=e.postProcesses?e.postProcesses.map(i=>new Nc({webGlContext:this.gl_,scaleRatio:i.scaleRatio,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,uniforms:i.uniforms})):[new Nc({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(e){this.uniforms_=[],this.addUniforms(e)}addUniforms(e){for(const t in e)this.uniforms_.push({name:t,value:e[t]})}canvasCacheKeyMatches(e){return this.canvasCacheKey_===Gc(e)}getExtension(e){if(e in this.extensionCache_)return this.extensionCache_[e];const t=this.gl_.getExtension(e);return this.extensionCache_[e]=t,t}getInstancedRenderingExtension_(){const e=this.getExtension("ANGLE_instanced_arrays");return se(!!e,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),e}bindBuffer(e){const t=this.gl_,i=O(e);let s=this.bufferCache_[i];if(!s){const r=t.createBuffer();s={buffer:e,webGlBuffer:r},this.bufferCache_[i]=s}t.bindBuffer(e.getType(),s.webGlBuffer)}flushBufferData(e){const t=this.gl_;this.bindBuffer(e),t.bufferData(e.getType(),e.getArray(),e.getUsage())}deleteBuffer(e){const t=O(e);delete this.bufferCache_[t]}disposeInternal(){const e=this.gl_.canvas;e.removeEventListener(Sr.LOST,this.boundHandleWebGLContextLost_),e.removeEventListener(Sr.RESTORED,this.boundHandleWebGLContextRestored_),Vy(this.canvasCacheKey_),delete this.gl_}prepareDraw(e,t,i){const s=this.gl_,r=this.getCanvas(),o=e.size,a=e.pixelRatio;(r.width!==o[0]*a||r.height!==o[1]*a)&&(r.width=o[0]*a,r.height=o[1]*a,r.style.width=o[0]+"px",r.style.height=o[1]+"px");for(let l=this.postProcessPasses_.length-1;l>=0;l--)this.postProcessPasses_[l].init(e);s.bindTexture(s.TEXTURE_2D,null),s.clearColor(0,0,0,0),s.depthRange(0,1),s.clearDepth(1),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),s.enable(s.BLEND),s.blendFunc(s.ONE,t?s.ZERO:s.ONE_MINUS_SRC_ALPHA),i?(s.enable(s.DEPTH_TEST),s.depthFunc(s.LEQUAL)):s.disable(s.DEPTH_TEST)}bindFrameBuffer(e,t){const i=this.getGL();i.bindFramebuffer(i.FRAMEBUFFER,e),t&&i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0)}bindInitialFrameBuffer(){const e=this.getGL(),t=this.postProcessPasses_[0].getFrameBuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);const i=this.postProcessPasses_[0].getRenderTargetTexture();e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0)}bindTexture(e,t,i){const s=this.gl_;s.activeTexture(s.TEXTURE0+t),s.bindTexture(s.TEXTURE_2D,e),s.uniform1i(this.getUniformLocation(i),t)}bindAttribute(e,t,i){const s=this.getGL();this.bindBuffer(e);const r=this.getAttributeLocation(t);s.enableVertexAttribArray(r),s.vertexAttribPointer(r,i,s.FLOAT,!1,0,0)}prepareDrawToRenderTarget(e,t,i,s){const r=this.gl_,o=t.getSize();r.bindFramebuffer(r.FRAMEBUFFER,t.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,t.getDepthbuffer()),r.viewport(0,0,o[0],o[1]),r.bindTexture(r.TEXTURE_2D,t.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,i?r.ZERO:r.ONE_MINUS_SRC_ALPHA),s?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(e,t){const i=this.gl_;this.getExtension("OES_element_index_uint");const s=i.UNSIGNED_INT,r=4,o=t-e,a=e*r;i.drawElements(i.TRIANGLES,o,s,a)}drawElementsInstanced(e,t,i){const s=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),o=s.UNSIGNED_INT,a=4,l=t-e,h=e*a;r.drawElementsInstancedANGLE(s.TRIANGLES,l,o,h,i);for(let c=0;c<this.maxAttributeCount_;c++)r.vertexAttribDivisorANGLE(c,0)}finalizeDraw(e,t,i){for(let s=0,r=this.postProcessPasses_.length;s<r;s++)s===r-1?this.postProcessPasses_[s].apply(e,null,t,i):this.postProcessPasses_[s].apply(e,this.postProcessPasses_[s+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(e){const t=e.size,i=e.viewState.rotation,s=e.pixelRatio;this.setUniformFloatValue(qt.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(qt.ZOOM,e.viewState.zoom),this.setUniformFloatValue(qt.RESOLUTION,e.viewState.resolution),this.setUniformFloatValue(qt.PIXEL_RATIO,s),this.setUniformFloatVec2(qt.VIEWPORT_SIZE_PX,[t[0],t[1]]),this.setUniformFloatValue(qt.ROTATION,i)}applyHitDetectionUniform(e){const t=this.getUniformLocation(qt.HIT_DETECTION);this.getGL().uniform1i(t,e?1:0),e&&this.setUniformFloatValue(qt.PIXEL_RATIO,.5)}applyUniforms(e){const t=this.gl_;let i,s=0;this.uniforms_.forEach(r=>{if(i=typeof r.value=="function"?r.value(e):r.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData||i instanceof WebGLTexture){i instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=i):r.texture||(r.prevValue=void 0,r.texture=t.createTexture()),this.bindTexture(r.texture,s,r.name),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);const o=!(i instanceof HTMLImageElement)||i.complete;!(i instanceof WebGLTexture)&&o&&r.prevValue!==i&&(r.prevValue=i,t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i)),s++}else if(Array.isArray(i)&&i.length===6)this.setUniformMatrixValue(r.name,no(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:t.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);return;case 3:t.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);return;case 4:t.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&t.uniform1f(this.getUniformLocation(r.name),i)})}useProgram(e,t){this.disableAllAttributes_(),this.gl_.useProgram(e),this.currentProgram_=e,t&&(this.applyFrameState(t),this.applyUniforms(t))}compileShader(e,t){const i=this.gl_,s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}getProgram(e,t){const i=this.gl_,s=this.compileShader(e,i.FRAGMENT_SHADER),r=this.compileShader(t,i.VERTEX_SHADER),o=i.createProgram();if(i.attachShader(o,s),i.attachShader(o,r),i.linkProgram(o),!i.getShaderParameter(s,i.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${i.getShaderInfoLog(s)}`;throw new Error(a)}if(i.deleteShader(s),!i.getShaderParameter(r,i.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(a)}if(i.deleteShader(r),!i.getProgramParameter(o,i.LINK_STATUS)){const a=`GL program linking failed: ${i.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(e){const t=O(this.currentProgram_);return this.uniformLocationsByProgram_[t]===void 0&&(this.uniformLocationsByProgram_[t]={}),this.uniformLocationsByProgram_[t][e]===void 0&&(this.uniformLocationsByProgram_[t][e]=this.gl_.getUniformLocation(this.currentProgram_,e)),this.uniformLocationsByProgram_[t][e]}getAttributeLocation(e){const t=O(this.currentProgram_);return this.attribLocationsByProgram_[t]===void 0&&(this.attribLocationsByProgram_[t]={}),this.attribLocationsByProgram_[t][e]===void 0&&(this.attribLocationsByProgram_[t][e]=this.gl_.getAttribLocation(this.currentProgram_,e)),this.attribLocationsByProgram_[t][e]}makeProjectionTransform(e,t){const i=e.size,s=e.viewState.rotation,r=e.viewState.resolution,o=e.viewState.center;return ft(t,0,0,2/(r*i[0]),2/(r*i[1]),-s,-o[0],-o[1]),t}setUniformFloatValue(e,t){this.gl_.uniform1f(this.getUniformLocation(e),t)}setUniformFloatVec2(e,t){this.gl_.uniform2fv(this.getUniformLocation(e),t)}setUniformFloatVec4(e,t){this.gl_.uniform4fv(this.getUniformLocation(e),t)}setUniformMatrixValue(e,t){this.gl_.uniformMatrix4fv(this.getUniformLocation(e),!1,t)}disableAllAttributes_(){for(let e=0;e<this.maxAttributeCount_;e++)this.gl_.disableVertexAttribArray(e)}enableAttributeArray_(e,t,i,s,r,o){const a=this.getAttributeLocation(e);a<0||(this.gl_.enableVertexAttribArray(a),this.gl_.vertexAttribPointer(a,t,i,!1,s,r),o&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(a,1))}enableAttributes_(e,t){const i=Ky(e);let s=0;for(let r=0;r<e.length;r++){const o=e[r];o.name&&this.enableAttributeArray_(o.name,o.size,o.type||bd,i,s,t),s+=o.size*Md(o.type)}}enableAttributes(e){this.enableAttributes_(e,!1)}enableAttributesInstanced(e){this.enableAttributes_(e,!0)}handleWebGLContextLost(e){tn(this.bufferCache_),this.currentProgram_=null,e.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(e,t,i,s){const r=this.gl_;i=i||r.createTexture();const o=s?r.NEAREST:r.LINEAR;r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const a=0,l=r.RGBA,h=0,c=r.RGBA,u=r.UNSIGNED_BYTE;return t instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,e[0],e[1],h,c,u,t):t?r.texImage2D(r.TEXTURE_2D,a,l,c,u,t):r.texImage2D(r.TEXTURE_2D,a,l,e[0],e[1],h,c,u,null),i}}function Ky(n){let e=0;for(let t=0;t<n.length;t++){const i=n[t];e+=i.size*Md(i.type)}return e}function Md(n){switch(n){case Oe.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Oe.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Oe.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Oe.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class Hy extends Qn{constructor(e){super(),this.tile,this.handleTileChange_=this.handleTileChange_.bind(this),this.gutter=e.gutter||0,this.helper=e.helper,this.loaded=!1,this.ready=!1}setTile(e){if(e!==this.tile)if(this.tile&&this.tile.removeEventListener(Z.CHANGE,this.handleTileChange_),this.tile=e,this.loaded=e.getState()===D.LOADED,this.loaded)this.uploadTile();else{if(e instanceof Po){const t=e.getImage();t instanceof Image&&!t.crossOrigin&&(t.crossOrigin="anonymous")}e.addEventListener(Z.CHANGE,this.handleTileChange_)}}uploadTile(){W()}setReady(){this.ready=!0,this.dispatchEvent(Z.CHANGE)}handleTileChange_(){this.tile.getState()===D.LOADED&&(this.loaded=!0,this.uploadTile())}setHelper(e){this.helper=e,this.helper&&this.loaded&&this.uploadTile()}disposeInternal(){this.setHelper(null),this.tile.removeEventListener(Z.CHANGE,this.handleTileChange_)}}function Dd(n,e,t){const i=t?n.LINEAR:n.NEAREST;n.bindTexture(n.TEXTURE_2D,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,i)}function qy(n,e,t,i){Dd(n,e,i),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)}function Uc(n,e,t,i,s,r){const o=n.getGL();let a,l;t instanceof Float32Array?(a=o.FLOAT,n.getExtension("OES_texture_float"),l=n.getExtension("OES_texture_float_linear")!==null):(a=o.UNSIGNED_BYTE,l=!0),Dd(o,e,r&&l);const h=t.byteLength/i[1];let c=1;h%8===0?c=8:h%4===0?c=4:h%2===0&&(c=2);let u;switch(s){case 1:{u=o.LUMINANCE;break}case 2:{u=o.LUMINANCE_ALPHA;break}case 3:{u=o.RGB;break}case 4:{u=o.RGBA;break}default:throw new Error(`Unsupported number of bands: ${s}`)}const d=o.getParameter(o.UNPACK_ALIGNMENT);o.pixelStorei(o.UNPACK_ALIGNMENT,c),o.texImage2D(o.TEXTURE_2D,0,u,i[0],i[1],0,u,a,t),o.pixelStorei(o.UNPACK_ALIGNMENT,d)}let Ln=null;function Jy(){Ln=Te(1,1,void 0,{willReadFrequently:!0})}class Qy extends Hy{constructor(e){super(e),this.textures=[],this.renderSize_=Se(e.grid.getTileSize(e.tile.tileCoord[0])),this.bandCount=NaN;const t=new As(Vs,ph);t.fromArray([0,1,1,1,1,0,0,0]),this.helper.flushBufferData(t),this.coords=t,this.setTile(e.tile)}setHelper(e){const t=this.helper?.getGL();if(t){this.helper.deleteBuffer(this.coords);for(let i=0;i<this.textures.length;++i)t.deleteTexture(this.textures[i])}super.setHelper(e),e&&e.flushBufferData(this.coords)}uploadTile(){const e=this.helper,t=e.getGL(),i=this.tile;this.textures.length=0;let s;i instanceof Po||i instanceof ah?s=i.getImage():s=i.getData();const r=Kn(s);if(r){const p=t.createTexture();this.textures.push(p),this.bandCount=4,qy(t,p,r,i.interpolate),this.setReady();return}s=Za(s);const o=i.getSize(),a=[o[0]+2*this.gutter,o[1]+2*this.gutter],l=s instanceof Float32Array,h=a[0]*a[1],c=l?Float32Array:Uint8Array,u=c.BYTES_PER_ELEMENT,d=s.byteLength/a[1];this.bandCount=Math.floor(d/u/a[0]);const f=Math.ceil(this.bandCount/4);if(f===1){const p=t.createTexture();this.textures.push(p),Uc(e,p,s,a,this.bandCount,i.interpolate),this.setReady();return}const g=new Array(f);for(let p=0;p<f;++p){const T=t.createTexture();this.textures.push(T);const x=p<f-1?4:(this.bandCount-1)%4+1;g[p]=new c(h*x)}let _=0,m=0;const y=a[0]*this.bandCount;for(let p=0;p<a[1];++p){for(let T=0;T<y;++T){const x=s[m+T],E=Math.floor(_/this.bandCount),R=T%this.bandCount,C=Math.floor(R/4),v=g[C],w=v.length/h,P=R%4;v[E*w+P]=x,++_}m+=d/u}for(let p=0;p<f;++p){const T=this.textures[p],x=g[p],E=x.length/h;Uc(e,T,x,a,E,i.interpolate)}this.setReady()}getImagePixelData_(e,t,i){const s=this.gutter,r=this.renderSize_[0],o=this.renderSize_[1];Ln||Jy(),Ln.clearRect(0,0,1,1);const a=e.width,l=e.height,h=a-2*s,c=l-2*s,u=s+Math.floor(h*(t/r)),d=s+Math.floor(c*(i/o));let f;try{Ln.drawImage(e,u,d,1,1,0,0,1,1),f=Ln.getImageData(0,0,1,1).data}catch{return Ln=null,null}return f}getArrayPixelData_(e,t,i,s){const r=this.gutter,o=this.renderSize_[0],a=this.renderSize_[1],l=t[0],h=t[1],c=l+2*r,u=h+2*r,d=r+Math.floor(l*(i/o)),f=r+Math.floor(h*(s/a));if(e instanceof DataView){const _=e.byteLength/(c*u),m=_*(f*c+d),y=e.buffer.slice(m,m+_);return new DataView(y)}const g=this.bandCount*(f*c+d);return e.slice(g,g+this.bandCount)}getPixelData(e,t){if(!this.loaded)return null;if(this.tile instanceof Ys){const i=this.tile.getData(),s=Za(i);if(s){const r=this.tile.getSize();return this.getArrayPixelData_(s,r,e,t)}return this.getImagePixelData_(Kn(i),e,t)}return this.getImagePixelData_(this.tile.getImage(),e,t)}}class bo extends ld{constructor(e,t){super(e),t=t||{},this.inversePixelTransform_=Ce(),this.postProcesses_=t.postProcesses,this.uniforms_=t.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},e.addChangeListener(ce.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(e,t){const i=this.getLayer();if(i.hasListener(ke.PRECOMPOSE)){const s=new Ps(ke.PRECOMPOSE,void 0,t,e);i.dispatchEvent(s)}}dispatchPostComposeEvent(e,t){const i=this.getLayer();if(i.hasListener(ke.POSTCOMPOSE)){const s=new Ps(ke.POSTCOMPOSE,void 0,t,e);i.dispatchEvent(s)}}reset(e){this.uniforms_=e.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(e){if(this.getLayer().getRenderSource()){let t=!0,i=-1,s;for(let o=0,a=e.layerStatesArray.length;o<a;o++){const l=e.layerStatesArray[o].layer,h=l.getRenderer();if(!(h instanceof bo)){t=!0;continue}const c=l.getClassName();if((t||c!==s)&&(i+=1,t=!1),s=c,h===this)break}const r="map/"+e.mapId+"/group/"+i;(!this.helper||!this.helper.canvasCacheKeyMatches(r)||this.helper.needsToBeRecreated())&&(this.removeHelper(),this.helper=new Zy({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),s&&(this.helper.getCanvas().className=s),this.afterHelperCreated())}return this.prepareFrameInternal(e)}afterHelperCreated(){}prepareFrameInternal(e){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(ce.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(e,t,i){const s=this.getLayer();if(s.hasListener(e)){ft(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);const r=new Ps(e,this.inversePixelTransform_,i,t);s.dispatchEvent(r)}}preRender(e,t){this.dispatchRenderEvent_(ke.PRERENDER,e,t)}postRender(e,t){this.dispatchRenderEvent_(ke.POSTRENDER,e,t)}}const ex={TILE_TRANSFORM:"u_tileTransform",TRANSITION_ALPHA:"u_transitionAlpha",DEPTH:"u_depth",RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",RESOLUTION:"u_resolution",ZOOM:"u_zoom",GLOBAL_ALPHA:"u_globalAlpha",PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix"};function Bc(n){return 1/(n+2)}function tx(){return{tileIds:new Set,representationsByZ:{}}}function zc(n,e){return n.tileIds.has(O(e))}function Xc(n,e,t){const i=n.representationsByZ;t in i||(i[t]=new Set),i[t].add(e),n.tileIds.add(O(e.tile))}function ma(n,e){const t=n.layerStatesArray[n.layerIndex];t.extent&&(e=We(e,ct(t.extent,n.viewState.projection)));const i=t.layer.getRenderSource();if(!i.getWrapX()){const s=i.getTileGridForProjection(n.viewState.projection).getExtent();s&&(e=We(e,s))}return e}function nl(n,e){return`${O(n)},${n.getKey()},${n.getRevision()},${In(e)}`}class ix extends bo{constructor(e,t){super(e,{uniforms:t.uniforms,postProcesses:t.postProcesses}),this.renderComplete=!1,this.tileTransform_=Ce(),this.tempMat4=ln(),this.tempTileRange_=new Io(0,0,0,0),this.tempTileCoord_=Hn(0,0,0),this.tempSize_=[0,0];const i=t.cacheSize!==void 0?t.cacheSize:512;this.tileRepresentationCache=new Ha(i),this.frameState=null,this.renderedProjection_=void 0}reset(e){super.reset({uniforms:e.uniforms})}prepareFrameInternal(e){this.renderedProjection_?e.viewState.projection!==this.renderedProjection_&&(this.clearCache(),this.renderedProjection_=e.viewState.projection):this.renderedProjection_=e.viewState.projection;const i=this.getLayer().getRenderSource();return!i||Di(ma(e,e.extent))?!1:i.getState()==="ready"}createTileRepresentation(e){return W()}enqueueTiles(e,t,i,s,r){const o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=l.getGutterForProjection(o.projection),u=O(l);u in e.wantedTiles||(e.wantedTiles[u]={});const d=e.wantedTiles[u],f=this.tileRepresentationCache,g=a.getMapInternal(),_=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),g?g.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),m=o.rotation,y=m?xl(o.center,o.resolution,m,e.size):void 0;for(let p=i;p>=_;--p){const T=h.getTileRangeForExtentAndZ(t,p,this.tempTileRange_),x=h.getResolution(p);for(let E=T.minX;E<=T.maxX;++E)for(let R=T.minY;R<=T.maxY;++R){if(m&&!h.tileCoordIntersectsViewport([p,E,R],y))continue;const C=Hn(p,E,R,this.tempTileCoord_),v=nl(l,C);let w,P;if(f.containsKey(v)&&(w=f.get(v),P=w.tile),(!w||w.tile.key!==l.getKey())&&(P=l.getTile(p,E,R,e.pixelRatio,o.projection),!P)||zc(s,P))continue;w?w.setTile(P):(w=this.createTileRepresentation({tile:P,grid:h,helper:this.helper,gutter:c}),f.set(v,w)),Xc(s,w,p);const A=P.getKey();d[A]=!0,P.getState()===D.IDLE&&(e.tileQueue.isKeyQueued(A)||e.tileQueue.enqueue([P,u,h.getTileCoordCenter(C),x]))}}}beforeTilesRender(e,t){this.helper.prepareDraw(this.frameState,!t,!0)}beforeTilesMaskRender(e){return!1}renderTile(e,t,i,s,r,o,a,l,h,c,u){}renderTileMask(e,t,i,s){}drawTile_(e,t,i,s,r,o,a){if(!t.ready)return;const h=t.tile.tileCoord,c=In(h),u=c in o?o[c]:1,d=a.getResolution(i),f=Se(a.getTileSize(i),this.tempSize_),g=a.getOrigin(i),_=a.getTileCoordExtent(h),m=u<1?-1:Bc(i);u<1&&(e.animate=!0);const y=e.viewState,p=y.center[0],T=y.center[1],x=f[0]+2*s,E=f[1]+2*s,R=x/E,C=(p-g[0])/(f[0]*d),v=(g[1]-T)/(f[1]*d),w=y.resolution/d,P=h[1],A=h[2];Ga(this.tileTransform_),vs(this.tileTransform_,2/(e.size[0]*w/x),-2/(e.size[1]*w/x)),kg(this.tileTransform_,y.rotation),vs(this.tileTransform_,1,1/R),Fl(this.tileTransform_,(f[0]*(P-C)-s)/x,(f[1]*(A-v)-s)/E),this.renderTile(t,this.tileTransform_,e,r,d,f,g,_,m,s,u)}renderFrame(e){this.frameState=e,this.renderComplete=!0;const t=this.helper.getGL();this.preRender(t,e);const i=e.viewState,s=this.getLayer(),r=s.getRenderSource(),o=r.getTileGridForProjection(i.projection),a=r.getGutterForProjection(i.projection),l=ma(e,e.extent),h=o.getZForResolution(i.resolution,r.zDirection),c=tx(),u=s.getPreload();if(e.nextExtent){const T=o.getZForResolution(i.nextResolution,r.zDirection),x=ma(e,e.nextExtent);this.enqueueTiles(e,x,T,c,u)}this.enqueueTiles(e,l,h,c,0),u>0&&setTimeout(()=>{this.enqueueTiles(e,l,h-1,c,u-1)},0);const d={};let f=!1;const g=c.representationsByZ;if(h in g){const T=O(this),x=e.time;for(const E of g[h]){const R=E.tile;if(R.getState()===D.EMPTY)continue;const C=R.tileCoord;if(E.ready){const P=R.getAlpha(T,x);if(P===1){R.endTransition(T);continue}f=!0;const A=In(C);d[A]=P}if(this.renderComplete=!1,this.findAltTiles_(o,C,h+1,c))continue;const w=o.getMinZoom();for(let P=h-1;P>=w&&!this.findAltTiles_(o,C,P,c);--P);}}const _=Object.keys(g).map(Number).sort(ru);if(this.beforeTilesMaskRender(e))for(let T=0,x=_.length;T<x;++T){const E=_[T];for(const R of g[E]){const C=R.tile.tileCoord;if(In(C)in d)continue;const w=o.getTileCoordExtent(C);this.renderTileMask(R,E,w,Bc(E))}}this.beforeTilesRender(e,f);for(let T=0,x=_.length;T<x;++T){const E=_[T];for(const R of g[E]){const C=R.tile.tileCoord;In(C)in d||this.drawTile_(e,R,E,a,l,d,o)}}if(h in g)for(const T of g[h]){const x=T.tile.tileCoord;In(x)in d&&this.drawTile_(e,T,h,a,l,d,o)}this.beforeFinalize(e),this.helper.finalizeDraw(e,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const y=this.helper.getCanvas();return this.tileRepresentationCache.expireCache(),this.postRender(t,e),y}beforeFinalize(e){}findAltTiles_(e,t,i,s){const r=e.getTileRangeForTileCoordAndZ(t,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileRepresentationCache,l=this.getLayer().getRenderSource();for(let h=r.minX;h<=r.maxX;++h)for(let c=r.minY;c<=r.maxY;++c){const u=nl(l,[i,h,c]);let d=!1;if(a.containsKey(u)){const f=a.get(u);f.ready&&!zc(s,f.tile)&&(Xc(s,f,i),d=!0)}d||(o=!1)}return o}clearCache(){super.clearCache();const e=this.tileRepresentationCache;e.forEach(t=>t.dispose()),e.clear()}afterHelperCreated(){super.afterHelperCreated(),this.tileRepresentationCache.forEach(e=>e.setHelper(this.helper))}disposeInternal(){super.disposeInternal(),delete this.frameState}}const Ke={...ex,TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight",TEXTURE_RESOLUTION:"u_textureResolution",TEXTURE_ORIGIN_X:"u_textureOriginX",TEXTURE_ORIGIN_Y:"u_textureOriginY"},nx={TEXTURE_COORD:"a_textureCoord"},sx=[{name:nx.TEXTURE_COORD,size:2,type:Oe.FLOAT}];class CT extends ix{constructor(e,t){super(e,t),this.program_,this.vertexShader_=t.vertexShader,this.fragmentShader_=t.fragmentShader,this.indices_=new As(Fo,ph),this.indices_.fromArray([0,1,3,1,2,3]),this.paletteTextures_=t.paletteTextures||[]}reset(e){if(super.reset(e),this.helper){const t=this.helper.getGL();for(const i of this.paletteTextures_)i.delete(t)}if(this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.paletteTextures_=e.paletteTextures||[],this.helper){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_);const t=this.helper.getGL();for(const i of this.paletteTextures_)i.getTexture(t)}}afterHelperCreated(){super.afterHelperCreated();const e=this.helper.getGL();for(const t of this.paletteTextures_)t.getTexture(e);this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.helper.flushBufferData(this.indices_)}removeHelper(){if(this.helper){const e=this.helper.getGL();for(const t of this.paletteTextures_)t.delete(e)}super.removeHelper()}createTileRepresentation(e){return new Qy(e)}beforeTilesRender(e,t){super.beforeTilesRender(e,t),this.helper.useProgram(this.program_,e)}renderTile(e,t,i,s,r,o,a,l,h,c,u){const d=this.helper.getGL();this.helper.bindBuffer(e.coords),this.helper.bindBuffer(this.indices_),this.helper.enableAttributes(sx);let f=0;for(;f<e.textures.length;){const R=`${Ke.TILE_TEXTURE_ARRAY}[${f}]`;this.helper.bindTexture(e.textures[f],f,R),++f}for(let R=0;R<this.paletteTextures_.length;++R){const C=this.paletteTextures_[R],v=C.getTexture(d);this.helper.bindTexture(v,f,C.name),++f}const g=i.viewState,_=o[0]+2*c,m=o[1]+2*c,p=e.tile.tileCoord,T=p[1],x=p[2];this.helper.setUniformMatrixValue(Ke.TILE_TRANSFORM,no(this.tempMat4,t)),this.helper.setUniformFloatValue(Ke.TRANSITION_ALPHA,u),this.helper.setUniformFloatValue(Ke.DEPTH,h);let E=s;c>0&&(E=l,We(E,s,E)),this.helper.setUniformFloatVec4(Ke.RENDER_EXTENT,E),this.helper.setUniformFloatValue(Ke.RESOLUTION,g.resolution),this.helper.setUniformFloatValue(Ke.ZOOM,g.zoom),this.helper.setUniformFloatValue(Ke.TEXTURE_PIXEL_WIDTH,_),this.helper.setUniformFloatValue(Ke.TEXTURE_PIXEL_HEIGHT,m),this.helper.setUniformFloatValue(Ke.TEXTURE_RESOLUTION,r),this.helper.setUniformFloatValue(Ke.TEXTURE_ORIGIN_X,a[0]+T*o[0]*r-c*r),this.helper.setUniformFloatValue(Ke.TEXTURE_ORIGIN_Y,a[1]-x*o[1]*r+c*r),this.helper.drawElements(0,this.indices_.getSize())}getData(e){if(!this.helper.getGL())return null;const i=this.frameState;if(!i)return null;const s=this.getLayer(),r=me(i.pixelToCoordinateTransform,e.slice()),o=i.viewState,a=s.getExtent();if(a&&!li(ct(a,o.projection),r))return null;const l=s.getSources(Be([r]),o.resolution);let h,c,u;for(h=l.length-1;h>=0;--h)if(c=l[h],c.getState()==="ready"){if(u=c.getTileGridForProjection(o.projection),c.getWrapX())break;const f=u.getExtent();if(!f||li(f,r))break}if(h<0)return null;const d=this.tileRepresentationCache;for(let f=u.getZForResolution(o.resolution);f>=u.getMinZoom();--f){const g=u.getTileCoordForCoordAndZ(r,f),_=nl(c,g);if(!d.containsKey(_))continue;const m=d.get(_);if(m.tile.getState()===D.EMPTY)return null;if(!m.loaded)continue;const p=u.getOrigin(f),T=Se(u.getTileSize(f)),x=u.getResolution(f),E=(r[0]-p[0])/x-g[1]*T[0],R=(p[1]-r[1])/x-g[2]*T[1];return m.getPixelData(E,R)}return null}disposeInternal(){const e=this.helper;if(e){const t=e.getGL();for(const i of this.paletteTextures_)i.delete(t);this.paletteTextures_.length=0,t.deleteProgram(this.program_),delete this.program_,e.deleteBuffer(this.indices_)}super.disposeInternal(),delete this.indices_}}class rx{constructor(e,t){this.name=e,this.data=t,this.texture_=null}getTexture(e){if(!this.texture_){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.data.length/4,1,0,e.RGBA,e.UNSIGNED_BYTE,this.data),this.texture_=t}return this.texture_}delete(e){this.texture_&&e.deleteTexture(this.texture_),this.texture_=null}}function ox(n,e){return`operator_${n}_${Object.keys(e.functions).length}`}function Ai(n){const e=n.toString();return e.includes(".")?e:e+".0"}function yh(n){if(n.length<2||n.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${n.length}(${n.map(Ai).join(", ")})`}function Nr(n){const e=wt(n),t=e.length>3?e[3]:1;return yh([e[0]/255,e[1]/255,e[2]/255,t])}function ax(n){const e=Se(n);return yh(e)}const pa={};let lx=0;function Zs(n){return n in pa||(pa[n]=lx++),pa[n]}function ti(n){return Ai(Zs(n))}function xh(n){return"u_var_"+n}function Od(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const ya="getBandValue",hx="u_paletteTextures",Nd="featureId",Gd="geometryType",sl=-9999999;function cx(n,e,t,i){const s=Ue(n,e,t);return Eh(s,e,i)}function re(n){return(e,t,i)=>{const s=t.args.length,r=new Array(s);for(let o=0;o<s;++o)r[o]=Eh(t.args[o],i,e);return n(r,e)}}const ux={[S.Get]:(n,e)=>{const i=e.args[0].value;i in n.properties||(n.properties[i]={name:i,type:e.type});let r="a_prop_"+i;return Ot(e.type,Fe)&&(r=`(${r} > 0.0)`),r},[S.Id]:n=>(n.featureId=!0,"a_"+Nd),[S.GeometryType]:n=>(n.geometryType=!0,"a_"+Gd),[S.LineMetric]:()=>"currentLineMetric",[S.Var]:(n,e)=>{const i=e.args[0].value;i in n.variables||(n.variables[i]={name:i,type:e.type});let r=xh(i);return Ot(e.type,Fe)&&(r=`(${r} > 0.0)`),r},[S.Has]:(n,e)=>{const i=e.args[0].value;return i in n.properties||(n.properties[i]={name:i,type:e.type}),`(a_prop_${i} != ${Ai(sl)})`},[S.Resolution]:()=>"u_resolution",[S.Zoom]:()=>"u_zoom",[S.Time]:()=>"u_time",[S.Any]:re(n=>`(${n.join(" || ")})`),[S.All]:re(n=>`(${n.join(" && ")})`),[S.Not]:re(([n])=>`(!${n})`),[S.Equal]:re(([n,e])=>`(${n} == ${e})`),[S.NotEqual]:re(([n,e])=>`(${n} != ${e})`),[S.GreaterThan]:re(([n,e])=>`(${n} > ${e})`),[S.GreaterThanOrEqualTo]:re(([n,e])=>`(${n} >= ${e})`),[S.LessThan]:re(([n,e])=>`(${n} < ${e})`),[S.LessThanOrEqualTo]:re(([n,e])=>`(${n} <= ${e})`),[S.Multiply]:re(n=>`(${n.join(" * ")})`),[S.Divide]:re(([n,e])=>`(${n} / ${e})`),[S.Add]:re(n=>`(${n.join(" + ")})`),[S.Subtract]:re(([n,e])=>`(${n} - ${e})`),[S.Clamp]:re(([n,e,t])=>`clamp(${n}, ${e}, ${t})`),[S.Mod]:re(([n,e])=>`mod(${n}, ${e})`),[S.Pow]:re(([n,e])=>`pow(${n}, ${e})`),[S.Abs]:re(([n])=>`abs(${n})`),[S.Floor]:re(([n])=>`floor(${n})`),[S.Ceil]:re(([n])=>`ceil(${n})`),[S.Round]:re(([n])=>`floor(${n} + 0.5)`),[S.Sin]:re(([n])=>`sin(${n})`),[S.Cos]:re(([n])=>`cos(${n})`),[S.Atan]:re(([n,e])=>e!==void 0?`atan(${n}, ${e})`:`atan(${n})`),[S.Sqrt]:re(([n])=>`sqrt(${n})`),[S.Match]:re(n=>{const e=n[0],t=n[n.length-1];let i=null;for(let s=n.length-3;s>=1;s-=2){const r=n[s],o=n[s+1];i=`(${e} == ${r} ? ${o} : ${i||t})`}return i}),[S.Between]:re(([n,e,t])=>`(${n} >= ${e} && ${n} <= ${t})`),[S.Interpolate]:re(([n,e,...t])=>{let i="";for(let s=0;s<t.length-2;s+=2){const r=t[s],o=i||t[s+1],a=t[s+2],l=t[s+3];let h;n===Ai(1)?h=`(${e} - ${r}) / (${a} - ${r})`:h=`(pow(${n}, (${e} - ${r})) - 1.0) / (pow(${n}, (${a} - ${r})) - 1.0)`,i=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return i}),[S.Case]:re(n=>{const e=n[n.length-1];let t=null;for(let i=n.length-3;i>=0;i-=2){const s=n[i],r=n[i+1];t=`(${s} ? ${r} : ${t||e})`}return t}),[S.In]:re(([n,...e],t)=>{const i=ox("in",t),s=[];for(let r=0;r<e.length;r+=1)s.push(` if (inputValue == ${e[r]}) { return true; }`);return t.functions[i]=`bool ${i}(float inputValue) {
|
||
${s.join(`
|
||
`)}
|
||
return false;
|
||
}`,`${i}(${n})`}),[S.Array]:re(n=>`vec${n.length}(${n.join(", ")})`),[S.Color]:re(n=>{if(n.length===1)return`vec4(vec3(${n[0]} / 255.0), 1.0)`;if(n.length===2)return`vec4(vec3(${n[0]} / 255.0), ${n[1]})`;const e=n.slice(0,3).map(i=>`${i} / 255.0`);if(n.length===3)return`vec4(${e.join(", ")}, 1.0)`;const t=n[3];return`vec4(${e.join(", ")}, ${t})`}),[S.Band]:re(([n,e,t],i)=>{if(!(ya in i.functions)){let s="";const r=i.bandCount||1;for(let o=0;o<r;o++){const a=Math.floor(o/4);let l=o%4;o===r-1&&l===1&&(l=3);const h=`${Ke.TILE_TEXTURE_ARRAY}[${a}]`;s+=` if (band == ${o+1}.0) {
|
||
return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
|
||
}
|
||
`}i.functions[ya]=`float getBandValue(float band, float xOffset, float yOffset) {
|
||
float dx = xOffset / ${Ke.TEXTURE_PIXEL_WIDTH};
|
||
float dy = yOffset / ${Ke.TEXTURE_PIXEL_HEIGHT};
|
||
${s}
|
||
}`}return`${ya}(${n}, ${e??"0.0"}, ${t??"0.0"})`}),[S.Palette]:(n,e)=>{const[t,...i]=e.args,s=i.length,r=new Uint8Array(s*4);for(let h=0;h<i.length;h++){const c=i[h].value,u=wt(c),d=h*4;r[d]=u[0],r[d+1]=u[1],r[d+2]=u[2],r[d+3]=u[3]*255}n.paletteTextures||(n.paletteTextures=[]);const o=`${hx}[${n.paletteTextures.length}]`,a=new rx(o,r);n.paletteTextures.push(a);const l=Eh(t,B,n);return`texture2D(${o}, vec2((${l} + 0.5) / ${s}.0, 0.5))`}};function Eh(n,e,t){if(n instanceof $u){const i=ux[n.operator];if(i===void 0)throw new Error(`No compiler defined for this operator: ${JSON.stringify(n.operator)}`);return i(t,n,e)}if((n.type&B)>0)return Ai(n.value);if((n.type&Fe)>0)return n.value.toString();if((n.type&Me)>0)return ti(n.value.toString());if((n.type&ye)>0)return Nr(n.value);if((n.type&ot)>0)return yh(n.value);if((n.type&Tt)>0)return ax(n.value);throw new Error(`Unexpected expression ${n.value} (expected type ${Mn(e)})`)}function dx(){return{"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"}}const jc=.985;function q(n,e,t){const i=ih();return cx(e,t,i,n)}function fx(n){const e=wt(n),t=e[0]*256,i=e[1],s=e[2]*256,r=Math.round(e[3]*255);return[t+i,s+r]}const gx=`vec4 unpackColor(vec2 packedColor) {
|
||
return vec4(
|
||
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
|
||
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
|
||
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
|
||
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
|
||
);
|
||
}`;function Th(n){return n===ye||n===Tt?2:n===ot?4:1}function rl(n){const e=Th(n);return e>1?`vec${e}`:"float"}function kd(n,e){for(const t in e.variables){const i=e.variables[t],s=xh(i.name);let r=rl(i.type);i.type===ye&&(r="vec4"),n.addUniform(s,r)}for(const t in e.properties){const i=e.properties[t],s=rl(i.type),r=`a_prop_${i.name}`;i.type===ye?n.addAttribute(r,s,`unpackColor(${r})`,"vec4"):n.addAttribute(r,s)}for(const t in e.functions)n.addVertexShaderFunction(e.functions[t]),n.addFragmentShaderFunction(e.functions[t])}function Ud(n,e){const t={};for(const i in n.variables){const s=n.variables[i],r=xh(s.name);t[r]=()=>{const o=e[s.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(s.type===ye){const a=[...wt(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Zs(o):o}}return t}function Bd(n){const e={};for(const t in n.properties){const i=n.properties[t],s=r=>{const o=r.get(i.name);return i.type===ye?fx([...wt(o||"#eee")]):typeof o=="string"?Zs(o):typeof o=="boolean"?o?1:0:o};e[`prop_${i.name}`]={size:Th(i.type),callback:s}}return e}const Rn=`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
precision highp float;
|
||
#else
|
||
precision mediump float;
|
||
#endif
|
||
uniform mat4 u_projectionMatrix;
|
||
uniform mat4 u_screenToWorldMatrix;
|
||
uniform vec2 u_viewportSizePx;
|
||
uniform float u_pixelRatio;
|
||
uniform float u_globalAlpha;
|
||
uniform float u_time;
|
||
uniform float u_zoom;
|
||
uniform float u_resolution;
|
||
uniform float u_rotation;
|
||
uniform vec4 u_renderExtent;
|
||
uniform vec2 u_patternOrigin;
|
||
uniform float u_depth;
|
||
uniform mediump int u_hitDetection;
|
||
|
||
const float PI = 3.141592653589793238;
|
||
const float TWO_PI = 2.0 * PI;
|
||
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
|
||
|
||
${gx}
|
||
`,Cn=dx();class zd{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${Ai(Cn["circle-radius"])} + ${Ai(Cn["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Nr(Cn["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.discardExpression_="false",this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=Ai(Cn["stroke-width"]),this.strokeColorExpression_=Nr(Cn["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=ti("round"),this.strokeJoinExpression_=ti("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Nr(Cn["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(e,t){return this.uniforms_.push({name:e,type:t}),this}addAttribute(e,t,i,s){return this.attributes_.push({name:e,type:t,varyingName:e.replace(/^a_/,"v_"),varyingType:s??t,varyingExpression:i??e}),this}setSymbolSizeExpression(e){return this.hasSymbol_=!0,this.symbolSizeExpression_=e,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(e){return this.symbolRotationExpression_=e,this}setSymbolOffsetExpression(e){return this.symbolOffsetExpression_=e,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(e){return this.hasSymbol_=!0,this.symbolColorExpression_=e,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(e){return this.texCoordExpression_=e,this}setFragmentDiscardExpression(e){return this.discardExpression_=e,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(e){return this.symbolRotateWithView_=e,this}setStrokeWidthExpression(e){return this.hasStroke_=!0,this.strokeWidthExpression_=e,this}setStrokeColorExpression(e){return this.hasStroke_=!0,this.strokeColorExpression_=e,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(e){return this.strokeOffsetExpression_=e,this}setStrokeCapExpression(e){return this.strokeCapExpression_=e,this}setStrokeJoinExpression(e){return this.strokeJoinExpression_=e,this}setStrokeMiterLimitExpression(e){return this.strokeMiterLimitExpression_=e,this}setStrokeDistanceFieldExpression(e){return this.strokeDistanceFieldExpression_=e,this}setStrokePatternLengthExpression(e){return this.strokePatternLengthExpression_=e,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(e){return this.hasFill_=!0,this.fillColorExpression_=e,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(e){return this.vertexShaderFunctions_.includes(e)?this:(this.vertexShaderFunctions_.push(e),this)}addFragmentShaderFunction(e){return this.fragmentShaderFunctions_.includes(e)?this:(this.fragmentShaderFunctions_.push(e),this)}getSymbolVertexShader(){return this.hasSymbol_?`${Rn}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_position;
|
||
attribute vec2 a_localPosition;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec2 v_texCoord;
|
||
varying vec2 v_quadCoord;
|
||
varying vec4 v_hitColor;
|
||
varying vec2 v_centerPx;
|
||
varying float v_angle;
|
||
varying vec2 v_quadSizePx;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
vec2 pxToScreen(vec2 coordPx) {
|
||
vec2 scaled = coordPx / u_viewportSizePx / 0.5;
|
||
return scaled;
|
||
}
|
||
|
||
vec2 screenToPx(vec2 coordScreen) {
|
||
return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
void main(void) {
|
||
v_quadSizePx = ${this.symbolSizeExpression_};
|
||
vec2 halfSizePx = v_quadSizePx * 0.5;
|
||
vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
|
||
vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
|
||
float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};
|
||
float c = cos(-angle);
|
||
float s = sin(-angle);
|
||
offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
|
||
vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
|
||
gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
|
||
vec4 texCoord = ${this.texCoordExpression_};
|
||
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
|
||
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
|
||
v_texCoord = vec2(u, v);
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
v_angle = angle;
|
||
c = cos(-v_angle);
|
||
s = sin(-v_angle);
|
||
centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);
|
||
v_centerPx = screenToPx(center.xy) + centerOffsetPx;
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${Rn}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec2 v_texCoord;
|
||
varying vec4 v_hitColor;
|
||
varying vec2 v_centerPx;
|
||
varying float v_angle;
|
||
varying vec2 v_quadSizePx;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
if (${this.discardExpression_}) { discard; }
|
||
vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center
|
||
float c = cos(v_angle);
|
||
float s = sin(v_angle);
|
||
coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);
|
||
gl_FragColor = ${this.symbolColorExpression_};
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.05) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}getStrokeVertexShader(){return this.hasStroke_?`${Rn}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_segmentStart;
|
||
attribute vec2 a_segmentEnd;
|
||
attribute vec2 a_localPosition;
|
||
attribute float a_measureStart;
|
||
attribute float a_measureEnd;
|
||
attribute float a_angleTangentSum;
|
||
attribute float a_distanceLow;
|
||
attribute float a_distanceHigh;
|
||
attribute vec2 a_joinAngles;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec2 v_segmentStartPx;
|
||
varying vec2 v_segmentEndPx;
|
||
varying float v_angleStart;
|
||
varying float v_angleEnd;
|
||
varying float v_width;
|
||
varying vec4 v_hitColor;
|
||
varying float v_distancePx;
|
||
varying float v_measureStart;
|
||
varying float v_measureEnd;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
vec2 worldToPx(vec2 worldPos) {
|
||
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
||
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
vec4 pxToScreen(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return vec4(screenPos, u_depth, 1.0);
|
||
}
|
||
|
||
bool isCap(float joinAngle) {
|
||
return joinAngle < -0.1;
|
||
}
|
||
|
||
vec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {
|
||
float halfAngle = joinAngle / 2.0;
|
||
float c = cos(halfAngle);
|
||
float s = sin(halfAngle);
|
||
vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);
|
||
float length = 1.0 / s;
|
||
return angleBisectorNormal * length;
|
||
}
|
||
|
||
vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
|
||
// if on a cap or the join angle is too high, offset the line along the segment normal
|
||
if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {
|
||
return point - normal * offsetPx;
|
||
}
|
||
// offset is applied along the inverted normal (positive offset goes "right" relative to line direction)
|
||
return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;
|
||
}
|
||
|
||
void main(void) {
|
||
v_angleStart = a_joinAngles.x;
|
||
v_angleEnd = a_joinAngles.y;
|
||
float startEndRatio = a_localPosition.x * 0.5 + 0.5;
|
||
currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
|
||
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
|
||
|
||
float lineWidth = ${this.strokeWidthExpression_};
|
||
float lineOffsetPx = ${this.strokeOffsetExpression_};
|
||
|
||
// compute segment start/end in px with offset
|
||
vec2 segmentStartPx = worldToPx(a_segmentStart);
|
||
vec2 segmentEndPx = worldToPx(a_segmentEnd);
|
||
vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);
|
||
vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);
|
||
segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),
|
||
segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
|
||
|
||
// compute current vertex position
|
||
float normalDir = -1. * a_localPosition.y;
|
||
float tangentDir = -1. * a_localPosition.x;
|
||
float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
|
||
vec2 joinDirection;
|
||
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
|
||
// if angle is too high, do not make a proper join
|
||
if (cos(angle) > ${jc} || isCap(angle)) {
|
||
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
|
||
} else {
|
||
joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
|
||
}
|
||
positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing
|
||
gl_Position = pxToScreen(positionPx);
|
||
|
||
v_segmentStartPx = segmentStartPx;
|
||
v_segmentEndPx = segmentEndPx;
|
||
v_width = lineWidth;
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
|
||
v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
|
||
float distanceHighPx = a_distanceHigh / u_resolution;
|
||
${this.strokePatternLengthExpression_!==null?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});
|
||
distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});
|
||
`:""}v_distancePx += distanceHighPx;
|
||
|
||
v_measureStart = a_measureStart;
|
||
v_measureEnd = a_measureEnd;
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${Rn}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec2 v_segmentStartPx;
|
||
varying vec2 v_segmentEndPx;
|
||
varying float v_angleStart;
|
||
varying float v_angleEnd;
|
||
varying float v_width;
|
||
varying vec4 v_hitColor;
|
||
varying float v_distancePx;
|
||
varying float v_measureStart;
|
||
varying float v_measureEnd;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
|
||
vec2 pxToWorld(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
||
}
|
||
|
||
bool isCap(float joinAngle) {
|
||
return joinAngle < -0.1;
|
||
}
|
||
|
||
float segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
vec2 tangent = normalize(end - start);
|
||
vec2 normal = vec2(-tangent.y, tangent.x);
|
||
vec2 startToPoint = point - start;
|
||
return abs(dot(startToPoint, normal)) - width * 0.5;
|
||
}
|
||
|
||
float buttCapDistanceField(vec2 point, vec2 start, vec2 end) {
|
||
vec2 startToPoint = point - start;
|
||
vec2 tangent = normalize(end - start);
|
||
return dot(startToPoint, -tangent);
|
||
}
|
||
|
||
float squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
return buttCapDistanceField(point, start, end) - width * 0.5;
|
||
}
|
||
|
||
float roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment
|
||
return length(point - start) - width * 0.5 - onSegment;
|
||
}
|
||
|
||
float roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
return roundCapDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
||
vec2 startToPoint = point - start;
|
||
vec2 tangent = normalize(end - start);
|
||
float c = cos(joinAngle * 0.5);
|
||
float s = sin(joinAngle * 0.5);
|
||
float direction = -sign(sin(joinAngle));
|
||
vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);
|
||
float radius = width * 0.5 * s;
|
||
return dot(startToPoint, bisector * direction) - radius;
|
||
}
|
||
|
||
float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
||
if (cos(joinAngle) > ${jc}) { // avoid risking a division by zero
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
}
|
||
float miterLength = 1. / sin(joinAngle * 0.5);
|
||
float miterLimit = ${this.strokeMiterLimitExpression_};
|
||
if (miterLength > miterLimit) {
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
}
|
||
return -1000.;
|
||
}
|
||
|
||
float capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {
|
||
if (capType == ${ti("butt")}) {
|
||
return buttCapDistanceField(point, start, end);
|
||
} else if (capType == ${ti("square")}) {
|
||
return squareCapDistanceField(point, start, end, width);
|
||
}
|
||
return roundCapDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {
|
||
if (joinType == ${ti("bevel")}) {
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
} else if (joinType == ${ti("miter")}) {
|
||
return miterJoinDistanceField(point, start, end, width, joinAngle);
|
||
}
|
||
return roundJoinDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {
|
||
if (isCap(joinAngle)) {
|
||
return capDistanceField(point, start, end, width, capType);
|
||
}
|
||
return joinDistanceField(point, start, end, width, joinAngle, joinType);
|
||
}
|
||
|
||
float distanceFromSegment(vec2 point, vec2 start, vec2 end) {
|
||
vec2 tangent = end - start;
|
||
vec2 startToPoint = point - start;
|
||
// inspire by capsule fn in https://iquilezles.org/articles/distfunctions/
|
||
float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);
|
||
return length(startToPoint - tangent * h);
|
||
}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
|
||
vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;
|
||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
vec2 worldPos = pxToWorld(currentPointPx);
|
||
if (
|
||
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
||
worldPos[0] < u_renderExtent[0] ||
|
||
worldPos[1] < u_renderExtent[1] ||
|
||
worldPos[0] > u_renderExtent[2] ||
|
||
worldPos[1] > u_renderExtent[3]
|
||
)
|
||
) {
|
||
discard;
|
||
}
|
||
#endif
|
||
|
||
float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);
|
||
segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero
|
||
vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;
|
||
vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
|
||
vec2 startToPointPx = currentPointPx - v_segmentStartPx;
|
||
float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));
|
||
float currentLengthPx = lengthToPointPx + v_distancePx;
|
||
float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);
|
||
float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;
|
||
currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);
|
||
|
||
if (${this.discardExpression_}) { discard; }
|
||
|
||
float capType = ${this.strokeCapExpression_};
|
||
float joinType = ${this.strokeJoinExpression_};
|
||
float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);
|
||
float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);
|
||
float distanceField = max(
|
||
segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),
|
||
max(segmentStartDistance, segmentEndDistance)
|
||
);
|
||
distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});
|
||
|
||
vec4 color = ${this.strokeColorExpression_};
|
||
color.a *= smoothstep(0.5, -0.5, distanceField);
|
||
gl_FragColor = color;
|
||
gl_FragColor.a *= u_globalAlpha;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.1) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}getFillVertexShader(){return this.hasFill_?`${Rn}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_position;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec4 v_hitColor;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
void main(void) {
|
||
gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getFillFragmentShader(){return this.hasFill_?`${Rn}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec4 v_hitColor;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
vec2 pxToWorld(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
||
}
|
||
|
||
vec2 worldToPx(vec2 worldPos) {
|
||
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
||
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;
|
||
vec2 pxOrigin = worldToPx(u_patternOrigin);
|
||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
vec2 worldPos = pxToWorld(pxPos);
|
||
if (
|
||
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
||
worldPos[0] < u_renderExtent[0] ||
|
||
worldPos[1] < u_renderExtent[1] ||
|
||
worldPos[0] > u_renderExtent[2] ||
|
||
worldPos[1] > u_renderExtent[3]
|
||
)
|
||
) {
|
||
discard;
|
||
}
|
||
#endif
|
||
if (${this.discardExpression_}) { discard; }
|
||
gl_FragColor = ${this.fillColorExpression_};
|
||
gl_FragColor.a *= u_globalAlpha;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.1) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}}class ro{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(e,t){for(let i=0;i<e.length;i++)this.addFeature(e[i],t)}addFeature(e,t){let i=e.getGeometry();i&&(t&&(i=i.clone(),i.applyTransform(t)),this.addGeometry_(i,e))}clearFeatureEntryInPointBatch_(e){const t=O(e),i=this.pointBatch.entries[t];if(i)return this.pointBatch.geometriesCount-=i.flatCoordss.length,delete this.pointBatch.entries[t],i}clearFeatureEntryInLineStringBatch_(e){const t=O(e),i=this.lineStringBatch.entries[t];if(i)return this.lineStringBatch.verticesCount-=i.verticesCount,this.lineStringBatch.geometriesCount-=i.flatCoordss.length,delete this.lineStringBatch.entries[t],i}clearFeatureEntryInPolygonBatch_(e){const t=O(e),i=this.polygonBatch.entries[t];if(i)return this.polygonBatch.verticesCount-=i.verticesCount,this.polygonBatch.ringsCount-=i.ringsCount,this.polygonBatch.geometriesCount-=i.flatCoordss.length,delete this.polygonBatch.entries[t],i}addGeometry_(e,t){const i=e.getType();switch(i){case"GeometryCollection":{const s=e.getGeometriesArray();for(const r of s)this.addGeometry_(r,t);break}case"MultiPolygon":{const s=e;this.addCoordinates_(i,s.getFlatCoordinates(),s.getEndss(),t,O(t),s.getStride());break}case"MultiLineString":{const s=e;this.addCoordinates_(i,s.getFlatCoordinates(),s.getEnds(),t,O(t),s.getStride());break}case"MultiPoint":{const s=e;this.addCoordinates_(i,s.getFlatCoordinates(),null,t,O(t),s.getStride());break}case"Polygon":{const s=e;this.addCoordinates_(i,s.getFlatCoordinates(),s.getEnds(),t,O(t),s.getStride());break}case"Point":{const s=e;this.addCoordinates_(i,s.getFlatCoordinates(),null,t,O(t),s.getStride());break}case"LineString":case"LinearRing":{const s=e,r=s.getStride();this.addCoordinates_(i,s.getFlatCoordinates(),null,t,O(t),r,s.getLayout?.());break}}}addCoordinates_(e,t,i,s,r,o,a){let l;switch(e){case"MultiPolygon":{const h=i;for(let c=0,u=h.length;c<u;c++){let d=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,_=d[d.length-1];d=g>0?d.map(m=>m-g):d,this.addCoordinates_("Polygon",t.slice(g,_),d,s,r,o,a)}break}case"MultiLineString":{const h=i;for(let c=0,u=h.length;c<u;c++){const d=c>0?h[c-1]:0;this.addCoordinates_("LineString",t.slice(d,h[c]),null,s,r,o,a)}break}case"MultiPoint":for(let h=0,c=t.length;h<c;h+=o)this.addCoordinates_("Point",t.slice(h,h+2),null,s,r,null,null);break;case"Polygon":{const h=i;if(s instanceof it){const d=Mu(t,h);if(d.length>1){this.addCoordinates_("MultiPolygon",t,d,s,r,o,a);return}}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:s,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=t.length/o;const c=i.length,u=i.map((d,f,g)=>f>0?(d-g[f-1])/o:d/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(_x(t,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(u),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let d=0,f=h.length;d<f;d++){const g=d>0?h[d-1]:0;this.addCoordinates_("LinearRing",t.slice(g,h[d]),null,s,r,o,a)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:s,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(t);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:s,flatCoordss:[],verticesCount:0})),l=t.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(mx(t,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(e,t){const i=this.uidToRef_.get(e),s=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return t.ref=s,i||(this.refToFeature_.set(s,t.feature),this.uidToRef_.set(e,s)),t}removeRef_(e,t){if(!e)throw new Error("This feature has no ref: "+t);this.refToFeature_.delete(e),this.uidToRef_.delete(t),this.freeGlobalRef_.push(e)}changeFeature(e,t){if(!this.uidToRef_.get(O(e)))return;this.removeFeature(e);let i=e.getGeometry();i&&(t&&(i=i.clone(),i.applyTransform(t)),this.addGeometry_(i,e))}removeFeature(e){let t=this.clearFeatureEntryInPointBatch_(e);t=this.clearFeatureEntryInPolygonBatch_(e)||t,t=this.clearFeatureEntryInLineStringBatch_(e)||t,t&&this.removeRef_(t.ref,O(t.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(e){return this.refToFeature_.get(e)}isEmpty(){return this.globalCounter_===0}filter(e){const t=new ro;t.globalCounter_=this.globalCounter_,t.uidToRef_=this.uidToRef_,t.refToFeature_=this.refToFeature_;let i=!0;for(const s of this.refToFeature_.values())e(s)&&(t.addFeature(s),i=!1);return i?new ro:t}}function _x(n,e){return e===2?n:n.filter((t,i)=>i%e<2)}function mx(n,e,t){return e===3&&t==="XYM"?n:e===4?n.filter((i,s)=>s%e!==2):e===3?n.map((i,s)=>s%e!==2?i:0):new Array(n.length*1.5).fill(0).map((i,s)=>s%3===2?0:n[Math.round(s/1.5)])}function px(){const n='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r<i;r++){const f=e(t,n[r]*x,r<i-1?n[r+1]*x:t.length,x,!1);f===f.next&&(f.steiner=!0),o.push(a(f))}o.sort(u);for(let t=0;t<o.length;t++)r=s(o[t],r);return r}(t,n,f,x)),t.length>80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;r<i;r+=x){const x=t[r],o=t[r+1];x<c&&(c=x),o<y&&(y=o),x>e&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o<n;o+=r)x+=(t[i]-t[o])*(t[o+1]+t[i+1]),i=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=d(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t<n&&(f++,i=i.nextZ,i);t++);let u=n;for(;f>0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const f=o,u=o.x,s=o.y;let c=1/0;n=o;do{if(r>=n.x&&n.x>=u&&r!==n.x&&y(x<s?r:i,x,u,s,x<s?i:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);g(n,t)&&(e<c||e===c&&(n.x>o.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function y(t,e,n,r,x,o,i,f){return(x-i)*(e-f)>=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function I(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const z=[],B={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function P(t,e,n,r,x){const o=t[e++],i=t[e++],f=z;f.length=r;for(let n=0;n<f.length;n++)f[n]=t[e+n];let u=x?x.instanceAttributesPosition:0;return n[u++]=o,n[u++]=i,f.length&&(n.set(f,u),u+=f.length),B.instanceAttributesPosition=u,B}function N(t,e,n,r,x,o,i,f,u,s){const l=[t[e],t[e+1]],c=[t[n],t[n+1]],a=t[e+2],y=t[n+2],h=E(f,[...l]),p=E(f,[...c]);function v(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],i=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),f=[(n[0]-t[0])/i,(n[1]-t[1])/i];let u=0===r||0===i?0:Math.acos((s=f[0]*x[0]+f[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;u=Math.max(u,1e-5);return f[0]*o[0]+f[1]*o[1]>0?u:2*Math.PI-u}let b=-1,M=-1,m=s;const A=null!==x;if(null!==r){b=v(h,p,E(f,[...[t[r],t[r+1]]])),Math.cos(b)<=.985&&(m+=Math.tan((b-Math.PI)/2))}if(A){M=v(p,h,E(f,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((Math.PI-M)/2))}const g=Math.pow(2,24),Z=u%g,d=Math.floor(u/g)*g;return o.push(l[0],l[1],a,c[0],c[1],y,b,M,Z,d,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:m}}function R(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t<s;t++)l+=e[f++],t<s-1&&(c[t]=l);const a=e.slice(f,f+2*l),y=t(a,c,2);for(let t=0;t<y.length;t++)x.push(y[t]+r.length/i);for(let t=0;t<a.length;t+=2)r.push(a[t],a[t+1],...u);return f+2*l}const S="GENERATE_POLYGON_BUFFERS",T="GENERATE_POINT_BUFFERS",_="GENERATE_LINE_STRING_BUFFERS",O=self;O.onmessage=t=>{const e=t.data;switch(e.type){case T:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t<o.length;t+=x)l=P(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);O.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case _:{const t=[],n=e.customAttributesSize,r=3,x=new Float32Array(e.renderInstructions);let o=0;const i=[1,0,0,1,0,0];let f,u;for(I(i,e.renderInstructionsTransform);o<x.length;){u=Array.from(x.slice(o,o+n)),o+=n,f=x[o++];const e=o,s=o+(f-1)*r,l=x[e]===x[s]&&x[e+1]===x[s+1];let c=0,a=0;for(let n=0;n<f-1;n++){let y=null;n>0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n<f-2?h=o+(n+2)*r:l&&(h=e+r);const p=N(x,o+n*r,o+(n+1)*r,y,h,t,u,i,c,a);c=p.length,a=p.angle}o+=f*r}const s=Uint32Array.from([0,1,3,1,2,3]),l=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),c=Float32Array.from(t),a=Object.assign({indicesBuffer:s.buffer,vertexAttributesBuffer:l.buffer,instanceAttributesBuffer:c.buffer,renderInstructions:x.buffer},e);O.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case S:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=R(x,o,t,n,r);const i=Uint32Array.from(n),f=Float32Array.from(t),u=Float32Array.from([]),s=Object.assign({indicesBuffer:i.buffer,vertexAttributesBuffer:f.buffer,instanceAttributesBuffer:u.buffer,renderInstructions:x.buffer},e);O.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker(typeof Blob>"u"?"data:application/javascript;base64,"+Buffer.from(n,"binary").toString("base64"):URL.createObjectURL(new Blob([n],{type:"application/javascript"})))}const xa={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function yx(n,e){e=e||[];const t=256,i=t-1,s=Math.floor(n/t/t/t)/i,r=Math.floor(n/t/t)%t/i,o=Math.floor(n/t)%t/i,a=n%t/i;return e[0]=s*256*255+r*255,e[1]=o*256*255+a*255,e}function xx(n){let e=0;const t=256,i=t-1;return e+=Math.round(n[0]*t*t*t*i),e+=Math.round(n[1]*t*t*i),e+=Math.round(n[2]*t*i),e+=Math.round(n[3]*i),e}function Rh(n,e,t,i){let s=0;for(const r in e){const o=e[r],a=o.callback.call(t,t.feature);let l=a?.[0]??a;l===sl&&console.warn('The "has" operator might return false positives.'),l===void 0?l=sl:l===null&&(l=0),n[i+s++]=l,!(!o.size||o.size===1)&&(n[i+s++]=a[1],!(o.size<3)&&(n[i+s++]=a[2],!(o.size<4)&&(n[i+s++]=a[3])))}return s}function Mo(n){return Object.keys(n).reduce((e,t)=>e+(n[t].size||1),0)}function Ex(n,e,t,i){const s=(2+Mo(t))*n.geometriesCount;(!e||e.length!==s)&&(e=new Float32Array(s));const r=[];let o=0;for(const a in n.entries){const l=n.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++)r[0]=l.flatCoordss[h][0],r[1]=l.flatCoordss[h][1],me(i,r),e[o++]=r[0],e[o++]=r[1],o+=Rh(e,t,l,o)}return e}function Tx(n,e,t,i){const s=3*n.verticesCount+(1+Mo(t))*n.geometriesCount;(!e||e.length!==s)&&(e=new Float32Array(s));const r=[];let o=0;for(const a in n.entries){const l=n.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Ut(l.flatCoordss[h],0,r.length,3,i,r,3),o+=Rh(e,t,l,o),e[o++]=r.length/3;for(let u=0,d=r.length;u<d;u+=3)e[o++]=r[u],e[o++]=r[u+1],e[o++]=r[u+2]}}return e}function Rx(n,e,t,i){const s=2*n.verticesCount+(1+Mo(t))*n.geometriesCount+n.ringsCount;(!e||e.length!==s)&&(e=new Float32Array(s));const r=[];let o=0;for(const a in n.entries){const l=n.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Ut(l.flatCoordss[h],0,r.length,2,i,r),o+=Rh(e,t,l,o),e[o++]=l.ringsVerticesCounts[h].length;for(let u=0,d=l.ringsVerticesCounts[h].length;u<d;u++)e[o++]=l.ringsVerticesCounts[h][u];for(let u=0,d=r.length;u<d;u+=2)e[o++]=r[u],e[o++]=r[u+1]}}return e}function oo(n){return(JSON.stringify(n).split("").reduce((t,i)=>(t<<5)-t+i.charCodeAt(0),0)>>>0).toString()}function Ch(n,e,t,i){if(`${i}radius`in n&&i!=="icon-"){let s=q(t,n[`${i}radius`],B);if(`${i}radius2`in n){const r=q(t,n[`${i}radius2`],B);s=`max(${s}, ${r})`}`${i}stroke-width`in n&&(s=`(${s} + ${q(t,n[`${i}stroke-width`],B)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${s} * 2. + 0.5)`)}if(`${i}scale`in n){const s=q(t,n[`${i}scale`],Tt);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${s}`)}`${i}displacement`in n&&e.setSymbolOffsetExpression(q(t,n[`${i}displacement`],ot)),`${i}rotation`in n&&e.setSymbolRotationExpression(q(t,n[`${i}rotation`],B)),`${i}rotate-with-view`in n&&e.setSymbolRotateWithView(!!n[`${i}rotate-with-view`])}function Xd(n,e,t,i,s){let r="vec4(0.)";if(e!==null&&(r=e),t!==null&&i!==null){const l=`smoothstep(-${i} + 0.63, -${i} - 0.58, ${n})`;r=`mix(${t}, ${r}, ${l})`}const o=`(1.0 - smoothstep(-0.63, 0.58, ${n}))`;let a=`${r} * vec4(1.0, 1.0, 1.0, ${o})`;return s!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${s})`),a}function Sh(n,e,t,i,s){const r=new Image;r.crossOrigin=n[`${i}cross-origin`]===void 0?"anonymous":n[`${i}cross-origin`],se(typeof n[`${i}src`]=="string",`WebGL layers do not support expressions for the ${i}src style property`),r.src=n[`${i}src`],t[`u_texture${s}_size`]=()=>r.complete?[r.width,r.height]:[0,0],e.addUniform(`u_texture${s}_size`,"vec2");const o=`u_texture${s}_size`;return t[`u_texture${s}`]=r,e.addUniform(`u_texture${s}`,"sampler2D"),o}function vh(n,e,t,i,s){let r=q(t,n[`${e}offset`],Tt);if(`${e}offset-origin`in n)switch(n[`${e}offset-origin`]){case"top-right":r=`vec2(${i}.x, 0.) + ${s} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${i}.y) + ${s} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${i} - ${s} - ${r}`;break}return r}function Cx(n,e,t,i){i.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
|
||
return length(point) - radius;
|
||
}`,Ch(n,e,i,"circle-");let s=null;"circle-opacity"in n&&(s=q(i,n["circle-opacity"],B));let r="coordsPx";"circle-scale"in n&&(r=`coordsPx / ${q(i,n["circle-scale"],Tt)}`);let o=null;"circle-fill-color"in n&&(o=q(i,n["circle-fill-color"],ye));let a=null;"circle-stroke-color"in n&&(a=q(i,n["circle-stroke-color"],ye));let l=q(i,n["circle-radius"],B),h=null;"circle-stroke-width"in n&&(h=q(i,n["circle-stroke-width"],B),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=Xd(c,o,a,h,s);e.setSymbolColorExpression(u)}function Sx(n,e,t,i){i.functions.round=`float round(float v) {
|
||
return sign(v) * floor(abs(v) + 0.5);
|
||
}`,i.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
|
||
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
||
float c = cos(startAngle);
|
||
float s = sin(startAngle);
|
||
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
||
float alpha = TWO_PI / numPoints; // the angle of one sector
|
||
float beta = atan(pointRotated.y, pointRotated.x);
|
||
float gamma = round(beta / alpha) * alpha; // angle in sector
|
||
c = cos(-gamma);
|
||
s = sin(-gamma);
|
||
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
||
vec2 tipToPoint = inSector + vec2(-radius, 0.);
|
||
vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);
|
||
return dot(normalize(edgeNormal), tipToPoint);
|
||
}`,i.functions.regularDistanceField=`float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {
|
||
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
||
float c = cos(startAngle);
|
||
float s = sin(startAngle);
|
||
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
||
float alpha = TWO_PI / numPoints; // the angle of one sector
|
||
float radiusIn = radius * cos(PI / numPoints);
|
||
float beta = atan(pointRotated.y, pointRotated.x);
|
||
float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid
|
||
c = cos(-gamma);
|
||
s = sin(-gamma);
|
||
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
||
return inSector.x - radiusIn;
|
||
}`,Ch(n,e,i,"shape-");let s=null;"shape-opacity"in n&&(s=q(i,n["shape-opacity"],B));let r="coordsPx";"shape-scale"in n&&(r=`coordsPx / ${q(i,n["shape-scale"],Tt)}`);let o=null;"shape-fill-color"in n&&(o=q(i,n["shape-fill-color"],ye));let a=null;"shape-stroke-color"in n&&(a=q(i,n["shape-stroke-color"],ye));let l=null;"shape-stroke-width"in n&&(l=q(i,n["shape-stroke-width"],B));const h=q(i,n["shape-points"],B);let c="0.";"shape-angle"in n&&(c=q(i,n["shape-angle"],B));let u,d=q(i,n["shape-radius"],B);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in n){let g=q(i,n["shape-radius2"],B);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${r}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${r}, ${h}, ${d}, ${c})`;const f=Xd(u,o,a,l,s);e.setSymbolColorExpression(f)}function vx(n,e,t,i){let s="vec4(1.0)";"icon-color"in n&&(s=q(i,n["icon-color"],ye)),"icon-opacity"in n&&(s=`${s} * vec4(1.0, 1.0, 1.0, ${q(i,n["icon-opacity"],B)})`);const r=oo(n["icon-src"]),o=Sh(n,e,t,"icon-",r);if(e.setSymbolColorExpression(`${s} * texture2D(u_texture${r}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in n&&"icon-height"in n&&e.setSymbolSizeExpression(`vec2(${q(i,n["icon-width"],B)}, ${q(i,n["icon-height"],B)})`),"icon-offset"in n&&"icon-size"in n){const a=q(i,n["icon-size"],ot),l=e.getSymbolSizeExpression();e.setSymbolSizeExpression(a);const h=vh(n,"icon-",i,"v_quadSizePx",a);e.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(Ch(n,e,i,"icon-"),"icon-anchor"in n){const a=q(i,n["icon-anchor"],ot);let l="1.0";"icon-scale"in n&&(l=q(i,n["icon-scale"],Tt));let h;n["icon-anchor-x-units"]==="pixels"&&n["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:n["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:n["icon-anchor-y-units"]==="pixels"?h=`${a} * vec2(v_quadSizePx.x, vec2(${l}).x)`:h=`${a} * v_quadSizePx`;let c=`v_quadSizePx * vec2(0.5, -0.5) + ${h} * vec2(-1., 1.)`;if("icon-anchor-origin"in n)switch(n["icon-anchor-origin"]){case"top-right":c=`v_quadSizePx * -0.5 + ${h}`;break;case"bottom-left":c=`v_quadSizePx * 0.5 - ${h}`;break;case"bottom-right":c=`v_quadSizePx * vec2(-0.5, 0.5) + ${h} * vec2(1., -1.)`;break}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${c}`)}}function wx(n,e,t,i){if("stroke-color"in n&&e.setStrokeColorExpression(q(i,n["stroke-color"],ye)),"stroke-pattern-src"in n){const s=oo(n["stroke-pattern-src"]),r=Sh(n,e,t,"stroke-pattern-",s);let o=r,a="vec2(0.)";"stroke-pattern-offset"in n&&"stroke-pattern-size"in n&&(o=q(i,n["stroke-pattern-size"],ot),a=vh(n,"stroke-pattern-",i,r,o));let l="0.";"stroke-pattern-spacing"in n&&(l=q(i,n["stroke-pattern-spacing"],B));let h="0.";"stroke-pattern-start-offset"in n&&(h=q(i,n["stroke-pattern-start-offset"],B)),i.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
|
||
float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
|
||
float spacingScaled = spacingPx * sampleSize.y / lineWidth;
|
||
float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
|
||
float isInsideOfPattern = step(uCoordPx, sampleSize.x);
|
||
float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;
|
||
// make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
||
uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);
|
||
vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);
|
||
vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;
|
||
return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);
|
||
}`;const c=`u_texture${s}`;let u="1.";"stroke-color"in n&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${r}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),i.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {
|
||
float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;
|
||
return patternLengthPx + spacingPx;
|
||
}`,e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in n&&e.setStrokeWidthExpression(q(i,n["stroke-width"],B)),"stroke-offset"in n&&e.setStrokeOffsetExpression(q(i,n["stroke-offset"],B)),"stroke-line-cap"in n&&e.setStrokeCapExpression(q(i,n["stroke-line-cap"],Me)),"stroke-line-join"in n&&e.setStrokeJoinExpression(q(i,n["stroke-line-join"],Me)),"stroke-miter-limit"in n&&e.setStrokeMiterLimitExpression(q(i,n["stroke-miter-limit"],B)),"stroke-line-dash"in n){i.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {
|
||
float localDistance = mod(distance, dashLengthTotal);
|
||
float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
|
||
distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
|
||
if (capType == ${ti("square")}) {
|
||
distanceSegment -= lineWidth * 0.5;
|
||
} else if (capType == ${ti("round")}) {
|
||
distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
|
||
}
|
||
return distanceSegment;
|
||
}`;let s=n["stroke-line-dash"].map(g=>q(i,g,B));s.length%2===1&&(s=[...s,...s]);let r="0.";"stroke-line-dash-offset"in n&&(r=q(i,n["stroke-line-dash-offset"],B));const a=`dashDistanceField_${oo(n["stroke-line-dash"])}`,l=s.map((g,_)=>`float dashLength${_}`).join(", "),h=s.map((g,_)=>`dashLength${_}`).join(" + ");let c="0.",u=`getSingleDashDistance(distance, radius, ${c}, dashLength0, totalDashLength, capType, lineWidth)`;for(let g=2;g<s.length;g+=2)c=`${c} + dashLength${g-2} + dashLength${g-1}`,u=`min(${u}, getSingleDashDistance(distance, radius, ${c}, dashLength${g}, totalDashLength, capType, lineWidth))`;i.functions[a]=`float ${a}(float distance, float radius, float capType, float lineWidth, ${l}) {
|
||
float totalDashLength = ${h};
|
||
return ${u};
|
||
}`;const d=s.map((g,_)=>`${g}`).join(", ");e.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${d})`);let f=s.join(" + ");e.getStrokePatternLengthExpression()&&(i.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
|
||
return patternLength1 * patternLength2;
|
||
}`,f=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${f})`),e.setStrokePatternLengthExpression(f)}}function Px(n,e,t,i){if("fill-color"in n&&e.setFillColorExpression(q(i,n["fill-color"],ye)),"fill-pattern-src"in n){const s=oo(n["fill-pattern-src"]),r=Sh(n,e,t,"fill-pattern-",s);let o=r,a="vec2(0.)";"fill-pattern-offset"in n&&"fill-pattern-size"in n&&(o=q(i,n["fill-pattern-size"],ot),a=vh(n,"fill-pattern-",i,r,o)),i.functions.sampleFillPattern=`vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 pxOrigin, vec2 pxPosition) {
|
||
float scaleRatio = pow(2., mod(u_zoom + 0.5, 1.) - 0.5);
|
||
vec2 pxRelativePos = pxPosition - pxOrigin;
|
||
// rotate the relative position from origin by the current view rotation
|
||
pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));
|
||
// sample position is computed according to the sample offset & size
|
||
vec2 samplePos = mod(pxRelativePos / scaleRatio, sampleSize);
|
||
// also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
||
samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
|
||
samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
|
||
return texture2D(texture, (samplePos + textureOffset) / textureSize);
|
||
}`;const l=`u_texture${s}`;let h="1.";"fill-color"in n&&(h=e.getFillColorExpression()),e.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${r}, ${a}, ${o}, pxOrigin, pxPos)`)}}function $c(n,e,t){const i=Od(),s=new zd,r={};if("icon-src"in n?vx(n,s,r,i):"shape-points"in n?Sx(n,s,r,i):"circle-radius"in n&&Cx(n,s,r,i),wx(n,s,r,i),Px(n,s,r,i),t){const l=q(i,t,Fe);s.setFragmentDiscardExpression(`!${l}`)}const o={};function a(l,h,c,u){if(!i[l])return;const d=rl(c),f=Th(c);s.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",Gd,Me,l=>Zs(nh(l.getGeometry()))),a("featureId",Nd,Me|B,l=>{const h=l.getId()??null;return typeof h=="string"?Zs(h):h}),kd(s,i),{builder:s,attributes:{...o,...Bd(i)},uniforms:{...r,...Ud(i,e)}}}const Ix=[];let Ea;function Ax(){return Ea||(Ea=px()),Ea}let Lx=0;const xt={POSITION:"a_position",LOCAL_POSITION:"a_localPosition",SEGMENT_START:"a_segmentStart",SEGMENT_END:"a_segmentEnd",MEASURE_START:"a_measureStart",MEASURE_END:"a_measureEnd",ANGLE_TANGENT_SUM:"a_angleTangentSum",JOIN_ANGLES:"a_joinAngles",DISTANCE_LOW:"a_distanceLow",DISTANCE_HIGH:"a_distanceHigh"};class Fx{constructor(e,t,i,s){this.helper_,this.hitDetectionEnabled_=!!s,this.styleShaders=bx(e,t),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return yx(this.ref,Ix)},size:2});for(const r of this.styleShaders){for(const o in r.attributes)o in this.customAttributes_||(this.customAttributes_[o]=r.attributes[o]);for(const o in r.uniforms)o in this.uniforms_||(this.uniforms_[o]=r.uniforms[o])}this.renderPasses_=this.styleShaders.map(r=>{const o={},a=Object.entries(this.customAttributes_).map(([l,h])=>({name:l in r.attributes||l==="hitColor"?`a_${l}`:null,size:h.size||1,type:Oe.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:xt.POSITION,size:2,type:Oe.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:xt.LOCAL_POSITION,size:2,type:Oe.FLOAT}],instancedAttributesDesc:[{name:xt.SEGMENT_START,size:2,type:Oe.FLOAT},{name:xt.MEASURE_START,size:1,type:Oe.FLOAT},{name:xt.SEGMENT_END,size:2,type:Oe.FLOAT},{name:xt.MEASURE_END,size:1,type:Oe.FLOAT},{name:xt.JOIN_ANGLES,size:2,type:Oe.FLOAT},{name:xt.DISTANCE_LOW,size:1,type:Oe.FLOAT},{name:xt.DISTANCE_HIGH,size:1,type:Oe.FLOAT},{name:xt.ANGLE_TANGENT_SUM,size:1,type:Oe.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:xt.LOCAL_POSITION,size:2,type:Oe.FLOAT}],instancedAttributesDesc:[{name:xt.POSITION,size:2,type:Oe.FLOAT},...a],instancePrimitiveVertexCount:6}),o}),this.hasFill_=this.renderPasses_.some(r=>r.fillRenderPass),this.hasStroke_=this.renderPasses_.some(r=>r.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(r=>r.symbolRenderPass),this.setHelper(i)}async generateBuffers(e,t){if(e.isEmpty())return null;const i=this.generateRenderInstructions_(e,t),[s,r,o]=await Promise.all([this.generateBuffersForType_(i.polygonInstructions,"Polygon",t),this.generateBuffersForType_(i.lineStringInstructions,"LineString",t),this.generateBuffersForType_(i.pointInstructions,"Point",t)]),a=Gs(Ce(),t);return{polygonBuffers:s,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(e,t){const i=this.hasFill_?Rx(e.polygonBatch,new Float32Array(0),this.customAttributes_,t):null,s=this.hasStroke_?Tx(e.lineStringBatch,new Float32Array(0),this.customAttributes_,t):null,r=this.hasSymbol_?Ex(e.pointBatch,new Float32Array(0),this.customAttributes_,t):null;return{polygonInstructions:i,lineStringInstructions:s,pointInstructions:r}}generateBuffersForType_(e,t,i){if(e===null)return null;const s=Lx++;let r;switch(t){case"Polygon":r=xa.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=xa.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=xa.GENERATE_POINT_BUFFERS;break}const o={id:s,type:r,renderInstructions:e.buffer,renderInstructionsTransform:i,customAttributesSize:Mo(this.customAttributes_)},a=Ax();return a.postMessage(o,[e.buffer]),e=null,new Promise(l=>{const h=c=>{const u=c.data;if(u.id!==s||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const d=new As(Fo,_a).fromArrayBuffer(u.indicesBuffer),f=new As(Vs,_a).fromArrayBuffer(u.vertexAttributesBuffer),g=new As(Vs,_a).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(e,t,i){for(const s of this.renderPasses_)s.fillRenderPass&&this.renderInternal_(e.polygonBuffers[0],e.polygonBuffers[1],e.polygonBuffers[2],s.fillRenderPass,t,i),s.strokeRenderPass&&this.renderInternal_(e.lineStringBuffers[0],e.lineStringBuffers[1],e.lineStringBuffers[2],s.strokeRenderPass,t,i),s.symbolRenderPass&&this.renderInternal_(e.pointBuffers[0],e.pointBuffers[1],e.pointBuffers[2],s.symbolRenderPass,t,i)}renderInternal_(e,t,i,s,r,o){const a=e.getSize();if(a===0)return;const l=s.instancedAttributesDesc.length;if(this.helper_.useProgram(s.program,r),this.helper_.bindBuffer(t),this.helper_.bindBuffer(e),this.helper_.enableAttributes(s.attributesDesc),this.helper_.bindBuffer(i),this.helper_.enableAttributesInstanced(s.instancedAttributesDesc),o(),l){const h=s.instancedAttributesDesc.reduce((u,d)=>u+(d.size||1),0),c=i.getSize()/h;this.helper_.drawElementsInstanced(0,a,c)}else this.helper_.drawElements(0,a)}setHelper(e,t=null){this.helper_=e;for(const i of this.renderPasses_)i.fillRenderPass&&(i.fillRenderPass.program=this.helper_.getProgram(i.fillRenderPass.fragmentShader,i.fillRenderPass.vertexShader)),i.strokeRenderPass&&(i.strokeRenderPass.program=this.helper_.getProgram(i.strokeRenderPass.fragmentShader,i.strokeRenderPass.vertexShader)),i.symbolRenderPass&&(i.symbolRenderPass.program=this.helper_.getProgram(i.symbolRenderPass.fragmentShader,i.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),t&&(t.polygonBuffers&&(this.helper_.flushBufferData(t.polygonBuffers[0]),this.helper_.flushBufferData(t.polygonBuffers[1]),this.helper_.flushBufferData(t.polygonBuffers[2])),t.lineStringBuffers&&(this.helper_.flushBufferData(t.lineStringBuffers[0]),this.helper_.flushBufferData(t.lineStringBuffers[1]),this.helper_.flushBufferData(t.lineStringBuffers[2])),t.pointBuffers&&(this.helper_.flushBufferData(t.pointBuffers[0]),this.helper_.flushBufferData(t.pointBuffers[1]),this.helper_.flushBufferData(t.pointBuffers[2])))}}function bx(n,e){const t=Array.isArray(n)?n:[n];if("style"in t[0]){const i=[],s=t,r=[];for(const o of s){const a=Array.isArray(o.style)?o.style:[o.style];let l=o.filter;o.else&&r.length&&(l=["all",...r.map(c=>["!",c])],o.filter&&l.push(o.filter),l.length<3&&(l=l[1])),o.filter&&r.push(o.filter);const h=a.map(c=>$c(c,e,l));i.push(...h)}return i}return"builder"in t[0]?t:t.map(i=>$c(i,e,null))}const Dt=new Uint8Array(4);class Mx{constructor(e,t){this.helper_=e;const i=e.getGL();this.texture_=i.createTexture(),this.framebuffer_=i.createFramebuffer(),this.depthbuffer_=i.createRenderbuffer(),this.size_=t||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(e){jt(e,this.size_)||(this.size_[0]=e[0],this.size_[1]=e[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const e=this.size_,t=this.helper_.getGL();t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.readPixels(0,0,e[0],e[1],t.RGBA,t.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(e,t){if(e<0||t<0||e>this.size_[0]||t>=this.size_[1])return Dt[0]=0,Dt[1]=0,Dt[2]=0,Dt[3]=0,Dt;this.readAll();const i=Math.floor(e)+(this.size_[1]-Math.floor(t)-1)*this.size_[0];return Dt[0]=this.data_[i*4],Dt[1]=this.data_[i*4+1],Dt[2]=this.data_[i*4+2],Dt[3]=this.data_[i*4+3],Dt}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const e=this.size_,t=this.helper_.getGL();this.texture_=this.helper_.createTexture(e,null,this.texture_),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.viewport(0,0,e[0],e[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture_,0),t.bindRenderbuffer(t.RENDERBUFFER,this.depthbuffer_),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e[0],e[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(e[0]*e[1]*4)}}function Dx(n,e){const t=n.viewState.projection,s=e.getSource().getWrapX()&&t.canWrapX(),r=t.getExtent(),o=n.extent,a=s?te(r):null,l=s?Math.ceil((o[2]-r[2])/a)+1:1;return[s?Math.floor((o[0]-r[0])/a):0,l,a]}const Sn={...qt,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class Ox extends bo{constructor(e,t){const i={[Sn.RENDER_EXTENT]:[0,0,0,0],[Sn.PATTERN_ORIGIN]:[0,0],[Sn.GLOBAL_ALPHA]:1};super(e,{uniforms:i,postProcesses:t.postProcesses}),this.hitDetectionEnabled_=!t.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=Qe(),this.currentTransform_=Ce(),this.tmpCoords_=[0,0],this.tmpTransform_=Ce(),this.tmpMat4_=ln(),this.currentFrameStateTransform_=Ce(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(t),this.batch_=new ro,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(e){const t=this.getLayer().getSource();let i;this.batch_.addFeatures(t.getFeatures(),i),this.sourceListenKeys_=[ee(t,Ne.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,i)),ee(t,Ne.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,i),this),ee(t,Ne.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),ee(t,Ne.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(e){this.styleVariables_=e.variables,this.style_=e.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new Fx(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(e){this.applyOptions_(e),this.helper&&this.createRenderers_(),super.reset(e)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new Mx(this.helper))}handleSourceFeatureAdded_(e,t){const i=t.feature;this.batch_.addFeature(i,e)}handleSourceFeatureChanged_(e,t){const i=t.feature;this.batch_.changeFeature(i,e)}handleSourceFeatureDelete_(e){const t=e.feature;this.batch_.removeFeature(t)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(e){Tu(this.tmpTransform_,this.currentFrameStateTransform_),Qs(this.tmpTransform_,e),this.helper.setUniformMatrixValue(Sn.PROJECTION_MATRIX,no(this.tmpMat4_,this.tmpTransform_)),Gs(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(Sn.SCREEN_TO_WORLD_MATRIX,no(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Gs(this.tmpTransform_,e),me(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(Sn.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(e){const t=this.helper.getGL();this.preRender(t,e);const[i,s,r]=Dx(e,this.getLayer());this.helper.prepareDraw(e),this.renderWorlds(e,!1,i,s,r),this.helper.finalizeDraw(e,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(e,!0,i,s,r),this.hitRenderTarget_.clearCachedData()),this.postRender(t,e),o}prepareFrameInternal(e){this.initialFeaturesAdded_||(this.addInitialFeatures_(e),this.initialFeaturesAdded_=!0);const t=this.getLayer(),i=t.getSource(),s=e.viewState,r=!e.viewHints[de.ANIMATING]&&!e.viewHints[de.INTERACTING],o=!qi(this.previousExtent_,e.extent),a=this.sourceRevision_<i.getRevision();if(a&&(this.sourceRevision_=i.getRevision()),r&&(o||a)){const l=s.projection,h=s.resolution,c=t instanceof os?t.getRenderBuffer():0,u=ai(e.extent,c*h);i.loadFeatures(u,h,l),this.ready=!1;const d=this.helper.makeProjectionTransform(e,Ce());this.styleRenderer_.generateBuffers(this.batch_,d).then(f=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=f,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=e.extent.slice()}return!0}renderWorlds(e,t,i,s,r){let o=i;t&&(this.hitRenderTarget_.setSize([Math.floor(e.size[0]/2),Math.floor(e.size[1]/2)]),this.helper.prepareDrawToRenderTarget(e,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(e,this.currentFrameStateTransform_),Fl(this.currentFrameStateTransform_,o*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,e,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform),this.helper.applyHitDetectionUniform(t)});while(++o<s)}forEachFeatureAtCoordinate(e,t,i,s,r){if(se(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.styleRenderer_||!this.hitDetectionEnabled_)return;const o=me(t.coordinateToPixelTransform,e.slice()),a=this.hitRenderTarget_.readPixel(o[0]/2,o[1]/2),l=[a[0]/255,a[1]/255,a[2]/255,a[3]/255],h=xx(l),c=this.batch_.getFeatureFromRef(h);if(c)return s(c,this.getLayer(),null)}disposeBuffers(e){const t=i=>{for(const s of i)s&&this.helper.deleteBuffer(s)};e.pointBuffers&&t(e.pointBuffers),e.lineStringBuffers&&t(e.lineStringBuffers),e.polygonBuffers&&t(e.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(e){ue(e)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Ht={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},Nx=["#00f","#0ff","#0f0","#ff0","#f00"];class ST extends os{constructor(e){e=e||{};const t=Object.assign({},e);delete t.gradient,delete t.radius,delete t.blur,delete t.weight,super(t),this.filter_=e.filter??!0,this.styleVariables_=e.variables||{},this.gradient_=null,this.addChangeListener(Ht.GRADIENT,this.handleGradientChanged_),this.setGradient(e.gradient?e.gradient:Nx),this.setBlur(e.blur!==void 0?e.blur:15),this.setRadius(e.radius!==void 0?e.radius:8);const i=e.weight?e.weight:"weight";this.weight_=i,this.setRenderOrder(null)}getBlur(){return this.get(Ht.BLUR)}getGradient(){return this.get(Ht.GRADIENT)}getRadius(){return this.get(Ht.RADIUS)}handleGradientChanged_(){this.gradient_=Gx(this.getGradient())}setBlur(e){const t=this.get(Ht.BLUR);if(this.set(Ht.BLUR,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setGradient(e){this.set(Ht.GRADIENT,e)}setRadius(e){const t=this.get(Ht.RADIUS);if(this.set(Ht.RADIUS,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setFilter(e){this.filter_=e,this.changed(),this.clearRenderer()}setWeight(e){this.weight_=e,this.changed(),this.clearRenderer()}createRenderer(){const e=new zd,t=Od(),i=q(t,this.filter_,Fe);let s=q(t,this.getRadius(),B),r=q(t,this.getBlur(),B);const o={};typeof this.getBlur()=="number"&&(r="a_blur",o.a_blur=()=>this.getBlur(),e.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(s="a_radius",o.a_radius=()=>this.getRadius(),e.addUniform("a_radius","float"));const a={};let l=null;if(typeof this.weight_=="string"||typeof this.weight_=="function"){const u=typeof this.weight_=="string"?d=>d.get(this.weight_):this.weight_;a.prop_weight={size:1,callback:d=>{const f=u(d);return f!==void 0?_e(f,0,1):1}},l="a_prop_weight",e.addAttribute("a_prop_weight","float")}else{const u=["clamp",this.weight_,0,1];l=q(t,u,B)}e.addFragmentShaderFunction(`float getBlurSlope() {
|
||
float blur = max(1., ${r});
|
||
float radius = ${s};
|
||
return radius / blur;
|
||
}`).setSymbolSizeExpression(`vec2(${s} + ${r}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * getBlurSlope()) * ${l})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * getBlurSlope()) * ${l})`).setStrokeWidthExpression(`(${s} + ${r}) * 2.`).setFillColorExpression(`vec4(${l})`).setFragmentDiscardExpression(`!${i}`),kd(e,t);const h=Bd(t),c=Ud(t,this.styleVariables_);return new Ox(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:e,attributes:{...h,...a},uniforms:{...c,...o}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
|
||
precision mediump float;
|
||
|
||
uniform sampler2D u_image;
|
||
uniform sampler2D u_gradientTexture;
|
||
uniform float u_opacity;
|
||
|
||
varying vec2 v_texCoord;
|
||
|
||
void main() {
|
||
vec4 color = texture2D(u_image, v_texCoord);
|
||
gl_FragColor.a = color.a * u_opacity;
|
||
gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(e){Object.assign(this.styleVariables_,e),this.changed()}renderDeclutter(){}}function Gx(n){const i=Te(1,256),s=i.createLinearGradient(0,0,1,256),r=1/(n.length-1);for(let o=0,a=n.length;o<a;++o)s.addColorStop(o*r,n[o]);return i.fillStyle=s,i.fillRect(0,0,1,256),i.canvas}function wi(n,e){const t=n.length;return e<0?n[e+t]:e>=t?n[e-t]:n[e]}function Dn(n,e){const t=n.length;let i=Math.floor(e);const s=e-i;i>=t?i-=t:i<0&&(i+=t);let r=i+1;r>=t&&(r-=t);const o=n[i],a=o[0],l=o[1],h=n[r],c=h[0]-a,u=h[1]-l;return[a+c*s,l+u*s]}const vr={index:-1,endIndex:NaN,closestTargetDistance:1/0};function jd(n,e,t,i){const s=n[0],r=n[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<e.targets.length;++u){const d=e.targets[u],f=d.coordinates;let g=1/0,_;for(let m=0;m<f.length-1;++m){const y=f[m],p=f[m+1],T=Yd(s,r,y,p);T.squaredDistance<g&&(g=T.squaredDistance,_=m+T.along)}g<o&&(o=g,d.ring&&e.targetIndex===u&&(d.endIndex>d.startIndex?_<d.startIndex&&(_+=f.length):d.endIndex<d.startIndex&&_>d.startIndex&&(_-=f.length)),l=_,a=u)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const u=Dn(h.coordinates,l),d=t.getPixelFromCoordinate(u),f=t.getPixelFromCoordinate(e.startCoord);Fn(d,f)>i&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const _=Ir(u,f,g);Ir(u,f,g-d)<_&&(l-=d)}else{const _=Ir(u,f,g);Ir(u,f,g+d)<_&&(l+=d)}}return vr.index=a,vr.endIndex=l,vr.closestTargetDistance=o,vr}function $d(n,e){const t=[];for(let i=0;i<e.length;++i){const r=e[i].getGeometry();Wd(n,r,t)}return t}function Wd(n,e,t){if(e instanceof dt){wr(n,e.getCoordinates(),!1,t);return}if(e instanceof hi){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s)wr(n,i[s],!1,t);return}if(e instanceof rt){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s)wr(n,i[s],!0,t);return}if(e instanceof bi){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length;a<l;++a)wr(n,o[a],!0,t)}return}if(e instanceof Je){const i=e.getGeometries();for(let s=0;s<i.length;++s)Wd(n,i[s],t);return}}function wr(n,e,t,i){const s=n[0],r=n[1];for(let o=0,a=e.length-1;o<a;++o){const l=e[o],h=e[o+1],c=Yd(s,r,l,h);if(c.squaredDistance===0){const u=o+c.along;i.push({coordinates:e,ring:t,startIndex:u,endIndex:u});return}}}function Pr(n,e){return ni(n[0],n[1],e[0],e[1])}function Ir(n,e,t){let i,s;e<t?(i=e,s=t):(i=t,s=e);const r=Math.ceil(i),o=Math.floor(s);if(r>o){const l=Dn(n,i),h=Dn(n,s);return Pr(l,h)}let a=0;if(i<r){const l=Dn(n,i),h=wi(n,r);a+=Pr(l,h)}if(o<s){const l=wi(n,o),h=Dn(n,s);a+=Pr(l,h)}for(let l=r;l<o-1;++l){const h=wi(n,l),c=wi(n,l+1);a+=Pr(h,c)}return a}const Ta={along:0,squaredDistance:0};function Yd(n,e,t,i){const s=t[0],r=t[1],o=i[0],a=i[1],l=o-s,h=a-r;let c=0,u=s,d=r;return(l!==0||h!==0)&&(c=_e(((n-s)*l+(e-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),Ta.along=c,Ta.squaredDistance=es(ni(n,e,u,d),10),Ta}const Ar={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class Lr extends Pt{constructor(e,t){super(e),this.feature=t}}class vT extends rn{constructor(e){const t=e;t.stopDown||(t.stopDown=Jn),super(t),this.on,this.once,this.un,this.options_=e,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=Ux(this.type_),this.stopClick_=!!e.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:Li,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let i=e.geometryFunction;if(!i){const s=this.mode_;if(s==="Circle")i=(r,o,a)=>{const l=o||new Ao([NaN,NaN]),h=xe(r[0]),c=$n(h,xe(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;s==="Point"?r=ut:s==="LineString"?r=dt:s==="Polygon"&&(r=rt),i=(o,a,l)=>(a?s==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new uh({source:new Rd({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:kx(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:Zl,this.freehandCondition_,e.freehand?this.freehandCondition_=Nn:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Zr,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(ja.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=Nn:t=e:t=Vr,this.traceCondition_=t}setMap(e){super.setMap(e),this.updateState_()}setFreehand(e){this.freehand_=e,this.freehand_?this.freehandCondition_=Nn:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Zr}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(e){e.originalEvent.type===Z.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let t=e.type===ne.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&e.type===ne.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,t=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===ne.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),i=!1):this.freehand_&&e.type===ne.POINTERDOWN?i=!1:t&&this.getPointerCount()<2?(i=e.type===ne.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===ne.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===ne.DBLCLICK&&(i=!1),super.handleEvent(e)&&i}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Jt(ne.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}const t=this.getMap(),i=t.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),s=t.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),r=Be([i,s]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=$d(e.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const i=e.startIndex<=e.endIndex,s=e.startIndex<=t;i===s?i&&t>e.endIndex||!i&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(i&&t<e.endIndex||!i&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let i=0;if(e<t){const s=Math.ceil(e);let r=Math.floor(t);r===t&&(r-=1),i=r-s+1}else{const s=Math.floor(e);let r=Math.ceil(t);r===t&&(r+=1),i=s-r+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(e,t,i){if(t===i)return;const s=[];if(t<i){const r=Math.ceil(t);let o=Math.floor(i);o===i&&(o-=1);for(let a=r;a<=o;++a)s.push(wi(e.coordinates,a))}else{const r=Math.floor(t);let o=Math.ceil(i);o===i&&(o+=1);for(let a=r;a>=o;--a)s.push(wi(e.coordinates,a))}s.length&&this.appendCoordinates(s)}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const a=e.map.getPixelFromCoordinate(t.startCoord);if(Fn(a,e.pixel)<this.snapTolerance_)return}const i=jd(e.coordinate,t,this.getMap(),this.snapTolerance_);if(t.targetIndex!==i.index){if(t.targetIndex!==-1){const l=t.targets[t.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=t.targets[i.index];this.addTracedCoordinates_(a,a.startIndex,i.endIndex)}else{const a=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(a,i.endIndex)}t.targetIndex=i.index;const s=t.targets[t.targetIndex];s.endIndex=i.endIndex;const r=Dn(s.coordinates,s.endIndex),o=this.getMap().getPixelFromCoordinate(r);e.coordinate=r,e.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(e){this.ignoreNextUpEvent_=!0,super.handleDragEvent(e)}handleUpEvent(e){let t=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);const i=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(e),this.shouldHandle_){const s=!this.finishCoordinate_;s&&this.startDrawing_(e.coordinate),!s&&this.freehand_?this.finishDrawing():!this.freehand_&&(!s||this.mode_==="Point")&&(this.atFinish_(e.pixel,i)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),t=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!t&&this.stopClick_&&e.preventDefault(),t}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const t=this.downPx_,i=e.pixel,s=t[0]-i[0],r=t[1]-i[1],o=s*s+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,t){let i=!1;if(this.sketchFeature_){let s=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")s=!t&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;s=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],t?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(s){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=e[0]-u[0],f=e[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(d*d+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new $e(new ut(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new $e);const t=e.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(t.getLayout(),t.getFlatCoordinates()),i.changed()):(i=new dt(t.getFlatCoordinates(),t.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(e){const t=this.getMap().getView().getProjection(),i=$r(this.geometryLayout_);for(;e.length<i;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new $e(new dt(this.sketchLineCoords_)));const s=this.geometryFunction_(this.sketchCoords_,void 0,t);this.sketchFeature_=new $e,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(s),this.updateSketchFeatures_(),this.dispatchEvent(new Lr(Ar.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){const t=this.getMap(),i=this.sketchFeature_.getGeometry(),s=t.getView().getProjection(),r=$r(this.geometryLayout_);let o,a;for(;e.length<r;)e.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(t.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=e[0],a[1]=e[1],this.geometryFunction_(this.sketchCoords_,i,s),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){const t=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection();let s,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=e.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():s=!0),r.push(e.slice()),this.geometryFunction_(r,t,i)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():s=!0),r.push(e.slice()),s&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,t,i)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),s?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;const t=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),s=this.mode_;for(let r=0;r<e;++r){let o;if(s==="LineString"||s==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,t,i),t.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(s==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,t,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const e=this.abortDrawing_();if(!e)return null;let t=this.sketchCoords_;const i=e.getGeometry(),s=this.getMap().getView().getProjection();return this.mode_==="LineString"?(t.pop(),this.geometryFunction_(t,i,s)):this.mode_==="Polygon"&&(t[0].pop(),this.geometryFunction_(t,i,s),t=i.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new an([t])):this.type_==="MultiLineString"?e.setGeometry(new hi([t])):this.type_==="MultiPolygon"&&e.setGeometry(new bi([t])),this.dispatchEvent(new Lr(Ar.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;const e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){const e=this.abortDrawing_();e&&this.dispatchEvent(new Lr(Ar.DRAWABORT,e))}appendCoordinates(e){const t=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(e[0]);let s;if(t==="LineString"||t==="Circle")s=this.sketchCoords_;else if(t==="Polygon")s=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&s.shift(),s.pop();for(let o=0;o<e.length;o++)this.addToDrawing_(e[o]);const r=e[e.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(e){const i=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=i.getCoordinates();const s=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=s.slice(),this.sketchCoords_.push(s.slice()),this.sketchPoint_=new $e(new ut(s)),this.updateSketchFeatures_(),this.dispatchEvent(new Lr(Ar.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);const t=this.overlay_.getSource();t.clear(!0),t.addFeatures(e)}updateState_(){const e=this.getMap(),t=this.getActive();(!e||!t)&&this.abortDrawing(),this.overlay_.setMap(t?e:null)}}function kx(){const n=sh();return function(e,t){return n[e.getGeometry().getType()]}}function Ux(n){switch(n){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+n)}}const Fr={SELECT:"select"};class br extends Pt{constructor(e,t,i,s){super(e),this.selected=t,this.deselected=i,this.mapBrowserEvent=s}}const Mr={};class Vd extends ns{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=e.condition?e.condition:ku,this.addCondition_=e.addCondition?e.addCondition:Vr,this.removeCondition_=e.removeCondition?e.removeCondition:Vr,this.toggleCondition_=e.toggleCondition?e.toggleCondition:Zr,this.multi_=e.multi?e.multi:!1,this.filter_=e.filter?e.filter:Li,this.hitTolerance_=e.hitTolerance?e.hitTolerance:0,this.style_=e.style!==void 0?e.style:Bx(),this.features_=e.features||new qe;let t;if(e.layers)if(typeof e.layers=="function")t=e.layers;else{const i=e.layers;t=function(s){return i.includes(s)}}else t=Li;this.layerFilter_=t,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(e,t){this.featureLayerAssociation_[O(e)]=t}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(e){return this.featureLayerAssociation_[O(e)]}setHitTolerance(e){this.hitTolerance_=e}setMap(e){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(e),e?(this.features_.addEventListener(Le.ADD,this.boundAddFeature_),this.features_.addEventListener(Le.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(Le.ADD,this.boundAddFeature_),this.features_.removeEventListener(Le.REMOVE,this.boundRemoveFeature_))}addFeature_(e){const t=e.element;if(this.style_&&this.applySelectedStyle_(t),!this.getLayer(t)){const i=this.findLayerOfFeature_(t);i&&this.addFeatureLayerAssociation_(t,i)}}removeFeature_(e){this.style_&&this.restorePreviousStyle_(e.element)}findLayerOfFeature_(e){return this.getMap().getAllLayers().find(function(i){if(i instanceof uh&&i.getSource()&&i.getSource().hasFeature(e))return i})}getStyle(){return this.style_}applySelectedStyle_(e){const t=O(e);t in Mr||(Mr[t]=e.getStyle()),e.setStyle(this.style_)}restorePreviousStyle_(e){const t=this.getMap().getInteractions().getArray();for(let s=t.length-1;s>=0;--s){const r=t[s];if(r!==this&&r instanceof Vd&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(e)!==-1){e.setStyle(r.getStyle());return}}const i=O(e);e.setStyle(Mr[i]),delete Mr[i]}removeFeatureLayerAssociation_(e){delete this.featureLayerAssociation_[O(e)]}selectFeatureInternal_(e,t,i){if(!(e instanceof $e)||!this.filter_(e,t))return;const s=this.getFeatures();return s.getArray().includes(e)||(this.addFeatureLayerAssociation_(e,t),s.push(e),i?.push(e)),e}selectFeature(e){const t=this.findLayerOfFeature_(e);if(!this.layerFilter_(t))return!1;const i=this.selectFeatureInternal_(e,t);return i&&this.dispatchEvent(new br(Fr.SELECT,[i],[],void 0)),!!i}removeFeatureInternal_(e,t){const i=this.getFeatures();if(!(!(e instanceof $e)||!i.getArray().includes(e)))return i.remove(e),this.removeFeatureLayerAssociation_(e),t?.push(e),e}deselectFeature(e){const t=this.removeFeatureInternal_(e);return t&&this.dispatchEvent(new br(Fr.SELECT,[],[t],void 0)),!!t}toggleFeature(e){this.deselectFeature(e)||this.selectFeature(e)}clearSelection(){tn(this.featureLayerAssociation_);const e=this.getFeatures(),t=e.getArray().slice();e.clear(),t.length!==0&&this.dispatchEvent(new br(Fr.SELECT,[],t,void 0))}handleEvent(e){if(!this.condition_(e))return!0;const t=this.addCondition_(e),i=this.removeCondition_(e),s=this.toggleCondition_(e),r=!t&&!i&&!s,o=e.map,a=this.getFeatures(),l=[],h=[];if(r){let c=!1;o.forEachFeatureAtPixel(e.pixel,(u,d)=>{if(c=!0,!!this.selectFeatureInternal_(u,d,h))return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let u=a.getLength()-1;u>=0;--u){const d=a.item(u);(h.length>0&&!h.includes(d)||!c)&&this.removeFeatureInternal_(d,l)}}else o.forEachFeatureAtPixel(e.pixel,(c,u)=>{let d;if((i||s)&&(d=this.removeFeatureInternal_(c,l)),(t||s)&&!d&&(d=this.selectFeatureInternal_(c,u,h)),!!d)return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});return(h.length>0||l.length>0)&&this.dispatchEvent(new br(Fr.SELECT,h,l,e)),!0}}function Bx(){const n=sh();return oe(n.Polygon,n.LineString),oe(n.GeometryCollection,n.LineString),function(e){return e.getGeometry()?n[e.getGeometry().getType()]:null}}const Wc=0,Ls=1,Yc=[0,0,0,0],Bn=[],Ra={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};function Ca(n,e,t){let i;switch(e){case"LineString":i=n;break;case"MultiLineString":case"Polygon":i=n[t[0]];break;case"MultiPolygon":i=n[t[1]][t[0]];break}return i}class Sa extends Pt{constructor(e,t,i){super(e),this.features=t,this.mapBrowserEvent=i}}class wT extends rn{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:Bu,this.defaultDeleteCondition_=function(i){return v_(i)&&ku(i)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:Nn,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Qa,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new uh({source:new Rd({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:Xx(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.traceSource_=e.traceSource||e.source||null,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null;let t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new qe(this.source_.getFeatures()),this.source_.addEventListener(Ne.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Ne.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Le.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Le.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}setTrace(e){let t;e?e===!0?t=Nn:t=e:t=Vr,this.traceCondition_=t}addFeature_(e){const t=e.getGeometry();if(t){const s=this.SEGMENT_WRITERS_[t.getType()];s&&s(e,t)}const i=this.getMap();i&&i.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_),e.addEventListener(Z.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new qe;const i=this.featuresBeingModified_.getArray();for(let s=0,r=t.length;s<r;++s){const o=t[s].feature;o&&!i.includes(o)&&this.featuresBeingModified_.push(o)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Sa(Ra.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(Z.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){const t=this.rBush_,i=[];t.forEach(function(s){e===s.feature&&i.push(s)});for(let s=i.length-1;s>=0;--s){const r=i[s];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===r&&this.dragSegments_.splice(o,1);t.remove(r)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){const t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){const i=t.getCoordinates(),s={feature:e,geometry:t,segment:[i,i]};this.rBush_.insert(t.getExtent(),s)}writeMultiPointGeometry_(e,t){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s],a={feature:e,geometry:t,depth:[s],index:s,segment:[o,o]};this.rBush_.insert(t.getExtent(),a)}}writeLineStringGeometry_(e,t){const i=t.getCoordinates();for(let s=0,r=i.length-1;s<r;++s){const o=i.slice(s,s+2),a={feature:e,geometry:t,index:s,segment:o};this.rBush_.insert(Be(o),a)}}writeMultiLineStringGeometry_(e,t){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[s],index:a,segment:h};this.rBush_.insert(Be(h),c)}}}writePolygonGeometry_(e,t){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[s],index:a,segment:h};this.rBush_.insert(Be(h),c)}}}writeMultiPolygonGeometry_(e,t){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length;a<l;++a){const h=o[a];for(let c=0,u=h.length-1;c<u;++c){const d=h.slice(c,c+2),f={feature:e,geometry:t,depth:[a,s],index:c,segment:d};this.rBush_.insert(Be(d),f)}}}}writeCircleGeometry_(e,t){const i=t.getCenter(),s={feature:e,geometry:t,index:Wc,segment:[i,i]},r={feature:e,geometry:t,index:Ls,segment:[i,i]},o=[s,r];s.featureSegments=o,r.featureSegments=o,this.rBush_.insert(Cs(i),s);let a=t;this.rBush_.insert(a.getExtent(),r)}writeGeometryCollectionGeometry_(e,t){const i=t.getGeometriesArray();for(let s=0;s<i.length;++s){const r=i[s],o=this.SEGMENT_WRITERS_[r.getType()];o(e,r)}}createOrUpdateVertexFeature_(e,t,i,s){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(e):(r=new $e(new ut(e)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",t),r.set("geometries",i),r.set("existing",s),r}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==ne.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=ne.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==ne.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}findInsertVerticesAndUpdateDragSegments_(e){if(this.handlePointerAtPixel_(e),this.dragSegments_.length=0,this.featuresBeingModified_=null,!this.vertexFeature_)return;this.getMap().getView().getProjection();const i=[],s=this.vertexFeature_.getGeometry().getCoordinates(),r=Be([s]),o=this.rBush_.getInExtent(r),a={};o.sort(zx);for(let l=0,h=o.length;l<h;++l){const c=o[l],u=c.segment;let d=O(c.geometry);const f=c.depth;if(f&&(d+="-"+f.join("-")),a[d]||(a[d]=new Array(2)),c.geometry.getType()==="Circle"&&c.index===Ls){const g=Zc(e,c);He(g,s)&&!a[d][0]&&(this.dragSegments_.push([c,0]),a[d][0]=c);continue}if(He(u[0],s)&&!a[d][0]){this.dragSegments_.push([c,0]),a[d][0]=c;continue}if(He(u[1],s)&&!a[d][1]){if(a[d][0]&&a[d][0].index===0){let g=c.geometry.getCoordinates();switch(c.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":g=g[f[1]];case"Polygon":if(c.index!==g[f[0]].length-2)continue;break}}this.dragSegments_.push([c,1]),a[d][1]=c;continue}O(u)in this.vertexSegments_&&!a[d][0]&&!a[d][1]&&i.push(c)}return i}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const r=e.map.getPixelFromCoordinate(t.startCoord);if(Fn(r,e.pixel)<this.pixelTolerance_)return}const i=jd(e.coordinate,t,e.map,this.pixelTolerance_);if(t.targetIndex===-1&&Math.sqrt(i.closestTargetDistance)/e.map.getView().getResolution()>this.pixelTolerance_)return;if(t.targetIndex!==i.index){if(t.targetIndex!==-1){const o=t.targets[t.targetIndex];this.removeTracedCoordinates_(o.startIndex,o.endIndex)}else for(const o of this.traceSegments_){const a=o[0],l=a.geometry,h=o[1],c=l.getCoordinates();Ca(c,l.getType(),a.depth).splice(a.index+h,1),l.setCoordinates(c),h===0&&(a.index-=1)}const r=t.targets[i.index];this.addTracedCoordinates_(r,r.startIndex,i.endIndex)}else{const r=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(r,i.endIndex)}t.targetIndex=i.index;const s=t.targets[t.targetIndex];s.endIndex=i.endIndex}getTraceCandidates_(e){const t=this.getMap(),i=this.pixelTolerance_,s=t.getCoordinateFromPixel([e.pixel[0]-i,e.pixel[1]+i]),r=t.getCoordinateFromPixel([e.pixel[0]+i,e.pixel[1]-i]),o=Be([s,r]);return this.traceSource_.getFeaturesInExtent(o)}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_(),this.traceSegments_=null;return}const t=this.getTraceCandidates_(e);if(t.length===0)return;const i=$d(e.coordinate,t);i.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:i,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const i=e.startIndex<=e.endIndex,s=e.startIndex<=t;i===s?i&&t>e.endIndex||!i&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(i&&t<e.endIndex||!i&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let i=0;if(e<t){const s=Math.ceil(e);let r=Math.floor(t);r===t&&(r-=1),i=r-s+1}else{const s=Math.floor(e);let r=Math.ceil(t);r===t&&(r+=1),i=s-r+1}if(i>0)for(const s of this.traceSegments_){const r=s[0],o=r.geometry,a=s[1];let l=s[0].index+1;a===1&&(l-=i);const h=o.getCoordinates();Ca(h,o.getType(),r.depth).splice(l,i),o.setCoordinates(h),a===1&&(r.index-=i)}}addTracedCoordinates_(e,t,i){if(t===i)return;const s=[];if(t<i){const r=Math.ceil(t);let o=Math.floor(i);o===i&&(o-=1);for(let a=r;a<=o;++a)s.push(wi(e.coordinates,a))}else{const r=Math.floor(t);let o=Math.ceil(i);o===i&&(o+=1);for(let a=r;a>=o;--a)s.push(wi(e.coordinates,a))}if(s.length)for(const r of this.traceSegments_){const o=r[0],a=o.geometry,l=r[1],h=o.index+1;l===0&&s.reverse();const c=a.getCoordinates();Ca(c,a.getType(),o.depth).splice(h,0,...s),a.setCoordinates(c),l===1&&(o.index+=s.length)}}updateGeometry_(e,t){const i=t[0],s=i.depth;let r;const o=i.segment,a=i.geometry,l=t[1];for(;e.length<a.getStride();)e.push(o[l][e.length]);switch(a.getType()){case"Point":r=e,o[0]=e,o[1]=e;break;case"MultiPoint":r=a.getCoordinates(),r[i.index]=e,o[0]=e,o[1]=e;break;case"LineString":r=a.getCoordinates(),r[i.index+l]=e,o[l]=e;break;case"MultiLineString":r=a.getCoordinates(),r[s[0]][i.index+l]=e,o[l]=e;break;case"Polygon":r=a.getCoordinates(),r[s[0]][i.index+l]=e,o[l]=e;break;case"MultiPolygon":r=a.getCoordinates(),r[s[1]][s[0]][i.index+l]=e,o[l]=e;break;case"Circle":const h=a;if(o[0]=e,o[1]=e,i.index===Wc)this.changingFeature_=!0,h.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0,this.getMap().getView().getProjection();let c=Fn(xe(h.getCenter()),xe(e));h.setRadius(c),this.changingFeature_=!1}break}r&&this.setGeometryCoordinates_(a,r)}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_.map(([o])=>o));const t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],i=[],s=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const o of this.dragSegments_){const a=o[0];Fn(Tl(r,a.segment),r)/e.map.getView().getResolution()<1&&this.traceSegments_.push(o)}}for(let o=0,a=this.dragSegments_.length;o<a;++o){const l=this.dragSegments_[o],h=l[0],c=h.feature;i.includes(c)||i.push(c);const u=h.geometry;s.includes(u)||s.push(u),this.updateGeometry_(t,l)}this.updateTrace_(e),this.createOrUpdateVertexFeature_(t,i,s,!0)}handleDownEvent(e){if(!this.condition_(e))return!1;const t=e.coordinate,i=this.findInsertVerticesAndUpdateDragSegments_(t);if(i?.length&&this.insertVertexCondition_(e)&&(this.willModifyFeatures_(e,i),this.vertexFeature_)){const s=this.vertexFeature_.getGeometry().getCoordinates();for(let r=i.length-1;r>=0;--r)this.insertVertex_(i[r],s);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){const i=this.dragSegments_[t][0],s=i.geometry;if(s.getType()==="Circle"){const r=s,o=r.getCenter(),a=i.featureSegments[0],l=i.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(Cs(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(Be(i.segment),i)}return this.featuresBeingModified_&&(this.toggleTraceState_(e),this.dispatchEvent(new Sa(Ra.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastCoordinate_=e.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(e){const t=this.getMap(),i=t.getPixelFromCoordinate(e);t.getView().getProjection();const s=function(a,l){return Vc(e,a)-Vc(e,l)};let r,o;if(this.hitDetection_){const a=typeof this.hitDetection_=="object"?l=>l===this.hitDetection_:void 0;t.forEachFeatureAtPixel(i,(l,h,c)=>{c&&c.getType()==="Point"&&(c=new ut(Qi(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof $e&&this.features_.getArray().includes(l)){o=u;const d=l.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:l,geometry:o,segment:[d,d]}]}return!0},{layerFilter:a})}if(!r){const a=ct(Cs(e,Yc)),l=t.getView().getResolution()*this.pixelTolerance_,h=mo(ai(a,l,Yc));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(s)[0],l=a.segment;let h=Zc(e,a);const c=t.getPixelFromCoordinate(h);let u=Fn(i,c);if(o||u<=this.pixelTolerance_){const d={};if(d[O(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-e[0],this.delta_[1]=h[1]-e[1]),a.geometry.getType()==="Circle"&&a.index===Ls)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const f=t.getPixelFromCoordinate(l[0]),g=t.getPixelFromCoordinate(l[1]),_=$n(c,f),m=$n(c,g);if(u=Math.sqrt(Math.min(_,m)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(h=_>m?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const y={};y[O(a.geometry)]=!0;for(let p=1,T=r.length;p<T;++p){const x=r[p].segment;if(He(l[0],x[0])&&He(l[1],x[1])||He(l[0],x[1])&&He(l[1],x[0])){const E=O(r[p].geometry);E in y||(y[E]=!0,d[O(x)]=!0)}else break}}this.vertexSegments_=d;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){const i=e.segment,s=e.feature,r=e.geometry,o=e.depth,a=e.index;let l;for(;t.length<r.getStride();)t.push(0);switch(r.getType()){case"MultiLineString":l=r.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"Polygon":l=r.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"MultiPolygon":l=r.getCoordinates(),l[o[1]][o[0]].splice(a+1,0,t);break;case"LineString":l=r.getCoordinates(),l.splice(a+1,0,t);break;default:return!1}this.setGeometryCoordinates_(r,l);const h=this.rBush_;h.remove(e),this.updateSegmentIndices_(r,a,o,1);const c={segment:[i[0],t],feature:s,geometry:r,depth:o,index:a};h.insert(Be(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[t,i[1]],feature:s,geometry:r,depth:o,index:a+1};return h.insert(Be(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(e){return e&&this.findInsertVerticesAndUpdateDragSegments_(e),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){const e=this.vertexFeature_?.getGeometry().getCoordinates();return e?Qi(e,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Be([e])).some(({segment:i})=>He(i[0],e)||He(i[1],e))}removePoint(e){if(e&&(e=xe(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=ne.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([s])=>s));const i=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Sa(Ra.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,i}return!1}removeVertex_(){const e=this.dragSegments_,t={};let i=!1,s,r,o,a,l,h,c,u,d,f,g;for(l=e.length-1;l>=0;--l)o=e[l],f=o[0],g=O(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in t||(t[g]={}),o[1]===0?(t[g].right=f,t[g].index=f.index):o[1]==1&&(t[g].left=f,t[g].index=f.index+1);for(g in t){switch(d=t[g].right,c=t[g].left,h=t[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,r=a.getCoordinates(),s=r,i=!1,a.getType()){case"MultiLineString":r[f.depth[0]].length>2&&(r[f.depth[0]].splice(h,1),i=!0);break;case"LineString":r.length>2&&(r.splice(h,1),i=!0);break;case"MultiPolygon":s=s[f.depth[1]];case"Polygon":s=s[f.depth[0]],s.length>4&&(h==s.length-1&&(h=0),s.splice(h,1),i=!0,h===0&&(s.pop(),s.push(s[0]),u=s.length-1));break}if(i){this.setGeometryCoordinates_(a,r);const _=[];if(c!==void 0&&(this.rBush_.remove(c),_.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),_.push(d.segment[1])),c!==void 0&&d!==void 0){const m={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:_};this.rBush_.insert(Be(m.segment),m)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return i}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Be([e])).some(({segment:i})=>!(He(i[0],e)||He(i[1],e)))}insertPoint(e){const t=e?xe(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return t?this.findInsertVerticesAndUpdateDragSegments_(t).reduce((s,r)=>s||this.insertVertex_(r,t),!1):!1}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,i,s){this.rBush_.forEachInExtent(e.getExtent(),function(r){r.geometry===e&&(i===void 0||r.depth===void 0||jt(r.depth,i))&&r.index>t&&(r.index+=s)})}}function zx(n,e){return n.index-e.index}function Vc(n,e,t){const i=e.geometry;if(i.getType()==="Circle"){let r=i;if(e.index===Ls){const o=$n(r.getCenter(),xe(n)),a=Math.sqrt(o)-r.getRadius();return a*a}}const s=xe(n);return Bn[0]=xe(e.segment[0]),Bn[1]=xe(e.segment[1]),eg(s,Bn)}function Zc(n,e,t){const i=e.geometry;if(i.getType()==="Circle"&&e.index===Ls)return Qi(i.getClosestPoint(xe(n)));const s=xe(n);return Bn[0]=xe(e.segment[0]),Bn[1]=xe(e.segment[1]),Qi(Tl(s,Bn))}function Xx(){const n=sh();return function(e,t){return n.Point}}class jx extends gh{constructor(){super()}getType(){return"text"}readFeature(e,t){return this.readFeatureFromText(Dr(e),this.adaptOptions(t))}readFeatureFromText(e,t){return W()}readFeatures(e,t){return this.readFeaturesFromText(Dr(e),this.adaptOptions(t))}readFeaturesFromText(e,t){return W()}readGeometry(e,t){return this.readGeometryFromText(Dr(e),this.adaptOptions(t))}readGeometryFromText(e,t){return W()}readProjection(e){return this.readProjectionFromText(Dr(e))}readProjectionFromText(e){return this.dataProjection}writeFeature(e,t){return this.writeFeatureText(e,this.adaptOptions(t))}writeFeatureText(e,t){return W()}writeFeatures(e,t){return this.writeFeaturesText(e,this.adaptOptions(t))}writeFeaturesText(e,t){return W()}writeGeometry(e,t){return this.writeGeometryText(e,this.adaptOptions(t))}writeGeometryText(e,t){return W()}}function Dr(n){return typeof n=="string"?n:""}const $x={POINT:ut,LINESTRING:dt,POLYGON:rt,MULTIPOINT:an,MULTILINESTRING:hi,MULTIPOLYGON:bi},Zd="EMPTY",Kd="Z",Hd="M",Wx="ZM",he={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},Yx={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class Vx{constructor(e){this.wkt=e,this.index_=-1}isAlpha_(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return t=t!==void 0?t:!1,e>="0"&&e<="9"||e=="."&&!t}isWhiteSpace_(e){return e==" "||e==" "||e=="\r"||e==`
|
||
`}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let i=e,s;if(e=="(")s=he.LEFT_PAREN;else if(e==",")s=he.COMMA;else if(e==")")s=he.RIGHT_PAREN;else if(this.isNumeric_(e)||e=="-")s=he.NUMBER,i=this.readNumber_();else if(this.isAlpha_(e))s=he.TEXT,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(e==="")s=he.EOF;else throw new Error("Unexpected character: "+e)}return{position:t,value:i,type:s}}readNumber_(){let e;const t=this.index_;let i=!1,s=!1;do e=="."?i=!0:(e=="e"||e=="E")&&(s=!0),e=this.nextChar_();while(this.isNumeric_(e,i)||!s&&(e=="e"||e=="E")||s&&(e=="-"||e=="+"));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do e=this.nextChar_();while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Zx{constructor(e){this.lexer_=e,this.token_={position:0,type:he.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let e="XY";const t=this.token_;if(this.isTokenType(he.TEXT)){const i=t.value;i===Kd?e="XYZ":i===Hd?e="XYM":i===Wx&&(e="XYZM"),e!=="XY"&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(he.LEFT_PAREN)){const e=[];do e.push(this.parseGeometry_());while(this.match(he.COMMA));if(this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(he.LEFT_PAREN)){const e=this.parsePoint_();if(this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(he.LEFT_PAREN)){const e=this.parsePointList_();if(this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(he.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(he.LEFT_PAREN)){let e;if(this.token_.type==he.LEFT_PAREN?e=this.parsePointTextList_():e=this.parsePointList_(),this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(he.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(he.LEFT_PAREN)){const e=this.parsePolygonTextList_();if(this.match(he.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let i=0;i<t;++i){const s=this.token_;if(this.match(he.NUMBER))e.push(s.value);else break}if(e.length==t)return e;throw new Error(this.formatErrorMessage_())}parsePointList_(){const e=[this.parsePoint_()];for(;this.match(he.COMMA);)e.push(this.parsePoint_());return e}parsePointTextList_(){const e=[this.parsePointText_()];for(;this.match(he.COMMA);)e.push(this.parsePointText_());return e}parseLineStringTextList_(){const e=[this.parseLineStringText_()];for(;this.match(he.COMMA);)e.push(this.parseLineStringText_());return e}parsePolygonTextList_(){const e=[this.parsePolygonText_()];for(;this.match(he.COMMA);)e.push(this.parsePolygonText_());return e}isEmptyGeometry_(){const e=this.isTokenType(he.TEXT)&&this.token_.value==Zd;return e&&this.consume_(),e}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const e=this.token_;if(this.match(he.TEXT)){const t=e.value;this.layout_=this.parseGeometryLayout_();const i=this.isEmptyGeometry_();if(t=="GEOMETRYCOLLECTION"){if(i)return new Je([]);const o=this.parseGeometryCollectionText_();return new Je(o)}const s=$x[t];if(!s)throw new Error("Invalid geometry type: "+t);let r;if(i)t=="POINT"?r=[NaN,NaN]:r=[];else switch(t){case"POINT":{r=this.parsePointText_();break}case"LINESTRING":{r=this.parseLineStringText_();break}case"POLYGON":{r=this.parsePolygonText_();break}case"MULTIPOINT":{r=this.parseMultiPointText_();break}case"MULTILINESTRING":{r=this.parseMultiLineStringText_();break}case"MULTIPOLYGON":{r=this.parseMultiPolygonText_();break}}return new s(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}class PT extends jx{constructor(e){super(),e=e||{},this.splitCollection_=e.splitCollection!==void 0?e.splitCollection:!1}parse_(e){const t=new Vx(e);return new Zx(t).parse()}readFeatureFromText(e,t){const i=this.readGeometryFromText(e,t),s=new $e;return s.setGeometry(i),s}readFeaturesFromText(e,t){let i=[];const s=this.readGeometryFromText(e,t);this.splitCollection_&&s.getType()=="GeometryCollection"?i=s.getGeometriesArray():i=[s];const r=[];for(let o=0,a=i.length;o<a;++o){const l=new $e;l.setGeometry(i[o]),r.push(l)}return r}readGeometryFromText(e,t){const i=this.parse_(e);return en(i,!1,t)}writeFeatureText(e,t){const i=e.getGeometry();return i?this.writeGeometryText(i,t):""}writeFeaturesText(e,t){if(e.length==1)return this.writeFeatureText(e[0],t);const i=[];for(let r=0,o=e.length;r<o;++r)i.push(e[r].getGeometry());const s=new Je(i);return this.writeGeometryText(s,t)}writeGeometryText(e,t){return Qd(en(e,!0,t))}}function qd(n){const e=n.getCoordinates();return e.length===0?"":e.join(" ")}function Kx(n){const e=[],t=n.getPoints();for(let i=0,s=t.length;i<s;++i)e.push("("+qd(t[i])+")");return e.join(",")}function Hx(n){const e=[],t=n.getGeometries();for(let i=0,s=t.length;i<s;++i)e.push(Qd(t[i]));return e.join(",")}function wh(n){const e=n.getCoordinates(),t=[];for(let i=0,s=e.length;i<s;++i)t.push(e[i].join(" "));return t.join(",")}function qx(n){const e=[],t=n.getLineStrings();for(let i=0,s=t.length;i<s;++i)e.push("("+wh(t[i])+")");return e.join(",")}function Jd(n){const e=[],t=n.getLinearRings();for(let i=0,s=t.length;i<s;++i)e.push("("+wh(t[i])+")");return e.join(",")}function Jx(n){const e=[],t=n.getPolygons();for(let i=0,s=t.length;i<s;++i)e.push("("+Jd(t[i])+")");return e.join(",")}function Qx(n){const e=n.getLayout();let t="";return(e==="XYZ"||e==="XYZM")&&(t+=Kd),(e==="XYM"||e==="XYZM")&&(t+=Hd),t}const eE={Point:qd,LineString:wh,Polygon:Jd,MultiPoint:Kx,MultiLineString:qx,MultiPolygon:Jx,GeometryCollection:Hx};function Qd(n){const e=n.getType(),t=eE[e],i=t(n);let s=Yx[e];if(typeof n.getFlatCoordinates=="function"){const r=Qx(n);r.length>0&&(s+=" "+r)}return i.length===0?s+" "+Zd:s+"("+i+")"}const Kc="http://www.w3.org/2001/XMLSchema-instance";function ar(n,e){return Do().createElementNS(n,e)}function ui(n,e){return ef(n,e,[]).join("")}function ef(n,e,t){if(n.nodeType==Node.CDATA_SECTION_NODE||n.nodeType==Node.TEXT_NODE)t.push(n.nodeValue);else{let i;for(i=n.firstChild;i;i=i.nextSibling)ef(i,e,t)}return t}function Pi(n){return"documentElement"in n}function Ii(n){return new DOMParser().parseFromString(n,"application/xml")}function Hc(n,e){return(function(t,i){const s=n.call(e??this,t,i);if(s!==void 0){const r=i[i.length-1];oe(r,s)}})}function Ei(n,e){return(function(t,i){const s=n.call(e??this,t,i);s!==void 0&&i[i.length-1].push(s)})}function Ph(n,e){return(function(t,i){const s=n.call(this,t,i);s!==void 0&&(i[i.length-1]=s)})}function U(n,e,t){return(function(i,s){const r=n.call(this,i,s);if(r!==void 0){const o=s[s.length-1],a=e!==void 0?e:i.localName;o[a]=r}})}function K(n,e){return(function(t,i,s){n.call(this,t,i,s),s[s.length-1].node.appendChild(t)})}function di(n,e){return(function(t,i,s){const o=i[i.length-1].node;let a=n;a===void 0&&(a=s);const l=o.namespaceURI;return ar(l,a)})}const vt=di();function Ft(n,e){const t=e.length,i=new Array(t);for(let s=0;s<t;++s)i[s]=n[e[s]];return i}function Y(n,e,t){t=t!==void 0?t:{};let i,s;for(i=0,s=n.length;i<s;++i)t[n[i]]=e;return t}function as(n,e,t,i){let s;for(s=e.firstElementChild;s;s=s.nextElementSibling){const r=n[s.namespaceURI];if(r!==void 0){const o=r[s.localName];o!==void 0&&o.call(i,s,t)}}}function ge(n,e,t,i,s){return i.push(n),as(e,t,i,s),i.pop()}function tE(n,e,t,i,s,r){const o=(s!==void 0?s:t).length;let a,l;for(let h=0;h<o;++h)a=t[h],a!==void 0&&(l=e.call(r,a,i,s!==void 0?s[h]:void 0),l!==void 0&&n[l.namespaceURI][l.localName].call(r,l,a,i))}function Ae(n,e,t,i,s,r,o){return s.push(n),tE(e,t,i,s,r,o),s.pop()}let va;function iE(){return va===void 0&&typeof XMLSerializer<"u"&&(va=new XMLSerializer),va}let wa;function Do(){return wa===void 0&&typeof document<"u"&&(wa=document.implementation.createDocument("","",null)),wa}class nE extends gh{constructor(){super(),this.xmlSerializer_=iE()}getType(){return"xml"}readFeature(e,t){if(!e)return null;if(typeof e=="string"){const i=Ii(e);return this.readFeatureFromDocument(i,t)}return Pi(e)?this.readFeatureFromDocument(e,t):this.readFeatureFromNode(e,t)}readFeatureFromDocument(e,t){const i=this.readFeaturesFromDocument(e,t);return i.length>0?i[0]:null}readFeatureFromNode(e,t){return null}readFeatures(e,t){if(!e)return[];if(typeof e=="string"){const i=Ii(e);return this.readFeaturesFromDocument(i,t)}return Pi(e)?this.readFeaturesFromDocument(e,t):this.readFeaturesFromNode(e,t)}readFeaturesFromDocument(e,t){const i=[];for(let s=e.firstChild;s;s=s.nextSibling)s.nodeType==Node.ELEMENT_NODE&&oe(i,this.readFeaturesFromNode(s,t));return i}readFeaturesFromNode(e,t){return W()}readGeometry(e,t){if(!e)return null;if(typeof e=="string"){const i=Ii(e);return this.readGeometryFromDocument(i,t)}return Pi(e)?this.readGeometryFromDocument(e,t):this.readGeometryFromNode(e,t)}readGeometryFromDocument(e,t){return null}readGeometryFromNode(e,t){return null}readProjection(e){if(!e)return null;if(typeof e=="string"){const t=Ii(e);return this.readProjectionFromDocument(t)}return Pi(e)?this.readProjectionFromDocument(e):this.readProjectionFromNode(e)}readProjectionFromDocument(e){return this.dataProjection}readProjectionFromNode(e){return this.dataProjection}writeFeature(e,t){const i=this.writeFeatureNode(e,t);return this.xmlSerializer_.serializeToString(i)}writeFeatureNode(e,t){return null}writeFeatures(e,t){const i=this.writeFeaturesNode(e,t);return this.xmlSerializer_.serializeToString(i)}writeFeaturesNode(e,t){return null}writeGeometry(e,t){const i=this.writeGeometryNode(e,t);return this.xmlSerializer_.serializeToString(i)}writeGeometryNode(e,t){return null}}function Mi(n){const e=ui(n,!1);return sE(e)}function sE(n){const e=/^\s*(true|1)|(false|0)\s*$/.exec(n);if(e)return e[1]!==void 0||!1}function Ee(n){const e=ui(n,!1);return rE(e)}function rE(n){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(n);if(e)return parseFloat(e[1])}function Ye(n){return ui(n,!1).trim()}function qn(n,e){Et(n,e?"1":"0")}function oE(n,e){n.appendChild(Do().createCDATASection(e))}function Vi(n,e){const t=e.toPrecision();n.appendChild(Do().createTextNode(t))}const aE=/^\s/,lE=/\s$/,hE=/(\n|\t|\r|<|&| {2})/;function Et(n,e){typeof e=="string"&&(aE.test(e)||lE.test(e)||hE.test(e))?e.split("]]>").forEach((t,i,s)=>{i<s.length-1&&(t+="]]"),i>0&&(t=">"+t),oE(n,t)}):n.appendChild(Do().createTextNode(e))}const fi=["http://www.google.com/kml/ext/2.2"],z=[null,"http://earth.google.com/kml/2.0","http://earth.google.com/kml/2.1","http://earth.google.com/kml/2.2","http://www.opengis.net/kml/2.2"],cE="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd",qc={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},uE=Y(z,{ExtendedData:mf,Region:pf,MultiGeometry:U(ff,"geometry"),LineString:U(uf,"geometry"),LinearRing:U(df,"geometry"),Point:U(gf,"geometry"),Polygon:U(_f,"geometry"),Style:U(Lh),StyleMap:VE,address:U(Ye),description:U(Ye),name:U(Ye),open:U(Mi),phoneNumber:U(Ye),styleUrl:U(of),visibility:U(Mi)},Y(fi,{MultiTrack:U(DE,"geometry"),Track:U(cf,"geometry")})),dE=Y(z,{ExtendedData:mf,Region:pf,Link:r0,address:U(Ye),description:U(Ye),name:U(Ye),open:U(Mi),phoneNumber:U(Ye),visibility:U(Mi)}),fE=Y(z,{href:U(rf)}),gE=Y(z,{Altitude:U(Ee),Longitude:U(Ee),Latitude:U(Ee),Tilt:U(Ee),AltitudeMode:U(Ye),Heading:U(Ee),Roll:U(Ee)}),tf=Y(z,{LatLonAltBox:JE,Lod:e0}),_E=Y(z,["Document","Placemark"]),mE=Y(z,{Document:K(f0),Placemark:K(Ef)});let zn,Gr=null,ol,Fs,bs,Ms,ao,al=null,Ih,ll=null,hl,Zi=null,Jc=null,cl=null;function lo(n){return 32/Math.min(n[0],n[1])}function pE(){zn=[255,255,255,1],Gr=new Lt({color:zn}),ol=[20,2],Fs="pixels",bs="pixels",Ms=[64,64],ao="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",al=new rs({anchor:ol,anchorOrigin:"bottom-left",anchorXUnits:Fs,anchorYUnits:bs,crossOrigin:"anonymous",rotation:0,scale:lo(Ms),size:Ms,src:ao}),Ih="NO_IMAGE",ll=new Bt({color:zn,width:1}),hl=new Bt({color:[51,51,51,1],width:2}),Zi=new sr({font:"bold 16px Helvetica",fill:Gr,stroke:hl,scale:.8}),Jc=new ze({fill:Gr,image:al,text:Zi,stroke:ll,zIndex:0}),cl=[Jc]}let Or;function yE(n){return n}class IT extends nE{constructor(e){super(),e=e||{},cl||pE(),this.dataProjection=pe("EPSG:4326"),this.defaultStyle_=e.defaultStyle?e.defaultStyle:cl,this.extractStyles_=e.extractStyles!==void 0?e.extractStyles:!0,this.writeStyles_=e.writeStyles!==void 0?e.writeStyles:!0,this.sharedStyles_={},this.showPointNames_=e.showPointNames!==void 0?e.showPointNames:!0,this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",this.iconUrlFunction_=e.iconUrlFunction?e.iconUrlFunction:yE,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(e,t){const i=Y(z,{Document:Hc(this.readDocumentOrFolder_,this),Folder:Hc(this.readDocumentOrFolder_,this),Placemark:Ei(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),s=ge([],i,e,t,this);if(s)return s}readPlacemark_(e,t){const i=ge({geometry:null},uE,e,t,this);if(!i)return;const s=new $e,r=e.getAttribute("id");r!==null&&s.setId(r);const o=t[0],a=i.geometry;if(a&&en(a,!1,o),s.setGeometry(a),delete i.geometry,this.extractStyles_){const l=i.Style,h=i.styleUrl,c=EE(l,h,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);s.setStyle(c)}return delete i.Style,s.setProperties(i,!0),s}readSharedStyle_(e,t){const i=e.getAttribute("id");if(i!==null){const s=Lh.call(this,e,t);if(s){let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+i,o).href:r="#"+i,this.sharedStyles_[r]=s}}}readSharedStyleMap_(e,t){const i=e.getAttribute("id");if(i===null)return;const s=lf.call(this,e,t);if(!s)return;let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+i,o).href:r="#"+i,this.sharedStyles_[r]=s}readFeatureFromNode(e,t){if(!z.includes(e.namespaceURI))return null;const i=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return i||null}readFeaturesFromNode(e,t){if(!z.includes(e.namespaceURI))return[];let i;const s=e.localName;if(s=="Document"||s=="Folder")return i=this.readDocumentOrFolder_(e,[this.getReadOptions(e,t)]),i||[];if(s=="Placemark"){const r=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return r?[r]:[]}if(s=="kml"){i=[];for(let r=e.firstElementChild;r;r=r.nextElementSibling){const o=this.readFeaturesFromNode(r,t);o&&oe(i,o)}return i}return[]}readName(e){if(e){if(typeof e=="string"){const t=Ii(e);return this.readNameFromDocument(t)}return Pi(e)?this.readNameFromDocument(e):this.readNameFromNode(e)}}readNameFromDocument(e){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType==Node.ELEMENT_NODE){const i=this.readNameFromNode(t);if(i)return i}}readNameFromNode(e){for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z.includes(t.namespaceURI)&&t.localName=="name")return Ye(t);for(let t=e.firstElementChild;t;t=t.nextElementSibling){const i=t.localName;if(z.includes(t.namespaceURI)&&(i=="Document"||i=="Folder"||i=="Placemark"||i=="kml")){const s=this.readNameFromNode(t);if(s)return s}}}readNetworkLinks(e){const t=[];if(typeof e=="string"){const i=Ii(e);oe(t,this.readNetworkLinksFromDocument(i))}else Pi(e)?oe(t,this.readNetworkLinksFromDocument(e)):oe(t,this.readNetworkLinksFromNode(e));return t}readNetworkLinksFromDocument(e){const t=[];for(let i=e.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&oe(t,this.readNetworkLinksFromNode(i));return t}readNetworkLinksFromNode(e){const t=[];for(let i=e.firstElementChild;i;i=i.nextElementSibling)if(z.includes(i.namespaceURI)&&i.localName=="NetworkLink"){const s=ge({},dE,i,[]);t.push(s)}for(let i=e.firstElementChild;i;i=i.nextElementSibling){const s=i.localName;z.includes(i.namespaceURI)&&(s=="Document"||s=="Folder"||s=="kml")&&oe(t,this.readNetworkLinksFromNode(i))}return t}readRegion(e){const t=[];if(typeof e=="string"){const i=Ii(e);oe(t,this.readRegionFromDocument(i))}else Pi(e)?oe(t,this.readRegionFromDocument(e)):oe(t,this.readRegionFromNode(e));return t}readRegionFromDocument(e){const t=[];for(let i=e.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&oe(t,this.readRegionFromNode(i));return t}readRegionFromNode(e){const t=[];for(let i=e.firstElementChild;i;i=i.nextElementSibling)if(z.includes(i.namespaceURI)&&i.localName=="Region"){const s=ge({},tf,i,[]);t.push(s)}for(let i=e.firstElementChild;i;i=i.nextElementSibling){const s=i.localName;z.includes(i.namespaceURI)&&(s=="Document"||s=="Folder"||s=="kml")&&oe(t,this.readRegionFromNode(i))}return t}readCamera(e){const t=[];if(typeof e=="string"){const i=Ii(e);oe(t,this.readCameraFromDocument(i))}else Pi(e)?oe(t,this.readCameraFromDocument(e)):oe(t,this.readCameraFromNode(e));return t}readCameraFromDocument(e){const t=[];for(let i=e.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&oe(t,this.readCameraFromNode(i));return t}readCameraFromNode(e){const t=[];for(let i=e.firstElementChild;i;i=i.nextElementSibling)if(z.includes(i.namespaceURI)&&i.localName==="Camera"){const s=ge({},gE,i,[]);t.push(s)}for(let i=e.firstElementChild;i;i=i.nextElementSibling){const s=i.localName;z.includes(i.namespaceURI)&&(s==="Document"||s==="Folder"||s==="Placemark"||s==="kml")&&oe(t,this.readCameraFromNode(i))}return t}writeFeaturesNode(e,t){t=this.adaptOptions(t);const i=ar(z[4],"kml"),s="http://www.w3.org/2000/xmlns/";i.setAttributeNS(s,"xmlns:gx",fi[0]),i.setAttributeNS(s,"xmlns:xsi",Kc),i.setAttributeNS(Kc,"xsi:schemaLocation",cE);const r={node:i},o={};e.length>1?o.Document=e:e.length==1&&(o.Placemark=e[0]);const a=_E[i.namespaceURI],l=Ft(o,a);return Ae(r,mE,vt,l,[t],a,this),i}}function xE(n,e){const t=[0,0];let i="start";const s=n.getImage();if(s){const a=s.getSize();if(a&&a.length==2){const l=s.getScaleArray(),h=s.getAnchor();t[0]=l[0]*(a[0]-h[0]),t[1]=l[1]*(a[1]/2-h[1]),i="left"}}let r=n.getText();return r?(r=r.clone(),r.setFont(r.getFont()||Zi.getFont()),r.setScale(r.getScale()||Zi.getScale()),r.setFill(r.getFill()||Zi.getFill()),r.setStroke(r.getStroke()||hl)):r=Zi.clone(),r.setText(e),r.setOffsetX(t[0]),r.setOffsetY(t[1]),r.setTextAlign(i),new ze({image:s,text:r})}function EE(n,e,t,i,s){return(function(r,o){let a=s,l="",h=[];if(a){const u=r.getGeometry();if(u)if(u instanceof Je)h=u.getGeometriesArrayRecursive().filter(function(d){const f=d.getType();return f==="Point"||f==="MultiPoint"}),a=h.length>0;else{const d=u.getType();a=d==="Point"||d==="MultiPoint"}}a&&(l=r.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(Or||(Or=document.createElement("textarea")),Or.innerHTML=l,l=Or.value));let c=t;if(n?c=n:e&&(c=nf(e,t,i)),a){const u=xE(c[0],l);if(h.length>0){u.setGeometry(new Je(h));const d=new ze({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null});return[u,d].concat(c.slice(1))}return u}return c})}function nf(n,e,t){return Array.isArray(n)?n:typeof n=="string"?nf(t[n],e,t):e}function Oo(n){const e=ui(n,!1),t=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(t){const i=t[1];return[parseInt(i.substr(6,2),16),parseInt(i.substr(4,2),16),parseInt(i.substr(2,2),16),parseInt(i.substr(0,2),16)/255]}}function sf(n){let e=ui(n,!1);const t=[];e=e.replace(/\s*,\s*/g,",");const i=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let s;for(;s=i.exec(e);){const r=parseFloat(s[1]),o=parseFloat(s[2]),a=s[3]?parseFloat(s[3]):0;t.push(r,o,a),e=e.substr(s[0].length)}if(e==="")return t}function rf(n){const e=ui(n,!1).trim();let t=n.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function of(n){const e=ui(n,!1).trim().replace(/^(?!.*#)/,"#");let t=n.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function TE(n){const e=n.getAttribute("xunits"),t=n.getAttribute("yunits");let i;return e!=="insetPixels"?t!=="insetPixels"?i="bottom-left":i="top-left":t!=="insetPixels"?i="bottom-right":i="top-right",{x:parseFloat(n.getAttribute("x")),xunits:qc[e],y:parseFloat(n.getAttribute("y")),yunits:qc[t],origin:i}}function af(n){return Ee(n)}const RE=Y(z,{Pair:YE});function lf(n,e){return ge(void 0,RE,n,e,this)}const CE=Y(z,{Icon:U(GE),color:U(Oo),heading:U(Ee),hotSpot:U(TE),scale:U(af)});function SE(n,e){const t=ge({},CE,n,e);if(!t)return;const i=e[e.length-1],s="Icon"in t?t.Icon:{},r=!("Icon"in t)||Object.keys(s).length>0;let o;const a=s.href;a?o=a:r&&(o=ao);let l,h,c,u="bottom-left";const d=t.hotSpot;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=ol,h=Fs,c=bs):o.includes("arrow-reverse")?(l=[54,42],h=Fs,c=bs):o.includes("paddle")&&(l=[32,1],h=Fs,c=bs));let f;const g=s.x,_=s.y;g!==void 0&&_!==void 0&&(f=[g,_]);let m;const y=s.w,p=s.h;y!==void 0&&p!==void 0&&(m=[y,p]);let T;const x=t.heading;x!==void 0&&(T=Ct(x));const E=t.scale,R=t.color;if(r){o==ao&&(m=Ms);const C=new rs({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:f,offsetOrigin:"bottom-left",rotation:T,scale:E,size:m,src:this.iconUrlFunction_(o),color:R}),v=C.getScaleArray()[0],w=C.getSize();if(w===null){const P=C.getImageState();if(P===X.IDLE||P===X.LOADING){const A=function(){const I=C.getImageState();if(!(I===X.IDLE||I===X.LOADING)){const F=C.getSize();if(F&&F.length==2){const b=lo(F);C.setScale(v*b)}C.unlistenImageChange(A)}};C.listenImageChange(A),P===X.IDLE&&C.load()}}else if(w.length==2){const P=lo(w);C.setScale(v*P)}i.imageStyle=C}else i.imageStyle=Ih}const vE=Y(z,{color:U(Oo),scale:U(af)});function wE(n,e){const t=ge({},vE,n,e);if(!t)return;const i=e[e.length-1],s=new sr({fill:new Lt({color:"color"in t?t.color:zn}),scale:t.scale});i.textStyle=s}const PE=Y(z,{color:U(Oo),width:U(Ee)});function IE(n,e){const t=ge({},PE,n,e);if(!t)return;const i=e[e.length-1],s=new Bt({color:"color"in t?t.color:zn,width:"width"in t?t.width:1});i.strokeStyle=s}const AE=Y(z,{color:U(Oo),fill:U(Mi),outline:U(Mi)});function LE(n,e){const t=ge({},AE,n,e);if(!t)return;const i=e[e.length-1],s=new Lt({color:"color"in t?t.color:zn});i.fillStyle=s;const r=t.fill;r!==void 0&&(i.fill=r);const o=t.outline;o!==void 0&&(i.outline=o)}const FE=Y(z,{coordinates:Ph(sf)});function hf(n,e){return ge(null,FE,n,e)}function bE(n,e){const i=e[e.length-1].coordinates,s=ui(n,!1),o=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(s);if(o){const a=parseFloat(o[1]),l=parseFloat(o[2]),h=parseFloat(o[3]);i.push([a,l,h])}else i.push([])}const ME=Y(fi,{Track:Ei(cf)});function DE(n,e){const t=ge([],ME,n,e);if(t)return new hi(t)}const OE=Y(z,{when:o0},Y(fi,{coord:bE}));function cf(n,e){const t=ge({coordinates:[],whens:[]},OE,n,e);if(!t)return;const i=[],s=t.coordinates,r=t.whens;for(let o=0,a=Math.min(s.length,r.length);o<a;++o)s[o].length==3&&i.push(s[o][0],s[o][1],s[o][2],r[o]);return new dt(i,"XYZM")}const NE=Y(z,{href:U(rf)},Y(fi,{x:U(Ee),y:U(Ee),w:U(Ee),h:U(Ee)}));function GE(n,e){const t=ge({},NE,n,e);return t||null}const kE=Y(z,{coordinates:Ph(sf)});function Ah(n,e){return ge(null,kE,n,e)}const No=Y(z,{extrude:U(Mi),tessellate:U(Mi),altitudeMode:U(Ye)});function uf(n,e){const t=ge({},No,n,e),i=Ah(n,e);if(i){const s=new dt(i,"XYZ");return s.setProperties(t,!0),s}}function df(n,e){const t=ge({},No,n,e),i=Ah(n,e);if(i){const s=new rt(i,"XYZ",[i.length]);return s.setProperties(t,!0),s}}const UE=Y(z,{LineString:Ei(uf),LinearRing:Ei(df),MultiGeometry:Ei(ff),Point:Ei(gf),Polygon:Ei(_f)});function ff(n,e){const t=ge([],UE,n,e);if(!t)return null;if(t.length===0)return new Je(t);let i,s=!0;const r=t[0].getType();let o;for(let a=1,l=t.length;a<l;++a)if(o=t[a],o.getType()!=r){s=!1;break}if(s){let a,l;if(r=="Point"){const h=t[0];a=h.getLayout(),l=h.getFlatCoordinates();for(let c=1,u=t.length;c<u;++c)o=t[c],oe(l,o.getFlatCoordinates());i=new an(l,a),Pa(i,t)}else if(r=="LineString")i=new hi(t),Pa(i,t);else if(r=="Polygon")i=new bi(t),Pa(i,t);else if(r=="GeometryCollection"||r.startsWith("Multi"))i=new Je(t);else throw new Error("Unknown geometry type found")}else i=new Je(t);return i}function gf(n,e){const t=ge({},No,n,e),i=Ah(n,e);if(i){const s=new ut(i,"XYZ");return s.setProperties(t,!0),s}}const BE=Y(z,{innerBoundaryIs:i0,outerBoundaryIs:s0});function _f(n,e){const t=ge({},No,n,e),i=ge([null],BE,n,e);if(i&&i[0]){const s=i[0],r=[s.length];for(let a=1,l=i.length;a<l;++a)oe(s,i[a]),r.push(s.length);const o=new rt(s,"XYZ",r);return o.setProperties(t,!0),o}}const zE=Y(z,{IconStyle:SE,LabelStyle:wE,LineStyle:IE,PolyStyle:LE});function Lh(n,e){const t=ge({},zE,n,e,this);if(!t)return null;let i="fillStyle"in t?t.fillStyle:Gr;const s=t.fill;s!==void 0&&!s&&(i=null);let r;"imageStyle"in t?t.imageStyle!=Ih&&(r=t.imageStyle):r=al;const o="textStyle"in t?t.textStyle:Zi,a="strokeStyle"in t?t.strokeStyle:ll,l=t.outline;return l!==void 0&&!l?[new ze({geometry:function(h){const c=h.getGeometry(),u=c.getType();if(u==="GeometryCollection"){const d=c;return new Je(d.getGeometriesArrayRecursive().filter(function(f){const g=f.getType();return g!=="Polygon"&&g!=="MultiPolygon"}))}if(u!=="Polygon"&&u!=="MultiPolygon")return c},fill:i,image:r,stroke:a,text:o,zIndex:void 0}),new ze({geometry:function(h){const c=h.getGeometry(),u=c.getType();if(u==="GeometryCollection"){const d=c;return new Je(d.getGeometriesArrayRecursive().filter(function(f){const g=f.getType();return g==="Polygon"||g==="MultiPolygon"}))}if(u==="Polygon"||u==="MultiPolygon")return c},fill:i,stroke:null,zIndex:void 0})]:[new ze({fill:i,image:r,stroke:a,text:o,zIndex:void 0})]}function Pa(n,e){const t=e.length,i=new Array(e.length),s=new Array(e.length),r=new Array(e.length);let o,a,l;o=!1,a=!1,l=!1;for(let h=0;h<t;++h){const c=e[h];i[h]=c.get("extrude"),s[h]=c.get("tessellate"),r[h]=c.get("altitudeMode"),o=o||i[h]!==void 0,a=a||s[h]!==void 0,l=l||r[h]}o&&n.set("extrude",i),a&&n.set("tessellate",s),l&&n.set("altitudeMode",r)}const XE=Y(z,{displayName:U(Ye),value:U(Ye)});function jE(n,e){const t=n.getAttribute("name");as(XE,n,e);const i=e[e.length-1];t&&i.displayName?i[t]={value:i.value,displayName:i.displayName,toString:function(){return i.value}}:t!==null?i[t]=i.value:i.displayName!==null&&(i[i.displayName]=i.value),delete i.value}const $E=Y(z,{Data:jE,SchemaData:KE});function mf(n,e){as($E,n,e)}function pf(n,e){as(tf,n,e)}const WE=Y(z,{Style:U(Lh),key:U(Ye),styleUrl:U(of)});function YE(n,e){const t=ge({},WE,n,e,this);if(!t)return;const i=t.key;if(i&&i=="normal"){const s=t.styleUrl;s&&(e[e.length-1]=s);const r=t.Style;r&&(e[e.length-1]=r)}}function VE(n,e){const t=lf.call(this,n,e);if(!t)return;const i=e[e.length-1];if(Array.isArray(t))i.Style=t;else if(typeof t=="string")i.styleUrl=t;else throw new Error("`styleMapValue` has an unknown type")}const ZE=Y(z,{SimpleData:HE});function KE(n,e){as(ZE,n,e)}function HE(n,e){const t=n.getAttribute("name");if(t!==null){const i=Ye(n),s=e[e.length-1];s[t]=i}}const qE=Y(z,{altitudeMode:U(Ye),minAltitude:U(Ee),maxAltitude:U(Ee),north:U(Ee),south:U(Ee),east:U(Ee),west:U(Ee)});function JE(n,e){const t=ge({},qE,n,e);if(!t)return;const i=e[e.length-1],s=[parseFloat(t.west),parseFloat(t.south),parseFloat(t.east),parseFloat(t.north)];i.extent=s,i.altitudeMode=t.altitudeMode,i.minAltitude=parseFloat(t.minAltitude),i.maxAltitude=parseFloat(t.maxAltitude)}const QE=Y(z,{minLodPixels:U(Ee),maxLodPixels:U(Ee),minFadeExtent:U(Ee),maxFadeExtent:U(Ee)});function e0(n,e){const t=ge({},QE,n,e);if(!t)return;const i=e[e.length-1];i.minLodPixels=parseFloat(t.minLodPixels),i.maxLodPixels=parseFloat(t.maxLodPixels),i.minFadeExtent=parseFloat(t.minFadeExtent),i.maxFadeExtent=parseFloat(t.maxFadeExtent)}const t0=Y(z,{LinearRing:Ei(hf)});function i0(n,e){const t=ge([],t0,n,e);t.length>0&&e[e.length-1].push(...t)}const n0=Y(z,{LinearRing:Ph(hf)});function s0(n,e){const t=ge(void 0,n0,n,e);if(t){const i=e[e.length-1];i[0]=t}}function r0(n,e){as(fE,n,e)}function o0(n,e){const i=e[e.length-1].whens,s=ui(n,!1),r=Date.parse(s);i.push(isNaN(r)?0:r)}function Go(n,e){const t=wt(e),s=[(t.length==4?t[3]:1)*255,t[2],t[1],t[0]];for(let r=0;r<4;++r){const o=Math.floor(s[r]).toString(16);s[r]=o.length==1?"0"+o:o}Et(n,s.join(""))}function a0(n,e,t){const i=t[t.length-1],s=i.layout,r=i.stride;let o;if(s=="XY"||s=="XYM")o=2;else if(s=="XYZ"||s=="XYZM")o=3;else throw new Error("Invalid geometry layout");const a=e.length;let l="";if(a>0){l+=e[0];for(let h=1;h<o;++h)l+=","+e[h];for(let h=r;h<a;h+=r){l+=" "+e[h];for(let c=1;c<o;++c)l+=","+e[h+c]}}Et(n,l)}const kr=Y(z,{Data:K(l0),value:K(c0),displayName:K(h0)});function l0(n,e,t){n.setAttribute("name",e.name);const i={node:n},s=e.value;typeof s=="object"?(s!==null&&s.displayName&&Ae(i,kr,vt,[s.displayName],t,["displayName"]),s!==null&&s.value&&Ae(i,kr,vt,[s.value],t,["value"])):Ae(i,kr,vt,[s],t,["value"])}function h0(n,e){Et(n,e)}function c0(n,e){Et(n,e)}const u0=Y(z,{Placemark:K(Ef)}),d0=function(n,e,t){const i=e[e.length-1].node;return ar(i.namespaceURI,"Placemark")};function f0(n,e,t){Ae({node:n},u0,d0,e,t,void 0,this)}const g0=di("Data");function _0(n,e,t){const i={node:n},s=e.names,r=e.values,o=s.length;for(let a=0;a<o;a++)Ae(i,kr,g0,[{name:s[a],value:r[a]}],t)}const Qc=Y(z,["href"],Y(fi,["x","y","w","h"])),eu=Y(z,{href:K(Et)},Y(fi,{x:K(Vi),y:K(Vi),w:K(Vi),h:K(Vi)})),m0=function(n,e,t){return ar(fi[0],"gx:"+t)};function p0(n,e,t){const i={node:n},s=t[t.length-1].node;let r=Qc[s.namespaceURI],o=Ft(e,r);Ae(i,eu,vt,o,t,r),r=Qc[fi[0]],o=Ft(e,r),Ae(i,eu,m0,o,t,r)}const y0=Y(z,["scale","heading","Icon","color","hotSpot"]),x0=Y(z,{Icon:K(p0),color:K(Go),heading:K(Vi),hotSpot:K(Y0),scale:K(Rf)});function E0(n,e,t){const i={node:n},s={},r=e.getSrc(),o=e.getSize(),a=e.getImageSize(),l={href:r};if(o){l.w=o[0],l.h=o[1];const m=e.getAnchor(),y=e.getOrigin();if(y&&a&&y[0]!==0&&y[1]!==o[1]&&(l.x=y[0],l.y=a[1]-(y[1]+o[1])),m&&(m[0]!==o[0]/2||m[1]!==o[1]/2)){const p={x:m[0],xunits:"pixels",y:o[1]-m[1],yunits:"pixels"};s.hotSpot=p}}s.Icon=l;let h=e.getScaleArray()[0],c=o;if(c===null&&(c=Ms),c.length==2){const m=lo(c);h=h/m}h!==1&&(s.scale=h);const u=e.getRotation();u!==0&&(s.heading=u);const d=e.getColor();d&&(s.color=d);const f=t[t.length-1].node,g=y0[f.namespaceURI],_=Ft(s,g);Ae(i,x0,vt,_,t,g)}const T0=Y(z,["color","scale"]),R0=Y(z,{color:K(Go),scale:K(Rf)});function C0(n,e,t){const i={node:n},s={},r=e.getFill();r&&(s.color=r.getColor());const o=e.getScale();o&&o!==1&&(s.scale=o);const a=t[t.length-1].node,l=T0[a.namespaceURI],h=Ft(s,l);Ae(i,R0,vt,h,t,l)}const S0=Y(z,["color","width"]),v0=Y(z,{color:K(Go),width:K(Vi)});function w0(n,e,t){const i={node:n},s={color:e.getColor(),width:Number(e.getWidth())||1},r=t[t.length-1].node,o=S0[r.namespaceURI],a=Ft(s,o);Ae(i,v0,vt,a,t,o)}const P0={Point:"Point",LineString:"LineString",LinearRing:"LinearRing",Polygon:"Polygon",MultiPoint:"MultiGeometry",MultiLineString:"MultiGeometry",MultiPolygon:"MultiGeometry",GeometryCollection:"MultiGeometry"},yf=function(n,e,t){if(n){const i=e[e.length-1].node;return ar(i.namespaceURI,P0[n.getType()])}},I0=di("Point"),A0=di("LineString"),L0=di("LinearRing"),F0=di("Polygon"),b0=Y(z,{LineString:K(Xn),Point:K(Xn),Polygon:K(Tf),GeometryCollection:K(xf)});function xf(n,e,t){const i={node:n},s=e.getType();let r=[],o;if(s==="GeometryCollection")e.getGeometriesArrayRecursive().forEach(function(a){const l=a.getType();if(l==="MultiPoint")r=r.concat(a.getPoints());else if(l==="MultiLineString")r=r.concat(a.getLineStrings());else if(l==="MultiPolygon")r=r.concat(a.getPolygons());else if(l==="Point"||l==="LineString"||l==="Polygon")r.push(a);else throw new Error("Unknown geometry type")}),o=yf;else if(s==="MultiPoint")r=e.getPoints(),o=I0;else if(s==="MultiLineString")r=e.getLineStrings(),o=A0;else if(s==="MultiPolygon")r=e.getPolygons(),o=F0;else throw new Error("Unknown geometry type");Ae(i,b0,o,r,t)}const M0=Y(z,{LinearRing:K(Xn)});function tu(n,e,t){Ae({node:n},M0,L0,[e],t)}const Ia=Y(z,{ExtendedData:K(_0),MultiGeometry:K(xf),LineString:K(Xn),LinearRing:K(Xn),Point:K(Xn),Polygon:K(Tf),Style:K(W0),address:K(Et),description:K(Et),name:K(Et),open:K(qn),phoneNumber:K(Et),styleUrl:K(Et),visibility:K(qn)}),D0=Y(z,["name","open","visibility","address","phoneNumber","description","styleUrl","Style"]),O0=di("ExtendedData");function Ef(n,e,t){const i={node:n};e.getId()&&n.setAttribute("id",e.getId());const s=e.getProperties(),r={address:1,description:1,name:1,open:1,phoneNumber:1,styleUrl:1,visibility:1};r[e.getGeometryName()]=1;const o=Object.keys(s||{}).sort().filter(function(f){return!r[f]}),a=e.getStyleFunction();if(a){const f=a(e,0);if(f){const g=Array.isArray(f)?f:[f];let _=g;if(e.getGeometry()&&(_=g.filter(function(m){const y=m.getGeometryFunction()(e);if(y){const p=y.getType();return p==="GeometryCollection"?y.getGeometriesArrayRecursive().filter(function(T){const x=T.getType();return x==="Point"||x==="MultiPoint"}).length:p==="Point"||p==="MultiPoint"}})),this.writeStyles_){let m=g,y=g;e.getGeometry()&&(m=g.filter(function(p){const T=p.getGeometryFunction()(e);if(T){const x=T.getType();return x==="GeometryCollection"?T.getGeometriesArrayRecursive().filter(function(E){const R=E.getType();return R==="LineString"||R==="MultiLineString"}).length:x==="LineString"||x==="MultiLineString"}}),y=g.filter(function(p){const T=p.getGeometryFunction()(e);if(T){const x=T.getType();return x==="GeometryCollection"?T.getGeometriesArrayRecursive().filter(function(E){const R=E.getType();return R==="Polygon"||R==="MultiPolygon"}).length:x==="Polygon"||x==="MultiPolygon"}})),s.Style={pointStyles:_,lineStyles:m,polyStyles:y}}if(_.length&&s.name===void 0){const m=_[0].getText();m&&(s.name=m.getText())}}}const l=t[t.length-1].node,h=D0[l.namespaceURI],c=Ft(s,h);if(Ae(i,Ia,vt,c,t,h),o.length>0){const f=Ft(s,o);Ae(i,Ia,O0,[{names:o,values:f}],t)}const u=t[0];let d=e.getGeometry();d&&(d=en(d,!0,u)),Ae(i,Ia,yf,[d],t)}const N0=Y(z,["extrude","tessellate","altitudeMode","coordinates"]),G0=Y(z,{extrude:K(qn),tessellate:K(qn),altitudeMode:K(Et),coordinates:K(a0)});function Xn(n,e,t){const i=e.getFlatCoordinates(),s={node:n};s.layout=e.getLayout(),s.stride=e.getStride();const r=e.getProperties();r.coordinates=i;const o=t[t.length-1].node,a=N0[o.namespaceURI],l=Ft(r,a);Ae(s,G0,vt,l,t,a)}const k0=Y(z,["color","fill","outline"]),iu=Y(z,{outerBoundaryIs:K(tu),innerBoundaryIs:K(tu)}),U0=di("innerBoundaryIs"),B0=di("outerBoundaryIs");function Tf(n,e,t){const i=e.getLinearRings(),s=i.shift(),r={node:n};Ae(r,iu,U0,i,t),Ae(r,iu,B0,[s],t)}const z0=Y(z,{color:K(Go),fill:K(qn),outline:K(qn)});function X0(n,e,t){const i={node:n},s=e.getFill(),r=e.getStroke(),o={color:s?s.getColor():void 0,fill:s?void 0:!1,outline:r?void 0:!1},a=t[t.length-1].node,l=k0[a.namespaceURI],h=Ft(o,l);Ae(i,z0,vt,h,t,l)}function Rf(n,e){Vi(n,Math.round(e*1e6)/1e6)}const j0=Y(z,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),$0=Y(z,{IconStyle:K(E0),LabelStyle:K(C0),LineStyle:K(w0),PolyStyle:K(X0)});function W0(n,e,t){const i={node:n},s={};if(e.pointStyles.length){const l=e.pointStyles[0].getText();l&&(s.LabelStyle=l);const h=e.pointStyles[0].getImage();h&&typeof h.getSrc=="function"&&(s.IconStyle=h)}if(e.lineStyles.length){const l=e.lineStyles[0].getStroke();l&&(s.LineStyle=l)}if(e.polyStyles.length){const l=e.polyStyles[0].getStroke();l&&!s.LineStyle&&(s.LineStyle=l),s.PolyStyle=e.polyStyles[0]}const r=t[t.length-1].node,o=j0[r.namespaceURI],a=Ft(s,o);Ae(i,$0,vt,a,t,o)}function Y0(n,e){n.setAttribute("x",String(e.x)),n.setAttribute("y",String(e.y)),n.setAttribute("xunits",e.xunits),n.setAttribute("yunits",e.yunits)}const V0=`
|
||
attribute vec4 a_position;
|
||
attribute vec4 a_texcoord;
|
||
|
||
uniform mat4 u_matrix;
|
||
uniform mat4 u_textureMatrix;
|
||
|
||
varying vec2 v_texcoord;
|
||
|
||
void main() {
|
||
gl_Position = u_matrix * a_position;
|
||
vec2 texcoord = (u_textureMatrix * a_texcoord).xy;
|
||
v_texcoord = texcoord;
|
||
}
|
||
`,Z0=`
|
||
precision mediump float;
|
||
|
||
varying vec2 v_texcoord;
|
||
|
||
uniform sampler2D u_texture;
|
||
|
||
void main() {
|
||
if (
|
||
v_texcoord.x < 0.0 ||
|
||
v_texcoord.y < 0.0 ||
|
||
v_texcoord.x > 1.0 ||
|
||
v_texcoord.y > 1.0
|
||
) {
|
||
discard;
|
||
}
|
||
gl_FragColor = texture2D(u_texture, v_texcoord);
|
||
}
|
||
`;class K0{constructor(e){this.gl_=e,this.program_=ul(e,Z0,V0),this.positionLocation=e.getAttribLocation(this.program_,"a_position"),this.texcoordLocation=e.getAttribLocation(this.program_,"a_texcoord"),this.matrixLocation=e.getUniformLocation(this.program_,"u_matrix"),this.textureMatrixLocation=e.getUniformLocation(this.program_,"u_textureMatrix"),this.textureLocation=e.getUniformLocation(this.program_,"u_texture"),this.positionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer),this.positions=[0,0,0,1,1,0,1,0,0,1,1,1],e.bufferData(e.ARRAY_BUFFER,new Float32Array(this.positions),e.STATIC_DRAW),this.texcoordBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),this.texcoords=[0,0,0,1,1,0,1,0,0,1,1,1],e.bufferData(e.ARRAY_BUFFER,new Float32Array(this.texcoords),e.STATIC_DRAW)}drawImage(e,t,i,s,r,o,a,l,h,c,u,d,f){const g=this.gl_;l===void 0&&(l=s),h===void 0&&(h=r),o===void 0&&(o=t),a===void 0&&(a=i),c===void 0&&(c=o),u===void 0&&(u=a),d===void 0&&(d=g.canvas.width),f===void 0&&(f=g.canvas.height),g.bindTexture(g.TEXTURE_2D,e),g.useProgram(this.program_),g.bindBuffer(g.ARRAY_BUFFER,this.positionBuffer),g.enableVertexAttribArray(this.positionLocation),g.vertexAttribPointer(this.positionLocation,2,g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,this.texcoordBuffer),g.enableVertexAttribArray(this.texcoordLocation),g.vertexAttribPointer(this.texcoordLocation,2,g.FLOAT,!1,0,0);let _=il(0,d,0,f,-1,1);_=Ny(_,l,h,0),_=Dc(_,c,u,1),g.uniformMatrix4fv(this.matrixLocation,!1,_);let m=Gy(s/t,r/i,0);m=Dc(m,o/t,a/i,1),g.uniformMatrix4fv(this.textureMatrixLocation,!1,m),g.uniform1i(this.textureLocation,0),g.drawArrays(g.TRIANGLES,0,this.positions.length/2)}}function nu(n,e,t){const i=n.createShader(e);if(i===null)throw new Error("Shader compilation failed");if(n.shaderSource(i,t),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS)){const s=n.getShaderInfoLog(i);throw s===null?new Error("Shader info log creation failed"):new Error(s)}return i}function ul(n,e,t){const i=n.createProgram(),s=nu(n,n.VERTEX_SHADER,t),r=nu(n,n.FRAGMENT_SHADER,e);if(i===null)throw new Error("Program creation failed");if(n.attachShader(i,s),n.attachShader(i,r),n.linkProgram(i),!n.getProgramParameter(i,n.LINK_STATUS))throw n.getProgramInfoLog(i)===null?new Error("Program info log creation failed"):new Error;return i}const H0=`
|
||
attribute vec4 a_position;
|
||
|
||
uniform mat4 u_matrix;
|
||
|
||
void main() {
|
||
gl_Position = u_matrix * a_position;
|
||
}
|
||
`,q0=`
|
||
precision mediump float;
|
||
|
||
uniform vec4 u_val;
|
||
void main() {
|
||
gl_FragColor = u_val;
|
||
}
|
||
`,J0=`
|
||
attribute vec4 a_position;
|
||
attribute vec2 a_texcoord;
|
||
|
||
varying vec2 v_texcoord;
|
||
|
||
uniform mat4 u_matrix;
|
||
|
||
void main() {
|
||
gl_Position = u_matrix * a_position;
|
||
v_texcoord = a_texcoord;
|
||
}
|
||
`,Q0=`
|
||
precision mediump float;
|
||
|
||
varying vec2 v_texcoord;
|
||
|
||
uniform sampler2D u_texture;
|
||
|
||
void main() {
|
||
if (v_texcoord.x < 0.0 || v_texcoord.x > 1.0 || v_texcoord.y < 0.0 || v_texcoord.y > 1.0) {
|
||
discard;
|
||
}
|
||
gl_FragColor = texture2D(u_texture, v_texcoord);
|
||
}
|
||
`;function eT(n,e,t,i){let s;return t&&t.length?s=t.shift():st?s=new OffscreenCanvas(n||300,e||300):s=document.createElement("canvas"),n&&(s.width=n),e&&(s.height=e),s.getContext("webgl",i)}function tT(n){const e=n.canvas;e.width=1,e.height=1,n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)}const su=[];function iT(n,e,t,i,s,r,o,a,l,h,c,u,d,f){const g=Math.round(i*e),_=Math.round(i*t);n.canvas.width=g,n.canvas.height=_;let m,y;if(y=n.createTexture(),n.bindTexture(n.TEXTURE_2D,y),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),d?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST)),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,g,_,0,n.RGBA,c,null),m=n.createFramebuffer(),n.bindFramebuffer(n.FRAMEBUFFER,m),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,y,0),m===null)throw new Error("Could not create framebuffer");if(y===null)throw new Error("Could not create texture");if(l.length===0)return{width:g,height:_,framebuffer:m,texture:y};const p=Qe();l.forEach(function(P,A,I){pl(p,P.extent)});let T,x,E;const R=1/s;{if(T=n.createTexture(),y===null)throw new Error("Could not create texture");x=Math.round(te(p)*R),E=Math.round(Ie(p)*R);const P=n.getParameter(n.MAX_TEXTURE_SIZE),A=Math.max(x,E),I=A>P?P/A:1,F=Math.round(x*I),b=Math.round(E*I);n.bindTexture(n.TEXTURE_2D,T),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),d?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST)),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,F,b,0,n.RGBA,c,null);const k=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,k),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,T,0);const M=new K0(n);l.forEach(function(G,N,j){const $=(G.extent[0]-p[0])*R*I,J=-(G.extent[3]-p[3])*R*I,L=te(G.extent)*R*I,ie=Ie(G.extent)*R*I;if(n.bindFramebuffer(n.FRAMEBUFFER,k),n.viewport(0,0,F,b),G.clipExtent){const fe=(G.clipExtent[0]-p[0])*R*I,ae=-(G.clipExtent[3]-p[3])*R*I,ve=te(G.clipExtent)*R*I,we=Ie(G.clipExtent)*R*I;n.enable(n.SCISSOR_TEST),n.scissor(d?fe:Math.round(fe),d?ae:Math.round(ae),d?ve:Math.round(fe+ve)-Math.round(fe),d?we:Math.round(ae+we)-Math.round(ae))}M.drawImage(G.texture,G.width,G.height,h,h,G.width-2*h,G.height-2*h,d?$:Math.round($),d?J:Math.round(J),d?L:Math.round($+L)-Math.round($),d?ie:Math.round(J+ie)-Math.round(J),F,b),n.disable(n.SCISSOR_TEST)}),n.deleteFramebuffer(k)}const C=Xt(o),v=Xt(p),w=P=>{const A=(P[0][0]-C[0])/r*i,I=-(P[0][1]-C[1])/r*i,F=(P[1][0]-C[0])/r*i,b=-(P[1][1]-C[1])/r*i,k=(P[2][0]-C[0])/r*i,M=-(P[2][1]-C[1])/r*i;return{u1:F,v1:b,u0:A,v0:I,u2:k,v2:M}};n.bindFramebuffer(n.FRAMEBUFFER,m),n.viewport(0,0,g,_);{const P=[],A=[],I=ul(n,Q0,J0);n.useProgram(I);const F=n.getUniformLocation(I,"u_texture");n.bindTexture(n.TEXTURE_2D,T),n.uniform1i(F,0),a.getTriangles().forEach(function($,J,L){const ie=$.source,fe=$.target,{u1:ae,v1:ve,u0:we,v0:gt,u2:at,v2:Ve}=w(fe),hn=(ie[0][0]-v[0])/s/x,ls=-(ie[0][1]-v[1])/s/E,Ni=(ie[1][0]-v[0])/s/x,$t=-(ie[1][1]-v[1])/s/E,et=(ie[2][0]-v[0])/s/x,_t=-(ie[2][1]-v[1])/s/E;P.push(ae,ve,we,gt,at,Ve),A.push(Ni,$t,hn,ls,et,_t)});const b=il(0,g,_,0,-1,1),k=n.getUniformLocation(I,"u_matrix");n.uniformMatrix4fv(k,!1,b);const M=n.getAttribLocation(I,"a_position"),G=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,G),n.bufferData(n.ARRAY_BUFFER,new Float32Array(P),n.STATIC_DRAW),n.vertexAttribPointer(M,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(M);const N=n.getAttribLocation(I,"a_texcoord"),j=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,j),n.bufferData(n.ARRAY_BUFFER,new Float32Array(A),n.STATIC_DRAW),n.vertexAttribPointer(N,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(N),n.drawArrays(n.TRIANGLES,0,P.length/2)}if(u){const P=ul(n,q0,H0);n.useProgram(P);const A=il(0,g,_,0,-1,1),I=n.getUniformLocation(P,"u_matrix");n.uniformMatrix4fv(I,!1,A);const F=Array.isArray(u)?u:[0,0,0,255],b=n.getUniformLocation(P,"u_val");n.uniform4fv(b,F);const k=n.getAttribLocation(P,"a_position"),M=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,M),n.vertexAttribPointer(k,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(k);const G=a.getTriangles().reduce(function(N,j){const $=j.target,{u1:J,v1:L,u0:ie,v0:fe,u2:ae,v2:ve}=w($);return N.concat([J,L,ie,fe,ie,fe,ae,ve,ae,ve,J,L])},[]);n.bufferData(n.ARRAY_BUFFER,new Float32Array(G),n.STATIC_DRAW),n.drawArrays(n.LINES,0,G.length/2)}return{width:g,height:_,framebuffer:m,texture:y}}class nT extends Ys{constructor(e){super({tileCoord:e.tileCoord,loader:()=>Promise.resolve(new Uint8ClampedArray(4)),interpolate:e.interpolate,transition:e.transition}),this.renderEdges_=e.renderEdges!==void 0?e.renderEdges:!1,this.pixelRatio_=e.pixelRatio,this.gutter_=e.gutter,this.reprojData_=null,this.reprojError_=null,this.reprojSize_=void 0,this.sourceTileGrid_=e.sourceTileGrid,this.targetTileGrid_=e.targetTileGrid,this.wrappedTileCoord_=e.wrappedTileCoord||e.tileCoord,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0;const t=e.sourceProj,i=t.getExtent(),s=e.sourceTileGrid.getExtent();this.clipExtent_=t.canWrapX()?s?We(i,s):i:s;const r=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),o=this.targetTileGrid_.getExtent();let a=this.sourceTileGrid_.getExtent();const l=o?We(r,o):r;if(Os(l)===0){this.state=D.EMPTY;return}i&&(a?a=We(a,i):a=i);const h=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),c=e.targetProj,u=nd(t,c,l,h);if(!isFinite(u)||u<=0){this.state=D.EMPTY;return}const d=e.errorThreshold!==void 0?e.errorThreshold:rd;if(this.triangulation_=new sd(t,c,l,a,u*d,h,e.transformMatrix),this.triangulation_.getTriangles().length===0){this.state=D.EMPTY;return}this.sourceZ_=this.sourceTileGrid_.getZForResolution(u);let f=this.triangulation_.calculateSourceExtent();if(a&&(t.canWrapX()?(f[1]=_e(f[1],a[1],a[3]),f[3]=_e(f[3],a[1],a[3])):f=We(f,a)),!Os(f))this.state=D.EMPTY;else{let g=0,_=0;t.canWrapX()&&(g=te(i),_=Math.floor((f[0]-i[0])/g)),El(f.slice(),t,!0).forEach(y=>{const p=this.sourceTileGrid_.getTileRangeForExtentAndZ(y,this.sourceZ_),T=e.getTileFunction;for(let x=p.minX;x<=p.maxX;x++)for(let E=p.minY;E<=p.maxY;E++){const R=T(this.sourceZ_,x,E,this.pixelRatio_);if(R){const C=_*g;this.sourceTiles_.push({tile:R,offset:C})}}++_}),this.sourceTiles_.length===0&&(this.state=D.EMPTY)}}getSize(){return this.reprojSize_}getData(){return this.reprojData_}getError(){return this.reprojError_}reproject_(){const e=[];let t=!1;if(this.sourceTiles_.forEach(x=>{const E=x.tile;if(!E||E.getState()!==D.LOADED)return;const R=E.getSize(),C=this.gutter_;let v;const w=Za(E.getData());w?v=w:(t=!0,v=lp(Kn(E.getData())));const P=[R[0]+2*C,R[1]+2*C],A=v instanceof Float32Array,I=P[0]*P[1],F=A?Float32Array:Uint8ClampedArray,b=new F(v.buffer),k=F.BYTES_PER_ELEMENT,M=k*b.length/I,G=b.byteLength/P[1],N=Math.floor(G/k/P[0]),j=this.sourceTileGrid_.getTileCoordExtent(E.tileCoord);j[0]+=x.offset,j[2]+=x.offset;const $=this.clipExtent_?.slice();$&&($[0]+=x.offset,$[2]+=x.offset),e.push({extent:j,clipExtent:$,data:b,dataType:F,bytesPerPixel:M,pixelSize:P,bandCount:N})}),this.sourceTiles_.length=0,e.length===0){this.state=D.ERROR,this.changed();return}const i=this.wrappedTileCoord_[0],s=this.targetTileGrid_.getTileSize(i),r=typeof s=="number"?s:s[0],o=typeof s=="number"?s:s[1],a=Math.round(r*this.pixelRatio_),l=Math.round(o*this.pixelRatio_),h=this.targetTileGrid_.getResolution(i),c=this.sourceTileGrid_.getResolution(this.sourceZ_),u=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),d=e[0].bandCount,f=new e[0].dataType(d*a*l),g=eT(a,l,su,{premultipliedAlpha:!1,antialias:!1});let _;const m=g.RGBA;let y;e[0].dataType==Float32Array?(y=g.FLOAT,g.getExtension("WEBGL_color_buffer_float"),g.getExtension("OES_texture_float"),g.getExtension("EXT_float_blend"),_=g.getExtension("OES_texture_float_linear")!==null&&this.interpolate):(y=g.UNSIGNED_BYTE,_=this.interpolate);const p=4,T=Math.ceil(d/p);for(let x=T-1;x>=0;--x){const E=[];for(let F=0,b=e.length;F<b;++F){const k=e[F],M=k.pixelSize,G=M[0],N=M[1],j=new k.dataType(p*G*N),$=k.data;let J=x*p;for(let ie=0,fe=j.length;ie<fe;ie+=p)j[ie]=$[J],j[ie+1]=$[J+1],j[ie+2]=$[J+2],j[ie+3]=$[J+3],J+=d;const L=g.createTexture();g.bindTexture(g.TEXTURE_2D,L),_?(g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.LINEAR),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,g.LINEAR)):(g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.NEAREST),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,g.NEAREST)),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),g.texImage2D(g.TEXTURE_2D,0,m,G,N,0,m,y,j),E.push({extent:k.extent,clipExtent:k.clipExtent,texture:L,width:G,height:N})}const{framebuffer:R,width:C,height:v}=iT(g,r,o,this.pixelRatio_,c,h,u,this.triangulation_,E,this.gutter_,y,this.renderEdges_,_),w=C,P=v*p,A=new e[0].dataType(w*P);g.bindFramebuffer(g.FRAMEBUFFER,R),g.readPixels(0,0,C,v,g.RGBA,y,A);let I=x*p;for(let F=0,b=A.length;F<b;F+=p){const k=(w-1-(F/P|0))*P+F%P;f[I]=A[k],f[I+1]=A[k+1],f[I+2]=A[k+2],f[I+3]=A[k+3],I+=d}}if(tT(g),su.push(g.canvas),t){const x=Te(r,o),E=new ImageData(f,r);x.putImageData(E,0,0),this.reprojData_=x.canvas}else this.reprojData_=f;this.reprojSize_=[a,l],this.state=D.LOADED,this.changed()}load(){if(this.state!==D.IDLE&&this.state!==D.ERROR)return;this.state=D.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{const i=t.getState();if(i!==D.IDLE&&i!==D.LOADING)return;e++;const s=ee(t,Z.CHANGE,()=>{const r=t.getState();(r==D.LOADED||r==D.ERROR||r==D.EMPTY)&&(ue(s),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t}){t.getState()==D.IDLE&&t.load()})}unlistenSources_(){this.sourcesListenerKeys_.forEach(ue),this.sourcesListenerKeys_=null}}class AT extends Pd{constructor(e){const t=e.projection===void 0?"EPSG:3857":e.projection;let i=e.tileGrid;i===void 0&&t&&(i=vd({extent:Lo(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize})),super({cacheSize:.1,attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:t,tileGrid:i,state:e.state,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0,this.tileSize_=e.tileSize?Se(e.tileSize):null,this.tileSizes_=null,this.tileLoadingKeys_={},this.loader_=e.loader,this.handleTileChange_=this.handleTileChange_.bind(this),this.bandCount=e.bandCount===void 0?4:e.bandCount,this.tileGridForProjection_={},this.crossOrigin_=e.crossOrigin||"anonymous",this.transformMatrix=null}setTileSizes(e){this.tileSizes_=e}getTileSize(e){if(this.tileSizes_)return this.tileSizes_[e];if(this.tileSize_)return this.tileSize_;const t=this.getTileGrid();return t?Se(t.getTileSize(e)):[256,256]}getGutterForProjection(e){const t=this.getProjection();return(!t||kt(t,e))&&!this.transformMatrix?this.gutter_:0}setLoader(e){this.loader_=e}getReprojTile_(e,t,i,s,r,o){const a=this.tileGrid||this.getTileGridForProjection(r||s),l=Math.max.apply(null,a.getResolutions().map((g,_)=>{const m=Se(a.getTileSize(_)),y=this.getTileSize(_);return Math.max(y[0]/m[0],y[1]/m[1])})),h=this.getTileGridForProjection(s),c=[e,t,i],u=this.getTileCoordForTileUrlFunction(c,s),d=Object.assign({sourceProj:r||s,sourceTileGrid:a,targetProj:s,targetTileGrid:h,tileCoord:c,wrappedTileCoord:u,pixelRatio:l,gutter:this.gutter_,getTileFunction:(g,_,m,y)=>this.getTile(g,_,m,y,void 0,o),transformMatrix:this.transformMatrix},this.tileOptions),f=new nT(d);return f.key=this.getKey(),f}getTile(e,t,i,s,r,o){const a=this.getProjection();if(r&&(a&&!kt(a,r)||this.transformMatrix))return this.getReprojTile_(e,t,i,r,a,o);const l=this.getTileSize(e),h=this.loader_,c=new AbortController,u={signal:c.signal,crossOrigin:this.crossOrigin_},d=this.getTileCoordForTileUrlFunction([e,t,i]);if(!d)return null;const f=this.getKey(),g=Is(this,f,e,t,i);if(o&&o.containsKey(g))return o.get(g);const _=d[0],m=d[1],y=d[2],p=this.getTileGrid()?.getFullTileRange(_);p&&(u.maxY=p.getHeight()-1);function T(){return fl(function(){return h(_,m,y,u)})}const x=Object.assign({tileCoord:[e,t,i],loader:T,size:l,controller:c},this.tileOptions),E=new Ys(x);return E.key=this.getKey(),E.addEventListener(Z.CHANGE,this.handleTileChange_),o?.set(g,E),E}handleTileChange_(e){const t=e.target,i=O(t),s=t.getState();let r;s==D.LOADING?(this.tileLoadingKeys_[i]=!0,r=Un.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=s==D.ERROR?Un.TILELOADERROR:s==D.LOADED?Un.TILELOADEND:void 0),r&&this.dispatchEvent(new Id(r,t))}getTileGridForProjection(e){const t=this.getProjection();if(this.tileGrid&&(!t||kt(t,e))&&!this.transformMatrix)return this.tileGrid;const i=O(e);return i in this.tileGridForProjection_||(this.tileGridForProjection_[i]=dh(e)),this.tileGridForProjection_[i]}setTileGridForProjection(e,t){const i=pe(e);if(i){const s=O(i);s in this.tileGridForProjection_||(this.tileGridForProjection_[s]=t)}}}export{hx as $,lT as A,bt as B,Ro as C,vT as D,Us as E,Lt as F,hT as G,ST as H,mT as I,Zr as J,wT as K,dt as L,dT as M,li as N,gT as O,rt as P,xp as Q,So as R,Vd as S,_T as T,ce as U,uh as V,CT as W,q as X,Od as Y,xh as Z,Ke as _,RT as a,nx as a0,ye as a1,B as a2,Zs as a3,AT as a4,sT as a5,Qs as a6,Sd as a7,Gs as a8,Ce as a9,PT as aA,qf as aa,mo as ab,Qi as ac,We as ad,_e as ae,pe as af,rT as ag,vl as ah,Mg as ai,me as aj,sr as ak,ss as al,ii as am,oT as an,TT as ao,b_ as ap,cT as aq,pT as ar,rg as as,sg as at,aT as au,fy as av,xT as aw,ET as ax,yT as ay,IT as az,Rd as b,hi as c,bi as d,Ao as e,ai as f,O as g,ze as h,Pe as i,Bt as j,nr as k,rn as l,ns as m,$e as n,ut as o,qe as p,pl as q,Qh as r,Fi as s,Js as t,Ff as u,Be as v,Qe as w,Bu as x,v_ as y,Nn as z};
|
||
//# sourceMappingURL=openlayers-J9qS6Th1.js.map
|