/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.122
 *
 * Copyright 2011-2022 Cesium Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Columbus View (Pat. Pend.)
 *
 * Portions licensed separately.
 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
 */
import{a as Se}from"./chunk-JQWRUZSV.js";import{a as D}from"./chunk-QE3ZUOZY.js";import{b as ae}from"./chunk-6P5KAIBX.js";import{c as R,d as Ot,e as me}from"./chunk-4FSVUTPL.js";var Ie=R(((e,t)=>{"use strict";t.exports=(e,t,i,r)=>{let n=65535&e|0,a=e>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{n=n+t[r++]|0,a=a+n|0}while(--s);n%=65521,a%=65521}return n|a<<16|0}})),De=R(((e,t)=>{"use strict";var i=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());t.exports=(e,t,r,n)=>{let a=i,s=n+r;e^=-1;for(let i=n;i<s;i++)e=e>>>8^a[255&(e^t[i])];return-1^e}})),Oe=R(((e,t)=>{"use strict";t.exports=function(e,t){let i,r,n,a,s,o,l,f,d,h,c,u,w,b,m,g,k,_,p,v,y,x,E,R,A=e.state;i=e.next_in,E=e.input,r=i+(e.avail_in-5),n=e.next_out,R=e.output,a=n-(t-e.avail_out),s=n+(e.avail_out-257),o=A.dmax,l=A.wsize,f=A.whave,d=A.wnext,h=A.window,c=A.hold,u=A.bits,w=A.lencode,b=A.distcode,m=(1<<A.lenbits)-1,g=(1<<A.distbits)-1;e:do{u<15&&(c+=E[i++]<<u,u+=8,c+=E[i++]<<u,u+=8),k=w[c&m];t:for(;;){if(_=k>>>24,c>>>=_,u-=_,_=k>>>16&255,0===_)R[n++]=65535&k;else{if(!(16&_)){if(64&_){if(32&_){A.mode=16191;break e}e.msg="invalid literal/length code",A.mode=16209;break e}k=w[(65535&k)+(c&(1<<_)-1)];continue t}for(p=65535&k,_&=15,_&&(u<_&&(c+=E[i++]<<u,u+=8),p+=c&(1<<_)-1,c>>>=_,u-=_),u<15&&(c+=E[i++]<<u,u+=8,c+=E[i++]<<u,u+=8),k=b[c&g];;){if(_=k>>>24,c>>>=_,u-=_,_=k>>>16&255,16&_){if(v=65535&k,_&=15,u<_&&(c+=E[i++]<<u,u+=8,u<_&&(c+=E[i++]<<u,u+=8)),v+=c&(1<<_)-1,v>o){e.msg="invalid distance too far back",A.mode=16209;break e}if(c>>>=_,u-=_,_=n-a,v>_){if(_=v-_,_>f&&A.sane){e.msg="invalid distance too far back",A.mode=16209;break e}if(y=0,x=h,0===d){if(y+=l-_,_<p){p-=_;do{R[n++]=h[y++]}while(--_);y=n-v,x=R}}else if(d<_){if(y+=l+d-_,_-=d,_<p){p-=_;do{R[n++]=h[y++]}while(--_);if(y=0,d<p){_=d,p-=_;do{R[n++]=h[y++]}while(--_);y=n-v,x=R}}}else if(y+=d-_,_<p){p-=_;do{R[n++]=h[y++]}while(--_);y=n-v,x=R}for(;p>2;)R[n++]=x[y++],R[n++]=x[y++],R[n++]=x[y++],p-=3;p&&(R[n++]=x[y++],p>1&&(R[n++]=x[y++]))}else{y=n-v;do{R[n++]=R[y++],R[n++]=R[y++],R[n++]=R[y++],p-=3}while(p>2);p&&(R[n++]=R[y++],p>1&&(R[n++]=R[y++]))}break}if(64&_){e.msg="invalid distance code",A.mode=16209;break e}k=b[(65535&k)+(c&(1<<_)-1)]}}break}}while(i<r&&n<s);p=u>>3,i-=p,u-=p<<3,c&=(1<<u)-1,e.next_in=i,e.next_out=n,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=n<s?s-n+257:257-(n-s),A.hold=c,A.bits=u}})),Me=R(((e,t)=>{"use strict";var i=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),r=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),n=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),a=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);t.exports=(e,t,s,o,l,f,d,h)=>{let c,u,w,b,m,g,k,_,p,v=h.bits,y=0,x=0,E=0,R=0,A=0,T=0,D=0,U=0,S=0,Z=0,I=null,O=new Uint16Array(16),N=new Uint16Array(16),C=null;for(y=0;y<=15;y++)O[y]=0;for(x=0;x<o;x++)O[t[s+x]]++;for(A=v,R=15;R>=1&&0===O[R];R--);if(A>R&&(A=R),0===R)return l[f++]=20971520,l[f++]=20971520,h.bits=1,0;for(E=1;E<R&&0===O[E];E++);for(A<E&&(A=E),U=1,y=1;y<=15;y++)if(U<<=1,U-=O[y],U<0)return-1;if(U>0&&(0===e||1!==R))return-1;for(N[1]=0,y=1;y<15;y++)N[y+1]=N[y]+O[y];for(x=0;x<o;x++)0!==t[s+x]&&(d[N[t[s+x]]++]=x);if(0===e?(I=C=d,g=20):1===e?(I=i,C=r,g=257):(I=n,C=a,g=0),Z=0,x=0,y=E,m=f,T=A,D=0,w=-1,S=1<<A,b=S-1,1===e&&S>852||2===e&&S>592)return 1;for(;;){k=y-D,d[x]+1<g?(_=0,p=d[x]):d[x]>=g?(_=C[d[x]-g],p=I[d[x]-g]):(_=96,p=0),c=1<<y-D,u=1<<T,E=u;do{u-=c,l[m+(Z>>D)+u]=k<<24|_<<16|p|0}while(0!==u);for(c=1<<y-1;Z&c;)c>>=1;if(0!==c?(Z&=c-1,Z+=c):Z=0,x++,0==--O[y]){if(y===R)break;y=t[s+d[x]]}if(y>A&&(Z&b)!==w){for(0===D&&(D=A),m+=E,T=y-D,U=1<<T;T+D<R&&(U-=O[T+D],!(U<=0));)T++,U<<=1;if(S+=1<<T,1===e&&S>852||2===e&&S>592)return 1;w=Z&b,l[w]=A<<24|T<<16|m-f|0}}return 0!==Z&&(l[m+Z]=y-D<<24|64<<16|0),h.bits=A,0}})),J=R(((e,t)=>{"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}})),bt=R(((e,t)=>{"use strict";var i=Ie(),r=De(),n=Oe(),a=Me(),{Z_FINISH:s,Z_BLOCK:o,Z_TREES:l,Z_OK:f,Z_STREAM_END:d,Z_NEED_DICT:h,Z_STREAM_ERROR:c,Z_DATA_ERROR:u,Z_MEM_ERROR:w,Z_BUF_ERROR:b,Z_DEFLATED:m}=J(),g=16180,k=16190,_=16191,p=16192,v=16194,y=16199,x=16200,E=16206,R=16209,A=16210,T=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function D(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var U,S,Z=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<g||t.mode>16211?1:0},I=e=>{if(Z(e))return c;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=g,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,f},O=e=>{if(Z(e))return c;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,I(e)},N=(e,t)=>{let i;if(Z(e))return c;let r=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?c:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,O(e))},C=(e,t)=>{if(!e)return c;let i=new D;e.state=i,i.strm=e,i.window=null,i.mode=g;let r=N(e,t);return r!==f&&(e.state=null),r},B=!0,M=e=>{if(B){U=new Int32Array(512),S=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,U,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,S,0,e.work,{bits:5}),B=!1}e.lencode=U,e.lenbits=9,e.distcode=S,e.distbits=5},F=(e,t,i,r)=>{let n,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>r&&(n=r),a.window.set(t.subarray(i-r,i-r+n),a.wnext),(r-=n)?(a.window.set(t.subarray(i-r,i),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0};t.exports.inflateReset=O,t.exports.inflateReset2=N,t.exports.inflateResetKeep=I,t.exports.inflateInit=e=>C(e,15),t.exports.inflateInit2=C,t.exports.inflate=(e,t)=>{let D,U,S,I,O,N,C,B,L,H,P,z,V,Y,j,G,K,J,Q,X,W,q,$,ee,te=0,ie=new Uint8Array(4),re=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Z(e)||!e.output||!e.input&&0!==e.avail_in)return c;D=e.state,D.mode===_&&(D.mode=p),O=e.next_out,S=e.output,C=e.avail_out,I=e.next_in,U=e.input,N=e.avail_in,B=D.hold,L=D.bits,H=N,P=C,q=f;e:for(;;)switch(D.mode){case g:if(0===D.wrap){D.mode=p;break}for(;L<16;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(2&D.wrap&&35615===B){0===D.wbits&&(D.wbits=15),D.check=0,ie[0]=255&B,ie[1]=B>>>8&255,D.check=r(D.check,ie,2,0),B=0,L=0,D.mode=16181;break}if(D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&B)<<8)+(B>>8))%31){e.msg="incorrect header check",D.mode=R;break}if((15&B)!==m){e.msg="unknown compression method",D.mode=R;break}if(B>>>=4,L-=4,W=8+(15&B),0===D.wbits&&(D.wbits=W),W>15||W>D.wbits){e.msg="invalid window size",D.mode=R;break}D.dmax=1<<D.wbits,D.flags=0,e.adler=D.check=1,D.mode=512&B?16189:_,B=0,L=0;break;case 16181:for(;L<16;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(D.flags=B,(255&D.flags)!==m){e.msg="unknown compression method",D.mode=R;break}if(57344&D.flags){e.msg="unknown header flags set",D.mode=R;break}D.head&&(D.head.text=B>>8&1),512&D.flags&&4&D.wrap&&(ie[0]=255&B,ie[1]=B>>>8&255,D.check=r(D.check,ie,2,0)),B=0,L=0,D.mode=16182;case 16182:for(;L<32;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}D.head&&(D.head.time=B),512&D.flags&&4&D.wrap&&(ie[0]=255&B,ie[1]=B>>>8&255,ie[2]=B>>>16&255,ie[3]=B>>>24&255,D.check=r(D.check,ie,4,0)),B=0,L=0,D.mode=16183;case 16183:for(;L<16;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}D.head&&(D.head.xflags=255&B,D.head.os=B>>8),512&D.flags&&4&D.wrap&&(ie[0]=255&B,ie[1]=B>>>8&255,D.check=r(D.check,ie,2,0)),B=0,L=0,D.mode=16184;case 16184:if(1024&D.flags){for(;L<16;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}D.length=B,D.head&&(D.head.extra_len=B),512&D.flags&&4&D.wrap&&(ie[0]=255&B,ie[1]=B>>>8&255,D.check=r(D.check,ie,2,0)),B=0,L=0}else D.head&&(D.head.extra=null);D.mode=16185;case 16185:if(1024&D.flags&&(z=D.length,z>N&&(z=N),z&&(D.head&&(W=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Uint8Array(D.head.extra_len)),D.head.extra.set(U.subarray(I,I+z),W)),512&D.flags&&4&D.wrap&&(D.check=r(D.check,U,z,I)),N-=z,I+=z,D.length-=z),D.length))break e;D.length=0,D.mode=16186;case 16186:if(2048&D.flags){if(0===N)break e;z=0;do{W=U[I+z++],D.head&&W&&D.length<65536&&(D.head.name+=String.fromCharCode(W))}while(W&&z<N);if(512&D.flags&&4&D.wrap&&(D.check=r(D.check,U,z,I)),N-=z,I+=z,W)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=16187;case 16187:if(4096&D.flags){if(0===N)break e;z=0;do{W=U[I+z++],D.head&&W&&D.length<65536&&(D.head.comment+=String.fromCharCode(W))}while(W&&z<N);if(512&D.flags&&4&D.wrap&&(D.check=r(D.check,U,z,I)),N-=z,I+=z,W)break e}else D.head&&(D.head.comment=null);D.mode=16188;case 16188:if(512&D.flags){for(;L<16;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(4&D.wrap&&B!==(65535&D.check)){e.msg="header crc mismatch",D.mode=R;break}B=0,L=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),e.adler=D.check=0,D.mode=_;break;case 16189:for(;L<32;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}e.adler=D.check=T(B),B=0,L=0,D.mode=k;case k:if(0===D.havedict)return e.next_out=O,e.avail_out=C,e.next_in=I,e.avail_in=N,D.hold=B,D.bits=L,h;e.adler=D.check=1,D.mode=_;case _:if(t===o||t===l)break e;case p:if(D.last){B>>>=7&L,L-=7&L,D.mode=E;break}for(;L<3;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}switch(D.last=1&B,B>>>=1,L-=1,3&B){case 0:D.mode=16193;break;case 1:if(M(D),D.mode=y,t===l){B>>>=2,L-=2;break e}break;case 2:D.mode=16196;break;case 3:e.msg="invalid block type",D.mode=R}B>>>=2,L-=2;break;case 16193:for(B>>>=7&L,L-=7&L;L<32;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if((65535&B)!=(B>>>16^65535)){e.msg="invalid stored block lengths",D.mode=R;break}if(D.length=65535&B,B=0,L=0,D.mode=v,t===l)break e;case v:D.mode=16195;case 16195:if(z=D.length,z){if(z>N&&(z=N),z>C&&(z=C),0===z)break e;S.set(U.subarray(I,I+z),O),N-=z,I+=z,C-=z,O+=z,D.length-=z;break}D.mode=_;break;case 16196:for(;L<14;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(D.nlen=257+(31&B),B>>>=5,L-=5,D.ndist=1+(31&B),B>>>=5,L-=5,D.ncode=4+(15&B),B>>>=4,L-=4,D.nlen>286||D.ndist>30){e.msg="too many length or distance symbols",D.mode=R;break}D.have=0,D.mode=16197;case 16197:for(;D.have<D.ncode;){for(;L<3;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}D.lens[re[D.have++]]=7&B,B>>>=3,L-=3}for(;D.have<19;)D.lens[re[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,$={bits:D.lenbits},q=a(0,D.lens,0,19,D.lencode,0,D.work,$),D.lenbits=$.bits,q){e.msg="invalid code lengths set",D.mode=R;break}D.have=0,D.mode=16198;case 16198:for(;D.have<D.nlen+D.ndist;){for(;te=D.lencode[B&(1<<D.lenbits)-1],j=te>>>24,G=te>>>16&255,K=65535&te,!(j<=L);){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(K<16)B>>>=j,L-=j,D.lens[D.have++]=K;else{if(16===K){for(ee=j+2;L<ee;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(B>>>=j,L-=j,0===D.have){e.msg="invalid bit length repeat",D.mode=R;break}W=D.lens[D.have-1],z=3+(3&B),B>>>=2,L-=2}else if(17===K){for(ee=j+3;L<ee;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}B>>>=j,L-=j,W=0,z=3+(7&B),B>>>=3,L-=3}else{for(ee=j+7;L<ee;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}B>>>=j,L-=j,W=0,z=11+(127&B),B>>>=7,L-=7}if(D.have+z>D.nlen+D.ndist){e.msg="invalid bit length repeat",D.mode=R;break}for(;z--;)D.lens[D.have++]=W}}if(D.mode===R)break;if(0===D.lens[256]){e.msg="invalid code -- missing end-of-block",D.mode=R;break}if(D.lenbits=9,$={bits:D.lenbits},q=a(1,D.lens,0,D.nlen,D.lencode,0,D.work,$),D.lenbits=$.bits,q){e.msg="invalid literal/lengths set",D.mode=R;break}if(D.distbits=6,D.distcode=D.distdyn,$={bits:D.distbits},q=a(2,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,$),D.distbits=$.bits,q){e.msg="invalid distances set",D.mode=R;break}if(D.mode=y,t===l)break e;case y:D.mode=x;case x:if(N>=6&&C>=258){e.next_out=O,e.avail_out=C,e.next_in=I,e.avail_in=N,D.hold=B,D.bits=L,n(e,P),O=e.next_out,S=e.output,C=e.avail_out,I=e.next_in,U=e.input,N=e.avail_in,B=D.hold,L=D.bits,D.mode===_&&(D.back=-1);break}for(D.back=0;te=D.lencode[B&(1<<D.lenbits)-1],j=te>>>24,G=te>>>16&255,K=65535&te,!(j<=L);){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(G&&!(240&G)){for(J=j,Q=G,X=K;te=D.lencode[X+((B&(1<<J+Q)-1)>>J)],j=te>>>24,G=te>>>16&255,K=65535&te,!(J+j<=L);){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}B>>>=J,L-=J,D.back+=J}if(B>>>=j,L-=j,D.back+=j,D.length=K,0===G){D.mode=16205;break}if(32&G){D.back=-1,D.mode=_;break}if(64&G){e.msg="invalid literal/length code",D.mode=R;break}D.extra=15&G,D.mode=16201;case 16201:if(D.extra){for(ee=D.extra;L<ee;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}D.length+=B&(1<<D.extra)-1,B>>>=D.extra,L-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=16202;case 16202:for(;te=D.distcode[B&(1<<D.distbits)-1],j=te>>>24,G=te>>>16&255,K=65535&te,!(j<=L);){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(!(240&G)){for(J=j,Q=G,X=K;te=D.distcode[X+((B&(1<<J+Q)-1)>>J)],j=te>>>24,G=te>>>16&255,K=65535&te,!(J+j<=L);){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}B>>>=J,L-=J,D.back+=J}if(B>>>=j,L-=j,D.back+=j,64&G){e.msg="invalid distance code",D.mode=R;break}D.offset=K,D.extra=15&G,D.mode=16203;case 16203:if(D.extra){for(ee=D.extra;L<ee;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}D.offset+=B&(1<<D.extra)-1,B>>>=D.extra,L-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){e.msg="invalid distance too far back",D.mode=R;break}D.mode=16204;case 16204:if(0===C)break e;if(z=P-C,D.offset>z){if(z=D.offset-z,z>D.whave&&D.sane){e.msg="invalid distance too far back",D.mode=R;break}z>D.wnext?(z-=D.wnext,V=D.wsize-z):V=D.wnext-z,z>D.length&&(z=D.length),Y=D.window}else Y=S,V=O-D.offset,z=D.length;z>C&&(z=C),C-=z,D.length-=z;do{S[O++]=Y[V++]}while(--z);0===D.length&&(D.mode=x);break;case 16205:if(0===C)break e;S[O++]=D.length,C--,D.mode=x;break;case E:if(D.wrap){for(;L<32;){if(0===N)break e;N--,B|=U[I++]<<L,L+=8}if(P-=C,e.total_out+=P,D.total+=P,4&D.wrap&&P&&(e.adler=D.check=D.flags?r(D.check,S,P,O-P):i(D.check,S,P,O-P)),P=C,4&D.wrap&&(D.flags?B:T(B))!==D.check){e.msg="incorrect data check",D.mode=R;break}B=0,L=0}D.mode=16207;case 16207:if(D.wrap&&D.flags){for(;L<32;){if(0===N)break e;N--,B+=U[I++]<<L,L+=8}if(4&D.wrap&&B!==(4294967295&D.total)){e.msg="incorrect length check",D.mode=R;break}B=0,L=0}D.mode=16208;case 16208:q=d;break e;case R:q=u;break e;case A:return w;default:return c}return e.next_out=O,e.avail_out=C,e.next_in=I,e.avail_in=N,D.hold=B,D.bits=L,(D.wsize||P!==e.avail_out&&D.mode<R&&(D.mode<E||t!==s))&&F(e,e.output,e.next_out,P-e.avail_out)?(D.mode=A,w):(H-=e.avail_in,P-=e.avail_out,e.total_in+=H,e.total_out+=P,D.total+=P,4&D.wrap&&P&&(e.adler=D.check=D.flags?r(D.check,S,P,e.next_out-P):i(D.check,S,P,e.next_out-P)),e.data_type=D.bits+(D.last?64:0)+(D.mode===_?128:0)+(D.mode===y||D.mode===v?256:0),(0===H&&0===P||t===s)&&q===f&&(q=b),q)},t.exports.inflateEnd=e=>{if(Z(e))return c;let t=e.state;return t.window&&(t.window=null),e.state=null,f},t.exports.inflateGetHeader=(e,t)=>{if(Z(e))return c;let i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,f):c},t.exports.inflateSetDictionary=(e,t)=>{let r,n,a,s=t.length;return Z(e)||(r=e.state,0!==r.wrap&&r.mode!==k)?c:r.mode===k&&(n=1,n=i(n,t,s,0),n!==r.check)?u:(a=F(e,t,s,s),a?(r.mode=A,w):(r.havedict=1,f))},t.exports.inflateInfo="pako inflate (from Nodeca project)"})),_t=R(((e,t)=>{"use strict";var i=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);t.exports.assign=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(let t in r)i(r,t)&&(e[t]=r[t])}}return e},t.exports.flattenChunks=e=>{let t=0;for(let i=0,r=e.length;i<r;i++)t+=e[i].length;let i=new Uint8Array(t);for(let t=0,r=0,n=e.length;t<n;t++){let n=e[t];i.set(n,r),r+=n.length}return i}})),kt=R(((e,t)=>{"use strict";var i=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}var r=new Uint8Array(256);for(let e=0;e<256;e++)r[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;r[254]=r[254]=1,t.exports.string2buf=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,r,n,a,s=e.length,o=0;for(n=0;n<s;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<s&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),a=0,n=0;a<o;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<s&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),i<128?t[a++]=i:i<2048?(t[a++]=192|i>>>6,t[a++]=128|63&i):i<65536?(t[a++]=224|i>>>12,t[a++]=128|i>>>6&63,t[a++]=128|63&i):(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63,t[a++]=128|i>>>6&63,t[a++]=128|63&i);return t};t.exports.buf2string=(e,t)=>{let n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let a,s,o=new Array(2*n);for(s=0,a=0;a<n;){let t=e[a++];if(t<128){o[s++]=t;continue}let i=r[t];if(i>4)o[s++]=65533,a+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&a<n;)t=t<<6|63&e[a++],i--;i>1?o[s++]=65533:t<65536?o[s++]=t:(t-=65536,o[s++]=55296|t>>10&1023,o[s++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&i)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e[i]);return r})(o,s)},t.exports.utf8border=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+r[e[i]]>t?i:t}})),Et=R(((e,t)=>{"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}})),St=R(((e,t)=>{"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}})),vt=R(((e,t)=>{"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}})),Rt=R(((e,t)=>{"use strict";var i=bt(),r=_t(),n=kt(),a=Et(),s=St(),o=vt(),l=Object.prototype.toString,{Z_NO_FLUSH:f,Z_FINISH:d,Z_OK:h,Z_STREAM_END:c,Z_NEED_DICT:u,Z_STREAM_ERROR:w,Z_DATA_ERROR:b,Z_MEM_ERROR:m}=J();function g(e){this.options=r.assign({chunkSize:65536,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;let f=i.inflateInit2(this.strm,t.windowBits);if(f!==h)throw new Error(a[f]);if(this.header=new o,i.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=n.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(f=i.inflateSetDictionary(this.strm,t.dictionary),f!==h)))throw new Error(a[f])}function k(e,t){let i=new g(t);if(i.push(e),i.err)throw i.msg||a[i.err];return i.result}g.prototype.push=function(e,t){let r,a,s,o=this.strm,g=this.options.chunkSize,k=this.options.dictionary;if(this.ended)return!1;for(a=t===~~t?t:!0===t?d:f,"[object ArrayBuffer]"===l.call(e)?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;;){for(0===o.avail_out&&(o.output=new Uint8Array(g),o.next_out=0,o.avail_out=g),r=i.inflate(o,a),r===u&&k&&(r=i.inflateSetDictionary(o,k),r===h?r=i.inflate(o,a):r===b&&(r=u));o.avail_in>0&&r===c&&o.state.wrap>0&&0!==e[o.next_in];)i.inflateReset(o),r=i.inflate(o,a);switch(r){case w:case b:case u:case m:return this.onEnd(r),this.ended=!0,!1}if(s=o.avail_out,o.next_out&&(0===o.avail_out||r===c))if("string"===this.options.to){let e=n.utf8border(o.output,o.next_out),t=o.next_out-e,i=n.buf2string(o.output,e);o.next_out=t,o.avail_out=g-t,t&&o.output.set(o.output.subarray(e,e+t),0),this.onData(i)}else this.onData(o.output.length===o.next_out?o.output:o.output.subarray(0,o.next_out));if(r!==h||0!==s){if(r===c)return r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===o.avail_in)break}}return!0},g.prototype.onData=function(e){this.chunks.push(e)},g.prototype.onEnd=function(e){e===h&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.exports.Inflate=g,t.exports.inflate=k,t.exports.inflateRaw=function(e,t){return(t=t||{}).raw=!0,k(e,t)},t.exports.ungzip=k,t.exports.constants=J()})),Nt=1953029805,Mt=2917034100;function oe(e,t){if(oe.passThroughDataForTesting)return t;ae.typeOf.object("key",e),ae.typeOf.object("data",t);let i=e.byteLength;if(0===i||i%4!=0)throw new D("The length of key must be greater than 0 and a multiple of 4.");let r=new DataView(t),n=r.getUint32(0,!0);if(n===Nt||n===Mt)return t;let a,s=new DataView(e),o=0,l=t.byteLength,f=l-l%8,d=i,h=8;for(;o<f;)for(h=(h+8)%24,a=h;o<f&&a<d;)r.setUint32(o,r.getUint32(o,!0)^s.getUint32(a,!0),!0),r.setUint32(o+4,r.getUint32(o+4,!0)^s.getUint32(a+4,!0),!0),o+=8,a+=24;if(o<l)for(a>=d&&(h=(h+8)%24,a=h);o<l;)r.setUint8(o,r.getUint8(o)^s.getUint8(a)),o++,a++}oe.passThroughDataForTesting=!1;var Te=oe;function Zt(e,t){return 0!=(e&t)}var F=Zt,Bt=[1,2,4,8],ve=15,Ct=16,Lt=64,Pt=128;function N(e,t,i,r,n,a){this._bits=e,this.cnodeVersion=t,this.imageryVersion=i,this.terrainVersion=r,this.imageryProvider=n,this.terrainProvider=a,this.ancestorHasTerrain=!1,this.terrainState=void 0}N.clone=function(e,t){return me(t)?(t._bits=e._bits,t.cnodeVersion=e.cnodeVersion,t.imageryVersion=e.imageryVersion,t.terrainVersion=e.terrainVersion,t.imageryProvider=e.imageryProvider,t.terrainProvider=e.terrainProvider):t=new N(e._bits,e.cnodeVersion,e.imageryVersion,e.terrainVersion,e.imageryProvider,e.terrainProvider),t.ancestorHasTerrain=e.ancestorHasTerrain,t.terrainState=e.terrainState,t},N.prototype.setParent=function(e){this.ancestorHasTerrain=e.ancestorHasTerrain||this.hasTerrain()},N.prototype.hasSubtree=function(){return F(this._bits,Ct)},N.prototype.hasImagery=function(){return F(this._bits,Lt)},N.prototype.hasTerrain=function(){return F(this._bits,Pt)},N.prototype.hasChildren=function(){return F(this._bits,ve)},N.prototype.hasChild=function(e){return F(this._bits,Bt[e])},N.prototype.getChildBitmask=function(){return this._bits&ve};var ye=N,Ut=Ot(Rt(),1),G=Uint16Array.BYTES_PER_ELEMENT,H=Int32Array.BYTES_PER_ELEMENT,Y=Uint32Array.BYTES_PER_ELEMENT,C={METADATA:0,TERRAIN:1,DBROOT:2};function Si(e,t){let i=C.fromString(e.type),r=e.buffer;Te(e.key,r);let n=Di(r);r=n.buffer;let a=n.length;switch(i){case C.METADATA:return vi(r,a,e.quadKey);case C.TERRAIN:return Ii(r,a,t);case C.DBROOT:return t.push(r),{buffer:r}}}C.fromString=function(e){return"Metadata"===e?C.METADATA:"Terrain"===e?C.TERRAIN:"DbRoot"===e?C.DBROOT:void 0};var Ti=32301;function vi(e,t,i){let r=new DataView(e),n=0,a=r.getUint32(n,!0);if(n+=Y,a!==Ti)throw new D("Invalid magic");let s=r.getUint32(n,!0);if(n+=Y,1!==s)throw new D("Invalid data type. Must be 1 for QuadTreePacket");let o=r.getUint32(n,!0);if(n+=Y,2!==o)throw new D("Invalid QuadTreePacket version. Only version 2 is supported.");let l=r.getInt32(n,!0);n+=H;let f=r.getInt32(n,!0);if(n+=H,32!==f)throw new D("Invalid instance size.");let d=r.getInt32(n,!0);n+=H;let h=r.getInt32(n,!0);n+=H;let c=r.getInt32(n,!0);if(n+=H,d!==l*f+n)throw new D("Invalid dataBufferOffset");if(d+h+c!==t)throw new D("Invalid packet offsets");let u=[];for(let e=0;e<l;++e){let e=r.getUint8(n);++n,++n;let t=r.getUint16(n,!0);n+=G;let i=r.getUint16(n,!0);n+=G;let a=r.getUint16(n,!0);n+=G,n+=G,n+=G,n+=H,n+=H,n+=8;let s=r.getUint8(n++),o=r.getUint8(n++);n+=G,u.push(new ye(e,t,i,a,s,o))}let w=[],b=0;let m=0,g=u[b++];return""===i?++m:w[i]=g,function e(t,i,r){let n=!1;if(4===r){if(i.hasSubtree())return;n=!0}for(let a=0;a<4;++a){let s=t+a.toString();if(n)w[s]=null;else if(r<4)if(i.hasChild(a)){if(b===l)return void console.log("Incorrect number of instances");let t=u[b++];w[s]=t,e(s,t,r+1)}else w[s]=null}}(i,g,m),w}var yi=5,Ai=4;function Ii(e,t,i){let r=new DataView(e),n=function(e){for(let i=0;i<Ai;++i){let i=r.getUint32(e,!0);if(e+=Y,(e+=i)>t)throw new D("Malformed terrain packet found.")}return e},a=0,s=[];for(;s.length<yi;){let t=a;a=n(a);let r=e.slice(t,a);i.push(r),s.push(r)}return s}var Dt=1953029805,Ri=2917034100;function Di(e){let t=new DataView(e),i=0,r=t.getUint32(i,!0);if(i+=Y,r!==Dt&&r!==Ri)throw new D("Invalid magic");let n=t.getUint32(i,r===Dt);i+=Y;let a=new Uint8Array(e,i),s=Ut.default.inflate(a);if(s.length!==n)throw new D("Size of packet doesn't match header");return s}var en=Se(Si);export{en as default};