0;return u&&Promise.all(l).then(()=>i(null)),lC(r,t,e,n,s,o,a),u}function lC(r,t,e,n,i,s,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(n,i);if(e.getRenderer())M_(r,l,e,t,o);else{const h=b_[l.getType()];h(r,l,e,t,o,s)}}function M_(r,t,e,n,i){if(t.getType()=="GeometryCollection"){const s=t.getGeometries();for(let o=0,a=s.length;o{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const n=[this.context.canvas.width,this.context.canvas.height];ie(this.pixelTransform,n);const i=this.renderedCenter_,s=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=n[0]*mr,d=n[1]*mr;c.push(this.getRenderTransform(i,s,o,mr,u,d,0).slice());const g=h.getSource(),f=a.getExtent();if(g.getWrapX()&&a.canWrapX()&&!Ze(f,l)){let p=l[0];const _=mt(f);let y=0,v;for(;p {const i=this.getLayer(),s=tt(i),o=i.getSource(),a=this.renderedProjection,l=a.getExtent(),h=this.renderedResolution,c=o.getTileGridForProjection(a),u=ie(this.renderedPixelToCoordinateTransform_,t.slice()),d=c.getTileCoordForCoordAndResolution(u,h);let g;for(let w=0,S=this.renderedTiles.length;wS[0]&&R[2]>S[2]&&w.push([R[0]-x,R[1],R[2]-x,R[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==g&&this.renderedRenderOrder_==p&&Ze(this.wrappedRenderedExtent_,y))return Xi(this.renderedExtent_,v)||(this.hitDetectionImageData_=null,this.renderedExtent_=v),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const E=new y_(T_(u,d),y,u,d);let T;for(let x=0,b=w.length;x{let R;const L=x.getStyleFunction()||e.getStyleFunction();if(L&&(R=L(x,u)),R){const N=this.renderFeature(x,M,R,E,T,this.getLayer().getDeclutter(),b);C=C&&!N}},G=uh(y),D=n.getFeaturesInExtent(G);p&&D.sort(p);for(let x=0,b=D.length;x=200&&a.status<300){const h=t.getType();let c;h=="json"?c=JSON.parse(a.responseText):h=="text"?c=a.responseText:h=="xml"?(c=a.responseXML,c||(c=new DOMParser().parseFromString(a.responseText,"application/xml"))):h=="arraybuffer"&&(c=a.response),c?s(t.readFeatures(c,{extent:e,featureProjection:i}),t.readProjection(c)):o()}else o()},a.onerror=o,a.send()}function xp(r,t){return function(e,n,i,s,o){const a=this;C_(r,t,e,n,i,function(l,h){a.addFeatures(l),s!==void 0&&s(l)},o||Zo)}}class Jn extends gn{constructor(t,e,n){super(t),this.feature=e,this.features=n}}class Lh extends eo{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Zo,this.format_=t.format,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(Rt(this.format_,"`format` must be set when `url` is set"),this.loader_=xp(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:_C;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new _p:null,this.loadedExtentsRtree_=new _p,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let n,i;Array.isArray(t.features)?i=t.features:t.features&&(n=t.features,i=n.getArray()),!e&&n===void 0&&(n=new Fl(i)),i!==void 0&&this.addFeaturesInternal(i),n!==void 0&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=tt(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const i=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(i,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Jn(Ne.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof ke||(this.featureChangeKeys_[t]=[se(e,Ct.CHANGE,this.handleFeatureChange_,this),se(e,Iu.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(e.getId()!==void 0){const i=String(e.getId());if(!(i in this.idIndex_))this.idIndex_[i]=e;else if(e instanceof ke){const s=this.idIndex_[i];s instanceof ke?Array.isArray(s)?s.push(e):this.idIndex_[i]=[s,e]:n=!1}else n=!1}return n&&(Rt(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],i=[];for(let s=0,o=t.length;s{if(n=typeof s.value=="function"?s.value(t):s.value,n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof ImageData||n instanceof WebGLTexture){n instanceof WebGLTexture&&!s.texture?(s.prevValue=void 0,s.texture=n):s.texture||(s.prevValue=void 0,s.texture=e.createTexture()),this.bindTexture(s.texture,i,s.name),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),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);const o=!(n instanceof HTMLImageElement)||n.complete;!(n instanceof WebGLTexture)&&o&&s.prevValue!==n&&(s.prevValue=n,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),i++}else if(Array.isArray(n)&&n.length===6)this.setUniformMatrixValue(s.name,L_(this.tmpMat4_,n));else if(Array.isArray(n)&&n.length<=4)switch(n.length){case 2:e.uniform2f(this.getUniformLocation(s.name),n[0],n[1]);return;case 3:e.uniform3f(this.getUniformLocation(s.name),n[0],n[1],n[2]);return;case 4:e.uniform4f(this.getUniformLocation(s.name),n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&e.uniform1f(this.getUniformLocation(s.name),n)})}useProgram(t,e){this.gl_.useProgram(t),this.currentProgram_=t,this.applyFrameState(e),this.applyUniforms(e)}compileShader(t,e){const n=this.gl_,i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}getProgram(t,e){const n=this.gl_,i=this.compileShader(t,n.FRAGMENT_SHADER),s=this.compileShader(e,n.VERTEX_SHADER),o=n.createProgram();if(n.attachShader(o,i),n.attachShader(o,s),n.linkProgram(o),!n.getShaderParameter(i,n.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${n.getShaderInfoLog(i)}`;throw new Error(a)}if(n.deleteShader(i),!n.getShaderParameter(s,n.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${n.getShaderInfoLog(s)}`;throw new Error(a)}if(n.deleteShader(s),!n.getProgramParameter(o,n.LINK_STATUS)){const a=`GL program linking failed: ${n.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(t){const e=tt(this.currentProgram_);return this.uniformLocationsByProgram_[e]===void 0&&(this.uniformLocationsByProgram_[e]={}),this.uniformLocationsByProgram_[e][t]===void 0&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=tt(this.currentProgram_);return this.attribLocationsByProgram_[e]===void 0&&(this.attribLocationsByProgram_[e]={}),this.attribLocationsByProgram_[e][t]===void 0&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const n=t.size,i=t.viewState.rotation,s=t.viewState.resolution,o=t.viewState.center;return ar(e,0,0,2/(s*n[0]),2/(s*n[1]),-i,-o[0],-o[1]),e}setUniformFloatValue(t,e){this.gl_.uniform1f(this.getUniformLocation(t),e)}setUniformFloatVec2(t,e){this.gl_.uniform2fv(this.getUniformLocation(t),e)}setUniformFloatVec4(t,e){this.gl_.uniform4fv(this.getUniformLocation(t),e)}setUniformMatrixValue(t,e){this.gl_.uniformMatrix4fv(this.getUniformLocation(t),!1,e)}enableAttributeArray_(t,e,n,i,s){const o=this.getAttributeLocation(t);o<0||(this.gl_.enableVertexAttribArray(o),this.gl_.vertexAttribPointer(o,e,n,!1,i,s))}enableAttributes(t){const e=GC(t);let n=0;for(let i=0;is?i>o?i:o:s>o?s:o,g=a>l?a>h?a:h:l>h?l:h,f=n.next;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=g&&ys(i,a,s,l,o,h,f.x,f.y)&&oe(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function UC(r,t,e,n){var i=r.prev,s=r,o=r.next;if(oe(i,s,o)>=0)return!1;for(var a=i.x,l=s.x,h=o.x,c=i.y,u=s.y,d=o.y,g=a0||f>0&&r;)0!==o&&(0===f||!r||n.z<=r.z)?(x=n,n=n.nextZ,o--):(x=r,r=r.nextZ,f--),i?i.nextZ=x:e=x,x.prevZ=i,i=x;n=r}i.nextZ=null,s*=2}while(u>1)}(x)}(e,r,x,i);for(var o,f,p=e;e.prev!==e.next;)if(o=e.prev,f=e.next,i?v(e,r,x,i):l(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(f.i/n|0),B(e),e=f.next,p=f.next;else if((e=f)===p){u?1===u?a(e=h(s(e),t,n),t,n,r,x,i,2):2===u&&c(e,t,n,r,x,i):a(s(e),t,n,r,x,i,1);break}}}function l(e){var t=e.prev,n=e,r=e.next;if(w(t,n,r)>=0)return!1;for(var x=t.x,i=n.x,u=r.x,o=t.y,f=n.y,s=r.y,a=xi?x>u?x:u:i>u?i:u,h=o>f?o>s?o:s:f>s?f:s,c=r.next;c!==t;){if(c.x>=a&&c.x<=v&&c.y>=l&&c.y<=h&&M(x,o,i,f,u,s,c.x,c.y)&&w(c.prev,c,c.next)>=0)return!1;c=c.next}return!0}function v(e,t,n,r){var x=e.prev,i=e,u=e.next;if(w(x,i,u)>=0)return!1;for(var o=x.x,f=i.x,s=u.x,a=x.y,l=i.y,v=u.y,h=o{const[e,...n]=t.args,i=n.length,s=new Uint8Array(i*4);for(let h=0;h=a.width)return null;const c=qt(o),u=Math.floor(a.height*((o[3]-i[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(t,e){const n=this.image_,i=n.getExtent(),s=n.getResolution(),[o,a]=Array.isArray(s)?s:[s,s],l=n.getPixelRatio(),h=t.layerStatesArray[t.layerIndex],c=t.pixelRatio,u=t.viewState,d=u.center,g=u.resolution,f=c*o/(g*l),p=c*a/(g*l),_=t.extent,y=u.resolution,v=u.rotation,w=Math.round(mt(_)/y*c),S=Math.round(qt(_)/y*c);ar(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/c,1/c,v,-w/2,-S/2),lh(this.inversePixelTransform,this.pixelTransform);const E=Ou(this.pixelTransform);this.useContainer(e,E,this.getBackground(t));const T=this.getRenderContext(t),M=this.context.canvas;M.width!=w||M.height!=S?(M.width=w,M.height=S):this.containerReused||T.clearRect(0,0,w,S);let C=!1,P=!0;if(h.extent){const x=kr(h.extent,u.projection);P=Yt(x,t.extent),C=P&&!Ze(x,t.extent),C&&this.clipUnrotated(T,t,x)}const G=n.getImage(),D=ar(this.tempTransform,w/2,S/2,f,p,0,l*(i[0]-d[0])/o,l*(d[1]-i[3])/a);this.renderedResolution=a*c/l;const z=G.width*D[0],m=G.height*D[3];if(this.getLayer().getSource().getInterpolate()||(T.imageSmoothingEnabled=!1),this.preRender(T,t),P&&z>=.5&&m>=.5){const x=D[4],b=D[5],R=h.opacity;R!==1&&(T.save(),T.globalAlpha=R),T.drawImage(G,0,0,+G.width,+G.height,x,b,z,m),R!==1&&T.restore()}return this.postRender(this.context,t),C&&T.restore(),T.imageSmoothingEnabled=!0,E!==M.style.transform&&(M.style.transform=E),this.container}}class Hd extends OI{constructor(t){super(t)}createRenderer(){return new W_(this)}getData(t){return super.getData(t)}}const ai={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class Z_ extends Ra{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getPreload(){return this.get(ai.PRELOAD)}setPreload(t){this.set(ai.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(ai.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(ai.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class q_ extends kd{constructor(t){super(t),this.extentChanged=!0,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.newTiles_=!1,this.tmpExtent=je(),this.tmpTileRange_=new jh(0,0,0,0)}isDrawableTile(t){const e=this.getLayer(),n=t.getState(),i=e.getUseInterimTilesOnError();return n==B.LOADED||n==B.EMPTY||n==B.ERROR&&!i}getTile(t,e,n,i){const s=i.pixelRatio,o=i.viewState.projection,a=this.getLayer();let l=a.getSource().getTile(t,e,n,s,o);return l.getState()==B.ERROR&&a.getUseInterimTilesOnError()&&a.getPreload()>0&&(this.newTiles_=!0),this.isDrawableTile(l)||(l=l.getInterimTile()),l}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),i=ie(e.pixelToCoordinateTransform,t.slice()),s=n.getExtent();if(s&&!yr(s,i))return null;const o=e.pixelRatio,a=e.viewState.projection,l=e.viewState,h=n.getRenderSource(),c=h.getTileGridForProjection(l.projection),u=h.getTilePixelRatio(e.pixelRatio);for(let d=c.getZForResolution(l.resolution);d>=c.getMinZoom();--d){const g=c.getTileCoordForCoordAndZ(i,d),f=h.getTile(d,g[1],g[2],o,a);if(!(f instanceof La||f instanceof zs)||f instanceof zs&&f.getState()===B.EMPTY)return null;if(f.getState()!==B.LOADED)continue;const p=c.getOrigin(d),_=ee(c.getTileSize(d)),y=c.getResolution(d),v=Math.floor(u*((i[0]-p[0])/y-g[1]*_[0])),w=Math.floor(u*((p[1]-i[1])/y-g[2]*_[1])),S=Math.round(u*h.getGutterForProjection(l.projection));return this.getImageData(f.getImage(),v+S,w+S)}return null}loadedTileCallback(t,e,n){return this.isDrawableTile(n)?super.loadedTileCallback(t,e,n):!1}prepareFrame(t){return!!this.getLayer().getSource()}renderFrame(t,e){const n=t.layerStatesArray[t.layerIndex],i=t.viewState,s=i.projection,o=i.resolution,a=i.center,l=i.rotation,h=t.pixelRatio,c=this.getLayer(),u=c.getSource(),d=u.getRevision(),g=u.getTileGridForProjection(s),f=g.getZForResolution(o,u.zDirection),p=g.getResolution(f);let _=t.extent;const y=t.viewState.resolution,v=u.getTilePixelRatio(h),w=Math.round(mt(_)/y*h),S=Math.round(qt(_)/y*h),E=n.extent&&kr(n.extent);E&&(_=xe(_,kr(n.extent)));const T=p*w/2/v,M=p*S/2/v,C=[a[0]-T,a[1]-M,a[0]+T,a[1]+M],P=g.getTileRangeForExtentAndZ(_,f),G={};G[f]={};const D=this.createLoadedTileFinder(u,s,G),z=this.tmpExtent,m=this.tmpTileRange_;this.newTiles_=!1;const x=l?zc(i.center,y,l,t.size):void 0;for(let ot=P.minX;ot<=P.maxX;++ot)for(let U=P.minY;U<=P.maxY;++U){if(l&&!g.tileCoordIntersectsViewport([f,ot,U],x))continue;const nt=this.getTile(f,ot,U,t);if(this.isDrawableTile(nt)){const Lt=tt(this);if(nt.getState()==B.LOADED){G[f][nt.tileCoord.toString()]=nt;let It=nt.inTransition(Lt);It&&n.opacity!==1&&(nt.endTransition(Lt),It=!1),!this.newTiles_&&(It||!this.renderedTiles.includes(nt))&&(this.newTiles_=!0)}if(nt.getAlpha(Lt,t.time)===1)continue}const ut=g.getTileCoordChildTileRange(nt.tileCoord,m,z);let _t=!1;ut&&(_t=D(f+1,ut)),_t||g.forEachTileCoordParentTileRange(nt.tileCoord,D,m,z)}const b=p/o*h/v;ar(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/h,1/h,l,-w/2,-S/2);const R=Ou(this.pixelTransform);this.useContainer(e,R,this.getBackground(t));const L=this.getRenderContext(t),N=this.context.canvas;lh(this.inversePixelTransform,this.pixelTransform),ar(this.tempTransform,w/2,S/2,b,b,0,-w/2,-S/2),N.width!=w||N.height!=S?(N.width=w,N.height=S):this.containerReused||L.clearRect(0,0,w,S),E&&this.clipUnrotated(L,t,E),u.getInterpolate()||(L.imageSmoothingEnabled=!1),this.preRender(L,t),this.renderedTiles.length=0;let k=Object.keys(G).map(Number);k.sort(on);let j,Z,Y;n.opacity===1&&(!this.containerReused||u.getOpaque(t.viewState.projection))?k=k.reverse():(j=[],Z=[]);for(let ot=k.length-1;ot>=0;--ot){const U=k[ot],nt=u.getTilePixelSize(U,h,s),ut=g.getResolution(U)/p,_t=nt[0]*ut*b,Lt=nt[1]*ut*b,It=g.getTileCoordForCoordAndZ(zn(C),U),Dt=g.getTileCoordExtent(It),$t=ie(this.tempTransform,[v*(Dt[0]-C[0])/p,v*(C[3]-Dt[3])/p]),me=v*u.getGutterForProjection(s),Oe=G[U];for(const dr in Oe){const ge=Oe[dr],qr=ge.tileCoord,Ba=It[1]-qr[1],Yh=Math.round($t[0]-(Ba-1)*_t),Xa=It[2]-qr[2],Wa=Math.round($t[1]-(Xa-1)*Lt),gr=Math.round($t[0]-Ba*_t),Ar=Math.round($t[1]-Xa*Lt),$r=Yh-gr,Lr=Wa-Ar,Hi=f===U,Ki=Hi&&ge.getAlpha(tt(this),t.time)!==1;let qn=!1;if(!Ki)if(j){Y=[gr,Ar,gr+$r,Ar,gr+$r,Ar+Lr,gr,Ar+Lr];for(let pn=0,Hh=j.length;pn0){e([]);return}const f=c.getTileCoordExtent(g.wrappedTileCoord),p=zn(f),_=[(u[0]-p[0])/h,(p[1]-u[1])/h],y=g.getSourceTiles().reduce(function(w,S){return w.concat(S.getFeatures())},[]);let v=g.hitDetectionImageData[s];if(!v){const w=ee(c.getTileSize(c.getZForResolution(h,o.zDirection))),S=this.renderedRotation_,E=[this.getRenderTransform(c.getTileCoordCenter(g.wrappedTileCoord),h,0,mr,w[0]*mr,w[1]*mr,0)];v=S_(w,E,y,i.getStyleFunction(),c.getTileCoordExtent(g.wrappedTileCoord),g.getReplayState(i).renderedResolution,S),g.hitDetectionImageData[s]=v}e(E_(_,y,v))})}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.renderedLayerRevision_!==void 0&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}renderDeclutter(t,e){const n=this.context,i=n.globalAlpha;n.globalAlpha=e.opacity;const s=t.viewHints,o=!(s[Jt.ANIMATING]||s[Jt.INTERACTING]),a=this.renderedTiles;for(let l=0,h=a.length;l>>0)*4294967296+(r>>>0)}function SP(r,t){const e=t.buf;let n,i;if(i=e[t.pos++],n=(i&112)>>4,i<128||(i=e[t.pos++],n|=(i&127)<<3,i<128)||(i=e[t.pos++],n|=(i&127)<<10,i<128)||(i=e[t.pos++],n|=(i&127)<<17,i<128)||(i=e[t.pos++],n|=(i&127)<<24,i<128)||(i=e[t.pos++],n|=(i&1)<<31,i<128))return wP(r,n);throw new Error("Expected varint not more than 10 bytes")}function mo(r){const t=r.buf;let e,n;return n=t[r.pos++],e=n&127,n<128||(n=t[r.pos++],e|=(n&127)<<7,n<128)||(n=t[r.pos++],e|=(n&127)<<14,n<128)||(n=t[r.pos++],e|=(n&127)<<21,n<128)?e:(n=t[r.pos],e|=(n&15)<<28,SP(e,r))}function EP(r,t,e,n){if(n==0){e==1&&(t[0]=r-1-t[0],t[1]=r-1-t[1]);const i=t[0];t[0]=t[1],t[1]=i}}var bP=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function TP(r,t,e){if(r>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>Math.pow(2,r)-1||e>Math.pow(2,r)-1)throw Error("tile x/y outside zoom level bounds");const n=bP[r],i=Math.pow(2,r);let s=0,o=0,a=0;const l=[t,e];let h=i/2;for(;h>0;)s=(l[0]&h)>0?1:0,o=(l[1]&h)>0?1:0,a+=h*h*(3*s^o),EP(h,l,s,o),h=h/2;return n+a}function ly(r,t){return We(this,null,function*(){if(t===1||t===0)return r;if(t===2){if(typeof globalThis.DecompressionStream>"u")return pu(new Uint8Array(r));{let e=new Response(r).body.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(e).arrayBuffer()}}else throw Error("Compression method not supported")})}var gs=(r=>(r[r.Unknown=0]="Unknown",r[r.Mvt=1]="Mvt",r[r.Png=2]="Png",r[r.Jpeg=3]="Jpeg",r[r.Webp=4]="Webp",r[r.Avif=5]="Avif",r))(gs||{}),MP=127;function RP(r,t){let e=0,n=r.length-1;for(;e<=n;){const i=n+e>>1,s=t-r[i].tileId;if(s>0)e=i+1;else if(s<0)n=i-1;else return r[i]}return n>=0&&(r[n].runLength===0||t-r[n].tileId{const o=new jh(Math.min(0,i[0]),Math.max(i[0]-1,-1),Math.min(0,i[1]),Math.max(i[1]-1,-1));if(n){const a=this.getTileRangeForExtentAndZ(n,s);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}):n&&this.calculateTileRanges_(n)}forEachTileCoord(t,e,n){const i=this.getTileRangeForExtentAndZ(t,e);for(let s=i.minX,o=i.maxX;s<=o;++s)for(let a=i.minY,l=i.maxY;a<=l;++a)n([e,s,a])}forEachTileCoordParentTileRange(t,e,n,i){let s,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,i);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),s=is(o,o,a,a,n)):s=this.getTileRangeForExtentAndZ(l,h,n),e(h,s))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,n){if(t[0]{const e=await this.ifdRequests[t-1];if(e.nextIFDByteOffset===0)throw new al(t);return this.parseFileDirectoryAt(e.nextIFDByteOffset)})(),this.ifdRequests[t]}async getImage(t=0){const e=await this.requestIFD(t);return new Ly(e.fileDirectory,e.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let t=0,e=!0;for(;e;)try{await this.requestIFD(t),++t}catch(n){if(n instanceof al)e=!1;else throw n}return t}async getGhostValues(){const t=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const e="GDAL_STRUCTURAL_METADATA_SIZE=",n=e.length+100;let i=await this.getSlice(t,n);if(e===ls(i,St.ASCII,e.length,t)){const s=ls(i,St.ASCII,n,t).split(`
-`)[0],o=Number(s.split("=")[1].split(" ")[0])+s.length;o>n&&(i=await this.getSlice(t,o));const a=ls(i,St.ASCII,o,t);this.ghostValues={},a.split(`
-`).filter(l=>l.length>0).map(l=>l.split("=")).forEach(([l,h])=>{this.ghostValues[l]=h})}return this.ghostValues}static async fromSource(t,e,n){const i=(await t.fetch([{offset:0,length:1024}],n))[0],s=new zA(i),o=s.getUint16(0,0);let a;if(o===18761)a=!0;else if(o===19789)a=!1;else throw new TypeError("Invalid byte order value.");const l=s.getUint16(2,a);let h;if(l===42)h=!1;else if(l===43){if(h=!0,s.getUint16(4,a)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");const c=h?s.getUint64(8,a):s.getUint32(4,a);return new Bs(t,a,h,c,e)}close(){return typeof this.source.close=="function"?this.source.close():!1}}class gL extends Fy{constructor(t,e){super(),this.mainFile=t,this.overviewFiles=e,this.imageFiles=[t].concat(e),this.fileDirectoriesPerFile=null,this.fileDirectoriesPerFileParsing=null,this.imageCount=null}async parseFileDirectoriesPerFile(){const t=[this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)].concat(this.overviewFiles.map(e=>e.parseFileDirectoryAt(e.firstIFDOffset)));return this.fileDirectoriesPerFile=await Promise.all(t),this.fileDirectoriesPerFile}async getImage(t=0){await this.getImageCount(),await this.parseFileDirectoriesPerFile();let e=0,n=0;for(let i=0;i