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>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:ne?-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;s0?s-1:s}return i-1}if(t>0){for(let s=1;s0||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;h0:!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;r0;)this.pop()}extend(e){for(let t=0,i=e.length;tthis.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=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{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>1;){const l=this.getLeftChildIndex_(e),h=this.getRightChildIndex_(e),c=he;){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;ae.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_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;ir&&(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=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&&nf&&(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;ts&&(l=l|Ge.RIGHT),ar&&(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[2]&&(n[2]=e[2]),e[1]n[3]&&(n[3]=e[3]),n}function Ss(n,e){e[0]n[2]&&(n[2]=e[0]),e[1]n[3]&&(n[3]=e[1])}function cu(n,e,t,i,s){for(;te[0]?i[0]=n[0]:i[0]=e[0],n[1]>e[1]?i[1]=n[1]:i[1]=e[1],n[2]=e[0]&&n[1]<=e[3]&&n[3]>=e[1]}function Di(n){return n[2]=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=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[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;so)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[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;i1?t:2,i=i??t,e===void 0&&(t>2?e=n.slice():e=new Array(s));for(let r=0;rgr?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;rZh&&(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=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{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().length1)u=t;else if(d>0){for(let f=0;fs&&(s=h),r=a,o=l}return s}function Dl(n,e,t,i,s){for(let r=0,o=t.length;r0;){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;pf&&(c=p,f=E)}f>s&&(l[(c-e)/i]=1,d+i0&&_>f)&&(g<0&&m0&&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;lr&&(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;oy&&(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=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;r0}function zl(n,e,t,i,s){s=s!==void 0?s:!1;for(let r=0,o=t.length;rc&&d1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let s=0;for(;s0}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=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o0?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;ui.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;ts.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;s0&&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]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;s0}}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;s0&&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{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.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);o0;)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 ne?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=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=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=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.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<",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;re){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;ri.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{for(let o=0;o{for(let o=0;o{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;as.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;ai(r)===s(r);case S.NotEqual:return r=>i(r)!==s(r);case S.LessThan:return r=>i(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{for(let o=0;o{for(let o=0;o{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!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{let o=1;for(let a=0;as[0](r)/s[1](r);case S.Add:return r=>{let o=0;for(let a=0;as[0](r)-s[1](r);case S.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(ol?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{for(let r=0;r{const r=i[0](s);for(let o=1;o{const r=i[0](s),o=i[1](s);let a,l;for(let h=2;h=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{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;ithis.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{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;onull;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;i4)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=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;h0)&&(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;ithis.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=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(){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.minXthis.maxX&&(this.maxX=e.maxX),e.minYthis.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;Veme(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.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<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;ithis.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;l0&&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{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;al&&(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;tthis.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=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(a0&&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;un&&(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{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;aG[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;G0?-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(;G0&&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;Ge?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(;uG&&(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!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;s0){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;cy.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{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;ru*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;w0;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{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[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&&gd.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]])}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{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{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;o1?o:2,r=r||new Array(o);for(let c=0;c>1;s=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;re.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{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;sn):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{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{--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=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{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||t0?i:Math.max(r/t[0],s/t[1]);const o=e+1,a=new Array(o);for(let l=0;lthis.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='© OpenStreetMap 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;hFd({...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){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
`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,e,!1,t,i):"")+"")}return l.push(this.createStepText(o,e,!0,t,i)),(this.scaleBarText_?`
`+r+"
":"")+l.join("")}createMarker(e){return`
`}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`
`+a+"
"}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;mT.value):null;let p;e:for(let T=0,x=g.length;T{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=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{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{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{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.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=_;--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;Tt.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(;f0&&(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{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{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`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{const[t,...i]=e.args,s=i.length,r=new Uint8Array(s*4);for(let h=0;h0)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;i0?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;c0?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;h1){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;d0?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;r80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;re&&(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;o0)for(let x=e;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;t0||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.x&&n.x>=u&&r!==n.x&&y(xo.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=(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;n0?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{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;t0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n"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(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`${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_{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{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=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;ud.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(fo){const l=Dn(n,i),h=Dn(n,s);return Pr(l,h)}let a=0;if(i{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&&te.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(e0&&this.removeLastPoints_(i)}addTracedCoordinates_(e,t,i){if(t===i)return;const s=[];if(t=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.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=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=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=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=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;sthis.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&&te.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(e0)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=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.lengtho));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=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;pi.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;i0&&(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;s0?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)=>{i0&&(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);o0&&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;h0){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{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