soonspacejs 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SoonSpace=t()}(this,(function(){"use strict";var e="soonspacejs",t="2.4.1",n=!1;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SoonSpace=t()}(this,(function(){"use strict";var e="soonspacejs",t="2.4.2",n=!1;
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2022 Three.js Authors
@@ -36,4 +36,4 @@ var Df=function(e,t){return(Df=Object.setPrototypeOf||{__proto__:[]}instanceof A
36
36
  <https://101arrowz.github.io/fflate>
37
37
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
38
38
  version 0.6.9
39
- */var wy={},by=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},_y=function(e){return new Worker(e)};try{URL.revokeObjectURL(by(""))}catch(gy){by=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},_y=function(e){return new Worker(e,{type:"module"})}}var Ay=Uint8Array,Sy=Uint16Array,My=Uint32Array,Ey=new Ay([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ty=new Ay([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Cy=new Ay([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Iy=function(e,t){for(var n=new Sy(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new My(n[30]);for(i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return[n,r]},Py=Iy(Ey,2),Dy=Py[0],Ry=Py[1];Dy[28]=258,Ry[258]=28;for(var Ly=Iy(Ty,0),By=Ly[0],Oy=Ly[1],Ny=new Sy(32768),ky=0;ky<32768;++ky){var Fy=(43690&ky)>>>1|(21845&ky)<<1;Fy=(61680&(Fy=(52428&Fy)>>>2|(13107&Fy)<<2))>>>4|(3855&Fy)<<4,Ny[ky]=((65280&Fy)>>>8|(255&Fy)<<8)>>>1}var Uy=function(e,t,n){for(var i=e.length,r=0,s=new Sy(t);r<i;++r)++s[e[r]-1];var o,a=new Sy(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(n){o=new Sy(1<<t);var l=15-t;for(r=0;r<i;++r)if(e[r])for(var c=r<<4|e[r],h=t-e[r],u=a[e[r]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[Ny[u]>>>l]=c}else for(o=new Sy(i),r=0;r<i;++r)e[r]&&(o[r]=Ny[a[e[r]-1]++]>>>15-e[r]);return o},zy=new Ay(288);for(ky=0;ky<144;++ky)zy[ky]=8;for(ky=144;ky<256;++ky)zy[ky]=9;for(ky=256;ky<280;++ky)zy[ky]=7;for(ky=280;ky<288;++ky)zy[ky]=8;var Hy=new Ay(32);for(ky=0;ky<32;++ky)Hy[ky]=5;var Gy=Uy(zy,9,0),Vy=Uy(zy,9,1),jy=Uy(Hy,5,0),Wy=Uy(Hy,5,1),Xy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Yy=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},Qy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},qy=function(e){return(e/8|0)+(7&e&&1)},Zy=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Sy?Sy:e instanceof My?My:Ay)(n-t);return i.set(e.subarray(t,n)),i},Ky=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Ay(0);var r=!t||n,s=!n||n.i;n||(n={}),t||(t=new Ay(3*i));var o=function(e){var n=t.length;if(e>n){var i=new Ay(Math.max(2*n,e));i.set(t),t=i}},a=n.f||0,l=n.p||0,c=n.b||0,h=n.l,u=n.d,d=n.m,p=n.n,f=8*i;do{if(!h){n.f=a=Yy(e,l,1);var m=Yy(e,l+1,3);if(l+=3,!m){var g=e[(T=qy(l)+4)-4]|e[T-3]<<8,v=T+g;if(v>i){if(s)throw"unexpected EOF";break}r&&o(c+g),t.set(e.subarray(T,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)h=Vy,u=Wy,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=Yy(e,l,31)+257,x=Yy(e,l+10,15)+4,w=y+Yy(e,l+5,31)+1;l+=14;for(var b=new Ay(w),_=new Ay(19),A=0;A<x;++A)_[Cy[A]]=Yy(e,l+3*A,7);l+=3*x;var S=Xy(_),M=(1<<S)-1,E=Uy(_,S,1);for(A=0;A<w;){var T,C=E[Yy(e,l,M)];if(l+=15&C,(T=C>>>4)<16)b[A++]=T;else{var I=0,P=0;for(16==T?(P=3+Yy(e,l,3),l+=2,I=b[A-1]):17==T?(P=3+Yy(e,l,7),l+=3):18==T&&(P=11+Yy(e,l,127),l+=7);P--;)b[A++]=I}}var D=b.subarray(0,y),R=b.subarray(y);d=Xy(D),p=Xy(R),h=Uy(D,d,1),u=Uy(R,p,1)}if(l>f){if(s)throw"unexpected EOF";break}}r&&o(c+131072);for(var L=(1<<d)-1,B=(1<<p)-1,O=l;;O=l){var N=(I=h[Qy(e,l)&L])>>>4;if((l+=15&I)>f){if(s)throw"unexpected EOF";break}if(!I)throw"invalid length/literal";if(N<256)t[c++]=N;else{if(256==N){O=l,h=null;break}var k=N-254;if(N>264){var F=Ey[A=N-257];k=Yy(e,l,(1<<F)-1)+Dy[A],l+=F}var U=u[Qy(e,l)&B],z=U>>>4;if(!U)throw"invalid distance";l+=15&U;R=By[z];if(z>3){F=Ty[z];R+=Qy(e,l)&(1<<F)-1,l+=F}if(l>f){if(s)throw"unexpected EOF";break}r&&o(c+131072);for(var H=c+k;c<H;c+=4)t[c]=t[c-R],t[c+1]=t[c+1-R],t[c+2]=t[c+2-R],t[c+3]=t[c+3-R];c=H}}n.l=h,n.p=O,n.b=c,h&&(a=1,n.m=d,n.d=u,n.n=p)}while(!a);return c==t.length?t:Zy(t,0,c)},Jy=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8},$y=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8,e[i+2]|=n>>>16},ex=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return[ax,0];if(1==r){var o=new Ay(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,h=1,u=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=r-1;)a=n[n[c].f<n[u].f?c++:u++],l=n[c!=h&&n[c].f<n[u].f?c++:u++],n[h++]={s:-1,f:a.f+l.f,l:a,r:l};var d=s[0].s;for(i=1;i<r;++i)s[i].s>d&&(d=s[i].s);var p=new Sy(d+1),f=tx(n[h-1],p,0);if(f>t){i=0;var m=0,g=f-t,v=1<<g;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i<r;++i){var y=s[i].s;if(!(p[y]>t))break;m+=v-(1<<f-p[y]),p[y]=t}for(m>>>=g;m>0;){var x=s[i].s;p[x]<t?m-=1<<t-p[x]++-1:++i}for(;i>=0&&m;--i){var w=s[i].s;p[w]==t&&(--p[w],++m)}f=t}return[new Ay(p),f]},tx=function(e,t,n){return-1==e.s?Math.max(tx(e.l,t,n+1),tx(e.r,t,n+1)):t[e.s]=n},nx=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Sy(++t),i=0,r=e[0],s=1,o=function(e){n[i++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=e[a]}return[n.subarray(0,i),t]},ix=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},rx=function(e,t,n){var i=n.length,r=qy(t+2);e[r]=255&i,e[r+1]=i>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var s=0;s<i;++s)e[r+s+4]=n[s];return 8*(r+4+i)},sx=function(e,t,n,i,r,s,o,a,l,c,h){Jy(t,h++,n),++r[256];for(var u=ex(r,15),d=u[0],p=u[1],f=ex(s,15),m=f[0],g=f[1],v=nx(d),y=v[0],x=v[1],w=nx(m),b=w[0],_=w[1],A=new Sy(19),S=0;S<y.length;++S)A[31&y[S]]++;for(S=0;S<b.length;++S)A[31&b[S]]++;for(var M=ex(A,7),E=M[0],T=M[1],C=19;C>4&&!E[Cy[C-1]];--C);var I,P,D,R,L=c+5<<3,B=ix(r,zy)+ix(s,Hy)+o,O=ix(r,d)+ix(s,m)+o+14+3*C+ix(A,E)+(2*A[16]+3*A[17]+7*A[18]);if(L<=B&&L<=O)return rx(t,h,e.subarray(l,l+c));if(Jy(t,h,1+(O<B)),h+=2,O<B){I=Uy(d,p,0),P=d,D=Uy(m,g,0),R=m;var N=Uy(E,T,0);Jy(t,h,x-257),Jy(t,h+5,_-1),Jy(t,h+10,C-4),h+=14;for(S=0;S<C;++S)Jy(t,h+3*S,E[Cy[S]]);h+=3*C;for(var k=[y,b],F=0;F<2;++F){var U=k[F];for(S=0;S<U.length;++S){var z=31&U[S];Jy(t,h,N[z]),h+=E[z],z>15&&(Jy(t,h,U[S]>>>5&127),h+=U[S]>>>12)}}}else I=Gy,P=zy,D=jy,R=Hy;for(S=0;S<a;++S)if(i[S]>255){z=i[S]>>>18&31;$y(t,h,I[z+257]),h+=P[z+257],z>7&&(Jy(t,h,i[S]>>>23&31),h+=Ey[z]);var H=31&i[S];$y(t,h,D[H]),h+=R[H],H>3&&($y(t,h,i[S]>>>5&8191),h+=Ty[H])}else $y(t,h,I[i[S]]),h+=P[i[S]];return $y(t,h,I[256]),h+P[256]},ox=new My([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ax=new Ay(0),lx=function(e,t,n,i,r,s){var o=e.length,a=new Ay(i+o+5*(1+Math.ceil(o/7e3))+r),l=a.subarray(i,a.length-r),c=0;if(!t||o<8)for(var h=0;h<=o;h+=65535){var u=h+65535;u<o?c=rx(l,c,e.subarray(h,u)):(l[h]=s,c=rx(l,c,e.subarray(h,o)))}else{for(var d=ox[t-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new Sy(32768),v=new Sy(m+1),y=Math.ceil(n/3),x=2*y,w=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<x)&m},b=new My(25e3),_=new Sy(288),A=new Sy(32),S=0,M=0,E=(h=0,0),T=0,C=0;h<o;++h){var I=w(h),P=32767&h,D=v[I];if(g[P]=D,v[I]=P,T<=h){var R=o-h;if((S>7e3||E>24576)&&R>423){c=sx(e,l,0,b,_,A,M,E,C,h-C,c),E=S=M=0,C=h;for(var L=0;L<286;++L)_[L]=0;for(L=0;L<30;++L)A[L]=0}var B=2,O=0,N=f,k=P-D&32767;if(R>2&&I==w(h-k))for(var F=Math.min(p,R)-1,U=Math.min(32767,h),z=Math.min(258,R);k<=U&&--N&&P!=D;){if(e[h+B]==e[h+B-k]){for(var H=0;H<z&&e[h+H]==e[h+H-k];++H);if(H>B){if(B=H,O=k,H>F)break;var G=Math.min(k,H-2),V=0;for(L=0;L<G;++L){var j=h-k+L+32768&32767,W=j-g[j]+32768&32767;W>V&&(V=W,D=j)}}}k+=(P=D)-(D=g[P])+32768&32767}if(O){b[E++]=268435456|Ry[B]<<18|Oy[O];var X=31&Ry[B],Y=31&Oy[O];M+=Ey[X]+Ty[Y],++_[257+X],++A[Y],T=h+B,++S}else b[E++]=e[h],++_[e[h]]}}c=sx(e,l,s,b,_,A,M,E,C,h-C,c),!s&&7&c&&(c=rx(l,c+1,ax))}return Zy(a,0,i+qy(c)+r)},cx=function(){for(var e=new My(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),hx=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=cx[255&n^t[i]]^n>>>8;e=n},d:function(){return~e}}},ux=function(){var e=1,t=0;return{p:function(n){for(var i=e,r=t,s=n.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)r+=i+=n[o];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}e=i,t=r},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},dx=function(e,t,n,i,r){return lx(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!r)},px=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},fx=function(e,t,n){for(var i=e(),r=e.toString(),s=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<i.length;++o){var a=i[o],l=s[o];if("function"==typeof a){t+=";"+l+"=";var c=a.toString();if(a.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;t+=c.slice(h,c.indexOf("(",h))}else for(var u in t+=c,a.prototype)t+=";"+l+".prototype."+u+"="+a.prototype[u].toString();else t+=c}else n[l]=a}return[t,n]},mx=[],gx=function(e,t,n,i){var r;if(!mx[n]){for(var s="",o={},a=e.length-1,l=0;l<a;++l)s=(r=fx(e[l],s,o))[0],o=r[1];mx[n]=fx(e[a],s,o)}var c=px({},mx[n][1]);return function(e,t,n,i,r){var s=_y(wy[t]||(wy[t]=by(e)));return s.onerror=function(e){return r(e.error,null)},s.onmessage=function(e){return r(null,e.data)},s.postMessage(n,i),s}(mx[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,function(e){var t=[];for(var n in e)(e[n]instanceof Ay||e[n]instanceof Sy||e[n]instanceof My)&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t}(c),i)},vx=function(){return[Ay,Sy,My,Ey,Ty,Cy,Dy,By,Vy,Wy,Ny,Uy,Xy,Yy,Qy,qy,Zy,Ky,Xx,Ax,Sx]},yx=function(){return[Ay,Sy,My,Ey,Ty,Cy,Ry,Oy,Gy,zy,jy,Hy,Ny,ox,ax,Uy,Jy,$y,ex,tx,nx,ix,rx,sx,qy,Zy,lx,dx,Gx,Ax]},xx=function(){return[Rx,Ox,Dx,hx,cx]},wx=function(){return[Lx,Bx]},bx=function(){return[Nx,Dx,ux]},_x=function(){return[kx]},Ax=function(e){return postMessage(e,[e.buffer])},Sx=function(e){return e&&e.size&&new Ay(e.size)},Mx=function(e,t,n,i,r,s){var o=gx(n,i,r,(function(e,t){o.terminate(),s(e,t)}));return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},Ex=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},Tx=function(e,t,n,i,r){var s,o=gx(e,i,r,(function(e,n){e?(o.terminate(),t.ondata.call(t,e)):(n[1]&&o.terminate(),t.ondata.call(t,e,n[0],n[1]))}));o.postMessage(n),t.push=function(e,n){if(s)throw"stream finished";if(!t.ondata)throw"no stream handler";o.postMessage([e,s=n],[e.buffer])},t.terminate=function(){o.terminate()}},Cx=function(e,t){return e[t]|e[t+1]<<8},Ix=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Px=function(e,t){return Ix(e,t)+4294967296*Ix(e,t+4)},Dx=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Rx=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Dx(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var i=0;i<=n.length;++i)e[i+10]=n.charCodeAt(i)}},Lx=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[n++]);return n+(2&t)},Bx=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Ox=function(e){return 10+(e.filename&&e.filename.length+1||0)},Nx=function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)},kx=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function Fx(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var Ux=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(dx(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),zx=function(){return function(e,t){Tx([yx,function(){return[Ex,Ux]}],this,Fx.call(this,e,t),(function(e){var t=new Ux(e.data);onmessage=Ex(t)}),6)}}();function Hx(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[yx],(function(e){return Ax(Gx(e.data[0],e.data[1]))}),0,n)}function Gx(e,t){return dx(e,t||{},0,0)}var Vx=function(){function e(e){this.s={},this.p=new Ay(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new Ay(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=Ky(this.p,this.o,this.s);this.ondata(Zy(n,t,this.s.b),this.d),this.o=Zy(n,this.s.b-32768),this.s.b=this.o.length,this.p=Zy(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),jx=function(){return function(e){this.ondata=e,Tx([vx,function(){return[Ex,Vx]}],this,0,(function(){var e=new Vx;onmessage=Ex(e)}),7)}}();function Wx(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[vx],(function(e){return Ax(Xx(e.data[0],Sx(e.data[1])))}),1,n)}function Xx(e,t){return Ky(e,t)}var Yx=function(){function e(e,t){this.c=hx(),this.l=0,this.v=1,Ux.call(this,e,t)}return e.prototype.push=function(e,t){Ux.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=dx(e,this.o,this.v&&Ox(this.o),t&&8,!t);this.v&&(Rx(n,this.o),this.v=0),t&&(Dx(n,n.length-8,this.c.d()),Dx(n,n.length-4,this.l)),this.ondata(n,t)},e}(),Qx=function(){return function(e,t){Tx([yx,xx,function(){return[Ex,Ux,Yx]}],this,Fx.call(this,e,t),(function(e){var t=new Yx(e.data);onmessage=Ex(t)}),8)}}();function qx(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[yx,xx,function(){return[Zx]}],(function(e){return Ax(Zx(e.data[0],e.data[1]))}),2,n)}function Zx(e,t){t||(t={});var n=hx(),i=e.length;n.p(e);var r=dx(e,t,Ox(t),8),s=r.length;return Rx(r,t),Dx(r,s-8,n.d()),Dx(r,s-4,i),r}var Kx=function(){function e(e){this.v=1,Vx.call(this,e)}return e.prototype.push=function(e,t){if(Vx.prototype.e.call(this,e),this.v){var n=this.p.length>3?Lx(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Vx.prototype.c.call(this,t)},e}(),Jx=function(){return function(e){this.ondata=e,Tx([vx,wx,function(){return[Ex,Vx,Kx]}],this,0,(function(){var e=new Kx;onmessage=Ex(e)}),9)}}();function $x(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[vx,wx,function(){return[ew]}],(function(e){return Ax(ew(e.data[0]))}),3,n)}function ew(e,t){return Ky(e.subarray(Lx(e),-8),t||new Ay(Bx(e)))}var tw=function(){function e(e,t){this.c=ux(),this.v=1,Ux.call(this,e,t)}return e.prototype.push=function(e,t){Ux.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=dx(e,this.o,this.v&&2,t&&4,!t);this.v&&(Nx(n,this.o),this.v=0),t&&Dx(n,n.length-4,this.c.d()),this.ondata(n,t)},e}(),nw=function(){return function(e,t){Tx([yx,bx,function(){return[Ex,Ux,tw]}],this,Fx.call(this,e,t),(function(e){var t=new tw(e.data);onmessage=Ex(t)}),10)}}();function iw(e,t){t||(t={});var n=ux();n.p(e);var i=dx(e,t,2,4);return Nx(i,t),Dx(i,i.length-4,n.d()),i}var rw=function(){function e(e){this.v=1,Vx.call(this,e)}return e.prototype.push=function(e,t){if(Vx.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Vx.prototype.c.call(this,t)},e}(),sw=function(){return function(e){this.ondata=e,Tx([vx,_x,function(){return[Ex,Vx,rw]}],this,0,(function(){var e=new rw;onmessage=Ex(e)}),11)}}();function ow(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[vx,_x,function(){return[aw]}],(function(e){return Ax(aw(e.data[0],Sx(e.data[1])))}),5,n)}function aw(e,t){return Ky((kx(e),e.subarray(2,-4)),t)}var lw=function(){function e(e){this.G=Kx,this.I=Vx,this.Z=rw,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new Ay(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,r=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(r):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(r):new this.Z(r),this.s.push(this.p,t),this.p=null}}},e}(),cw=function(){function e(e){this.G=Jx,this.I=jx,this.Z=sw,this.ondata=e}return e.prototype.push=function(e,t){lw.prototype.push.call(this,e,t)},e}();var hw=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r;s instanceof Ay?n[o]=[s,i]:Array.isArray(s)?n[o]=[s[0],px(i,s[1])]:hw(s,o+"/",n,i)}},uw="undefined"!=typeof TextEncoder&&new TextEncoder,dw="undefined"!=typeof TextDecoder&&new TextDecoder,pw=0;try{dw.decode(ax,{stream:!0}),pw=1}catch(gy){}var fw=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return[t,Zy(e,n-1)];r?3==r?(i=((15&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|i>>10,56320|1023&i)):t+=1&r?String.fromCharCode((31&i)<<6|63&e[n++]):String.fromCharCode((15&i)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(i)}},mw=function(){function e(e){this.ondata=e,pw?this.t=new TextDecoder:this.p=ax}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new Ay(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=fw(n),r=i[0],s=i[1];if(t){if(s.length)throw"invalid utf-8 data";this.p=null}else this.p=s;this.ondata(r,t)}},e}(),gw=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(vw(e),this.d=t||!1)},e}();function vw(e,t){if(t){for(var n=new Ay(e.length),i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(uw)return uw.encode(e);var r=e.length,s=new Ay(e.length+(e.length>>1)),o=0,a=function(e){s[o++]=e};for(i=0;i<r;++i){if(o+5>s.length){var l=new Ay(o+8+(r-i<<1));l.set(s),s=l}var c=e.charCodeAt(i);c<128||t?a(c):c<2048?(a(192|c>>6),a(128|63&c)):c>55295&&c<57344?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|63&c)):(a(224|c>>12),a(128|c>>6&63),a(128|63&c))}return Zy(s,0,o)}function yw(e,t){if(t){for(var n="",i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}if(dw)return dw.decode(e);var r=fw(e),s=r[0];if(r[1].length)throw"invalid utf-8 data";return s}var xw=function(e){return 1==e?3:e<6?2:9==e?1:0},ww=function(e,t){return t+30+Cx(e,t+26)+Cx(e,t+28)},bw=function(e,t,n){var i=Cx(e,t+28),r=yw(e.subarray(t+46,t+46+i),!(2048&Cx(e,t+8))),s=t+46+i,o=Ix(e,t+20),a=n&&4294967295==o?_w(e,s):[o,Ix(e,t+24),Ix(e,t+42)],l=a[0],c=a[1],h=a[2];return[Cx(e,t+10),l,c,r,s+Cx(e,t+30)+Cx(e,t+32),h]},_w=function(e,t){for(;1!=Cx(e,t);t+=4+Cx(e,t+2));return[Px(e,t+12),Px(e,t+4),Px(e,t+20)]},Aw=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)throw"extra field too long";t+=i+4}return t},Sw=function(e,t,n,i,r,s,o,a){var l=i.length,c=n.extra,h=a&&a.length,u=Aw(c);Dx(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==s&&8),e[t++]=r&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(Dx(e,t,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),t+=4,null!=s&&(Dx(e,t,n.crc),Dx(e,t+4,s),Dx(e,t+8,n.size)),Dx(e,t+12,l),Dx(e,t+14,u),t+=16,null!=o&&(Dx(e,t,h),Dx(e,t+6,n.attrs),Dx(e,t+10,o),t+=14),e.set(i,t),t+=l,u)for(var f in c){var m=c[f],g=m.length;Dx(e,t,+f),Dx(e,t+2,g),e.set(m,t+4),t+=4+g}return h&&(e.set(a,t),t+=h),t},Mw=function(e,t,n,i,r){Dx(e,t,101010256),Dx(e,t+8,n),Dx(e,t+10,n),Dx(e,t+12,i),Dx(e,t+16,r)},Ew=function(){function e(e){this.filename=e,this.c=hx(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),Tw=function(){function e(e,t){var n=this;t||(t={}),Ew.call(this,e),this.d=new Ux(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=xw(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){Ew.prototype.push.call(this,e,t)},e}(),Cw=function(){function e(e,t){var n=this;t||(t={}),Ew.call(this,e),this.d=new zx(t,(function(e,t,i){n.ondata(e,t,i)})),this.compression=8,this.flag=xw(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){Ew.prototype.push.call(this,e,t)},e}(),Iw=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=vw(e.filename),i=n.length,r=e.comment,s=r&&vw(r),o=i!=e.filename.length||s&&r.length!=s.length,a=i+Aw(e.extra)+30;if(i>65535)throw"filename too long";var l=new Ay(a);Sw(l,0,e,n,o);var c=[l],h=function(){for(var e=0,n=c;e<n.length;e++){var i=n[e];t.ondata(null,i,!1)}c=[]},u=this.d;this.d=0;var d=this.u.length,p=px(e,{f:n,u:o,o:s,t:function(){e.terminate&&e.terminate()},r:function(){if(h(),u){var e=t.u[d+1];e?e.r():t.d=1}u=1}}),f=0;e.ondata=function(n,i,r){if(n)t.ondata(n,i,r),t.terminate();else if(f+=i.length,c.push(i),r){var s=new Ay(16);Dx(s,0,134695760),Dx(s,4,e.crc),Dx(s,8,f),Dx(s,12,e.size),c.push(s),p.c=f,p.b=a+f+16,p.crc=e.crc,p.size=e.size,u&&p.r(),u=1}else u&&h()},this.u.push(p)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,i=0,r=this.u;i<r.length;i++){n+=46+(l=r[i]).f.length+Aw(l.extra)+(l.o?l.o.length:0)}for(var s=new Ay(n+22),o=0,a=this.u;o<a.length;o++){var l=a[o];Sw(s,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+Aw(l.extra)+(l.o?l.o.length:0),t+=l.b}Mw(s,e,this.u.length,n,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){t[e].t()}this.d=2},e}();var Pw=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),Dw=function(){function e(){var e=this;this.i=new Vx((function(t,n){e.ondata(null,t,n)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},e.compression=8,e}(),Rw=function(){function e(e,t){var n=this;t<32e4?this.i=new Vx((function(e,t){n.ondata(null,e,t)})):(this.i=new jx((function(e,t,i){n.ondata(e,t,i)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Zy(e,0)),this.i.push(e,t)},e.compression=8,e}(),Lw=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Pw},this.p=ax}return e.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var i=Math.min(this.c,e.length),r=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(e=e.subarray(i)).length)return this.push(e,t)}else{var s=0,o=0,a=void 0,l=void 0;this.p.length?e.length?((l=new Ay(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,h=this.c,u=h&&this.d,d=function(){var e,t=Ix(l,o);if(67324752==t){s=1,a=o,p.d=null,p.c=0;var i=Cx(l,o+6),r=Cx(l,o+8),u=2048&i,d=8&i,f=Cx(l,o+26),m=Cx(l,o+28);if(c>o+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=Ix(l,o+18),x=Ix(l,o+22),w=yw(l.subarray(o+30,o+=30+f),!u);4294967295==y?(e=d?[-2]:_w(l,o),y=e[0],x=e[1]):d&&(y=-1),o+=m,p.c=y;var b={name:w,compression:r,start:function(){if(!b.ondata)throw"no callback";if(y){var e=n.o[r];if(!e)throw"unknown compression type "+r;(v=y<0?new e(w):new e(w,y,x)).ondata=function(e,t,n){b.ondata(e,t,n)};for(var t=0,i=g;t<i.length;t++){var s=i[t];v.push(s,!1)}n.k[0]==g&&n.c?n.d=v:v.push(ax,!0)}else b.ondata(null,ax,!0)},terminate:function(){v&&v.terminate&&v.terminate()}};y>=0&&(b.size=y,b.originalSize=x),p.onfile(b)}return"break"}if(h){if(134695760==t)return a=o+=12+(-2==h&&8),s=3,p.c=0,"break";if(33639248==t)return a=o-=4,s=3,p.c=0,"break"}},p=this;o<c-4;++o){if("break"===d())break}if(this.p=ax,h<0){var f=s?l.subarray(0,a-12-(-2==h&&8)-(134695760==Ix(l,a-16)&&4)):l.subarray(0,o);u?u.push(f,!!s):this.k[+(2==s)].push(f)}if(2&s)return this.push(l.subarray(o),t);this.p=l.subarray(o)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();var Bw=Object.freeze({__proto__:null,Deflate:Ux,AsyncDeflate:zx,deflate:Hx,deflateSync:Gx,Inflate:Vx,AsyncInflate:jx,inflate:Wx,inflateSync:Xx,Gzip:Yx,AsyncGzip:Qx,gzip:qx,gzipSync:Zx,Gunzip:Kx,AsyncGunzip:Jx,gunzip:$x,gunzipSync:ew,Zlib:tw,AsyncZlib:nw,zlib:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[yx,bx,function(){return[iw]}],(function(e){return Ax(iw(e.data[0],e.data[1]))}),4,n)},zlibSync:iw,Unzlib:rw,AsyncUnzlib:sw,unzlib:ow,unzlibSync:aw,compress:qx,AsyncCompress:Qx,compressSync:Zx,Compress:Yx,Decompress:lw,AsyncDecompress:cw,decompress:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?$x(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Wx(e,t,n):ow(e,t,n)},decompressSync:function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?ew(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Xx(e,t):aw(e,t)},DecodeUTF8:mw,EncodeUTF8:gw,strToU8:vw,strFromU8:yw,ZipPassThrough:Ew,ZipDeflate:Tw,AsyncZipDeflate:Cw,Zip:Iw,zip:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";var i={};hw(e,"",i,t);var r=Object.keys(i),s=r.length,o=0,a=0,l=s,c=new Array(s),h=[],u=function(){for(var e=0;e<h.length;++e)h[e]()},d=function(){var e=new Ay(a+22),t=o,i=a-o;a=0;for(var r=0;r<l;++r){var s=c[r];try{var h=s.c.length;Sw(e,a,s,s.f,s.u,h);var u=30+s.f.length+Aw(s.extra),d=a+u;e.set(s.c,d),Sw(e,o,s,s.f,s.u,h,a,s.m),o+=16+u+(s.m?s.m.length:0),a=d+h}catch(e){return n(e,null)}}Mw(e,o,c.length,i,t),n(null,e)};s||d();for(var p=function(e){var t=r[e],l=i[t],p=l[0],f=l[1],m=hx(),g=p.length;m.p(p);var v=vw(t),y=v.length,x=f.comment,w=x&&vw(x),b=w&&w.length,_=Aw(f.extra),A=0==f.level?0:8,S=function(i,r){if(i)u(),n(i,null);else{var l=r.length;c[e]=px(f,{size:g,crc:m.d(),c:r,f:v,m:w,u:y!=t.length||w&&x.length!=b,compression:A}),o+=30+y+_+l,a+=76+2*(y+_)+(b||0)+l,--s||d()}};if(y>65535&&S("filename too long",null),A)if(g<16e4)try{S(null,Gx(p,f))}catch(e){S(e,null)}else h.push(Hx(p,f,S));else S(null,p)},f=0;f<l;++f)p(f);return u},zipSync:function(e,t){t||(t={});var n={},i=[];hw(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],l=a[0],c=a[1],h=0==c.level?0:8,u=(A=vw(o)).length,d=c.comment,p=d&&vw(d),f=p&&p.length,m=Aw(c.extra);if(u>65535)throw"filename too long";var g=h?Gx(l,c):l,v=g.length,y=hx();y.p(l),i.push(px(c,{size:l.length,crc:y.d(),c:g,f:A,m:p,u:u!=o.length||p&&d.length!=f,o:r,compression:h})),r+=30+u+m+v,s+=76+2*(u+m)+(f||0)+v}for(var x=new Ay(s+22),w=r,b=s-r,_=0;_<i.length;++_){var A=i[_];Sw(x,A.o,A,A.f,A.u,A.c.length);var S=30+A.f.length+Aw(A.extra);x.set(A.c,A.o+S),Sw(x,r,A,A.f,A.u,A.c.length,A.o,A.m),r+=16+S+(A.m?A.m.length:0)}return Mw(x,r,i.length,b,w),x},UnzipPassThrough:Pw,UnzipInflate:Dw,AsyncUnzipInflate:Rw,Unzip:Lw,unzip:function(e,t){if("function"!=typeof t)throw"no callback";for(var n=[],i=function(){for(var e=0;e<n.length;++e)n[e]()},r={},s=e.length-22;101010256!=Ix(e,s);--s)if(!s||e.length-s>65558)return void t("invalid zip file",null);var o=Cx(e,s+8);o||t(null,{});var a=o,l=Ix(e,s+16),c=4294967295==l;if(c){if(s=Ix(e,s-12),101075792!=Ix(e,s))return void t("invalid zip file",null);a=o=Ix(e,s+32),l=Ix(e,s+48)}for(var h=function(s){var a=bw(e,l,c),h=a[0],u=a[1],d=a[2],p=a[3],f=a[4],m=a[5],g=ww(e,m);l=f;var v=function(e,n){e?(i(),t(e,null)):(r[p]=n,--o||t(null,r))};if(h)if(8==h){var y=e.subarray(g,g+u);if(u<32e4)try{v(null,Xx(y,new Ay(d)))}catch(e){v(e,null)}else n.push(Wx(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,Zy(e,g,g+u))},u=0;u<a;++u)h();return i},unzipSync:function(e){for(var t={},n=e.length-22;101010256!=Ix(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var i=Cx(e,n+8);if(!i)return{};var r=Ix(e,n+16),s=4294967295==r;if(s){if(n=Ix(e,n-12),101075792!=Ix(e,n))throw"invalid zip file";i=Ix(e,n+32),r=Ix(e,n+48)}for(var o=0;o<i;++o){var a=bw(e,r,s),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],p=a[5],f=ww(e,p);if(r=d,l){if(8!=l)throw"unknown compression type "+l;t[u]=Xx(e.subarray(f,f+c),new Ay(h))}else t[u]=Zy(e,f,f+c)}return t}});function Ow(e,t,n){const i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,s=i,o=Math.floor((r+s)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?s=o:r=o,o=Math.floor((r+s)/2);return o}function Nw(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let i=1;for(let e=2;e<=t;++e)i*=e;for(let n=2;n<=e-t;++n)i*=n;return n/i}function kw(e,t,n,i,r){return function(e){const t=e.length,n=[],i=[];for(let r=0;r<t;++r){const t=e[r];n[r]=new dt(t.x,t.y,t.z),i[r]=t.w}const r=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(r[e-n].clone().multiplyScalar(Nw(e,n)*i[n]));r[e]=t.divideScalar(i[0])}return r}(function(e,t,n,i,r){const s=r<e?r:e,o=[],a=Ow(e,i,t),l=function(e,t,n,i,r){const s=[];for(let e=0;e<=n;++e)s[e]=0;const o=[];for(let e=0;e<=i;++e)o[e]=s.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let i=1;i<=n;++i){l[i]=t-r[e+1-i],c[i]=r[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=c[e+1],r=l[i-e];a[i][e]=t+r;const s=a[e][i-1]/a[i][e];a[e][i]=n+t*s,n=r*s}a[i][i]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,r=1;const l=[];for(let e=0;e<=n;++e)l[e]=s.slice(0);l[0][0]=1;for(let s=1;s<=i;++s){let i=0;const c=e-s,h=n-s;e>=s&&(l[r][0]=l[t][0]/a[h+1][c],i=l[r][0]*a[c][h]);const u=e-1<=h?s-1:n-e;for(let e=c>=-1?1:-c;e<=u;++e)l[r][e]=(l[t][e]-l[t][e-1])/a[h+1][c+e],i+=l[r][e]*a[c+e][h];e<=h&&(l[r][s]=-l[t][s-1]/a[h+1][e],i+=l[r][s]*a[e][h]),o[s][e]=i;const d=t;t=r,r=d}}let h=n;for(let e=1;e<=i;++e){for(let t=0;t<=n;++t)o[e][t]*=h;h*=n-e}return o}(a,i,e,s,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),i=t.w;t.x*=i,t.y*=i,t.z*=i,c[e]=t}for(let t=0;t<=s;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let i=1;i<=e;++i)n.add(c[a-e+i].clone().multiplyScalar(l[t][i]));o[t]=n}for(let e=s+1;e<=r+1;++e)o[e]=new rt(0,0,0);return o}(e,t,n,i,r))}class Fw extends Ea{constructor(e,t,n,i,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new rt(t.x,t.y,t.z,t.w)}}getPoint(e,t=new dt){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=function(e,t,n,i){const r=Ow(e,i,t),s=function(e,t,n,i){const r=[],s=[],o=[];r[0]=1;for(let a=1;a<=n;++a){s[a]=t-i[e+1-a],o[a]=i[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],i=s[a-e],l=r[e]/(t+i);r[e]=n+t*l,n=i*l}r[a]=n}return r}(r,i,e,t),o=new rt(0,0,0,0);for(let t=0;t<=e;++t){const i=n[r-e+t],a=s[t],l=i.w*a;o.x+=i.x*l,o.y+=i.y*l,o.z+=i.z*l,o.w+=i.w*a}return o}(this.degree,this.knots,this.controlPoints,i);return 1!==r.w&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new dt){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=kw(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}}let Uw,zw,Hw;class Gw extends Sc{constructor(e){super(e)}load(e,t,n,i){const r=this,s=""===r.path?Kc.extractUrlBase(e):r.path,o=new Ec(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(n,s))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===sb(e,0,t.length)}(e))Uw=(new Yw).parse(e);else{const t=sb(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(t){const i=e[t-1];return e=e.slice(n+t),n++,i}for(let e=0;e<t.length;++e){if(i(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Zw(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Zw(t));Uw=(new Xw).parse(t)}const n=new Pc(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Vw(n,this.manager).parse(Uw)}}class Vw{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){zw=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=(new jw).parse(i);return this.parseScene(i,r,n),Hw}parseConnections(){const e=new Map;if("Connections"in Uw){Uw.Connections.connections.forEach((function(t){const n=t[0],i=t[1],r=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const s={ID:i,relationship:r};e.get(n).parents.push(s),e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:n,relationship:r};e.get(i).children.push(o)}))}return e}parseImages(){const e={},t={};if("Video"in Uw.Objects){const n=Uw.Objects.Video;for(const i in n){const r=n[i];if(e[parseInt(i)]=r.RelativeFilename||r.Filename,"Content"in r){const e=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,s="string"==typeof r.Content&&""!==r.Content;if(e||s){const e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(const n in e){const i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in Uw.Objects){const n=Uw.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,r=e.WrapModeV,s=void 0!==i?i.value:0,o=void 0!==r?r.value:0;if(n.wrapS=0===s?u:d,n.wrapT=0===o?u:d,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,r=zw.get(e.id).children;let s;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const o=e.FileName.slice(-3).toLowerCase();if("tga"===o){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new it):(t.setPath(this.textureLoader.path),s=t.load(n))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new it):s=this.textureLoader.load(n);return this.textureLoader.setPath(i),s}parseMaterials(e){const t=new Map;if("Material"in Uw.Objects){const n=Uw.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!zw.has(n))return null;const s=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new $l;break;case"lambert":o=new nc;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new $l}return o.setValues(s),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new Ke).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new Ke).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new Ke).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new Ke).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new Ke).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new Ke).fromArray(e.SpecularColor.value));const r=this;return zw.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=de);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=de);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=l,i.envMap.encoding=de);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=de);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in Uw.Objects&&t in Uw.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=zw.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Uw.Objects){const n=Uw.Objects.Deformer;for(const i in n){const r=n[i],s=zw.get(parseInt(i));if("Skin"===r.attrType){const t=this.parseSkeleton(s,n);t.ID=i,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(s,n),e.id=i,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const r={ID:e.ID,indices:[],weights:[],transformLink:(new Vt).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const r=e.children[i],s=t[r.ID],o={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;o.geoID=zw.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(o)}return n}parseScene(e,t,n){Hw=new ao;const i=this.parseModels(e.skeletons,t,n),r=Uw.Objects.Model,s=this;i.forEach((function(e){const t=r[e.ID];s.setLookAtProperties(e,t);zw.get(e.ID).parents.forEach((function(t){const n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&Hw.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),Hw.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=nb(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const o=(new Ww).parse();1===Hw.children.length&&Hw.children[0].isGroup&&(Hw.children[0].animations=o,Hw=Hw.children[0]),Hw.animations=o}parseModels(e,t,n){const i=new Map,r=Uw.Objects.Model;for(const s in r){const o=parseInt(s),a=r[s],l=zw.get(o);let c=this.buildSkeleton(l,e,o,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new Yo;break;case"Null":default:c=new ao}c.name=a.attrName?Oh.sanitizeNodeName(a.attrName):"",c.ID=o}this.getTransformData(c,a),i.set(o,c)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach((function(e){for(const s in t){const o=t[s];o.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=r;r=new Yo,r.matrixWorld.copy(t.transformLink),r.name=i?Oh.sanitizeNodeName(i):"",r.ID=n,o.bones[s]=r,null!==e&&r.add(e)}}))}})),r}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=Uw.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new mn;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let r=1e3;void 0!==n.FarPlane&&(r=n.FarPlane.value/1e3);let s=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,o=n.AspectHeight.value);const a=s/o;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new _i(l,a,i,r),null!==c&&t.setFocalLength(c);break;case 1:t=new Xi(-s/2,s/2,o/2,-o/2,i,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new mn}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=Uw.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new mn;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new Ke).fromArray(n.Color.value));let r=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(r=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new Vc(i,r,s,o);break;case 1:t=new Wc(i,r);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=Be.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=Be.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new Fc(i,r,s,e,a,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Vc(i,r)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,s=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(r=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))})),o.length>1?s=o:o.length>0?s=o[0]:(s=new $l({color:13421772}),o.push(s)),"color"in r.attributes&&o.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new Xo(r,s),i.normalizeSkinWeights()):i=new fi(r,s),i}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new ra({color:3342591,linewidth:1});return new ha(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?ib(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){zw.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=Uw.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Hw.add(e.target)):e.lookAt((new dt).fromArray(t))}}}))}}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const r in e){const s=e[r];zw.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;zw.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Ko(s.bones),i[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in Uw.Objects){const t=Uw.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new Vt).fromArray(t.Matrix.a)})):e[i.Node]=(new Vt).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Uw&&"AmbientColor"in Uw.GlobalSettings){const e=Uw.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new Ke(t,n,i);Hw.add(new Xc(e,1))}}}}class jw{parse(e){const t=new Map;if("Geometry"in Uw.Objects){const n=Uw.Objects.Geometry;for(const i in n){const r=zw.get(parseInt(i)),s=this.parseGeometry(r,n[i],e);t.set(parseInt(i),s)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,r=[],s=e.parents.map((function(e){return Uw.Objects.Model[e.ID]}));if(0===s.length)return;const o=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=ib(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=nb(l);return this.genGeometry(t,o,r,c)}genGeometry(e,t,n,i){const r=new Zn;e.attrName&&(r.name=e.attrName);const s=this.parseGeoNode(e,t),o=this.genBuffers(s),a=new Hn(o.vertex,3);if(a.applyMatrix4(i),r.setAttribute("position",a),o.colors.length>0&&r.setAttribute("color",new Hn(o.colors,3)),t&&(r.setAttribute("skinIndex",new kn(o.weightsIndices,4)),r.setAttribute("skinWeight",new Hn(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const e=(new Ne).getNormalMatrix(i),t=new Hn(o.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(o.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),r.setAttribute(n,new Hn(o.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){const t=r.groups[r.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&r.addGroup(n,o.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,s=[],o=[],a=[],l=[],c=[],h=[];const u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(s.push(3*d,3*d+1,3*d+2),e.color){const t=$w(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,s=g[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;const o=e[n];e[n]=s,s=o}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)c.push(v[e]),h.push(g[e])}if(e.normal){const t=$w(p,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=$w(p,n,d,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const i=$w(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,m&&(u.genFace(t,e,s,f,o,a,l,c,h,i),n++,i=0,s=[],o=[],a=[],l=[],c=[],h=[])})),t}genFace(e,t,n,i,r,s,o,a,l,c){for(let h=2;h<c;h++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(h-1)]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+2]]),e.vertex.push(t.vertexPositions[n[3*h]]),e.vertex.push(t.vertexPositions[n[3*h+1]]),e.vertex.push(t.vertexPositions[n[3*h+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(h-1)]),e.vertexWeights.push(a[4*(h-1)+1]),e.vertexWeights.push(a[4*(h-1)+2]),e.vertexWeights.push(a[4*(h-1)+3]),e.vertexWeights.push(a[4*h]),e.vertexWeights.push(a[4*h+1]),e.vertexWeights.push(a[4*h+2]),e.vertexWeights.push(a[4*h+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(h-1)]),e.weightsIndices.push(l[4*(h-1)+1]),e.weightsIndices.push(l[4*(h-1)+2]),e.weightsIndices.push(l[4*(h-1)+3]),e.weightsIndices.push(l[4*h]),e.weightsIndices.push(l[4*h+1]),e.weightsIndices.push(l[4*h+2]),e.weightsIndices.push(l[4*h+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[3*(h-1)]),e.colors.push(s[3*(h-1)+1]),e.colors.push(s[3*(h-1)+2]),e.colors.push(s[3*h]),e.colors.push(s[3*h+1]),e.colors.push(s[3*h+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(h-1)]),e.normal.push(r[3*(h-1)+1]),e.normal.push(r[3*(h-1)+2]),e.normal.push(r[3*h]),e.normal.push(r[3*h+1]),e.normal.push(r[3*h+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][0]),e.uvs[n].push(o[n][1]),e.uvs[n].push(o[n][2*(h-1)]),e.uvs[n].push(o[n][2*(h-1)+1]),e.uvs[n].push(o[n][2*h]),e.uvs[n].push(o[n][2*h+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=Uw.Objects.Geometry[n.geoID];void 0!==s&&r.genMorphGeometry(e,t,s,i,n.name)}))}))}genMorphGeometry(e,t,n,i,r){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=o[3*e],c[t+1]=o[3*e+1],c[t+2]=o[3*e+2]}const h={vertexIndices:s,vertexPositions:c},u=this.genBuffers(h),d=new Hn(u.vertex,3);d.name=r||n.attrName,d.applyMatrix4(i),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let r=[];return"IndexToDirect"===n&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let r=[];return"IndexToDirect"===n&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let r=[];return"IndexToDirect"===n&&(r=e.ColorIndex.a),{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,r=[];for(let e=0;e<i.length;++e)r.push(e);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(void 0===Fw)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new Zn;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Zn;const n=t-1,i=e.KnotVector.a,r=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)r.push((new rt).fromArray(s,e));let o,a;if("Closed"===e.Form)r.push(r[0]);else if("Periodic"===e.Form){o=n,a=i.length-1-o;for(let e=0;e<n;++e)r.push(r[e])}const l=new Fw(n,i,r,o,a).getPoints(12*r.length);return(new Zn).setFromPoints(l)}}class Ww{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(void 0===Uw.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Uw.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){const e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Uw.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Kw),values:t[n].KeyValueFloat.a},r=zw.get(i.id);if(void 0!==r){const t=r.parents[0].ID,n=r.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){const t=Uw.Objects.AnimationLayer,n=new Map;for(const i in t){const t=[],r=zw.get(parseInt(i));if(void 0!==r){r.children.forEach((function(n,i){if(e.has(n.ID)){const r=e.get(n.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===t[i]){const e=zw.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const r=Uw.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:r.attrName?Oh.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Hw.traverse((function(e){e.ID===r.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new Vt),"PreRotation"in r&&(s.preRotation=r.PreRotation.value),"PostRotation"in r&&(s.postRotation=r.PostRotation.value),t[i]=s}}t[i]&&(t[i][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===t[i]){const e=zw.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=zw.get(e).parents[0].ID,s=zw.get(r).parents[0].ID,o=zw.get(s).parents[0].ID,a=Uw.Objects.Model[o],l={modelName:a.attrName?Oh.sanitizeNodeName(a.attrName):"",morphName:Uw.Objects.Deformer[e].attrName};t[i]=l}t[i][r.attr]=r}}})),n.set(parseInt(i),t)}}return n}parseAnimStacks(e){const t=Uw.Objects.AnimationStack,n={};for(const i in t){const r=zw.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new xc(e.name,-1,t)}generateTracks(e){const t=[];let n=new dt,i=new ut,r=new dt;if(e.transform&&e.transform.decompose(n,i,r),n=n.toArray(),i=(new $t).setFromQuaternion(i,e.eulerOrder).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){const r=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(r,t,n);return new yc(e+"."+i,r,s)}generateRotationTrack(e,t,n,i,r,s){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Be.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Be.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Be.degToRad));const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);void 0!==i&&((i=i.map(Be.degToRad)).push(s),i=(new $t).fromArray(i),i=(new ut).setFromEuler(i)),void 0!==r&&((r=r.map(Be.degToRad)).push(s),r=(new $t).fromArray(r),r=(new ut).setFromEuler(r).invert());const l=new ut,c=new $t,h=[];for(let e=0;e<a.length;e+=3)c.set(a[e],a[e+1],a[e+2],s),l.setFromEuler(c),void 0!==i&&l.premultiply(i),void 0!==r&&l.multiply(r),l.toArray(h,e/3*4);return new gc(e+".quaternion",o,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=Hw.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new fc(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){const r=t[i];r!==n&&(t[e]=r,n=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const i=n,r=[];let s=-1,o=-1,a=-1;return e.forEach((function(e){if(t.x&&(s=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==s){const e=t.x.values[s];r.push(e),i[0]=e}else r.push(i[0]);if(-1!==o){const e=t.y.values[o];r.push(e),i[1]=e}else r.push(i[1]);if(-1!==a){const e=t.z.values[a];r.push(e),i[2]=e}else r.push(i[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,r=Math.abs(i);if(r>=180){const s=r/180,o=i/s;let a=n+o;const l=e.times[t-1],c=(e.times[t]-l)/s;let h=l+c;const u=[],d=[];for(;h<e.times[t];)u.push(h),h+=c,d.push(a),a+=o;e.times=ob(e.times,t,u),e.values=ob(e.values,t,d)}}}}class Xw{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new qw,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){const r=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(r||s)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:n},s=this.parseNodeAttr(i),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,r):n in o?("PoseNode"===n?o.PoseNode.push(r):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==s.id&&(o[n][s.id]=r)):"number"==typeof s.id?(o[n]={},o[n][s.id]=r):"Properties70"!==n&&(o[n]="PoseNode"===n?[r]:r),"number"==typeof s.id&&(r.id=s.id),""!==s.name&&(r.attrName=s.name),""!==s.type&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===i){const e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=r.split(",").slice(3);o=o.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],function(e,t){for(let n=0,i=e.length,r=t.length;n<r;n++,i++)e[i]=t[n]}(r,o),void 0===s[i]&&(s[i]=[])}"Node"===i&&(s.id=r),i in s&&Array.isArray(s[i])?s[i].push(r):"a"!==i?s[i]=r:s.a=r,this.setCurrentProp(s,i),"a"===i&&","!==r.slice(-1)&&(s.a=rb(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=rb(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],s=i[1],o=i[2],a=i[3];let l=i[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=rb(l)}this.getPrevNode()[r]={type:s,type2:o,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),r)}}class Yw{parse(e){const t=new Qw(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new qw;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),o=e.getString(s);if(0===i)return null;const a=[];for(let t=0;t<r;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",h=a.length>2?a[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){const i=this.parseNode(e,t);null!==i&&this.parseSubNode(o,n,i)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==h&&(n.attrType=h),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],i=n.propertyList[1];const r=n.propertyList[2],s=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),o="Color"===i||"ColorRGB"===i||"Vector"===i||"Vector3D"===i||0===i.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:i,type2:r,flag:s,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),r=e.getUint32(),s=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}void 0===Bw&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=aw(new Uint8Array(e.getArrayBuffer(s))),a=new Qw(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(i);case"d":return a.getFloat64Array(i);case"f":return a.getFloat32Array(i);case"i":return a.getInt32Array(i);case"l":return a.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Qw{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Kc.decodeText(new Uint8Array(t))}}class qw{add(e,t){this[e]=t}}function Zw(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Kw(e){return e/46186158e3}const Jw=[];function $w(e,t,n,i){let r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);const s=r*i.dataSize,o=s+i.dataSize;return function(e,t,n,i){for(let r=n,s=0;r<i;r++,s++)e[s]=t[r];return e}(Jw,i.buffer,s,o)}const eb=new $t,tb=new dt;function nb(e){const t=new Vt,n=new Vt,i=new Vt,r=new Vt,s=new Vt,o=new Vt,a=new Vt,l=new Vt,c=new Vt,h=new Vt,u=new Vt,d=new Vt,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(tb.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(Be.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(eb.fromArray(t))}if(e.rotation){const t=e.rotation.map(Be.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(eb.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(Be.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(eb.fromArray(t)),r.invert()}e.scale&&s.scale(tb.fromArray(e.scale)),e.scalingOffset&&a.setPosition(tb.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(tb.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(tb.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(tb.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(u.copy(e.parentMatrix),h.copy(e.parentMatrixWorld));const f=n.clone().multiply(i).multiply(r),m=new Vt;m.extractRotation(h);const g=new Vt;g.copyPosition(h);const v=g.clone().invert().multiply(h),y=m.clone().invert().multiply(v),x=s,w=new Vt;if(0===p)w.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)w.copy(m).multiply(y).multiply(f).multiply(x);else{const e=(new Vt).scale((new dt).setFromMatrixScale(u)).clone().invert(),t=y.clone().multiply(e);w.copy(m).multiply(f).multiply(t).multiply(x)}const b=c.clone().invert(),_=o.clone().invert();let A=t.clone().multiply(l).multiply(c).multiply(n).multiply(i).multiply(r).multiply(b).multiply(a).multiply(o).multiply(s).multiply(_);const S=(new Vt).copyPosition(A),M=h.clone().multiply(S);return d.copyPosition(M),A=d.clone().multiply(w),A.premultiply(h.invert()),A}function ib(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function rb(e){return e.split(",").map((function(e){return parseFloat(e)}))}function sb(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),Kc.decodeText(new Uint8Array(e,t,n))}function ob(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class ab extends Ic{constructor(e){super(e)}parse(e){const t=0,n=1,i=2,r=3,s=9,o=10,a=11,l=48,c=4,h=0,u=1,d=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let f=0;const m=new Uint8Array(e),g={id_length:m[f++],colormap_type:m[f++],image_type:m[f++],colormap_index:m[f++]|m[f++]<<8,colormap_length:m[f++]|m[f++]<<8,colormap_size:m[f++],origin:[m[f++]|m[f++]<<8,m[f++]|m[f++]<<8],width:m[f++]|m[f++]<<8,height:m[f++]|m[f++]<<8,pixel_size:m[f++],flags:m[f++]};!function(e){switch(e.image_type){case n:case s:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case r:case o:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+f>e.length&&console.error("THREE.TGALoader: No data."),f+=g.id_length;let v=!1,y=!1,w=!1;switch(g.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case o:v=!0;break;case i:break;case a:v=!0,w=!0;break;case r:w=!0}const b=new Uint8Array(g.width*g.height*4),_=function(e,t,n,i,r){let s,o;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(o=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let o=0;const c=new Uint8Array(a);for(;o<l;)if(e=r[i++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=r[i++];for(n=0;n<t;++n)s.set(c,o+n*a);o+=a*t}else{for(t*=a,n=0;n<t;++n)s[o+n]=r[i++];o+=t}}else s=r.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:s,palettes:o}}(v,y,g,f,m);return function(e,t,n,i,r){let s,o,a,f,m,v;switch((g.flags&l)>>c){default:case d:s=0,a=1,m=t,o=0,f=1,v=n;break;case h:s=0,a=1,m=t,o=n-1,f=-1,v=-1;break;case p:s=t-1,a=-1,m=-1,o=0,f=1,v=n;break;case u:s=t-1,a=-1,m=-1,o=n-1,f=-1,v=-1}if(w)switch(g.pixel_size){case 8:!function(e,t,n,i,r,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==i;h+=n)for(c=r;c!==o;c+=s,u++)l=a[u],e[4*(c+d*h)+0]=l,e[4*(c+d*h)+1]=l,e[4*(c+d*h)+2]=l,e[4*(c+d*h)+3]=255}(e,o,f,v,s,a,m,i);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,h+=2)e[4*(l+u*c)+0]=a[h+0],e[4*(l+u*c)+1]=a[h+0],e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+3]=a[h+1]}(e,o,f,v,s,a,m,i);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,i,r,s,o,a,l){const c=l;let h,u,d,p=0;const f=g.width;for(d=t;d!==i;d+=n)for(u=r;u!==o;u+=s,p++)h=a[p],e[4*(u+f*d)+3]=255,e[4*(u+f*d)+2]=c[3*h+0],e[4*(u+f*d)+1]=c[3*h+1],e[4*(u+f*d)+0]=c[3*h+2]}(e,o,f,v,s,a,m,i,r);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==i;h+=n)for(c=r;c!==o;c+=s,u+=2)l=a[u+0]+(a[u+1]<<8),e[4*(c+d*h)+0]=(31744&l)>>7,e[4*(c+d*h)+1]=(992&l)>>2,e[4*(c+d*h)+2]=(31&l)<<3,e[4*(c+d*h)+3]=32768&l?0:255}(e,o,f,v,s,a,m,i);break;case 24:!function(e,t,n,i,r,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,h+=3)e[4*(l+u*c)+3]=255,e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2]}(e,o,f,v,s,a,m,i);break;case 32:!function(e,t,n,i,r,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,h+=4)e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2],e[4*(l+u*c)+3]=a[h+3]}(e,o,f,v,s,a,m,i);break;default:console.error("THREE.TGALoader: Format not supported.")}}(b,g.width,g.height,_.pixel_data,_.palettes),{data:b,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:x}}}class lb extends Sc{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new pb(e)})),this.register((function(e){return new xb(e)})),this.register((function(e){return new wb(e)})),this.register((function(e){return new fb(e)})),this.register((function(e){return new mb(e)})),this.register((function(e){return new gb(e)})),this.register((function(e){return new vb(e)})),this.register((function(e){return new yb(e)})),this.register((function(e){return new ub(e)})),this.register((function(e){return new bb(e)}))}load(e,t,n,i){const r=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Kc.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},a=new Ec(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},o={};if("string"==typeof e)r=e;else{if(Kc.decodeText(new Uint8Array(e,0,4))===_b){try{s[hb.KHR_BINARY_GLTF]=new Mb(e)}catch(e){return void(i&&i(e))}r=s[hb.KHR_BINARY_GLTF].content}else r=Kc.decodeText(new Uint8Array(e))}const a=JSON.parse(r);if(void 0===a.asset||a.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new r_(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],n=a.extensionsRequired||[];switch(t){case hb.KHR_MATERIALS_UNLIT:s[t]=new db;break;case hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[t]=new Ib;break;case hb.KHR_DRACO_MESH_COMPRESSION:s[t]=new Eb(a,this.dracoLoader);break;case hb.KHR_TEXTURE_TRANSFORM:s[t]=new Tb;break;case hb.KHR_MESH_QUANTIZATION:s[t]=new Pb;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function cb(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hb={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class ub{constructor(e){this.parser=e,this.name=hb.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const a=new Ke(16777215);void 0!==s.color&&a.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new Wc(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new Vc(a),o.distance=l;break;case"spot":o=new Fc(a),o.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class db{constructor(){this.name=hb.KHR_MATERIALS_UNLIT}getMaterialType(){return In}extendParams(e,t,n){const i=[];e.color=new Ke(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,de))}return Promise.all(i)}}class pb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Oe(e,e)}return Promise.all(r)}}class fb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Ke(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,de)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class mb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new Ke(o[0],o[1],o[2]),Promise.all(r)}}class vb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class yb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new Ke(o[0],o[1],o[2]),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,de)),Promise.all(r)}}class xb{constructor(e){this.parser=e,this.name=hb.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class wb{constructor(e){this.parser=e,this.name=hb.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class bb{constructor(e){this.name=hb.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,r.ready]).then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(t[0],n,i);return r.decodeGltfBuffer(new Uint8Array(a),s,o,l,e.mode,e.filter),a}))}return null}}const _b="glTF",Ab=1313821514,Sb=5130562;class Mb{constructor(e){this.name=hb.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Kc.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==_b)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(e,12);let r=0;for(;r<n;){const t=i.getUint32(r,!0);r+=4;const n=i.getUint32(r,!0);if(r+=4,n===Ab){const n=new Uint8Array(e,12+r,t);this.content=Kc.decodeText(n)}else if(n===Sb){const n=12+r;this.body=e.slice(n,n+t)}r+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Eb{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hb.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=Wb[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=Wb[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=Hb[r.componentType];l[i]=s,a[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=a[t];void 0!==i&&(n.normalized=i)}t(e)}),o,l)}))}))}}class Tb{constructor(){this.name=hb.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Cb extends Kl{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),r=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),o={specular:{value:(new Ke).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(const t in o)e.uniforms[t]=o[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",r).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){o.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){o.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Ib{constructor(){this.name=hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return Cb}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new Ke(1,1,1),e.opacity=1;const r=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&r.push(n.assignTexture(e,"map",i.diffuseTexture,de)),e.emissive=new Ke(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Ke(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;r.push(n.assignTexture(e,"glossinessMap",t)),r.push(n.assignTexture(e,"specularMap",t,de))}return Promise.all(r)}createMaterial(e){const t=new Cb(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class Pb{constructor(){this.name=hb.KHR_MESH_QUANTIZATION}}class Db extends ac{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}}Db.prototype.beforeStart_=Db.prototype.copySampleValue_,Db.prototype.afterEnd_=Db.prototype.copySampleValue_,Db.prototype.interpolate_=function(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=i-t,h=(n-t)/c,u=h*h,d=u*h,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let e=0;e!==o;e++){const t=s[f+e+o],n=s[f+e+a]*c,i=s[p+e+o],l=s[p+e]*c;r[e]=v*t+y*n+m*i+g*l}return r};const Rb=new ut;class Lb extends Db{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Rb.fromArray(r).normalize().toArray(r),r}}const Bb=0,Ob=1,Nb=2,kb=3,Fb=4,Ub=5,zb=6,Hb={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Gb={9728:f,9729:v,9984:m,9985:y,9986:g,9987:x},Vb={33071:d,33648:p,10497:u},jb={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wb={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xb={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yb={CUBICSPLINE:void 0,LINEAR:re,STEP:ie},Qb="OPAQUE",qb="MASK",Zb="BLEND";function Kb(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Kl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Jb(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function $b(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function e_(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function t_(e){const t=e.extensions&&e.extensions[hb.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+n_(t.attributes):e.indices+":"+n_(e.attributes)+":"+e.mode,n}function n_(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function i_(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class r_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new cb,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?this.textureLoader=new ih(this.options.manager):this.textureLoader=new Pc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ec(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Jb(r,s,i),$b(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this.loadAnimation(t);break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[hb.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(Kc.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=jb[i.type],o=Hb[i.componentType],a=o.BYTES_PER_ELEMENT,l=a*s,c=i.byteOffset||0,h=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,u=!0===i.normalized;let d,p;if(h&&h!==l){const e=Math.floor(c/h),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(d=new o(r,e*h,i.count*h/a),l=new xo(d,h/a),t.cache.add(n,l)),p=new bo(l,s,c%h/a,u)}else d=null===r?new o(i.count*s):new o(r,c,i.count*s),p=new Rn(d,s,u);if(void 0!==i.sparse){const t=jb.SCALAR,n=Hb[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],a,i.sparse.count*t),h=new o(e[2],l,i.sparse.count*s);null!==r&&(p=new Rn(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,h[e*s]),s>=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,s.name&&(t.name=s.name);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=Gb[n.magFilter]||v,t.minFilter=Gb[n.minFilter]||x,t.wrapS=Vb[n.wrapS]||u,t.wrapT=Vb[n.wrapT]||u,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new it(e);t.needsUpdate=!0,n(t)}),t.load(Kc.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===l&&o.revokeObjectURL(a),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),r.extensions[hb.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[hb.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[hb.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.encoding=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ma,Cn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ra,Cn.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Kl}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const o={},a=r.extensions||{},l=[];if(a[hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else if(a[hb.KHR_MATERIALS_UNLIT]){const e=i[hb.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else{const n=r.pbrMetallicRoughness||{};if(o.color=new Ke(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,de)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===r.doubleSided&&(o.side=2);const c=r.alphaMode||Qb;if(c===Zb?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===qb&&(o.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==In&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Oe(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==In&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(o.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==In&&(o.emissive=(new Ke).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==In&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,de)),Promise.all(l).then((function(){let n;return n=s===Cb?i[hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new s(o),r.name&&(n.name=r.name),$b(n,r),t.associations.set(n,{materials:e}),r.extensions&&Jb(i,n,r),n}))}createUniqueName(e){const t=Oh.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[hb.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return o_(n,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=t_(o),l=i[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[hb.KHR_DRACO_MESH_COMPRESSION]?r(o):o_(new Zn,o,t),i[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?Kb(this.cache):this.getDependency("material",s[e].material);o.push(t)}return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],h=s[n];let u;const d=o[n];if(h.mode===Fb||h.mode===Ub||h.mode===zb||void 0===h.mode)u=!0===r.isSkinnedMesh?new Xo(c,d):new fi(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===Ub?u.geometry=a_(u.geometry,1):h.mode===zb&&(u.geometry=a_(u.geometry,2));else if(h.mode===Ob)u=new pa(c,d);else if(h.mode===kb)u=new ha(c,d);else if(h.mode===Nb)u=new fa(c,d);else{if(h.mode!==Bb)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new wa(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&e_(u,r),u.name=t.createUniqueName(r.name||"mesh_"+e),$b(u,r),h.extensions&&Jb(i,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new ao;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new _i(Be.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new Xi(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),$b(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],r=[],s=[],o=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,h=void 0!==c.node?c.node:c.id,u=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",h)),i.push(this.getDependency("accessor",u)),r.push(this.getDependency("accessor",d)),s.push(l),o.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o)]).then((function(n){const i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=r[e],c=s[e],h=o[e],u=a[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,Xb[u.path]){case Xb.weights:d=fc;break;case Xb.rotation:d=gc;break;case Xb.position:case Xb.scale:default:d=yc}const p=t.name?t.name:t.uuid,f=void 0!==h.interpolation?Yb[h.interpolation]:re,m=[];Xb[u.path]===Xb.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(p);let g=c.array;if(c.normalized){const e=i_(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=m.length;e<t;e++){const t=new d(m[e]+"."+Xb[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(t.createInterpolant=function(e){return new(this instanceof gc?Lb:Db)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new xc(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==r.camera&&t.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let o;if(o=!0===r.isBone?new Yo:t.length>1?new ao:1===t.length?t[0]:new mn,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(r.name&&(o.userData.name=r.name,o.name=s),$b(o,r),r.extensions&&Jb(n,o,r),void 0!==r.matrix){const e=new Vt;e.fromArray(r.matrix),o.applyMatrix4(e)}else void 0!==r.translation&&o.position.fromArray(r.translation),void 0!==r.rotation&&o.quaternion.fromArray(r.rotation),void 0!==r.scale&&o.scale.fromArray(r.scale);return i.associations.has(o)||i.associations.set(o,{}),i.associations.get(o).nodes=e,o}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],r=this,s=new ao;i.name&&(s.name=r.createUniqueName(i.name)),$b(s,i),i.extensions&&Jb(n,s,i);const o=i.nodes||[],a=[];for(let e=0,n=o.length;e<n;e++)a.push(s_(o[e],s,t,r));return Promise.all(a).then((function(){return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof Cn||e instanceof it)&&t.set(e,n);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(s),s}))}}function s_(e,t,n,i){const r=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===r.skin)return e;let t;return i.getDependency("skin",r.skin).then((function(e){t=e;const n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(i.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const i=[],r=[];for(let e=0,s=n.length;e<s;e++){const s=n[e];if(s){i.push(s);const n=new Vt;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),r.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new Ko(i,r),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const s=[];if(r.children){const t=r.children;for(let r=0,o=t.length;r<o;r++){const o=t[r];s.push(s_(o,e,n,i))}}return Promise.all(s)}))}function o_(e,t,n){const i=t.attributes,r=[];function s(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=Wb[t]||t.toLowerCase();n in e.attributes||r.push(s(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return $b(e,t),function(e,t,n){const i=t.attributes,r=new mt;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new dt(t[0],t[1],t[2]),new dt(s[0],s[1],s[2])),e.normalized){const t=i_(Hb[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new dt,t=new dt;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,o=i.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),i.normalized){const e=i_(Hb[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const o=new Bt;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(i){const t=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==h.COLOR_0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],o=t[1],a=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function a_(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(2===t)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s}const l_=new WeakMap;class c_ extends Sc{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const r=new Ec(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(l_.has(e)){const t=l_.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),l_.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Zn;e.index&&t.setIndex(new Rn(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],r=i.name,s=i.array,o=i.itemSize;t.setAttribute(r,new Rn(s,o))}return t}_loadLibrary(e,t){const n=new Ec(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=h_.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function h_(){let e,t;function n(e,t,n,i,r,s){const o=s.num_components(),a=n.num_points()*o,l=a*r.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),h=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,c,l,h);const u=new r(e.HEAPF32.buffer,h,a).slice();return e._free(h),{name:i,array:u,itemSize:o}}onmessage=function(i){const r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=r.buffer,s=r.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,r){const s=r.attributeIDs,o=r.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(i,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[o[i]];let c,u;if(r.useUniqueIDs)u=s[i],c=t.GetAttributeByUniqueId(a,u);else{if(u=t.GetAttributeId(a,e[s[i]]),-1===u)continue;c=t.GetAttribute(a,u)}h.attributes.push(n(e,t,a,i,l,c))}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const i=3*n.num_faces(),r=4*i,s=e._malloc(r);t.GetTrianglesUInt32Array(n,r,s);const o=new Uint32Array(e.HEAPF32.buffer,s,i).slice();return e._free(s),{array:o,itemSize:1}}(e,t,a));return e.destroy(a),h}(t,o,a,s),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}class u_{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const d_=function noCompressWorker(e,t){const[n]=new Uint32Array(e,t,1);t+=4;const i=new Float32Array(e,t,3*n);t+=3*n*4;const r=new Float32Array(e,t,2*n);t+=2*n*4;const s=new Uint8Array(e,t,4*n);t+=4*n*1;const o=new Int8Array(e,t,3*n);t+=3*n*1;let a=(s.length+o.length)%4;a>0&&(a=4-a,t+=a);const l=new Uint32Array(e,t,1);t+=4;const[c]=l,h=new Uint32Array(e,t,c);t+=4*c;const u=new Uint32Array(e,t,1);t+=4;const[d]=u,p=[];if(d>0)for(let n=0;n<d;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);p.push({start:n,count:i,uuid:a,alphaMode:r})}return{position:i,normal:o,color:s,texcoord:r,indice:h,sub_mesh:p}},p_=function gzipCompressWorker(e){const[t]=new Uint32Array(e,0,1),n=new Uint8Array(e,4,e.byteLength-4),i=new pako.Inflate({chunkSize:t});i.push(n,!0);const{result:r}=i;if(r instanceof Uint8Array){const{buffer:e}=r;let t=0;const[n]=new Uint32Array(e,t,1);t+=4;const i=new Float32Array(e,t,3*n);t+=3*n*4;const s=new Float32Array(e,t,2*n);t+=2*n*4;const o=new Uint8Array(e,t,4*n);t+=4*n*1;const a=new Int8Array(e,t,3*n);t+=3*n*1;let l=(o.length+a.length)%4;l>0&&(l=4-l,t+=l);const c=new Uint32Array(e,t,1);t+=4;const[h]=c,u=new Uint32Array(e,t,h);t+=4*h;const d=new Uint32Array(e,t,1);t+=4;const[p]=d,f=[];if(p>0)for(let n=0;n<p;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);f.push({start:n,count:i,uuid:a,alphaMode:r})}return{position:i,normal:a,color:o,texcoord:s,indice:u,sub_mesh:f}}},f_=function parseChunkWorker(e){let t=0;const n=new Int8Array(e,t,128);t+=128,(new TextDecoder).decode(n.slice(0,4));const[i]=n.slice(4,8);if(0===i)return self.noCompressWorker(e,t);if(1===i){const t=e.slice(128);return self.gzipCompressWorker(t)}throw new Error("unknown compress mode [ .sbmx model ]")},m_="\n onmessage = function ( e ) {\n \n const message = e.data\n\n switch ( message.type ) {\n\n case 'decode': {\n\n const chunkInfo = parseChunkWorker( message.data )\n\n self.postMessage( { type: 'decode', data: chunkInfo, } )\n\n break\n \n }\n \n }\n\n }\n\n";class g_ extends Sc{constructor(){super(),this.loadedTextures=new Set,this.loadedMaterialsMap=new Map,this.loadedMaterials=new Array,this.dracoDecoderPath=null,this.workerPool=new u_(navigator.hardwareConcurrency),this.workerSourceURL="";const e=this._initWorkerCreator();this.workerPool.setWorkerCreator(e)}async parseAsync(e,t){const[{data:n}]=await Promise.all([this.workerPool.postMessage({type:"decode",data:e},[e]),this._createMaterial(t)]);if(n){const{type:e,data:i}=n;if("decode"===e){return this._createMeshByStream(i,t)}}}_initWorkerCreator(){if(!this.workerSourceURL){const e=["/* dat decoder */",["/* pako */","\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {}));\n}(this, (function (exports) { 'use strict';\n\n // Note: adler32 takes 12% for level 0 and 2% for level 6.\n // It isn't worth it to make additional optimizations as in original.\n // Small size is preferable.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express ofr implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const adler32 = (adler, buf, len, pos) => {\n let s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n };\n\n\n var adler32_1 = adler32;\n\n // Note: we can't get significant speed boost here.\n // So write code to minimize size - no pregenerated tables\n // and array tools dependencies.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // Use ordinary array, since untyped makes no boost here\n const makeTable = () => {\n let c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n };\n\n // Create table on load. Just 255 signed longs. Not a problem.\n const crcTable = new Uint32Array(makeTable());\n\n\n const crc32 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n\n crc ^= -1;\n\n for (let i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n };\n\n\n var crc32_1 = crc32;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // See state defs from inflate.js\n const BAD$1 = 30; /* got a data error -- remain here until reset */\n const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n /*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n var inffast = function inflate_fast(strm, start) {\n let _in; /* local strm.input */\n let last; /* have enough input while in < last */\n let _out; /* local strm.output */\n let beg; /* inflate()'s initial strm.output */\n let end; /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n let dmax; /* maximum distance from zlib header */\n //#endif\n let wsize; /* window size or zero if not using window */\n let whave; /* valid bytes in the window */\n let wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n let s_window; /* allocated sliding window, if wsize != 0 */\n let hold; /* local strm.hold */\n let bits; /* local strm.bits */\n let lcode; /* local strm.lencode */\n let dcode; /* local strm.distcode */\n let lmask; /* mask for first level of length codes */\n let dmask; /* mask for first level of distance codes */\n let here; /* retrieved table entry */\n let op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n let len; /* match length, unused bytes */\n let dist; /* match distance */\n let from; /* where to copy match from */\n let from_source;\n\n\n let input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n const state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n //#ifdef INFLATE_STRICT\n dmax = state.dmax;\n //#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n //#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const MAXBITS = 15;\n const ENOUGH_LENS$1 = 852;\n const ENOUGH_DISTS$1 = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const CODES$1 = 0;\n const LENS$1 = 1;\n const DISTS$1 = 2;\n\n const lbase = new Uint16Array([ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n ]);\n\n const lext = new Uint8Array([ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n ]);\n\n const dbase = new Uint16Array([ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n ]);\n\n const dext = new Uint8Array([ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n ]);\n\n const inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n {\n const bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n let len = 0; /* a code's length in bits */\n let sym = 0; /* index of code symbols */\n let min = 0, max = 0; /* minimum and maximum code lengths */\n let root = 0; /* number of index bits for root table */\n let curr = 0; /* number of index bits for current table */\n let drop = 0; /* code bits to drop for sub-table */\n let left = 0; /* number of prefix codes available */\n let used = 0; /* code entries in table used */\n let huff = 0; /* Huffman code */\n let incr; /* for incrementing code, index */\n let fill; /* index for replicating entries */\n let low; /* low bits for current root entry */\n let mask; /* mask for low root bits */\n let next; /* next available space in table */\n let base = null; /* base value table to use */\n let base_index = 0;\n // let shoextra; /* extra bits table to use */\n let end; /* use base and extra for symbol > end */\n const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n let extra = null;\n let extra_index = 0;\n\n let here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n };\n\n\n var inftrees = inflate_table;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var constants$1 = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\n const CODES = 0;\n const LENS = 1;\n const DISTS = 2;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n Z_DEFLATED\n } = constants$1;\n\n\n /* STATES ====================================================================*/\n /* ===========================================================================*/\n\n\n const HEAD = 1; /* i: waiting for magic header */\n const FLAGS = 2; /* i: waiting for method and flags (gzip) */\n const TIME = 3; /* i: waiting for modification time (gzip) */\n const OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n const EXLEN = 5; /* i: waiting for extra length (gzip) */\n const EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n const NAME = 7; /* i: waiting for end of file name (gzip) */\n const COMMENT = 8; /* i: waiting for end of comment (gzip) */\n const HCRC = 9; /* i: waiting for header crc (gzip) */\n const DICTID = 10; /* i: waiting for dictionary check value */\n const DICT = 11; /* waiting for inflateSetDictionary() call */\n const TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n const STORED = 14; /* i: waiting for stored size (length and complement) */\n const COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n const COPY = 16; /* i/o: waiting for input or output to copy stored block */\n const TABLE = 17; /* i: waiting for dynamic block table lengths */\n const LENLENS = 18; /* i: waiting for code length code lengths */\n const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n const LEN_ = 20; /* i: same as LEN below, but only first time in */\n const LEN = 21; /* i: waiting for length/lit/eob code */\n const LENEXT = 22; /* i: waiting for length extra bits */\n const DIST = 23; /* i: waiting for distance code */\n const DISTEXT = 24; /* i: waiting for distance extra bits */\n const MATCH = 25; /* o: waiting for output space to copy string */\n const LIT = 26; /* o: waiting for output space to write literal */\n const CHECK = 27; /* i: waiting for 32-bit check value */\n const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n const DONE = 29; /* finished check, done -- remain here until reset */\n const BAD = 30; /* got a data error -- remain here until reset */\n const MEM = 31; /* got an inflate() memory error -- remain here until reset */\n const SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n /* ===========================================================================*/\n\n\n\n const ENOUGH_LENS = 852;\n const ENOUGH_DISTS = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const MAX_WBITS = 15;\n /* 32K LZ77 window */\n const DEF_WBITS = MAX_WBITS;\n\n\n const zswap32 = (q) => {\n\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n };\n\n\n function InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Int32Array(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n }\n\n\n const inflateResetKeep = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\"));\n return Z_OK$1;\n };\n\n\n const inflateReset = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n };\n\n\n const inflateReset2 = (strm, windowBits) => {\n let wrap;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n };\n\n\n const inflateInit2 = (strm, windowBits) => {\n\n if (!strm) { return Z_STREAM_ERROR$1; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n const state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n };\n\n\n const inflateInit = (strm) => {\n\n return inflateInit2(strm, DEF_WBITS);\n };\n\n\n /*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\n let virgin = true;\n\n let lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\n const fixedtables = (state) => {\n\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n let sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inftrees(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inftrees(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n };\n\n\n /*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\n const updatewindow = (strm, src, end, copy) => {\n\n let dist;\n const state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n };\n\n\n const inflate$1 = (strm, flush) => {\n\n let state;\n let input, output; // input/output buffers\n let next; /* next input INDEX */\n let put; /* next output INDEX */\n let have, left; /* available input and output */\n let hold; /* bit buffer */\n let bits; /* bits in bit buffer */\n let _in, _out; /* save starting available input and output */\n let copy; /* number of stored or match bytes to copy */\n let from; /* where to copy match bytes from */\n let from_source;\n let here = 0; /* current decoding table entry */\n let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //let last; /* parent table entry */\n let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n let len; /* length to copy for repeats, bits to drop */\n let ret; /* return code */\n const hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n let opts;\n\n let n; // temporary variable for NEED_BITS\n\n const order = /* permutation of code lengths */\n new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR$1;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK$1;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n\n // !!! pako patch. Force use `options.windowBits` if passed.\n // Required to always use max window size by default.\n state.dmax = 1 << state.wbits;\n //state.dmax = 1 << len;\n\n //Tracev((stderr, \"inflate: zlib header ok\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32_1(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n output.set(input.subarray(next, next + copy), put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inffast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH$1))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n };\n\n\n const inflateEnd = (strm) => {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR$1;\n }\n\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n };\n\n\n const inflateGetHeader = (strm, head) => {\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK$1;\n };\n\n\n const inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n\n let state;\n let dictid;\n let ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32_1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\"));\n return Z_OK$1;\n };\n\n\n var inflateReset_1 = inflateReset;\n var inflateReset2_1 = inflateReset2;\n var inflateResetKeep_1 = inflateResetKeep;\n var inflateInit_1 = inflateInit;\n var inflateInit2_1 = inflateInit2;\n var inflate_2$1 = inflate$1;\n var inflateEnd_1 = inflateEnd;\n var inflateGetHeader_1 = inflateGetHeader;\n var inflateSetDictionary_1 = inflateSetDictionary;\n var inflateInfo = 'pako inflate (from Nodeca project)';\n\n /* Not implemented\n module.exports.inflateCopy = inflateCopy;\n module.exports.inflateGetDictionary = inflateGetDictionary;\n module.exports.inflateMark = inflateMark;\n module.exports.inflatePrime = inflatePrime;\n module.exports.inflateSync = inflateSync;\n module.exports.inflateSyncPoint = inflateSyncPoint;\n module.exports.inflateUndermine = inflateUndermine;\n */\n\n var inflate_1$1 = {\n \tinflateReset: inflateReset_1,\n \tinflateReset2: inflateReset2_1,\n \tinflateResetKeep: inflateResetKeep_1,\n \tinflateInit: inflateInit_1,\n \tinflateInit2: inflateInit2_1,\n \tinflate: inflate_2$1,\n \tinflateEnd: inflateEnd_1,\n \tinflateGetHeader: inflateGetHeader_1,\n \tinflateSetDictionary: inflateSetDictionary_1,\n \tinflateInfo: inflateInfo\n };\n\n const _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n\n var assign = function (obj /*from1, from2, from3, ...*/) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n };\n\n\n // Join array of chunks to single array.\n var flattenChunks = (chunks) => {\n // calculate data length\n let len = 0;\n\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n const result = new Uint8Array(len);\n\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n };\n\n var common = {\n \tassign: assign,\n \tflattenChunks: flattenChunks\n };\n\n // String encode/decode helpers\n\n\n // Quick check if we can use fast array to bin string conversion\n //\n // - apply(Array) can fail on Android 2.2\n // - apply(Uint8Array) can fail on iOS 5.1 Safari\n //\n let STR_APPLY_UIA_OK = true;\n\n try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n const _utf8len = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n }\n _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n // convert string to array (typed, when possible)\n var string2buf = (str) => {\n if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n };\n\n // Helper\n const buf2binstring = (buf, len) => {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n\n let result = '';\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n\n\n // convert array to string\n var buf2string = (buf, max) => {\n const len = max || buf.length;\n\n if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n\n let i, out;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n const utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n let c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n let c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n };\n\n\n // Calculate max possible position in utf8 buffer,\n // that will not break sequence. If that's not possible\n // - (very small limits) return max size as is.\n //\n // buf[] - utf8 bytes array\n // max - length limit (mandatory);\n var utf8border = (buf, max) => {\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n };\n\n var strings = {\n \tstring2buf: string2buf,\n \tbuf2string: buf2string,\n \tutf8border: utf8border\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n }\n\n var zstream = ZStream;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n }\n\n var gzheader = GZheader;\n\n const toString = Object.prototype.toString;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_NO_FLUSH, Z_FINISH,\n Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR\n } = constants$1;\n\n /* ===========================================================================*/\n\n\n /**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n /* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n /**\n * Inflate.result -> Uint8Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n /**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n /**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n /**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n * const chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\n function Inflate(options) {\n this.options = common.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ''\n }, options || {});\n\n const opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new zstream();\n this.strm.avail_out = 0;\n\n let status = inflate_1$1.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n\n this.header = new gzheader();\n\n inflate_1$1.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = inflate_1$1.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer): input data\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE\n * flush modes. See constants. Skipped or `false` means Z_NO_FLUSH,\n * `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. If end of stream detected,\n * [[Inflate#onEnd]] will be called.\n *\n * `flush_mode` is not needed for normal operation, because end of stream\n * detected automatically. You may try to use it for advanced things, but\n * this functionality was not tested.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n Inflate.prototype.push = function (data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n\n if (this.ended) return false;\n\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n\n // Convert data if needed\n if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n for (;;) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate_1$1.inflate(strm, _flush_mode);\n\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$1.inflateSetDictionary(strm, dictionary);\n\n if (status === Z_OK) {\n status = inflate_1$1.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n // Replace code with more verbose\n status = Z_NEED_DICT;\n }\n }\n\n // Skip snyc markers if more data follows and not raw mode\n while (strm.avail_in > 0 &&\n status === Z_STREAM_END &&\n strm.state.wrap > 0 &&\n data[strm.next_in] !== 0)\n {\n inflate_1$1.inflateReset(strm);\n status = inflate_1$1.inflate(strm, _flush_mode);\n }\n\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n // Remember real `avail_out` value, because we may patch out buffer content\n // to align utf8 strings boundaries.\n last_avail_out = strm.avail_out;\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n\n if (this.options.to === 'string') {\n\n let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail & realign counters\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n\n this.onData(utf8str);\n\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n\n // Must repeat iteration if out buffer is full\n if (status === Z_OK && last_avail_out === 0) continue;\n\n // Finalize if end of stream reached.\n if (status === Z_STREAM_END) {\n status = inflate_1$1.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n\n if (strm.avail_in === 0) break;\n }\n\n return true;\n };\n\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|String): output data. When string output requested,\n * each chunk will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n Inflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n };\n\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n Inflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = common.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n\n\n /**\n * inflate(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako');\n * const input = pako.deflate(new Uint8Array([1,2,3,4,5,6,7,8,9]));\n * let output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err) {\n * console.log(err);\n * }\n * ```\n **/\n function inflate(input, options) {\n const inflator = new Inflate(options);\n\n inflator.push(input);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) throw inflator.msg || messages[inflator.err];\n\n return inflator.result;\n }\n\n\n /**\n * inflateRaw(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n }\n\n\n /**\n * ungzip(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\n var Inflate_1 = Inflate;\n var inflate_2 = inflate;\n var inflateRaw_1 = inflateRaw;\n var ungzip = inflate;\n var constants = constants$1;\n\n var inflate_1 = {\n \tInflate: Inflate_1,\n \tinflate: inflate_2,\n \tinflateRaw: inflateRaw_1,\n \tungzip: ungzip,\n \tconstants: constants\n };\n\n exports.Inflate = Inflate_1;\n exports.constants = constants;\n exports['default'] = inflate_1;\n exports.inflate = inflate_2;\n exports.inflateRaw = inflateRaw_1;\n exports.ungzip = ungzip;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n","/* noCompress */",d_,"/* gzipCompress */",p_,"/* parseChunk */",f_].join("\n"),"","/* worker */",m_].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([e]))}return()=>new Worker(this.workerSourceURL)}_createMeshByStream(e,t){const n=new Zn;n.setIndex(new Rn(e.indice,1)),n.setAttribute("position",new Rn(e.position,3)),n.setAttribute("normal",new Rn(e.normal,3,!0)),n.setAttribute("uv",new Rn(e.texcoord,2));for(let i=0;i<e.sub_mesh.length;i++){const r=e.sub_mesh[i],{uuid:s,start:o,count:a}=r,l=this.loadedMaterialsMap.get(s);if(l){const{materialIndex:e}=l;n.addGroup(o,a,e)}else console.warn("no material",s,t)}n.computeBoundingBox(),n.computeBoundsTree();const i=new fi(n,this.loadedMaterials);return i.castShadow=!0,i.receiveShadow=!0,i}async _createMaterial(e){const t=e+"textureIndex.json";if(this.loadedTextures.has(t))return;const n=await Pd(t).then((e=>e.json()));this.loadedTextures.add(t),Object.entries(n).forEach((([t,n])=>{if(this.loadedMaterialsMap.has(t))return;const{name:i,base_map:r,nor_map:s,alphamode:o,color:a={r:1,g:1,b:1,a:1},metallic:l=.5,roughness:c=.5}=n;let h=null,d=null;if(r){const t=e+r;h=(new Pc).load(t,(e=>{e.needsUpdate=!0,Lv.needsUpdate=!0})),h.encoding=de,h.wrapS=u,h.wrapT=u,h.minFilter=1008,h.magFilter=v,h.flipY=!0}if(s){const t=e+s;d=(new Pc).load(t,(e=>{e.needsUpdate=!0,Lv.needsUpdate=!0})),d.encoding=de,d.wrapS=u,d.wrapT=u,d.flipY=!0}const{r:p,g:f,b:m,a:g}=a,y=0!==o,x=new Kl({name:i,color:new Ke(p,f,m),side:2,map:h,normalMap:d,metalness:l,roughness:c,opacity:g,transparent:y,depthWrite:!y}),w=this.loadedMaterials.push(x)-1;this.loadedMaterialsMap.set(t,{material:x,materialIndex:w})}))}}class v_ extends ly{constructor(e,t){super("Model",e,t),this.viewport=e,this.modelMaps=new Map,this.loadingManager=new _c,this.datLoader=new g_,this.gltfLoader=new lb(this.loadingManager),this.fbxLoader=new Gw(this.loadingManager),this.dracoDecoderPath=null,this.store=hy.createInstance({name:"soonspace",storeName:"modelData"}),this._initLoadingManager(this.loadingManager)}_initLoadingManager(e){e.addHandler(/\.tga$/i,new ab)}_setModelMpas(e,t){if(!this.modelMaps.has(e)){const n=t.sClone();this.modelMaps.set(e,n)}}async _parseSbmx(e,t,n){const i=Fd(e,0,8),r=new DataView(e.slice(8));if("SBMG----"===i){for(let e=0;e<r.byteLength;e++){const t=r.getUint8(e),n=(t>>4&15)+(t<<4&240);r.setUint8(e,n)}await this._parseGltf(r.buffer,t,n)}else"SBMD----"===i?await this._parseDat(r.buffer,t,n):await this._parseGltf(e,t,n)}async _parseDat(e,t,n){const i=await this.datLoader.parseAsync(e,t);i&&n.add(i)}_parseGltf(e,t,n){return new Promise(((i,r)=>{this.gltfLoader.parse(e,t,(e=>{const{animations:t}=e;t&&t.length>0&&(n.animations=t),e.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof fi&&e.geometry.computeBoundsTree()})),n.add(e.scene),i(n)}),(e=>{r(e)}))}))}_parseFbx(e,t,n){const i=this.fbxLoader.parse(e,t),{animations:r}=i;r&&r.length>0&&(n.animations=r),i.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof fi&&e.geometry.computeBoundsTree()})),n.add(i)}setDracoDecoderPath(e){this.dracoDecoderPath=e;const t=new c_;t.setDecoderPath(e),this.gltfLoader.setDRACOLoader(t),this.datLoader.dracoDecoderPath=e}load(e){return this._loadItem(e)}async _loadItem(e,t=this.scene){var n;const{url:i}=e,{useIndexedDB:r}=this.viewport.options,s=i.slice(i.lastIndexOf(".")+1),o=this.modelMaps.get(i);let a=null;if(o)return this.clone(o,e,t);r&&(a=await this.store.getItem(i)),a||(a=await this._fetchBuffer(e));const l=await this.parse(s,a,e);return null===(n=l.onLoad)||void 0===n||n.call(l,l),this.setObjectsCache(l),null!==t&&this.viewport.scener.addObject(l,t),l}async parse(e,t,n){const i=new Xv({format:e,...n}),{url:r}=n,s=Td(r),o=e.toLocaleUpperCase();if("SBMX"===o)await this._parseSbmx(t,s,i);else if("DAT"===o)await this._parseDat(t,s,i);else if("GLTF"===o||"GLB"===o)await this._parseGltf(t,s,i);else{if("FBX"!==o)throw new TypeError(`In soonspacejs: 加载通用模型资源(id:${n.id}, url:${r})格式错误,当前支持 fbx、gltf、glb !`);this._parseFbx(t,s,i)}return this._setModelMpas(r,i),i}clone(e,t,n){return new Promise(((i,r)=>{"Model"!==e.stype&&r("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:s,name:o,level:a,visible:l,position:c,rotation:h,scale:u,onClick:d,onDblClick:p,onRightClick:f,onLoad:m,userData:g}=t;function v(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)v(e.children[i],t.children[i],n)}const y=function(e){const t=new Map,n=new Map,i=e.sClone();return v(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(e instanceof Xo){const i=e,r=t.get(e),s=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=s.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)}})),i}(e);y.animations=y.animations.map((e=>e.clone())),s&&(y.sid=s),o&&(y.name=o),a&&(y.level=a),!1===l&&y.hide(),c&&y.position.set(c.x,c.y,c.z),h&&y.rotation.set(h.x,h.y,h.z),u&&y.scale.set(u.x,u.y,u.z),y.onClick=d?d.bind(y):null,y.onDblClick=p?p.bind(y):null,y.onRightClick=f?f.bind(y):null,y.onLoad=m?m.bind(y):null,y.onLoad&&y.onLoad(y),g&&(y.userData=g),this.setObjectsCache(y),null!==n&&this.viewport.scener.addObject(y,n||e.parent||this.scene),i(y)}))}async loadToGroup(e,t){const n=this.createGroup(e,null);for(let e=0;e<t.length;e++)try{const i=await this._loadItem(t[e],null);n.add(i)}catch(e){console.error(e)}return this.viewport.scener.addObject(n,this.scene),n}async addForGroup(e,t){const n=this.getById(e,"Group");if(n)for(let e=0;e<t.length;e++)try{const i=await this._loadItem(t[e],null);this.viewport.scener.addObject(i,n)}catch(e){console.error(e)}return n}clearIdb(){return this.store.clear()}dispose(){var e;null===(e=this.gltfLoader.dracoLoader)||void 0===e||e.dispose(),this.datLoader.workerPool.dispose()}async _fetchBuffer(e){const{url:t}=e,{useIndexedDB:n}=this.viewport.options;return Pd(t).then((e=>e.arrayBuffer())).then((e=>(n&&this.store.setItem(t,e),e)))}}class y_ extends ly{constructor(e,t){super("Poi",e,t),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new qv(t,e);return this.setObjectsCache(n),this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:i,name:r,level:s,visible:o,position:a,rotation:l,scale:c,onClick:h,onDblClick:u,onRightClick:d,userData:p}=t,f=e.sClone(!1);return this._copyMaterial(f),i&&(f.sid=i),r&&(f.name=r),s&&(f.level=s),Ld(o)&&(f.visible=o),a&&f.position.set(a.x,a.y,a.z),l&&f.rotation.set(l.x,l.y,l.z),c&&f.scale.set(c.x,c.y,c.z),f.onClick=h?h.bind(f):null,f.onDblClick=u?u.bind(f):null,f.onRightClick=d?d.bind(f):null,p&&(f.userData=p),this.setObjectsCache(f),null!==n&&this.viewport.scener.addObject(f,n||this.scene||e.parent),f}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this._createMaterial(e.url),i=new qv(t,e);this.setObjectsCache(i),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&(t.forEach((e=>{const t=this._createMaterial(e.url),i=new qv(t,e);this.setObjectsCache(i),n.add(i)})),this.viewport.scener.addObject(n,this.scene)),n}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new Pc).load(e);t.flipY=!0;const n=new _o({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof fi||e instanceof No)&&(Od(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof Cn&&(e.material=e.material.clone()))}))}}class x_ extends ly{constructor(e,t){super("PoiNode",e,t)}create(e){this._openEnableRenderCss(e);const t=new Gv(e);return this.setObjectsCache(t),this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new Gv(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&(t.forEach((e=>{this._openEnableRenderCss(e);const t=new Gv(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class w_ extends ly{constructor(e,t){super("Canvas3D",e,t)}create(e){const t=new sy(e);return this.setObjectsCache(t),this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=new sy(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&(t.forEach((e=>{const t=new sy(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}}class b_{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(e){if(!Od(e))return console.error("In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph isn't an array )");if(!(e.length<1))for(let t=0;t<e.length;t++){const n=e[t];if(2!==n.length)return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph item must be an array and contain 2 values [name, vertices], Failed at index: ${t} )`);const i=n[0],r=n[1];this.graph[i]=[];for(let e=0;e<r.length;e++){const t=r[e],n=t[0],s=t[1];this.graph[i][n]=s}}}getPath(e,t){if(void 0===this.graph[e])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method source ${e} doesn't exist )`),[];if(void 0===this.graph[t])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method target ${t} doesn't exist )`),[];if(e===t)return[];let n;for(this.queue=new Sd,this.queue.add(e,0),this.previous[e]=null;n=this.queue.shift();){if(n===t){const e=[];for(;Bd(n)&&null!==this.previous[n];)e.unshift(n),n=this.previous[n];return e}const e=this.queue.getDistance(n);if(e===1/0)return[];for(const t in this.graph[n]){const i=this.queue.getDistance(Number(t)),r=e+this.graph[n][t];r<i&&(this.queue.update(Number(t),r),this.previous[t]=n)}}return[]}}class __ extends ly{constructor(e,t){super("Topology",e,t),this.dijkstra=new b_}createFromGml(e){const{url:t,linkWidth:n=20,linkColor:i=65280,renderNode:r=!0,nodeColor:s=255}=e;return vy(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const o=[],a=new Map;let l=[],c=[];const h=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;Od(h)?h.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...h.state],c=[...c,...h.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],i=e.State.topoNode["gml:Node"].node_name;o.push({id:Rd(n)?n:"",name:Rd(i)?i:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),a.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],i=e.Transition.topoEdge["gml:Edge"].length["#text"],r=e.Transition.topoEdge["gml:Edge"].restrict["#text"],s=e.Transition.topoEdge["gml:Edge"].passable["#text"],l=a.get(t),c=a.get(n),h=e.Transition._attributes["gml:id"],u=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==l&&void 0!==c&&("2"!==s&&"3"!==s&&o[l].graphs.push({targetNodeId:n,linkInfo:{id:h,name:u},enable:!0,length:parseInt(i),restrict:parseInt(r),passable:parseInt(s)}),"1"!==s&&"3"!==s&&o[c].graphs.push({targetNodeId:t,linkInfo:{id:h,name:u},enable:!0,length:parseInt(i),restrict:parseInt(r),passable:parseInt(s)}))})),this.setDijkstraGraph(o);const u=new ey({...e,type:"network",nodes:o,linkWidth:n,renderLink:!0,linkColor:i,renderNode:r,nodeColor:s});return this.setObjectsCache(u),this.viewport.scener.addObject(u,this.scene),Promise.resolve(u)}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const n=new ey(t);return this.setObjectsCache(n),this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs({...e.info,nodes:t});return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const i=new ey(t);this.setObjectsCache(i),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const i=new ey(t);this.setObjectsCache(i),n.add(i)})),n}getShortestPath(e,t){const n=Cd(e.info.nodes),i=gd(t.start),r=gd(t.end);let s=null,o=1/0,a=null,l=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const n=e.nodes.find((e=>e.sid===t.id));if(n){const e=_d(n).position,c=e.distanceTo(i),h=e.distanceTo(r);c<o&&(o=c,s=t),h<l&&(l=h,a=t)}}})),null!==s&&null!==a){const i=+s.id,r=+a.id,o=this.dijkstra.getPath(i,r);if(o.length>0){const i=[s];o.forEach((e=>{const t=n.find((t=>t.id==e));t&&i.push(t)}));for(let e=0;e<i.length;e++)i[e].position.y+=1;const r={...t,type:"line",nodes:i,...e.getSpaceAttribute(!0)};this.generateLineTopologyInfoNodeGraphs(r);const a=new ey(r);return this.setObjectsCache(a),this.viewport.scener.addObject(a,this.scene),a}}return null}getShortestPathByMultipleStartPoints(e,t){const{nodes:n}=e.info,i=[];t.start.forEach((e=>{const r=gd(e),s=gd(t.end);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=gd(e.position),n=t.distanceTo(r),i=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),i<c&&(c=i,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:r,graphs:[]}];t.forEach(((t,i)=>{const s=n.find((e=>e.id==t));s&&(e+=0===i?gd(s.position).distanceTo(r):gd(s.position).distanceTo(gd(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(gd(o[o.length-1].position)),i.push({nodeInfo:o,pathLength:e})}}}));let r=[],s=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,r=e)})),r.length){for(let e=0;e<r.length;e++)r[e].position.y+=1;const n={...t,type:"line",nodes:r,position:e.getWorldPosition(new dt),rotation:(new $t).setFromQuaternion(e.getWorldQuaternion(new ut)),scale:e.getWorldScale(new dt)};this.generateLineTopologyInfoNodeGraphs(n);const i=new ey(n);return this.setObjectsCache(i),this.viewport.scener.addObject(i,this.scene),i}return null}getShortestPathByMultipleEndPoints(e,t){const{nodes:n}=e.info,i=[];t.end.forEach((e=>{const r=gd(t.start),s=gd(e);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=gd(e.position),n=t.distanceTo(r),i=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),i<c&&(c=i,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:r,graphs:[]}];t.forEach(((t,i)=>{const s=n.find((e=>e.id==t));s&&(e+=0===i?gd(s.position).distanceTo(r):gd(s.position).distanceTo(gd(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(gd(o[o.length-1].position)),i.push({nodeInfo:o,pathLength:e})}}}));let r=[],s=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,r=e)})),r.length){for(let e=0;e<r.length;e++)r[e].position.y+=1;const n={...t,type:"line",nodes:r,position:e.getWorldPosition(new dt),rotation:(new $t).setFromQuaternion(e.getWorldQuaternion(new ut)),scale:e.getWorldScale(new dt)};this.generateLineTopologyInfoNodeGraphs(n);const i=new ey(n);return this.setObjectsCache(i),this.viewport.scener.addObject(i,this.scene),i}return null}setDijkstraGraph(e){const t=[];e.forEach((n=>{if(n.graphs&&n.graphs.length>0){const i=[];n.graphs.forEach((t=>{const r=e.find((e=>e.id===t.targetNodeId));r&&i.push([Number(t.targetNodeId),t.length||gd(n.position).distanceTo(gd(r.position))])})),t.push([Number(n.id),i])}})),t.length>0&&this.dijkstra.setGraph(t)}generateLineTopologyInfoNodeGraphs(e){if("line"===e.type)for(let t=0;t<e.nodes.length;t++)if(t===e.nodes.length-1)e.nodes[t].graphs=[];else{const n=e.nodes[t],i=e.nodes[t+1];e.nodes[t].graphs=[{targetNodeId:i.id,linkInfo:{id:`${n.id}_to_${i.id}`,name:`${n.name||n.id}_to_${i.name||i.id}`},enable:!0,length:gd(e.nodes[t].position).distanceTo(gd(i.position)),restrict:0,passable:0}]}return e}}class A_ extends ha{constructor(e,t){const n=new Zn;n.setAttribute("position",new Hn([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new ra({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Zn;i.setAttribute("position",new Hn([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new fi(i,new In({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class S_ extends ly{constructor(e,t){super("Helper",e,t)}addGridHelper(e){const{id:t,size:n=1e3,divisions:i=20,color:r="#fff",position:s={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:a={x:1,y:1,z:1}}=e,l=new lu(n,i,r,r);return l.position.set(s.x,s.y,s.z),l.rotation.set(o.x,o.y,o.z),l.scale.set(a.x,a.y,a.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,i=new _u(n);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addBoxHelper(e){const{id:t,box:n,color:i="#00ff00"}=e,r=new yu(n,new Ke(i));return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPlaneHelper(e){const{id:t,width:n=500,height:i=500,color:r="#00ff00",opacity:s=.2,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new kv(new Ni(n,i),new In({color:r,opacity:s,transparent:s<1,side:2}),{id:t,position:o,rotation:a,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:i=500,height:r=500,opacity:s=1,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,h=(new Pc).load(t),d=new Ni(i,r);d.computeBoundingBox();const p=new Kl({side:2,map:h,transparent:s<1,opacity:s,roughness:.8});p.map&&(p.map.repeat.set(c.x,c.x),p.map.wrapS=u,p.map.wrapT=u,p.map.version++),a.x-=Math.PI/2,p.version++;const f=new oy(d,p,{id:n,position:o,rotation:a,scale:l});return f.userData.sid=n,f.userData.stype="Helper",this.viewport.scener.addObject(f,this.scene),f}addDirectionalLightHelper(e){const{id:t,light:n,color:i,size:r=50}=e,s=new du(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new au(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(e){const{id:t,light:n,color:i}=e,r=new Kh(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPointLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new iu(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addRectAreaLightHelper(e){const{id:t,light:n,color:i}=e,r=new A_(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}}class M_ extends ly{constructor(e,t){super("PluginObject",e,t)}createObject(e,t){const n=new Hv(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){const n=this.getById(e);return n?(this.viewport.scener.addObject(t,n),n):null}}class E_ extends ly{constructor(e,t){super("Group",e,t)}}class T_{constructor(e){this.viewport=e,this.scene=new Uv({id:"sceneManage"}),this.store={groupManager:new E_(e,this.scene),lightManager:new cy(e,this.scene),sbmManager:new xy(e,this.scene),modelManager:new v_(e,this.scene),poiManager:new y_(e,this.scene),poiNodeManager:new x_(e,this.scene),canvas3DManager:new w_(e,this.scene),topologyManager:new __(e,this.scene),helperManager:new S_(e,this.scene),pluginObjectManager:new M_(e,this.scene)},e.postUpdate.set("ManagerRender",this.update.bind(this)),e.scene.add(this.scene)}levelUpdate(){if(!this.viewport.options.levelEnabled)return;const e=(e,t)=>{e.visible!==t&&(e instanceof Gv&&e._setElementDisplay(t),e.visible=t,e.matrixAutoUpdate=t,e.autoUpdate=!0)},t=t=>{const{level:n,handleHide:i,autoUpdate:r}=t,{max:s=null,min:o=null}=n;if(r)t.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!i&&(s||o)){const n=this.viewport.camera.position.distanceTo(t.position);e(t,!(s&&n>s)&&!(o&&n<o))}};this.scene.traverse((e=>{(e instanceof Fv||e instanceof kv)&&t(e)}))}update(){if(0===this.scene.children.length)return;const e=performance.now();this.levelUpdate(),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}clearObject(){this.store.sbmManager.clear(),this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.lightManager.clear()}dispose(){this.store.modelManager.dispose()}}self.THREE=Bu;class C_{constructor(e){this.THREE=Bu,this.THREE_PLUGINS={TransformControls:ju,Lensflare:{Lensflare:pd,LensflareElement:fd}},this.version=t,this.animation=ip,this.library=ay,this.utils=zd,this.plugins={};const{el:n,options:i={},events:r={}}=e;if(this.domElement=document.querySelector(n),this.options={showInfo:!1,showStats:!1,showViewHelper:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{},hoverEnabled:!1,levelEnabled:!1,closeInfoLog:!1,closeWarnLog:!0,useIndexedDB:!0,logarithmicDepthBuffer:!0,...i},this.viewport=new Nv(this.options),this.signals=this.viewport.signals,this.manager=new T_(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(r),this._initDefaultSettings()}_init(){const{showGrid:t,background:n,fog:i,controls:r,closeInfoLog:s,closeWarnLog:o,useIndexedDB:a}=this.options;if(!s){md(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),md(e,{color:"#3eaf7c","font-size":"24px"}),md(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),md("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),md("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),md("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?Rd(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):Nd(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),i&&this.openSceneFog(!0===i?void 0:i),r&&this.setControlsOptions(r),o&&(window.console.warn=function(){}),a&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:i,modelRightClick:r,modelDblClick:s,poiHover:o,poiUnHover:a,poiClick:l,poiRightClick:c,poiDblClick:h,selectPosition:u,sceneClick:d,resize:p}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),i&&this.signals.modelClick.add(i),r&&this.signals.modelRightClick.add(r),s&&this.signals.modelDblClick.add(s),o&&this.signals.poiHover.add(o),a&&this.signals.poiUnHover.add(a),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),h&&this.signals.poiDblClick.add(h),u&&this.signals.selectPosition.add(u),d&&this.signals.sceneClick.add(d),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultSettings(){this.setEnvironment(),this.setColorSpace("sRGB"),this.setToneMapping({type:"Linear",exposure:.8})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){return this.manager.store.pluginObjectManager.addToObject(e,t)}getPluginObjectById(e){return this.manager.store.pluginObjectManager.getById(e)}getPluginObjectByName(e){return this.manager.store.pluginObjectManager.getByName(e)}removePluginObjectById(e){return this.manager.store.pluginObjectManager.removeById(e)}setSobel(){this.viewport.setSobel()}setBloom(){this.viewport.setBloom()}setSSAO(e){this.viewport.setSSAO(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setToneMapping(e){this.viewport.setToneMapping(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundImage(e){this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){return this.clear(),this.clearSignals(),this.manager.dispose(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e,t="frontTop",n){return this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e,t="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e,t="frontTop",n){return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(e="frontTop",t){return this.flyToObj(this.manager.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e,t="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.lightManager.createAmbientLight(e)}setAmbientLight(e){return this.manager.store.lightManager.setAmbientLight(e)}createDirectionalLight(e){return this.manager.store.lightManager.createDirectionalLight(e)}setDirectionalLight(e){return this.manager.store.lightManager.setDirectionalLight(e)}createHemisphereLight(e){return this.manager.store.lightManager.createHemisphereLight(e)}setHemisphereLight(e){return this.manager.store.lightManager.setHemisphereLight(e)}createSpotLight(e){return this.manager.store.lightManager.createSpotLight(e)}setSpotLight(e){return this.manager.store.lightManager.setSpotLight(e)}createPointLight(e){return this.manager.store.lightManager.createPointLight(e)}setPointLight(e){return this.manager.store.lightManager.setPointLight(e)}createRectAreaLight(e){return this.manager.store.lightManager.createRectAreaLight(e)}setRectAreaLight(e){return this.manager.store.lightManager.setRectAreaLight(e)}getLightById(e){return this.manager.store.lightManager.getById(e)}removeLightById(e){return this.manager.store.lightManager.removeById(e)}getAllLight(){return this.manager.store.lightManager.getAll()}clearLight(){return this.manager.store.lightManager.clear()}showAllLight(){return this.manager.store.lightManager.showAll()}hideAllLight(){return this.manager.store.lightManager.hideAll()}updateAllShadow(){return this.manager.store.lightManager.updateAllShadow()}createGroup(e){return this.manager.store.groupManager.createGroup(e)}getGroupById(e){return this.manager.store.groupManager.getById(e)}getGroupByName(e){return this.manager.store.groupManager.getByName(e)}getAllGroup(){return this.manager.store.groupManager.getAll()}removeGroupById(e){return this.manager.store.groupManager.removeById(e)}loadSbm(e,t){return this.manager.store.sbmManager.load(e,t)}parseSbm(e,t,n){return this.manager.store.sbmManager.parse(e,t,n)}cloneSbm(e,t,n){return this.manager.store.sbmManager.clone(e,t,n)}getSbmById(e){return this.manager.store.sbmManager.getById(e)}getSbmByName(e){return this.manager.store.sbmManager.getByName(e)}getSbmByUserDataProperty(e,t){return this.manager.store.sbmManager.getByUserDataProperty(e,t)}removeSbmById(e){return this.manager.store.sbmManager.removeById(e)}createGroupForSbm(e){return console.warn("createGroupForSbm is deprecated, use createGroup instead"),this.createGroup(e)}loadSbmToGroup(e,t,n){return this.manager.store.sbmManager.loadToGroup(e,t,n)}addSbmForGroup(e,t,n){return this.manager.store.sbmManager.addForGroup(e,t,n)}createSbmGroupFromXml(e,t){return this.manager.store.sbmManager.createGroupFromXml(e,t)}getSbmGroupById(e){return console.warn("getSbmGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getSbmGroupByName(e){return console.warn("getSbmGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllSbmGroup(){return console.warn("getAllSbmGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeSbmGroupById(e){return console.warn("removeSbmGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearSbm(){return this.manager.store.sbmManager.clear()}getAllSbm(){return this.manager.store.sbmManager.getAll()}showAllSbm(){return this.manager.store.sbmManager.showAll()}hideAllSbm(){return this.manager.store.sbmManager.hideAll()}getSbmModelMaps(){return this.manager.store.sbmManager.modelMaps}setSbmModelMaps(e){this.manager.store.sbmManager.modelMaps=e}clearIdb(){return Promise.all([this.manager.store.sbmManager.clearIdb(),this.manager.store.modelManager.clearIdb()])}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return this.manager.store.modelManager.getById(e)}getModelByName(e){return this.manager.store.modelManager.getByName(e)}getModelByUserDataProperty(e,t){return this.manager.store.modelManager.getByUserDataProperty(e,t)}removeModelById(e){return this.manager.store.modelManager.removeById(e)}createGroupForModel(e){return console.warn("createGroupForModel is deprecated, use createGroup instead"),this.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){return this.manager.store.modelManager.addForGroup(e,t)}getModelGroupById(e){return console.warn("getModelGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getModelGroupByName(e){return console.warn("getModelGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllModelGroup(){return console.warn("getAllModelGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeModelGroupById(e){return console.warn("removeModelGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return this.manager.store.poiManager.getById(e)}getPoiByName(e){return this.manager.store.poiManager.getByName(e)}getPoiByUserDataProperty(e,t){return this.manager.store.poiManager.getByUserDataProperty(e,t)}removePoiById(e){return this.manager.store.poiManager.removeById(e)}createGroupForPoi(e){return console.warn("createGroupForPoi is deprecated, use createGroup instead"),this.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){return this.manager.store.poiManager.addForGroup(e,t)}getPoiGroupById(e){return console.warn("getPoiGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getPoiGroupByName(e){return console.warn("getPoiGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllPoiGroup(){return console.warn("getAllPoiGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiGroupById(e){return console.warn("removePoiGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return this.manager.store.poiNodeManager.getById(e)}getPoiNodeByName(e){return this.manager.store.poiNodeManager.getByName(e)}getPoiNodeByUserDataProperty(e,t){return this.manager.store.poiNodeManager.getByUserDataProperty(e,t)}removePoiNodeById(e){return this.manager.store.poiNodeManager.removeById(e)}createGroupForPoiNode(e){return console.warn("createGroupForPoiNode is deprecated, use createGroup instead"),this.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){return this.manager.store.poiNodeManager.addForGroup(e,t)}getPoiNodeGroupById(e){return console.warn("getPoiNodeGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getPoiNodeGroupByName(e){return console.warn("getPoiNodeGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllPoiNodeGroup(){return console.warn("getAllPoiNodeGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiNodeGroupById(e){return console.warn("removePoiNodeGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return this.manager.store.canvas3DManager.getById(e)}getCanvas3DByName(e){return this.manager.store.canvas3DManager.getByName(e)}getCanvas3DByUserDataProperty(e,t){return this.manager.store.canvas3DManager.getByUserDataProperty(e,t)}removeCanvas3DById(e){return this.manager.store.canvas3DManager.removeById(e)}createGroupForCanvas3D(e){return console.warn("createGroupForCanvas3D is deprecated, use createGroup instead"),this.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){return this.manager.store.canvas3DManager.addForGroup(e,t)}getCanvas3DGroupById(e){return console.warn("getCanvas3DGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getCanvas3DGroupByName(e){return console.warn("getCanvas3DGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllCanvas3DGroup(){return console.warn("getAllCanvas3DGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeCanvas3DGroupById(e){return console.warn("removeCanvas3DGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return this.manager.store.topologyManager.getById(e)}getTopologyByName(e){return this.manager.store.topologyManager.getByName(e)}getTopologyByUserDataProperty(e,t){return this.manager.store.topologyManager.getByUserDataProperty(e,t)}removeTopologyById(e){return this.manager.store.topologyManager.removeById(e)}createGroupForTopology(e){return console.warn("createGroupForTopology is deprecated, use createGroup instead"),this.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){return this.manager.store.topologyManager.addForGroup(e,t)}getTopologyGroupById(e){return console.warn("getTopologyGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getTopologyGroupByName(e){return console.warn("getTopologyGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllTopologyGroup(){return console.warn("getAllTopologyGroup is deprecated, use getAllGroups instead"),this.getAllGroup()}removeTopologyGroupById(e){return console.warn("removeTopologyGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return console.warn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return this.manager.store.helperManager.getById(e)}removeHelperById(e){return this.manager.store.helperManager.removeById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}}return C_.THREE=Bu,C_}));
39
+ */var wy={},by=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},_y=function(e){return new Worker(e)};try{URL.revokeObjectURL(by(""))}catch(gy){by=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},_y=function(e){return new Worker(e,{type:"module"})}}var Ay=Uint8Array,Sy=Uint16Array,My=Uint32Array,Ey=new Ay([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ty=new Ay([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Cy=new Ay([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Iy=function(e,t){for(var n=new Sy(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new My(n[30]);for(i=1;i<30;++i)for(var s=n[i];s<n[i+1];++s)r[s]=s-n[i]<<5|i;return[n,r]},Py=Iy(Ey,2),Dy=Py[0],Ry=Py[1];Dy[28]=258,Ry[258]=28;for(var Ly=Iy(Ty,0),By=Ly[0],Oy=Ly[1],Ny=new Sy(32768),ky=0;ky<32768;++ky){var Fy=(43690&ky)>>>1|(21845&ky)<<1;Fy=(61680&(Fy=(52428&Fy)>>>2|(13107&Fy)<<2))>>>4|(3855&Fy)<<4,Ny[ky]=((65280&Fy)>>>8|(255&Fy)<<8)>>>1}var Uy=function(e,t,n){for(var i=e.length,r=0,s=new Sy(t);r<i;++r)++s[e[r]-1];var o,a=new Sy(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(n){o=new Sy(1<<t);var l=15-t;for(r=0;r<i;++r)if(e[r])for(var c=r<<4|e[r],h=t-e[r],u=a[e[r]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[Ny[u]>>>l]=c}else for(o=new Sy(i),r=0;r<i;++r)e[r]&&(o[r]=Ny[a[e[r]-1]++]>>>15-e[r]);return o},zy=new Ay(288);for(ky=0;ky<144;++ky)zy[ky]=8;for(ky=144;ky<256;++ky)zy[ky]=9;for(ky=256;ky<280;++ky)zy[ky]=7;for(ky=280;ky<288;++ky)zy[ky]=8;var Hy=new Ay(32);for(ky=0;ky<32;++ky)Hy[ky]=5;var Gy=Uy(zy,9,0),Vy=Uy(zy,9,1),jy=Uy(Hy,5,0),Wy=Uy(Hy,5,1),Xy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Yy=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},Qy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},qy=function(e){return(e/8|0)+(7&e&&1)},Zy=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Sy?Sy:e instanceof My?My:Ay)(n-t);return i.set(e.subarray(t,n)),i},Ky=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Ay(0);var r=!t||n,s=!n||n.i;n||(n={}),t||(t=new Ay(3*i));var o=function(e){var n=t.length;if(e>n){var i=new Ay(Math.max(2*n,e));i.set(t),t=i}},a=n.f||0,l=n.p||0,c=n.b||0,h=n.l,u=n.d,d=n.m,p=n.n,f=8*i;do{if(!h){n.f=a=Yy(e,l,1);var m=Yy(e,l+1,3);if(l+=3,!m){var g=e[(T=qy(l)+4)-4]|e[T-3]<<8,v=T+g;if(v>i){if(s)throw"unexpected EOF";break}r&&o(c+g),t.set(e.subarray(T,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)h=Vy,u=Wy,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=Yy(e,l,31)+257,x=Yy(e,l+10,15)+4,w=y+Yy(e,l+5,31)+1;l+=14;for(var b=new Ay(w),_=new Ay(19),A=0;A<x;++A)_[Cy[A]]=Yy(e,l+3*A,7);l+=3*x;var S=Xy(_),M=(1<<S)-1,E=Uy(_,S,1);for(A=0;A<w;){var T,C=E[Yy(e,l,M)];if(l+=15&C,(T=C>>>4)<16)b[A++]=T;else{var I=0,P=0;for(16==T?(P=3+Yy(e,l,3),l+=2,I=b[A-1]):17==T?(P=3+Yy(e,l,7),l+=3):18==T&&(P=11+Yy(e,l,127),l+=7);P--;)b[A++]=I}}var D=b.subarray(0,y),R=b.subarray(y);d=Xy(D),p=Xy(R),h=Uy(D,d,1),u=Uy(R,p,1)}if(l>f){if(s)throw"unexpected EOF";break}}r&&o(c+131072);for(var L=(1<<d)-1,B=(1<<p)-1,O=l;;O=l){var N=(I=h[Qy(e,l)&L])>>>4;if((l+=15&I)>f){if(s)throw"unexpected EOF";break}if(!I)throw"invalid length/literal";if(N<256)t[c++]=N;else{if(256==N){O=l,h=null;break}var k=N-254;if(N>264){var F=Ey[A=N-257];k=Yy(e,l,(1<<F)-1)+Dy[A],l+=F}var U=u[Qy(e,l)&B],z=U>>>4;if(!U)throw"invalid distance";l+=15&U;R=By[z];if(z>3){F=Ty[z];R+=Qy(e,l)&(1<<F)-1,l+=F}if(l>f){if(s)throw"unexpected EOF";break}r&&o(c+131072);for(var H=c+k;c<H;c+=4)t[c]=t[c-R],t[c+1]=t[c+1-R],t[c+2]=t[c+2-R],t[c+3]=t[c+3-R];c=H}}n.l=h,n.p=O,n.b=c,h&&(a=1,n.m=d,n.d=u,n.n=p)}while(!a);return c==t.length?t:Zy(t,0,c)},Jy=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8},$y=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8,e[i+2]|=n>>>16},ex=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return[ax,0];if(1==r){var o=new Ay(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,h=1,u=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=r-1;)a=n[n[c].f<n[u].f?c++:u++],l=n[c!=h&&n[c].f<n[u].f?c++:u++],n[h++]={s:-1,f:a.f+l.f,l:a,r:l};var d=s[0].s;for(i=1;i<r;++i)s[i].s>d&&(d=s[i].s);var p=new Sy(d+1),f=tx(n[h-1],p,0);if(f>t){i=0;var m=0,g=f-t,v=1<<g;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i<r;++i){var y=s[i].s;if(!(p[y]>t))break;m+=v-(1<<f-p[y]),p[y]=t}for(m>>>=g;m>0;){var x=s[i].s;p[x]<t?m-=1<<t-p[x]++-1:++i}for(;i>=0&&m;--i){var w=s[i].s;p[w]==t&&(--p[w],++m)}f=t}return[new Ay(p),f]},tx=function(e,t,n){return-1==e.s?Math.max(tx(e.l,t,n+1),tx(e.r,t,n+1)):t[e.s]=n},nx=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Sy(++t),i=0,r=e[0],s=1,o=function(e){n[i++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=e[a]}return[n.subarray(0,i),t]},ix=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},rx=function(e,t,n){var i=n.length,r=qy(t+2);e[r]=255&i,e[r+1]=i>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var s=0;s<i;++s)e[r+s+4]=n[s];return 8*(r+4+i)},sx=function(e,t,n,i,r,s,o,a,l,c,h){Jy(t,h++,n),++r[256];for(var u=ex(r,15),d=u[0],p=u[1],f=ex(s,15),m=f[0],g=f[1],v=nx(d),y=v[0],x=v[1],w=nx(m),b=w[0],_=w[1],A=new Sy(19),S=0;S<y.length;++S)A[31&y[S]]++;for(S=0;S<b.length;++S)A[31&b[S]]++;for(var M=ex(A,7),E=M[0],T=M[1],C=19;C>4&&!E[Cy[C-1]];--C);var I,P,D,R,L=c+5<<3,B=ix(r,zy)+ix(s,Hy)+o,O=ix(r,d)+ix(s,m)+o+14+3*C+ix(A,E)+(2*A[16]+3*A[17]+7*A[18]);if(L<=B&&L<=O)return rx(t,h,e.subarray(l,l+c));if(Jy(t,h,1+(O<B)),h+=2,O<B){I=Uy(d,p,0),P=d,D=Uy(m,g,0),R=m;var N=Uy(E,T,0);Jy(t,h,x-257),Jy(t,h+5,_-1),Jy(t,h+10,C-4),h+=14;for(S=0;S<C;++S)Jy(t,h+3*S,E[Cy[S]]);h+=3*C;for(var k=[y,b],F=0;F<2;++F){var U=k[F];for(S=0;S<U.length;++S){var z=31&U[S];Jy(t,h,N[z]),h+=E[z],z>15&&(Jy(t,h,U[S]>>>5&127),h+=U[S]>>>12)}}}else I=Gy,P=zy,D=jy,R=Hy;for(S=0;S<a;++S)if(i[S]>255){z=i[S]>>>18&31;$y(t,h,I[z+257]),h+=P[z+257],z>7&&(Jy(t,h,i[S]>>>23&31),h+=Ey[z]);var H=31&i[S];$y(t,h,D[H]),h+=R[H],H>3&&($y(t,h,i[S]>>>5&8191),h+=Ty[H])}else $y(t,h,I[i[S]]),h+=P[i[S]];return $y(t,h,I[256]),h+P[256]},ox=new My([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ax=new Ay(0),lx=function(e,t,n,i,r,s){var o=e.length,a=new Ay(i+o+5*(1+Math.ceil(o/7e3))+r),l=a.subarray(i,a.length-r),c=0;if(!t||o<8)for(var h=0;h<=o;h+=65535){var u=h+65535;u<o?c=rx(l,c,e.subarray(h,u)):(l[h]=s,c=rx(l,c,e.subarray(h,o)))}else{for(var d=ox[t-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new Sy(32768),v=new Sy(m+1),y=Math.ceil(n/3),x=2*y,w=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<x)&m},b=new My(25e3),_=new Sy(288),A=new Sy(32),S=0,M=0,E=(h=0,0),T=0,C=0;h<o;++h){var I=w(h),P=32767&h,D=v[I];if(g[P]=D,v[I]=P,T<=h){var R=o-h;if((S>7e3||E>24576)&&R>423){c=sx(e,l,0,b,_,A,M,E,C,h-C,c),E=S=M=0,C=h;for(var L=0;L<286;++L)_[L]=0;for(L=0;L<30;++L)A[L]=0}var B=2,O=0,N=f,k=P-D&32767;if(R>2&&I==w(h-k))for(var F=Math.min(p,R)-1,U=Math.min(32767,h),z=Math.min(258,R);k<=U&&--N&&P!=D;){if(e[h+B]==e[h+B-k]){for(var H=0;H<z&&e[h+H]==e[h+H-k];++H);if(H>B){if(B=H,O=k,H>F)break;var G=Math.min(k,H-2),V=0;for(L=0;L<G;++L){var j=h-k+L+32768&32767,W=j-g[j]+32768&32767;W>V&&(V=W,D=j)}}}k+=(P=D)-(D=g[P])+32768&32767}if(O){b[E++]=268435456|Ry[B]<<18|Oy[O];var X=31&Ry[B],Y=31&Oy[O];M+=Ey[X]+Ty[Y],++_[257+X],++A[Y],T=h+B,++S}else b[E++]=e[h],++_[e[h]]}}c=sx(e,l,s,b,_,A,M,E,C,h-C,c),!s&&7&c&&(c=rx(l,c+1,ax))}return Zy(a,0,i+qy(c)+r)},cx=function(){for(var e=new My(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),hx=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=cx[255&n^t[i]]^n>>>8;e=n},d:function(){return~e}}},ux=function(){var e=1,t=0;return{p:function(n){for(var i=e,r=t,s=n.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)r+=i+=n[o];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}e=i,t=r},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},dx=function(e,t,n,i,r){return lx(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!r)},px=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},fx=function(e,t,n){for(var i=e(),r=e.toString(),s=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<i.length;++o){var a=i[o],l=s[o];if("function"==typeof a){t+=";"+l+"=";var c=a.toString();if(a.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;t+=c.slice(h,c.indexOf("(",h))}else for(var u in t+=c,a.prototype)t+=";"+l+".prototype."+u+"="+a.prototype[u].toString();else t+=c}else n[l]=a}return[t,n]},mx=[],gx=function(e,t,n,i){var r;if(!mx[n]){for(var s="",o={},a=e.length-1,l=0;l<a;++l)s=(r=fx(e[l],s,o))[0],o=r[1];mx[n]=fx(e[a],s,o)}var c=px({},mx[n][1]);return function(e,t,n,i,r){var s=_y(wy[t]||(wy[t]=by(e)));return s.onerror=function(e){return r(e.error,null)},s.onmessage=function(e){return r(null,e.data)},s.postMessage(n,i),s}(mx[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,function(e){var t=[];for(var n in e)(e[n]instanceof Ay||e[n]instanceof Sy||e[n]instanceof My)&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t}(c),i)},vx=function(){return[Ay,Sy,My,Ey,Ty,Cy,Dy,By,Vy,Wy,Ny,Uy,Xy,Yy,Qy,qy,Zy,Ky,Xx,Ax,Sx]},yx=function(){return[Ay,Sy,My,Ey,Ty,Cy,Ry,Oy,Gy,zy,jy,Hy,Ny,ox,ax,Uy,Jy,$y,ex,tx,nx,ix,rx,sx,qy,Zy,lx,dx,Gx,Ax]},xx=function(){return[Rx,Ox,Dx,hx,cx]},wx=function(){return[Lx,Bx]},bx=function(){return[Nx,Dx,ux]},_x=function(){return[kx]},Ax=function(e){return postMessage(e,[e.buffer])},Sx=function(e){return e&&e.size&&new Ay(e.size)},Mx=function(e,t,n,i,r,s){var o=gx(n,i,r,(function(e,t){o.terminate(),s(e,t)}));return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},Ex=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},Tx=function(e,t,n,i,r){var s,o=gx(e,i,r,(function(e,n){e?(o.terminate(),t.ondata.call(t,e)):(n[1]&&o.terminate(),t.ondata.call(t,e,n[0],n[1]))}));o.postMessage(n),t.push=function(e,n){if(s)throw"stream finished";if(!t.ondata)throw"no stream handler";o.postMessage([e,s=n],[e.buffer])},t.terminate=function(){o.terminate()}},Cx=function(e,t){return e[t]|e[t+1]<<8},Ix=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Px=function(e,t){return Ix(e,t)+4294967296*Ix(e,t+4)},Dx=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Rx=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Dx(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var i=0;i<=n.length;++i)e[i+10]=n.charCodeAt(i)}},Lx=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[n++]);return n+(2&t)},Bx=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Ox=function(e){return 10+(e.filename&&e.filename.length+1||0)},Nx=function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)},kx=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function Fx(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var Ux=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(dx(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),zx=function(){return function(e,t){Tx([yx,function(){return[Ex,Ux]}],this,Fx.call(this,e,t),(function(e){var t=new Ux(e.data);onmessage=Ex(t)}),6)}}();function Hx(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[yx],(function(e){return Ax(Gx(e.data[0],e.data[1]))}),0,n)}function Gx(e,t){return dx(e,t||{},0,0)}var Vx=function(){function e(e){this.s={},this.p=new Ay(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new Ay(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=Ky(this.p,this.o,this.s);this.ondata(Zy(n,t,this.s.b),this.d),this.o=Zy(n,this.s.b-32768),this.s.b=this.o.length,this.p=Zy(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),jx=function(){return function(e){this.ondata=e,Tx([vx,function(){return[Ex,Vx]}],this,0,(function(){var e=new Vx;onmessage=Ex(e)}),7)}}();function Wx(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[vx],(function(e){return Ax(Xx(e.data[0],Sx(e.data[1])))}),1,n)}function Xx(e,t){return Ky(e,t)}var Yx=function(){function e(e,t){this.c=hx(),this.l=0,this.v=1,Ux.call(this,e,t)}return e.prototype.push=function(e,t){Ux.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=dx(e,this.o,this.v&&Ox(this.o),t&&8,!t);this.v&&(Rx(n,this.o),this.v=0),t&&(Dx(n,n.length-8,this.c.d()),Dx(n,n.length-4,this.l)),this.ondata(n,t)},e}(),Qx=function(){return function(e,t){Tx([yx,xx,function(){return[Ex,Ux,Yx]}],this,Fx.call(this,e,t),(function(e){var t=new Yx(e.data);onmessage=Ex(t)}),8)}}();function qx(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[yx,xx,function(){return[Zx]}],(function(e){return Ax(Zx(e.data[0],e.data[1]))}),2,n)}function Zx(e,t){t||(t={});var n=hx(),i=e.length;n.p(e);var r=dx(e,t,Ox(t),8),s=r.length;return Rx(r,t),Dx(r,s-8,n.d()),Dx(r,s-4,i),r}var Kx=function(){function e(e){this.v=1,Vx.call(this,e)}return e.prototype.push=function(e,t){if(Vx.prototype.e.call(this,e),this.v){var n=this.p.length>3?Lx(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Vx.prototype.c.call(this,t)},e}(),Jx=function(){return function(e){this.ondata=e,Tx([vx,wx,function(){return[Ex,Vx,Kx]}],this,0,(function(){var e=new Kx;onmessage=Ex(e)}),9)}}();function $x(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[vx,wx,function(){return[ew]}],(function(e){return Ax(ew(e.data[0]))}),3,n)}function ew(e,t){return Ky(e.subarray(Lx(e),-8),t||new Ay(Bx(e)))}var tw=function(){function e(e,t){this.c=ux(),this.v=1,Ux.call(this,e,t)}return e.prototype.push=function(e,t){Ux.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=dx(e,this.o,this.v&&2,t&&4,!t);this.v&&(Nx(n,this.o),this.v=0),t&&Dx(n,n.length-4,this.c.d()),this.ondata(n,t)},e}(),nw=function(){return function(e,t){Tx([yx,bx,function(){return[Ex,Ux,tw]}],this,Fx.call(this,e,t),(function(e){var t=new tw(e.data);onmessage=Ex(t)}),10)}}();function iw(e,t){t||(t={});var n=ux();n.p(e);var i=dx(e,t,2,4);return Nx(i,t),Dx(i,i.length-4,n.d()),i}var rw=function(){function e(e){this.v=1,Vx.call(this,e)}return e.prototype.push=function(e,t){if(Vx.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Vx.prototype.c.call(this,t)},e}(),sw=function(){return function(e){this.ondata=e,Tx([vx,_x,function(){return[Ex,Vx,rw]}],this,0,(function(){var e=new rw;onmessage=Ex(e)}),11)}}();function ow(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[vx,_x,function(){return[aw]}],(function(e){return Ax(aw(e.data[0],Sx(e.data[1])))}),5,n)}function aw(e,t){return Ky((kx(e),e.subarray(2,-4)),t)}var lw=function(){function e(e){this.G=Kx,this.I=Vx,this.Z=rw,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new Ay(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,r=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(r):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(r):new this.Z(r),this.s.push(this.p,t),this.p=null}}},e}(),cw=function(){function e(e){this.G=Jx,this.I=jx,this.Z=sw,this.ondata=e}return e.prototype.push=function(e,t){lw.prototype.push.call(this,e,t)},e}();var hw=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r;s instanceof Ay?n[o]=[s,i]:Array.isArray(s)?n[o]=[s[0],px(i,s[1])]:hw(s,o+"/",n,i)}},uw="undefined"!=typeof TextEncoder&&new TextEncoder,dw="undefined"!=typeof TextDecoder&&new TextDecoder,pw=0;try{dw.decode(ax,{stream:!0}),pw=1}catch(gy){}var fw=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return[t,Zy(e,n-1)];r?3==r?(i=((15&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|i>>10,56320|1023&i)):t+=1&r?String.fromCharCode((31&i)<<6|63&e[n++]):String.fromCharCode((15&i)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(i)}},mw=function(){function e(e){this.ondata=e,pw?this.t=new TextDecoder:this.p=ax}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new Ay(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=fw(n),r=i[0],s=i[1];if(t){if(s.length)throw"invalid utf-8 data";this.p=null}else this.p=s;this.ondata(r,t)}},e}(),gw=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(vw(e),this.d=t||!1)},e}();function vw(e,t){if(t){for(var n=new Ay(e.length),i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(uw)return uw.encode(e);var r=e.length,s=new Ay(e.length+(e.length>>1)),o=0,a=function(e){s[o++]=e};for(i=0;i<r;++i){if(o+5>s.length){var l=new Ay(o+8+(r-i<<1));l.set(s),s=l}var c=e.charCodeAt(i);c<128||t?a(c):c<2048?(a(192|c>>6),a(128|63&c)):c>55295&&c<57344?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|63&c)):(a(224|c>>12),a(128|c>>6&63),a(128|63&c))}return Zy(s,0,o)}function yw(e,t){if(t){for(var n="",i=0;i<e.length;i+=16384)n+=String.fromCharCode.apply(null,e.subarray(i,i+16384));return n}if(dw)return dw.decode(e);var r=fw(e),s=r[0];if(r[1].length)throw"invalid utf-8 data";return s}var xw=function(e){return 1==e?3:e<6?2:9==e?1:0},ww=function(e,t){return t+30+Cx(e,t+26)+Cx(e,t+28)},bw=function(e,t,n){var i=Cx(e,t+28),r=yw(e.subarray(t+46,t+46+i),!(2048&Cx(e,t+8))),s=t+46+i,o=Ix(e,t+20),a=n&&4294967295==o?_w(e,s):[o,Ix(e,t+24),Ix(e,t+42)],l=a[0],c=a[1],h=a[2];return[Cx(e,t+10),l,c,r,s+Cx(e,t+30)+Cx(e,t+32),h]},_w=function(e,t){for(;1!=Cx(e,t);t+=4+Cx(e,t+2));return[Px(e,t+12),Px(e,t+4),Px(e,t+20)]},Aw=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)throw"extra field too long";t+=i+4}return t},Sw=function(e,t,n,i,r,s,o,a){var l=i.length,c=n.extra,h=a&&a.length,u=Aw(c);Dx(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==s&&8),e[t++]=r&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(Dx(e,t,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),t+=4,null!=s&&(Dx(e,t,n.crc),Dx(e,t+4,s),Dx(e,t+8,n.size)),Dx(e,t+12,l),Dx(e,t+14,u),t+=16,null!=o&&(Dx(e,t,h),Dx(e,t+6,n.attrs),Dx(e,t+10,o),t+=14),e.set(i,t),t+=l,u)for(var f in c){var m=c[f],g=m.length;Dx(e,t,+f),Dx(e,t+2,g),e.set(m,t+4),t+=4+g}return h&&(e.set(a,t),t+=h),t},Mw=function(e,t,n,i,r){Dx(e,t,101010256),Dx(e,t+8,n),Dx(e,t+10,n),Dx(e,t+12,i),Dx(e,t+16,r)},Ew=function(){function e(e){this.filename=e,this.c=hx(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),Tw=function(){function e(e,t){var n=this;t||(t={}),Ew.call(this,e),this.d=new Ux(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=xw(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){Ew.prototype.push.call(this,e,t)},e}(),Cw=function(){function e(e,t){var n=this;t||(t={}),Ew.call(this,e),this.d=new zx(t,(function(e,t,i){n.ondata(e,t,i)})),this.compression=8,this.flag=xw(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){Ew.prototype.push.call(this,e,t)},e}(),Iw=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=vw(e.filename),i=n.length,r=e.comment,s=r&&vw(r),o=i!=e.filename.length||s&&r.length!=s.length,a=i+Aw(e.extra)+30;if(i>65535)throw"filename too long";var l=new Ay(a);Sw(l,0,e,n,o);var c=[l],h=function(){for(var e=0,n=c;e<n.length;e++){var i=n[e];t.ondata(null,i,!1)}c=[]},u=this.d;this.d=0;var d=this.u.length,p=px(e,{f:n,u:o,o:s,t:function(){e.terminate&&e.terminate()},r:function(){if(h(),u){var e=t.u[d+1];e?e.r():t.d=1}u=1}}),f=0;e.ondata=function(n,i,r){if(n)t.ondata(n,i,r),t.terminate();else if(f+=i.length,c.push(i),r){var s=new Ay(16);Dx(s,0,134695760),Dx(s,4,e.crc),Dx(s,8,f),Dx(s,12,e.size),c.push(s),p.c=f,p.b=a+f+16,p.crc=e.crc,p.size=e.size,u&&p.r(),u=1}else u&&h()},this.u.push(p)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,i=0,r=this.u;i<r.length;i++){n+=46+(l=r[i]).f.length+Aw(l.extra)+(l.o?l.o.length:0)}for(var s=new Ay(n+22),o=0,a=this.u;o<a.length;o++){var l=a[o];Sw(s,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+Aw(l.extra)+(l.o?l.o.length:0),t+=l.b}Mw(s,e,this.u.length,n,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){t[e].t()}this.d=2},e}();var Pw=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),Dw=function(){function e(){var e=this;this.i=new Vx((function(t,n){e.ondata(null,t,n)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},e.compression=8,e}(),Rw=function(){function e(e,t){var n=this;t<32e4?this.i=new Vx((function(e,t){n.ondata(null,e,t)})):(this.i=new jx((function(e,t,i){n.ondata(e,t,i)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Zy(e,0)),this.i.push(e,t)},e.compression=8,e}(),Lw=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Pw},this.p=ax}return e.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var i=Math.min(this.c,e.length),r=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(e=e.subarray(i)).length)return this.push(e,t)}else{var s=0,o=0,a=void 0,l=void 0;this.p.length?e.length?((l=new Ay(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,h=this.c,u=h&&this.d,d=function(){var e,t=Ix(l,o);if(67324752==t){s=1,a=o,p.d=null,p.c=0;var i=Cx(l,o+6),r=Cx(l,o+8),u=2048&i,d=8&i,f=Cx(l,o+26),m=Cx(l,o+28);if(c>o+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=Ix(l,o+18),x=Ix(l,o+22),w=yw(l.subarray(o+30,o+=30+f),!u);4294967295==y?(e=d?[-2]:_w(l,o),y=e[0],x=e[1]):d&&(y=-1),o+=m,p.c=y;var b={name:w,compression:r,start:function(){if(!b.ondata)throw"no callback";if(y){var e=n.o[r];if(!e)throw"unknown compression type "+r;(v=y<0?new e(w):new e(w,y,x)).ondata=function(e,t,n){b.ondata(e,t,n)};for(var t=0,i=g;t<i.length;t++){var s=i[t];v.push(s,!1)}n.k[0]==g&&n.c?n.d=v:v.push(ax,!0)}else b.ondata(null,ax,!0)},terminate:function(){v&&v.terminate&&v.terminate()}};y>=0&&(b.size=y,b.originalSize=x),p.onfile(b)}return"break"}if(h){if(134695760==t)return a=o+=12+(-2==h&&8),s=3,p.c=0,"break";if(33639248==t)return a=o-=4,s=3,p.c=0,"break"}},p=this;o<c-4;++o){if("break"===d())break}if(this.p=ax,h<0){var f=s?l.subarray(0,a-12-(-2==h&&8)-(134695760==Ix(l,a-16)&&4)):l.subarray(0,o);u?u.push(f,!!s):this.k[+(2==s)].push(f)}if(2&s)return this.push(l.subarray(o),t);this.p=l.subarray(o)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();var Bw=Object.freeze({__proto__:null,Deflate:Ux,AsyncDeflate:zx,deflate:Hx,deflateSync:Gx,Inflate:Vx,AsyncInflate:jx,inflate:Wx,inflateSync:Xx,Gzip:Yx,AsyncGzip:Qx,gzip:qx,gzipSync:Zx,Gunzip:Kx,AsyncGunzip:Jx,gunzip:$x,gunzipSync:ew,Zlib:tw,AsyncZlib:nw,zlib:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return Mx(e,t,[yx,bx,function(){return[iw]}],(function(e){return Ax(iw(e.data[0],e.data[1]))}),4,n)},zlibSync:iw,Unzlib:rw,AsyncUnzlib:sw,unzlib:ow,unzlibSync:aw,compress:qx,AsyncCompress:Qx,compressSync:Zx,Compress:Yx,Decompress:lw,AsyncDecompress:cw,decompress:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?$x(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Wx(e,t,n):ow(e,t,n)},decompressSync:function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?ew(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Xx(e,t):aw(e,t)},DecodeUTF8:mw,EncodeUTF8:gw,strToU8:vw,strFromU8:yw,ZipPassThrough:Ew,ZipDeflate:Tw,AsyncZipDeflate:Cw,Zip:Iw,zip:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";var i={};hw(e,"",i,t);var r=Object.keys(i),s=r.length,o=0,a=0,l=s,c=new Array(s),h=[],u=function(){for(var e=0;e<h.length;++e)h[e]()},d=function(){var e=new Ay(a+22),t=o,i=a-o;a=0;for(var r=0;r<l;++r){var s=c[r];try{var h=s.c.length;Sw(e,a,s,s.f,s.u,h);var u=30+s.f.length+Aw(s.extra),d=a+u;e.set(s.c,d),Sw(e,o,s,s.f,s.u,h,a,s.m),o+=16+u+(s.m?s.m.length:0),a=d+h}catch(e){return n(e,null)}}Mw(e,o,c.length,i,t),n(null,e)};s||d();for(var p=function(e){var t=r[e],l=i[t],p=l[0],f=l[1],m=hx(),g=p.length;m.p(p);var v=vw(t),y=v.length,x=f.comment,w=x&&vw(x),b=w&&w.length,_=Aw(f.extra),A=0==f.level?0:8,S=function(i,r){if(i)u(),n(i,null);else{var l=r.length;c[e]=px(f,{size:g,crc:m.d(),c:r,f:v,m:w,u:y!=t.length||w&&x.length!=b,compression:A}),o+=30+y+_+l,a+=76+2*(y+_)+(b||0)+l,--s||d()}};if(y>65535&&S("filename too long",null),A)if(g<16e4)try{S(null,Gx(p,f))}catch(e){S(e,null)}else h.push(Hx(p,f,S));else S(null,p)},f=0;f<l;++f)p(f);return u},zipSync:function(e,t){t||(t={});var n={},i=[];hw(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],l=a[0],c=a[1],h=0==c.level?0:8,u=(A=vw(o)).length,d=c.comment,p=d&&vw(d),f=p&&p.length,m=Aw(c.extra);if(u>65535)throw"filename too long";var g=h?Gx(l,c):l,v=g.length,y=hx();y.p(l),i.push(px(c,{size:l.length,crc:y.d(),c:g,f:A,m:p,u:u!=o.length||p&&d.length!=f,o:r,compression:h})),r+=30+u+m+v,s+=76+2*(u+m)+(f||0)+v}for(var x=new Ay(s+22),w=r,b=s-r,_=0;_<i.length;++_){var A=i[_];Sw(x,A.o,A,A.f,A.u,A.c.length);var S=30+A.f.length+Aw(A.extra);x.set(A.c,A.o+S),Sw(x,r,A,A.f,A.u,A.c.length,A.o,A.m),r+=16+S+(A.m?A.m.length:0)}return Mw(x,r,i.length,b,w),x},UnzipPassThrough:Pw,UnzipInflate:Dw,AsyncUnzipInflate:Rw,Unzip:Lw,unzip:function(e,t){if("function"!=typeof t)throw"no callback";for(var n=[],i=function(){for(var e=0;e<n.length;++e)n[e]()},r={},s=e.length-22;101010256!=Ix(e,s);--s)if(!s||e.length-s>65558)return void t("invalid zip file",null);var o=Cx(e,s+8);o||t(null,{});var a=o,l=Ix(e,s+16),c=4294967295==l;if(c){if(s=Ix(e,s-12),101075792!=Ix(e,s))return void t("invalid zip file",null);a=o=Ix(e,s+32),l=Ix(e,s+48)}for(var h=function(s){var a=bw(e,l,c),h=a[0],u=a[1],d=a[2],p=a[3],f=a[4],m=a[5],g=ww(e,m);l=f;var v=function(e,n){e?(i(),t(e,null)):(r[p]=n,--o||t(null,r))};if(h)if(8==h){var y=e.subarray(g,g+u);if(u<32e4)try{v(null,Xx(y,new Ay(d)))}catch(e){v(e,null)}else n.push(Wx(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,Zy(e,g,g+u))},u=0;u<a;++u)h();return i},unzipSync:function(e){for(var t={},n=e.length-22;101010256!=Ix(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var i=Cx(e,n+8);if(!i)return{};var r=Ix(e,n+16),s=4294967295==r;if(s){if(n=Ix(e,n-12),101075792!=Ix(e,n))throw"invalid zip file";i=Ix(e,n+32),r=Ix(e,n+48)}for(var o=0;o<i;++o){var a=bw(e,r,s),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],p=a[5],f=ww(e,p);if(r=d,l){if(8!=l)throw"unknown compression type "+l;t[u]=Xx(e.subarray(f,f+c),new Ay(h))}else t[u]=Zy(e,f,f+c)}return t}});function Ow(e,t,n){const i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,s=i,o=Math.floor((r+s)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?s=o:r=o,o=Math.floor((r+s)/2);return o}function Nw(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let i=1;for(let e=2;e<=t;++e)i*=e;for(let n=2;n<=e-t;++n)i*=n;return n/i}function kw(e,t,n,i,r){return function(e){const t=e.length,n=[],i=[];for(let r=0;r<t;++r){const t=e[r];n[r]=new dt(t.x,t.y,t.z),i[r]=t.w}const r=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(r[e-n].clone().multiplyScalar(Nw(e,n)*i[n]));r[e]=t.divideScalar(i[0])}return r}(function(e,t,n,i,r){const s=r<e?r:e,o=[],a=Ow(e,i,t),l=function(e,t,n,i,r){const s=[];for(let e=0;e<=n;++e)s[e]=0;const o=[];for(let e=0;e<=i;++e)o[e]=s.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let i=1;i<=n;++i){l[i]=t-r[e+1-i],c[i]=r[e+i]-t;let n=0;for(let e=0;e<i;++e){const t=c[e+1],r=l[i-e];a[i][e]=t+r;const s=a[e][i-1]/a[i][e];a[e][i]=n+t*s,n=r*s}a[i][i]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,r=1;const l=[];for(let e=0;e<=n;++e)l[e]=s.slice(0);l[0][0]=1;for(let s=1;s<=i;++s){let i=0;const c=e-s,h=n-s;e>=s&&(l[r][0]=l[t][0]/a[h+1][c],i=l[r][0]*a[c][h]);const u=e-1<=h?s-1:n-e;for(let e=c>=-1?1:-c;e<=u;++e)l[r][e]=(l[t][e]-l[t][e-1])/a[h+1][c+e],i+=l[r][e]*a[c+e][h];e<=h&&(l[r][s]=-l[t][s-1]/a[h+1][e],i+=l[r][s]*a[e][h]),o[s][e]=i;const d=t;t=r,r=d}}let h=n;for(let e=1;e<=i;++e){for(let t=0;t<=n;++t)o[e][t]*=h;h*=n-e}return o}(a,i,e,s,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),i=t.w;t.x*=i,t.y*=i,t.z*=i,c[e]=t}for(let t=0;t<=s;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let i=1;i<=e;++i)n.add(c[a-e+i].clone().multiplyScalar(l[t][i]));o[t]=n}for(let e=s+1;e<=r+1;++e)o[e]=new rt(0,0,0);return o}(e,t,n,i,r))}class Fw extends Ea{constructor(e,t,n,i,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new rt(t.x,t.y,t.z,t.w)}}getPoint(e,t=new dt){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=function(e,t,n,i){const r=Ow(e,i,t),s=function(e,t,n,i){const r=[],s=[],o=[];r[0]=1;for(let a=1;a<=n;++a){s[a]=t-i[e+1-a],o[a]=i[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],i=s[a-e],l=r[e]/(t+i);r[e]=n+t*l,n=i*l}r[a]=n}return r}(r,i,e,t),o=new rt(0,0,0,0);for(let t=0;t<=e;++t){const i=n[r-e+t],a=s[t],l=i.w*a;o.x+=i.x*l,o.y+=i.y*l,o.z+=i.z*l,o.w+=i.w*a}return o}(this.degree,this.knots,this.controlPoints,i);return 1!==r.w&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new dt){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=kw(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}}let Uw,zw,Hw;class Gw extends Sc{constructor(e){super(e)}load(e,t,n,i){const r=this,s=""===r.path?Kc.extractUrlBase(e):r.path,o=new Ec(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(n,s))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===sb(e,0,t.length)}(e))Uw=(new Yw).parse(e);else{const t=sb(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(t){const i=e[t-1];return e=e.slice(n+t),n++,i}for(let e=0;e<t.length;++e){if(i(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Zw(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Zw(t));Uw=(new Xw).parse(t)}const n=new Pc(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Vw(n,this.manager).parse(Uw)}}class Vw{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){zw=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=(new jw).parse(i);return this.parseScene(i,r,n),Hw}parseConnections(){const e=new Map;if("Connections"in Uw){Uw.Connections.connections.forEach((function(t){const n=t[0],i=t[1],r=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const s={ID:i,relationship:r};e.get(n).parents.push(s),e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:n,relationship:r};e.get(i).children.push(o)}))}return e}parseImages(){const e={},t={};if("Video"in Uw.Objects){const n=Uw.Objects.Video;for(const i in n){const r=n[i];if(e[parseInt(i)]=r.RelativeFilename||r.Filename,"Content"in r){const e=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,s="string"==typeof r.Content&&""!==r.Content;if(e||s){const e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(const n in e){const i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+i+'" is not supported.')}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in Uw.Objects){const n=Uw.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,r=e.WrapModeV,s=void 0!==i?i.value:0,o=void 0!==r?r.value:0;if(n.wrapS=0===s?u:d,n.wrapT=0===o?u:d,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,r=zw.get(e.id).children;let s;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const o=e.FileName.slice(-3).toLowerCase();if("tga"===o){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new it):(t.setPath(this.textureLoader.path),s=t.load(n))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new it):s=this.textureLoader.load(n);return this.textureLoader.setPath(i),s}parseMaterials(e){const t=new Map;if("Material"in Uw.Objects){const n=Uw.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!zw.has(n))return null;const s=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new $l;break;case"lambert":o=new nc;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new $l}return o.setValues(s),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new Ke).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(i.color=(new Ke).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new Ke).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(i.emissive=(new Ke).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new Ke).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new Ke).fromArray(e.SpecularColor.value));const r=this;return zw.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.encoding=de);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.encoding=de);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=l,i.envMap.encoding=de);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.encoding=de);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in Uw.Objects&&t in Uw.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=zw.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Uw.Objects){const n=Uw.Objects.Deformer;for(const i in n){const r=n[i],s=zw.get(parseInt(i));if("Skin"===r.attrType){const t=this.parseSkeleton(s,n);t.ID=i,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){const e={id:i};e.rawTargets=this.parseMorphTargets(s,n),e.id=i,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const i=t[e.ID];if("Cluster"!==i.attrType)return;const r={ID:e.ID,indices:[],weights:[],transformLink:(new Vt).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const r=e.children[i],s=t[r.ID],o={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;o.geoID=zw.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(o)}return n}parseScene(e,t,n){Hw=new ao;const i=this.parseModels(e.skeletons,t,n),r=Uw.Objects.Model,s=this;i.forEach((function(e){const t=r[e.ID];s.setLookAtProperties(e,t);zw.get(e.ID).parents.forEach((function(t){const n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&Hw.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),Hw.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=nb(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const o=(new Ww).parse();1===Hw.children.length&&Hw.children[0].isGroup&&(Hw.children[0].animations=o,Hw=Hw.children[0]),Hw.animations=o}parseModels(e,t,n){const i=new Map,r=Uw.Objects.Model;for(const s in r){const o=parseInt(s),a=r[s],l=zw.get(o);let c=this.buildSkeleton(l,e,o,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new Yo;break;case"Null":default:c=new ao}c.name=a.attrName?Oh.sanitizeNodeName(a.attrName):"",c.ID=o}this.getTransformData(c,a),i.set(o,c)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach((function(e){for(const s in t){const o=t[s];o.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=r;r=new Yo,r.matrixWorld.copy(t.transformLink),r.name=i?Oh.sanitizeNodeName(i):"",r.ID=n,o.bones[s]=r,null!==e&&r.add(e)}}))}})),r}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=Uw.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new mn;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let r=1e3;void 0!==n.FarPlane&&(r=n.FarPlane.value/1e3);let s=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,o=n.AspectHeight.value);const a=s/o;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new _i(l,a,i,r),null!==c&&t.setFocalLength(c);break;case 1:t=new Xi(-s/2,s/2,o/2,-o/2,i,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new mn}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=Uw.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new mn;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new Ke).fromArray(n.Color.value));let r=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(r=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new Vc(i,r,s,o);break;case 1:t=new Wc(i,r);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=Be.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=Be.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new Fc(i,r,s,e,a,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Vc(i,r)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,s=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(r=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))})),o.length>1?s=o:o.length>0?s=o[0]:(s=new $l({color:13421772}),o.push(s)),"color"in r.attributes&&o.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new Xo(r,s),i.normalizeSkinWeights()):i=new fi(r,s),i}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new ra({color:3342591,linewidth:1});return new ha(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?ib(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){zw.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=Uw.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Hw.add(e.target)):e.lookAt((new dt).fromArray(t))}}}))}}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const r in e){const s=e[r];zw.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;zw.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Ko(s.bones),i[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in Uw.Objects){const t=Uw.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new Vt).fromArray(t.Matrix.a)})):e[i.Node]=(new Vt).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Uw&&"AmbientColor"in Uw.GlobalSettings){const e=Uw.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){const e=new Ke(t,n,i);Hw.add(new Xc(e,1))}}}}class jw{parse(e){const t=new Map;if("Geometry"in Uw.Objects){const n=Uw.Objects.Geometry;for(const i in n){const r=zw.get(parseInt(i)),s=this.parseGeometry(r,n[i],e);t.set(parseInt(i),s)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,r=[],s=e.parents.map((function(e){return Uw.Objects.Model[e.ID]}));if(0===s.length)return;const o=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=ib(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=nb(l);return this.genGeometry(t,o,r,c)}genGeometry(e,t,n,i){const r=new Zn;e.attrName&&(r.name=e.attrName);const s=this.parseGeoNode(e,t),o=this.genBuffers(s),a=new Hn(o.vertex,3);if(a.applyMatrix4(i),r.setAttribute("position",a),o.colors.length>0&&r.setAttribute("color",new Hn(o.colors,3)),t&&(r.setAttribute("skinIndex",new kn(o.weightsIndices,4)),r.setAttribute("skinWeight",new Hn(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const e=(new Ne).getNormalMatrix(i),t=new Hn(o.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(o.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),r.setAttribute(n,new Hn(o.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){const t=r.groups[r.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&r.addGroup(n,o.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,s=[],o=[],a=[],l=[],c=[],h=[];const u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(s.push(3*d,3*d+1,3*d+2),e.color){const t=$w(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,s=g[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;const o=e[n];e[n]=s,s=o}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)c.push(v[e]),h.push(g[e])}if(e.normal){const t=$w(p,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=$w(p,n,d,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const i=$w(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,m&&(u.genFace(t,e,s,f,o,a,l,c,h,i),n++,i=0,s=[],o=[],a=[],l=[],c=[],h=[])})),t}genFace(e,t,n,i,r,s,o,a,l,c){for(let h=2;h<c;h++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(h-1)]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+2]]),e.vertex.push(t.vertexPositions[n[3*h]]),e.vertex.push(t.vertexPositions[n[3*h+1]]),e.vertex.push(t.vertexPositions[n[3*h+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(h-1)]),e.vertexWeights.push(a[4*(h-1)+1]),e.vertexWeights.push(a[4*(h-1)+2]),e.vertexWeights.push(a[4*(h-1)+3]),e.vertexWeights.push(a[4*h]),e.vertexWeights.push(a[4*h+1]),e.vertexWeights.push(a[4*h+2]),e.vertexWeights.push(a[4*h+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(h-1)]),e.weightsIndices.push(l[4*(h-1)+1]),e.weightsIndices.push(l[4*(h-1)+2]),e.weightsIndices.push(l[4*(h-1)+3]),e.weightsIndices.push(l[4*h]),e.weightsIndices.push(l[4*h+1]),e.weightsIndices.push(l[4*h+2]),e.weightsIndices.push(l[4*h+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[3*(h-1)]),e.colors.push(s[3*(h-1)+1]),e.colors.push(s[3*(h-1)+2]),e.colors.push(s[3*h]),e.colors.push(s[3*h+1]),e.colors.push(s[3*h+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(h-1)]),e.normal.push(r[3*(h-1)+1]),e.normal.push(r[3*(h-1)+2]),e.normal.push(r[3*h]),e.normal.push(r[3*h+1]),e.normal.push(r[3*h+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][0]),e.uvs[n].push(o[n][1]),e.uvs[n].push(o[n][2*(h-1)]),e.uvs[n].push(o[n][2*(h-1)+1]),e.uvs[n].push(o[n][2*h]),e.uvs[n].push(o[n][2*h+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=Uw.Objects.Geometry[n.geoID];void 0!==s&&r.genMorphGeometry(e,t,s,i,n.name)}))}))}genMorphGeometry(e,t,n,i,r){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=o[3*e],c[t+1]=o[3*e+1],c[t+2]=o[3*e+2]}const h={vertexIndices:s,vertexPositions:c},u=this.genBuffers(h),d=new Hn(u.vertex,3);d.name=r||n.attrName,d.applyMatrix4(i),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let r=[];return"IndexToDirect"===n&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let r=[];return"IndexToDirect"===n&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let r=[];return"IndexToDirect"===n&&(r=e.ColorIndex.a),{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,r=[];for(let e=0;e<i.length;++e)r.push(e);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(void 0===Fw)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new Zn;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Zn;const n=t-1,i=e.KnotVector.a,r=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)r.push((new rt).fromArray(s,e));let o,a;if("Closed"===e.Form)r.push(r[0]);else if("Periodic"===e.Form){o=n,a=i.length-1-o;for(let e=0;e<n;++e)r.push(r[e])}const l=new Fw(n,i,r,o,a).getPoints(12*r.length);return(new Zn).setFromPoints(l)}}class Ww{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(void 0===Uw.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Uw.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){const e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Uw.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Kw),values:t[n].KeyValueFloat.a},r=zw.get(i.id);if(void 0!==r){const t=r.parents[0].ID,n=r.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){const t=Uw.Objects.AnimationLayer,n=new Map;for(const i in t){const t=[],r=zw.get(parseInt(i));if(void 0!==r){r.children.forEach((function(n,i){if(e.has(n.ID)){const r=e.get(n.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===t[i]){const e=zw.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const r=Uw.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:r.attrName?Oh.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Hw.traverse((function(e){e.ID===r.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new Vt),"PreRotation"in r&&(s.preRotation=r.PreRotation.value),"PostRotation"in r&&(s.postRotation=r.PostRotation.value),t[i]=s}}t[i]&&(t[i][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===t[i]){const e=zw.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=zw.get(e).parents[0].ID,s=zw.get(r).parents[0].ID,o=zw.get(s).parents[0].ID,a=Uw.Objects.Model[o],l={modelName:a.attrName?Oh.sanitizeNodeName(a.attrName):"",morphName:Uw.Objects.Deformer[e].attrName};t[i]=l}t[i][r.attr]=r}}})),n.set(parseInt(i),t)}}return n}parseAnimStacks(e){const t=Uw.Objects.AnimationStack,n={};for(const i in t){const r=zw.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new xc(e.name,-1,t)}generateTracks(e){const t=[];let n=new dt,i=new ut,r=new dt;if(e.transform&&e.transform.decompose(n,i,r),n=n.toArray(),i=(new $t).setFromQuaternion(i,e.eulerOrder).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){const r=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(r,t,n);return new yc(e+"."+i,r,s)}generateRotationTrack(e,t,n,i,r,s){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Be.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Be.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Be.degToRad));const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);void 0!==i&&((i=i.map(Be.degToRad)).push(s),i=(new $t).fromArray(i),i=(new ut).setFromEuler(i)),void 0!==r&&((r=r.map(Be.degToRad)).push(s),r=(new $t).fromArray(r),r=(new ut).setFromEuler(r).invert());const l=new ut,c=new $t,h=[];for(let e=0;e<a.length;e+=3)c.set(a[e],a[e+1],a[e+2],s),l.setFromEuler(c),void 0!==i&&l.premultiply(i),void 0!==r&&l.multiply(r),l.toArray(h,e/3*4);return new gc(e+".quaternion",o,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=Hw.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new fc(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){const r=t[i];r!==n&&(t[e]=r,n=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const i=n,r=[];let s=-1,o=-1,a=-1;return e.forEach((function(e){if(t.x&&(s=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==s){const e=t.x.values[s];r.push(e),i[0]=e}else r.push(i[0]);if(-1!==o){const e=t.y.values[o];r.push(e),i[1]=e}else r.push(i[1]);if(-1!==a){const e=t.z.values[a];r.push(e),i[2]=e}else r.push(i[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,r=Math.abs(i);if(r>=180){const s=r/180,o=i/s;let a=n+o;const l=e.times[t-1],c=(e.times[t]-l)/s;let h=l+c;const u=[],d=[];for(;h<e.times[t];)u.push(h),h+=c,d.push(a),a+=o;e.times=ob(e.times,t,u),e.values=ob(e.values,t,d)}}}}class Xw{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new qw,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){const r=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(r||s)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:n},s=this.parseNodeAttr(i),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,r):n in o?("PoseNode"===n?o.PoseNode.push(r):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==s.id&&(o[n][s.id]=r)):"number"==typeof s.id?(o[n]={},o[n][s.id]=r):"Properties70"!==n&&(o[n]="PoseNode"===n?[r]:r),"number"==typeof s.id&&(r.id=s.id),""!==s.name&&(r.attrName=s.name),""!==s.type&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===i){const e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=r.split(",").slice(3);o=o.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],function(e,t){for(let n=0,i=e.length,r=t.length;n<r;n++,i++)e[i]=t[n]}(r,o),void 0===s[i]&&(s[i]=[])}"Node"===i&&(s.id=r),i in s&&Array.isArray(s[i])?s[i].push(r):"a"!==i?s[i]=r:s.a=r,this.setCurrentProp(s,i),"a"===i&&","!==r.slice(-1)&&(s.a=rb(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=rb(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],s=i[1],o=i[2],a=i[3];let l=i[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=rb(l)}this.getPrevNode()[r]={type:s,type2:o,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),r)}}class Yw{parse(e){const t=new Qw(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new qw;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),o=e.getString(s);if(0===i)return null;const a=[];for(let t=0;t<r;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",h=a.length>2?a[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){const i=this.parseNode(e,t);null!==i&&this.parseSubNode(o,n,i)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==h&&(n.attrType=h),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],i=n.propertyList[1];const r=n.propertyList[2],s=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),o="Color"===i||"ColorRGB"===i||"Vector"===i||"Vector3D"===i||0===i.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:i,type2:r,flag:s,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),r=e.getUint32(),s=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}void 0===Bw&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=aw(new Uint8Array(e.getArrayBuffer(s))),a=new Qw(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(i);case"d":return a.getFloat64Array(i);case"f":return a.getFloat32Array(i);case"i":return a.getInt32Array(i);case"l":return a.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Qw{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Kc.decodeText(new Uint8Array(t))}}class qw{add(e,t){this[e]=t}}function Zw(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Kw(e){return e/46186158e3}const Jw=[];function $w(e,t,n,i){let r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);const s=r*i.dataSize,o=s+i.dataSize;return function(e,t,n,i){for(let r=n,s=0;r<i;r++,s++)e[s]=t[r];return e}(Jw,i.buffer,s,o)}const eb=new $t,tb=new dt;function nb(e){const t=new Vt,n=new Vt,i=new Vt,r=new Vt,s=new Vt,o=new Vt,a=new Vt,l=new Vt,c=new Vt,h=new Vt,u=new Vt,d=new Vt,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(tb.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(Be.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(eb.fromArray(t))}if(e.rotation){const t=e.rotation.map(Be.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(eb.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(Be.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(eb.fromArray(t)),r.invert()}e.scale&&s.scale(tb.fromArray(e.scale)),e.scalingOffset&&a.setPosition(tb.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(tb.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(tb.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(tb.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(u.copy(e.parentMatrix),h.copy(e.parentMatrixWorld));const f=n.clone().multiply(i).multiply(r),m=new Vt;m.extractRotation(h);const g=new Vt;g.copyPosition(h);const v=g.clone().invert().multiply(h),y=m.clone().invert().multiply(v),x=s,w=new Vt;if(0===p)w.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)w.copy(m).multiply(y).multiply(f).multiply(x);else{const e=(new Vt).scale((new dt).setFromMatrixScale(u)).clone().invert(),t=y.clone().multiply(e);w.copy(m).multiply(f).multiply(t).multiply(x)}const b=c.clone().invert(),_=o.clone().invert();let A=t.clone().multiply(l).multiply(c).multiply(n).multiply(i).multiply(r).multiply(b).multiply(a).multiply(o).multiply(s).multiply(_);const S=(new Vt).copyPosition(A),M=h.clone().multiply(S);return d.copyPosition(M),A=d.clone().multiply(w),A.premultiply(h.invert()),A}function ib(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function rb(e){return e.split(",").map((function(e){return parseFloat(e)}))}function sb(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),Kc.decodeText(new Uint8Array(e,t,n))}function ob(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class ab extends Ic{constructor(e){super(e)}parse(e){const t=0,n=1,i=2,r=3,s=9,o=10,a=11,l=48,c=4,h=0,u=1,d=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let f=0;const m=new Uint8Array(e),g={id_length:m[f++],colormap_type:m[f++],image_type:m[f++],colormap_index:m[f++]|m[f++]<<8,colormap_length:m[f++]|m[f++]<<8,colormap_size:m[f++],origin:[m[f++]|m[f++]<<8,m[f++]|m[f++]<<8],width:m[f++]|m[f++]<<8,height:m[f++]|m[f++]<<8,pixel_size:m[f++],flags:m[f++]};!function(e){switch(e.image_type){case n:case s:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case r:case o:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+f>e.length&&console.error("THREE.TGALoader: No data."),f+=g.id_length;let v=!1,y=!1,w=!1;switch(g.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case o:v=!0;break;case i:break;case a:v=!0,w=!0;break;case r:w=!0}const b=new Uint8Array(g.width*g.height*4),_=function(e,t,n,i,r){let s,o;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(o=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let o=0;const c=new Uint8Array(a);for(;o<l;)if(e=r[i++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=r[i++];for(n=0;n<t;++n)s.set(c,o+n*a);o+=a*t}else{for(t*=a,n=0;n<t;++n)s[o+n]=r[i++];o+=t}}else s=r.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:s,palettes:o}}(v,y,g,f,m);return function(e,t,n,i,r){let s,o,a,f,m,v;switch((g.flags&l)>>c){default:case d:s=0,a=1,m=t,o=0,f=1,v=n;break;case h:s=0,a=1,m=t,o=n-1,f=-1,v=-1;break;case p:s=t-1,a=-1,m=-1,o=0,f=1,v=n;break;case u:s=t-1,a=-1,m=-1,o=n-1,f=-1,v=-1}if(w)switch(g.pixel_size){case 8:!function(e,t,n,i,r,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==i;h+=n)for(c=r;c!==o;c+=s,u++)l=a[u],e[4*(c+d*h)+0]=l,e[4*(c+d*h)+1]=l,e[4*(c+d*h)+2]=l,e[4*(c+d*h)+3]=255}(e,o,f,v,s,a,m,i);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,h+=2)e[4*(l+u*c)+0]=a[h+0],e[4*(l+u*c)+1]=a[h+0],e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+3]=a[h+1]}(e,o,f,v,s,a,m,i);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,i,r,s,o,a,l){const c=l;let h,u,d,p=0;const f=g.width;for(d=t;d!==i;d+=n)for(u=r;u!==o;u+=s,p++)h=a[p],e[4*(u+f*d)+3]=255,e[4*(u+f*d)+2]=c[3*h+0],e[4*(u+f*d)+1]=c[3*h+1],e[4*(u+f*d)+0]=c[3*h+2]}(e,o,f,v,s,a,m,i,r);break;case 16:!function(e,t,n,i,r,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==i;h+=n)for(c=r;c!==o;c+=s,u+=2)l=a[u+0]+(a[u+1]<<8),e[4*(c+d*h)+0]=(31744&l)>>7,e[4*(c+d*h)+1]=(992&l)>>2,e[4*(c+d*h)+2]=(31&l)<<3,e[4*(c+d*h)+3]=32768&l?0:255}(e,o,f,v,s,a,m,i);break;case 24:!function(e,t,n,i,r,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,h+=3)e[4*(l+u*c)+3]=255,e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2]}(e,o,f,v,s,a,m,i);break;case 32:!function(e,t,n,i,r,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==i;c+=n)for(l=r;l!==o;l+=s,h+=4)e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2],e[4*(l+u*c)+3]=a[h+3]}(e,o,f,v,s,a,m,i);break;default:console.error("THREE.TGALoader: Format not supported.")}}(b,g.width,g.height,_.pixel_data,_.palettes),{data:b,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:x}}}class lb extends Sc{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new pb(e)})),this.register((function(e){return new xb(e)})),this.register((function(e){return new wb(e)})),this.register((function(e){return new fb(e)})),this.register((function(e){return new mb(e)})),this.register((function(e){return new gb(e)})),this.register((function(e){return new vb(e)})),this.register((function(e){return new yb(e)})),this.register((function(e){return new ub(e)})),this.register((function(e){return new bb(e)}))}load(e,t,n,i){const r=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Kc.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},a=new Ec(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{r.parse(n,s,(function(n){t(n),r.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const s={},o={};if("string"==typeof e)r=e;else{if(Kc.decodeText(new Uint8Array(e,0,4))===_b){try{s[hb.KHR_BINARY_GLTF]=new Mb(e)}catch(e){return void(i&&i(e))}r=s[hb.KHR_BINARY_GLTF].content}else r=Kc.decodeText(new Uint8Array(e))}const a=JSON.parse(r);if(void 0===a.asset||a.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new r_(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],n=a.extensionsRequired||[];switch(t){case hb.KHR_MATERIALS_UNLIT:s[t]=new db;break;case hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[t]=new Ib;break;case hb.KHR_DRACO_MESH_COMPRESSION:s[t]=new Eb(a,this.dracoLoader);break;case hb.KHR_TEXTURE_TRANSFORM:s[t]=new Tb;break;case hb.KHR_MESH_QUANTIZATION:s[t]=new Pb;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function cb(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hb={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class ub{constructor(e){this.parser=e,this.name=hb.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const a=new Ke(16777215);void 0!==s.color&&a.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new Wc(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new Vc(a),o.distance=l;break;case"spot":o=new Fc(a),o.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class db{constructor(){this.name=hb.KHR_MATERIALS_UNLIT}getMaterialType(){return In}extendParams(e,t,n){const i=[];e.color=new Ke(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,de))}return Promise.all(i)}}class pb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Oe(e,e)}return Promise.all(r)}}class fb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Ke(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,de)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class mb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new Ke(o[0],o[1],o[2]),Promise.all(r)}}class vb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class yb{constructor(e){this.parser=e,this.name=hb.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Jl:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new Ke(o[0],o[1],o[2]),void 0!==s.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,de)),Promise.all(r)}}class xb{constructor(e){this.parser=e,this.name=hb.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class wb{constructor(e){this.parser=e,this.name=hb.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=i.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class bb{constructor(e){this.name=hb.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,r.ready]).then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(t[0],n,i);return r.decodeGltfBuffer(new Uint8Array(a),s,o,l,e.mode,e.filter),a}))}return null}}const _b="glTF",Ab=1313821514,Sb=5130562;class Mb{constructor(e){this.name=hb.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Kc.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==_b)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(e,12);let r=0;for(;r<n;){const t=i.getUint32(r,!0);r+=4;const n=i.getUint32(r,!0);if(r+=4,n===Ab){const n=new Uint8Array(e,12+r,t);this.content=Kc.decodeText(n)}else if(n===Sb){const n=12+r;this.body=e.slice(n,n+t)}r+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Eb{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hb.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=Wb[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=Wb[t]||t.toLowerCase();if(void 0!==s[t]){const r=n.accessors[e.attributes[t]],s=Hb[r.componentType];l[i]=s,a[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=a[t];void 0!==i&&(n.normalized=i)}t(e)}),o,l)}))}))}}class Tb{constructor(){this.name=hb.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Cb extends Kl{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),i=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),r=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),o={specular:{value:(new Ke).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(const t in o)e.uniforms[t]=o[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",r).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){o.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){o.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Ib{constructor(){this.name=hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return Cb}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new Ke(1,1,1),e.opacity=1;const r=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&r.push(n.assignTexture(e,"map",i.diffuseTexture,de)),e.emissive=new Ke(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Ke(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;r.push(n.assignTexture(e,"glossinessMap",t)),r.push(n.assignTexture(e,"specularMap",t,de))}return Promise.all(r)}createMaterial(e){const t=new Cb(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class Pb{constructor(){this.name=hb.KHR_MESH_QUANTIZATION}}class Db extends ac{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}}Db.prototype.beforeStart_=Db.prototype.copySampleValue_,Db.prototype.afterEnd_=Db.prototype.copySampleValue_,Db.prototype.interpolate_=function(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=i-t,h=(n-t)/c,u=h*h,d=u*h,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let e=0;e!==o;e++){const t=s[f+e+o],n=s[f+e+a]*c,i=s[p+e+o],l=s[p+e]*c;r[e]=v*t+y*n+m*i+g*l}return r};const Rb=new ut;class Lb extends Db{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Rb.fromArray(r).normalize().toArray(r),r}}const Bb=0,Ob=1,Nb=2,kb=3,Fb=4,Ub=5,zb=6,Hb={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Gb={9728:f,9729:v,9984:m,9985:y,9986:g,9987:x},Vb={33071:d,33648:p,10497:u},jb={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wb={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xb={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yb={CUBICSPLINE:void 0,LINEAR:re,STEP:ie},Qb="OPAQUE",qb="MASK",Zb="BLEND";function Kb(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Kl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Jb(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function $b(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function e_(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function t_(e){const t=e.extensions&&e.extensions[hb.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+n_(t.attributes):e.indices+":"+n_(e.attributes)+":"+e.mode,n}function n_(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function i_(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class r_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new cb,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?this.textureLoader=new ih(this.options.manager):this.textureLoader=new Pc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ec(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Jb(r,s,i),$b(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this.loadAnimation(t);break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[hb.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(Kc.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],s=jb[i.type],o=Hb[i.componentType],a=o.BYTES_PER_ELEMENT,l=a*s,c=i.byteOffset||0,h=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,u=!0===i.normalized;let d,p;if(h&&h!==l){const e=Math.floor(c/h),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(d=new o(r,e*h,i.count*h/a),l=new xo(d,h/a),t.cache.add(n,l)),p=new bo(l,s,c%h/a,u)}else d=null===r?new o(i.count*s):new o(r,c,i.count*s),p=new Rn(d,s,u);if(void 0!==i.sparse){const t=jb.SCALAR,n=Hb[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],a,i.sparse.count*t),h=new o(e[2],l,i.sparse.count*s);null!==r&&(p=new Rn(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,h[e*s]),s>=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,s.name&&(t.name=s.name);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=Gb[n.magFilter]||v,t.minFilter=Gb[n.minFilter]||x,t.wrapS=Vb[n.wrapS]||u,t.wrapT=Vb[n.wrapT]||u,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new it(e);t.needsUpdate=!0,n(t)}),t.load(Kc.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===l&&o.revokeObjectURL(a),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),r.extensions[hb.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[hb.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[hb.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.encoding=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ma,Cn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ra,Cn.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Kl}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const o={},a=r.extensions||{},l=[];if(a[hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else if(a[hb.KHR_MATERIALS_UNLIT]){const e=i[hb.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else{const n=r.pbrMetallicRoughness||{};if(o.color=new Ke(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,de)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===r.doubleSided&&(o.side=2);const c=r.alphaMode||Qb;if(c===Zb?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===qb&&(o.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==In&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Oe(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==In&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(o.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==In&&(o.emissive=(new Ke).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==In&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,de)),Promise.all(l).then((function(){let n;return n=s===Cb?i[hb.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new s(o),r.name&&(n.name=r.name),$b(n,r),t.associations.set(n,{materials:e}),r.extensions&&Jb(i,n,r),n}))}createUniqueName(e){const t=Oh.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[hb.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return o_(n,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=t_(o),l=i[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[hb.KHR_DRACO_MESH_COMPRESSION]?r(o):o_(new Zn,o,t),i[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?Kb(this.cache):this.getDependency("material",s[e].material);o.push(t)}return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],h=s[n];let u;const d=o[n];if(h.mode===Fb||h.mode===Ub||h.mode===zb||void 0===h.mode)u=!0===r.isSkinnedMesh?new Xo(c,d):new fi(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===Ub?u.geometry=a_(u.geometry,1):h.mode===zb&&(u.geometry=a_(u.geometry,2));else if(h.mode===Ob)u=new pa(c,d);else if(h.mode===kb)u=new ha(c,d);else if(h.mode===Nb)u=new fa(c,d);else{if(h.mode!==Bb)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new wa(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&e_(u,r),u.name=t.createUniqueName(r.name||"mesh_"+e),$b(u,r),h.extensions&&Jb(i,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new ao;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new _i(Be.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new Xi(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),$b(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],r=[],s=[],o=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,h=void 0!==c.node?c.node:c.id,u=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",h)),i.push(this.getDependency("accessor",u)),r.push(this.getDependency("accessor",d)),s.push(l),o.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(s),Promise.all(o)]).then((function(n){const i=n[0],r=n[1],s=n[2],o=n[3],a=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=r[e],c=s[e],h=o[e],u=a[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,Xb[u.path]){case Xb.weights:d=fc;break;case Xb.rotation:d=gc;break;case Xb.position:case Xb.scale:default:d=yc}const p=t.name?t.name:t.uuid,f=void 0!==h.interpolation?Yb[h.interpolation]:re,m=[];Xb[u.path]===Xb.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(p);let g=c.array;if(c.normalized){const e=i_(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=m.length;e<t;e++){const t=new d(m[e]+"."+Xb[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(t.createInterpolant=function(e){return new(this instanceof gc?Lb:Db)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new xc(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==r.camera&&t.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let o;if(o=!0===r.isBone?new Yo:t.length>1?new ao:1===t.length?t[0]:new mn,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(r.name&&(o.userData.name=r.name,o.name=s),$b(o,r),r.extensions&&Jb(n,o,r),void 0!==r.matrix){const e=new Vt;e.fromArray(r.matrix),o.applyMatrix4(e)}else void 0!==r.translation&&o.position.fromArray(r.translation),void 0!==r.rotation&&o.quaternion.fromArray(r.rotation),void 0!==r.scale&&o.scale.fromArray(r.scale);return i.associations.has(o)||i.associations.set(o,{}),i.associations.get(o).nodes=e,o}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],r=this,s=new ao;i.name&&(s.name=r.createUniqueName(i.name)),$b(s,i),i.extensions&&Jb(n,s,i);const o=i.nodes||[],a=[];for(let e=0,n=o.length;e<n;e++)a.push(s_(o[e],s,t,r));return Promise.all(a).then((function(){return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof Cn||e instanceof it)&&t.set(e,n);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(s),s}))}}function s_(e,t,n,i){const r=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===r.skin)return e;let t;return i.getDependency("skin",r.skin).then((function(e){t=e;const n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(i.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const i=[],r=[];for(let e=0,s=n.length;e<s;e++){const s=n[e];if(s){i.push(s);const n=new Vt;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),r.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new Ko(i,r),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const s=[];if(r.children){const t=r.children;for(let r=0,o=t.length;r<o;r++){const o=t[r];s.push(s_(o,e,n,i))}}return Promise.all(s)}))}function o_(e,t,n){const i=t.attributes,r=[];function s(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=Wb[t]||t.toLowerCase();n in e.attributes||r.push(s(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return $b(e,t),function(e,t,n){const i=t.attributes,r=new mt;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new dt(t[0],t[1],t[2]),new dt(s[0],s[1],s[2])),e.normalized){const t=i_(Hb[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new dt,t=new dt;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,o=i.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),i.normalized){const e=i_(Hb[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const o=new Bt;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,r=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(i){const t=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==h.COLOR_0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],o=t[1],a=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function a_(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(2===t)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(r),s}const l_=new WeakMap;class c_ extends Sc{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const r=new Ec(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(l_.has(e)){const t=l_.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),l_.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Zn;e.index&&t.setIndex(new Rn(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],r=i.name,s=i.array,o=i.itemSize;t.setAttribute(r,new Rn(s,o))}return t}_loadLibrary(e,t){const n=new Ec(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=h_.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function h_(){let e,t;function n(e,t,n,i,r,s){const o=s.num_components(),a=n.num_points()*o,l=a*r.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),h=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,c,l,h);const u=new r(e.HEAPF32.buffer,h,a).slice();return e._free(h),{name:i,array:u,itemSize:o}}onmessage=function(i){const r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=r.buffer,s=r.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,r){const s=r.attributeIDs,o=r.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(i,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[o[i]];let c,u;if(r.useUniqueIDs)u=s[i],c=t.GetAttributeByUniqueId(a,u);else{if(u=t.GetAttributeId(a,e[s[i]]),-1===u)continue;c=t.GetAttribute(a,u)}h.attributes.push(n(e,t,a,i,l,c))}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const i=3*n.num_faces(),r=4*i,s=e._malloc(r);t.GetTrianglesUInt32Array(n,r,s);const o=new Uint32Array(e.HEAPF32.buffer,s,i).slice();return e._free(s),{array:o,itemSize:1}}(e,t,a));return e.destroy(a),h}(t,o,a,s),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}class u_{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const d_=()=>{self.noCompressWorker=function(e,t){const[n]=new Uint32Array(e,t,1);t+=4;const i=new Float32Array(e,t,3*n);t+=3*n*4;const r=new Float32Array(e,t,2*n);t+=2*n*4;const s=new Uint8Array(e,t,4*n);t+=4*n*1;const o=new Int8Array(e,t,3*n);t+=3*n*1;let a=(s.length+o.length)%4;a>0&&(a=4-a,t+=a);const l=new Uint32Array(e,t,1);t+=4;const[c]=l,h=new Uint32Array(e,t,c);t+=4*c;const u=new Uint32Array(e,t,1);t+=4;const[d]=u,p=[];if(d>0)for(let n=0;n<d;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);p.push({start:n,count:i,uuid:a,alphaMode:r})}return{position:i,normal:o,color:s,texcoord:r,indice:h,sub_mesh:p}}},p_=()=>{self.gzipCompressWorker=function(e){const[t]=new Uint32Array(e,0,1),n=new Uint8Array(e,4,e.byteLength-4),i=new pako.Inflate({chunkSize:t});i.push(n,!0);const{result:r}=i;if(r instanceof Uint8Array){const{buffer:e}=r;let t=0;const[n]=new Uint32Array(e,t,1);t+=4;const i=new Float32Array(e,t,3*n);t+=3*n*4;const s=new Float32Array(e,t,2*n);t+=2*n*4;const o=new Uint8Array(e,t,4*n);t+=4*n*1;const a=new Int8Array(e,t,3*n);t+=3*n*1;let l=(o.length+a.length)%4;l>0&&(l=4-l,t+=l);const c=new Uint32Array(e,t,1);t+=4;const[h]=c,u=new Uint32Array(e,t,h);t+=4*h;const d=new Uint32Array(e,t,1);t+=4;const[p]=d,f=[];if(p>0)for(let n=0;n<p;n++){const[n]=new Uint32Array(e,t,1);t+=4;const[i]=new Uint32Array(e,t,1);t+=4;const[r]=new Uint32Array(e,t,1);t+=4;const[s]=new Uint32Array(e,t,1);t+=4;const o=new Uint8Array(e,t,s);t+=s;const a=(new TextDecoder).decode(o);f.push({start:n,count:i,uuid:a,alphaMode:r})}return{position:i,normal:a,color:o,texcoord:s,indice:u,sub_mesh:f}}}},f_=()=>{self.parseChunkWorker=function(e){let t=0;const n=new Int8Array(e,t,128);t+=128,(new TextDecoder).decode(n.slice(0,4));const[i]=n.slice(4,8);if(0===i)return self.noCompressWorker(e,t);if(1===i){const t=e.slice(128);return self.gzipCompressWorker(t)}throw new Error("unknown compress mode [ .sbmx model ]")}},m_="\n onmessage = function ( e ) {\n \n const message = e.data\n\n switch ( message.type ) {\n\n case 'decode': {\n\n const chunkInfo = self.parseChunkWorker( message.data )\n\n self.postMessage( { type: 'decode', data: chunkInfo, } )\n\n break\n \n }\n \n }\n\n }\n\n";class g_ extends Sc{constructor(){super(),this.loadedTextures=new Set,this.loadedMaterialsMap=new Map,this.loadedMaterials=new Array,this.dracoDecoderPath=null,this.workerPool=new u_(navigator.hardwareConcurrency),this.workerSourceURL="";const e=this._initWorkerCreator();this.workerPool.setWorkerCreator(e)}async parseAsync(e,t){const[{data:n}]=await Promise.all([this.workerPool.postMessage({type:"decode",data:e},[e]),this._createMaterial(t)]);if(n){const{type:e,data:i}=n;if("decode"===e){return this._createMeshByStream(i,t)}}}_initWorkerCreator(){if(!this.workerSourceURL){const e=d_.toString(),t=p_.toString(),n=f_.toString(),i=["/* dat decoder */",["/* pako */","\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {}));\n}(this, (function (exports) { 'use strict';\n\n // Note: adler32 takes 12% for level 0 and 2% for level 6.\n // It isn't worth it to make additional optimizations as in original.\n // Small size is preferable.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express ofr implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const adler32 = (adler, buf, len, pos) => {\n let s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n };\n\n\n var adler32_1 = adler32;\n\n // Note: we can't get significant speed boost here.\n // So write code to minimize size - no pregenerated tables\n // and array tools dependencies.\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // Use ordinary array, since untyped makes no boost here\n const makeTable = () => {\n let c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n };\n\n // Create table on load. Just 255 signed longs. Not a problem.\n const crcTable = new Uint32Array(makeTable());\n\n\n const crc32 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n\n crc ^= -1;\n\n for (let i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n };\n\n\n var crc32_1 = crc32;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n // See state defs from inflate.js\n const BAD$1 = 30; /* got a data error -- remain here until reset */\n const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n /*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n var inffast = function inflate_fast(strm, start) {\n let _in; /* local strm.input */\n let last; /* have enough input while in < last */\n let _out; /* local strm.output */\n let beg; /* inflate()'s initial strm.output */\n let end; /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n let dmax; /* maximum distance from zlib header */\n //#endif\n let wsize; /* window size or zero if not using window */\n let whave; /* valid bytes in the window */\n let wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n let s_window; /* allocated sliding window, if wsize != 0 */\n let hold; /* local strm.hold */\n let bits; /* local strm.bits */\n let lcode; /* local strm.lencode */\n let dcode; /* local strm.distcode */\n let lmask; /* mask for first level of length codes */\n let dmask; /* mask for first level of distance codes */\n let here; /* retrieved table entry */\n let op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n let len; /* match length, unused bytes */\n let dist; /* match distance */\n let from; /* where to copy match from */\n let from_source;\n\n\n let input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n const state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n //#ifdef INFLATE_STRICT\n dmax = state.dmax;\n //#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n //#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n const MAXBITS = 15;\n const ENOUGH_LENS$1 = 852;\n const ENOUGH_DISTS$1 = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const CODES$1 = 0;\n const LENS$1 = 1;\n const DISTS$1 = 2;\n\n const lbase = new Uint16Array([ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n ]);\n\n const lext = new Uint8Array([ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n ]);\n\n const dbase = new Uint16Array([ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n ]);\n\n const dext = new Uint8Array([ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n ]);\n\n const inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n {\n const bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n let len = 0; /* a code's length in bits */\n let sym = 0; /* index of code symbols */\n let min = 0, max = 0; /* minimum and maximum code lengths */\n let root = 0; /* number of index bits for root table */\n let curr = 0; /* number of index bits for current table */\n let drop = 0; /* code bits to drop for sub-table */\n let left = 0; /* number of prefix codes available */\n let used = 0; /* code entries in table used */\n let huff = 0; /* Huffman code */\n let incr; /* for incrementing code, index */\n let fill; /* index for replicating entries */\n let low; /* low bits for current root entry */\n let mask; /* mask for low root bits */\n let next; /* next available space in table */\n let base = null; /* base value table to use */\n let base_index = 0;\n // let shoextra; /* extra bits table to use */\n let end; /* use base and extra for symbol > end */\n const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n let extra = null;\n let extra_index = 0;\n\n let here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n };\n\n\n var inftrees = inflate_table;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var constants$1 = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\n const CODES = 0;\n const LENS = 1;\n const DISTS = 2;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n Z_DEFLATED\n } = constants$1;\n\n\n /* STATES ====================================================================*/\n /* ===========================================================================*/\n\n\n const HEAD = 1; /* i: waiting for magic header */\n const FLAGS = 2; /* i: waiting for method and flags (gzip) */\n const TIME = 3; /* i: waiting for modification time (gzip) */\n const OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n const EXLEN = 5; /* i: waiting for extra length (gzip) */\n const EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n const NAME = 7; /* i: waiting for end of file name (gzip) */\n const COMMENT = 8; /* i: waiting for end of comment (gzip) */\n const HCRC = 9; /* i: waiting for header crc (gzip) */\n const DICTID = 10; /* i: waiting for dictionary check value */\n const DICT = 11; /* waiting for inflateSetDictionary() call */\n const TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n const STORED = 14; /* i: waiting for stored size (length and complement) */\n const COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n const COPY = 16; /* i/o: waiting for input or output to copy stored block */\n const TABLE = 17; /* i: waiting for dynamic block table lengths */\n const LENLENS = 18; /* i: waiting for code length code lengths */\n const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n const LEN_ = 20; /* i: same as LEN below, but only first time in */\n const LEN = 21; /* i: waiting for length/lit/eob code */\n const LENEXT = 22; /* i: waiting for length extra bits */\n const DIST = 23; /* i: waiting for distance code */\n const DISTEXT = 24; /* i: waiting for distance extra bits */\n const MATCH = 25; /* o: waiting for output space to copy string */\n const LIT = 26; /* o: waiting for output space to write literal */\n const CHECK = 27; /* i: waiting for 32-bit check value */\n const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n const DONE = 29; /* finished check, done -- remain here until reset */\n const BAD = 30; /* got a data error -- remain here until reset */\n const MEM = 31; /* got an inflate() memory error -- remain here until reset */\n const SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n /* ===========================================================================*/\n\n\n\n const ENOUGH_LENS = 852;\n const ENOUGH_DISTS = 592;\n //const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\n const MAX_WBITS = 15;\n /* 32K LZ77 window */\n const DEF_WBITS = MAX_WBITS;\n\n\n const zswap32 = (q) => {\n\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n };\n\n\n function InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Int32Array(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n }\n\n\n const inflateResetKeep = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\"));\n return Z_OK$1;\n };\n\n\n const inflateReset = (strm) => {\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n };\n\n\n const inflateReset2 = (strm, windowBits) => {\n let wrap;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n };\n\n\n const inflateInit2 = (strm, windowBits) => {\n\n if (!strm) { return Z_STREAM_ERROR$1; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n const state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n };\n\n\n const inflateInit = (strm) => {\n\n return inflateInit2(strm, DEF_WBITS);\n };\n\n\n /*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\n let virgin = true;\n\n let lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\n const fixedtables = (state) => {\n\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n let sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inftrees(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inftrees(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n };\n\n\n /*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\n const updatewindow = (strm, src, end, copy) => {\n\n let dist;\n const state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n };\n\n\n const inflate$1 = (strm, flush) => {\n\n let state;\n let input, output; // input/output buffers\n let next; /* next input INDEX */\n let put; /* next output INDEX */\n let have, left; /* available input and output */\n let hold; /* bit buffer */\n let bits; /* bits in bit buffer */\n let _in, _out; /* save starting available input and output */\n let copy; /* number of stored or match bytes to copy */\n let from; /* where to copy match bytes from */\n let from_source;\n let here = 0; /* current decoding table entry */\n let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //let last; /* parent table entry */\n let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n let len; /* length to copy for repeats, bits to drop */\n let ret; /* return code */\n const hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n let opts;\n\n let n; // temporary variable for NEED_BITS\n\n const order = /* permutation of code lengths */\n new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR$1;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK$1;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n\n // !!! pako patch. Force use `options.windowBits` if passed.\n // Required to always use max window size by default.\n state.dmax = 1 << state.wbits;\n //state.dmax = 1 << len;\n\n //Tracev((stderr, \"inflate: zlib header ok\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32_1(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32_1(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32_1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n output.set(input.subarray(next, next + copy), put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inffast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\" :\n // \"inflate: literal 0x%02x\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH$1))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n };\n\n\n const inflateEnd = (strm) => {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR$1;\n }\n\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n };\n\n\n const inflateGetHeader = (strm, head) => {\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n const state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK$1;\n };\n\n\n const inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n\n let state;\n let dictid;\n let ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32_1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\"));\n return Z_OK$1;\n };\n\n\n var inflateReset_1 = inflateReset;\n var inflateReset2_1 = inflateReset2;\n var inflateResetKeep_1 = inflateResetKeep;\n var inflateInit_1 = inflateInit;\n var inflateInit2_1 = inflateInit2;\n var inflate_2$1 = inflate$1;\n var inflateEnd_1 = inflateEnd;\n var inflateGetHeader_1 = inflateGetHeader;\n var inflateSetDictionary_1 = inflateSetDictionary;\n var inflateInfo = 'pako inflate (from Nodeca project)';\n\n /* Not implemented\n module.exports.inflateCopy = inflateCopy;\n module.exports.inflateGetDictionary = inflateGetDictionary;\n module.exports.inflateMark = inflateMark;\n module.exports.inflatePrime = inflatePrime;\n module.exports.inflateSync = inflateSync;\n module.exports.inflateSyncPoint = inflateSyncPoint;\n module.exports.inflateUndermine = inflateUndermine;\n */\n\n var inflate_1$1 = {\n \tinflateReset: inflateReset_1,\n \tinflateReset2: inflateReset2_1,\n \tinflateResetKeep: inflateResetKeep_1,\n \tinflateInit: inflateInit_1,\n \tinflateInit2: inflateInit2_1,\n \tinflate: inflate_2$1,\n \tinflateEnd: inflateEnd_1,\n \tinflateGetHeader: inflateGetHeader_1,\n \tinflateSetDictionary: inflateSetDictionary_1,\n \tinflateInfo: inflateInfo\n };\n\n const _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n\n var assign = function (obj /*from1, from2, from3, ...*/) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n };\n\n\n // Join array of chunks to single array.\n var flattenChunks = (chunks) => {\n // calculate data length\n let len = 0;\n\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n const result = new Uint8Array(len);\n\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n };\n\n var common = {\n \tassign: assign,\n \tflattenChunks: flattenChunks\n };\n\n // String encode/decode helpers\n\n\n // Quick check if we can use fast array to bin string conversion\n //\n // - apply(Array) can fail on Android 2.2\n // - apply(Uint8Array) can fail on iOS 5.1 Safari\n //\n let STR_APPLY_UIA_OK = true;\n\n try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n const _utf8len = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n }\n _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n // convert string to array (typed, when possible)\n var string2buf = (str) => {\n if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n };\n\n // Helper\n const buf2binstring = (buf, len) => {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n\n let result = '';\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n\n\n // convert array to string\n var buf2string = (buf, max) => {\n const len = max || buf.length;\n\n if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n\n let i, out;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n const utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n let c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n let c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n };\n\n\n // Calculate max possible position in utf8 buffer,\n // that will not break sequence. If that's not possible\n // - (very small limits) return max size as is.\n //\n // buf[] - utf8 bytes array\n // max - length limit (mandatory);\n var utf8border = (buf, max) => {\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n };\n\n var strings = {\n \tstring2buf: string2buf,\n \tbuf2string: buf2string,\n \tutf8border: utf8border\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n var messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n };\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n }\n\n var zstream = ZStream;\n\n // (C) 1995-2013 Jean-loup Gailly and Mark Adler\n // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n //\n // This software is provided 'as-is', without any express or implied\n // warranty. In no event will the authors be held liable for any damages\n // arising from the use of this software.\n //\n // Permission is granted to anyone to use this software for any purpose,\n // including commercial applications, and to alter it and redistribute it\n // freely, subject to the following restrictions:\n //\n // 1. The origin of this software must not be misrepresented; you must not\n // claim that you wrote the original software. If you use this software\n // in a product, an acknowledgment in the product documentation would be\n // appreciated but is not required.\n // 2. Altered source versions must be plainly marked as such, and must not be\n // misrepresented as being the original software.\n // 3. This notice may not be removed or altered from any source distribution.\n\n function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n }\n\n var gzheader = GZheader;\n\n const toString = Object.prototype.toString;\n\n /* Public constants ==========================================================*/\n /* ===========================================================================*/\n\n const {\n Z_NO_FLUSH, Z_FINISH,\n Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR\n } = constants$1;\n\n /* ===========================================================================*/\n\n\n /**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n /* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n /**\n * Inflate.result -> Uint8Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n /**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n /**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n /**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n * const chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\n function Inflate(options) {\n this.options = common.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ''\n }, options || {});\n\n const opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new zstream();\n this.strm.avail_out = 0;\n\n let status = inflate_1$1.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n\n this.header = new gzheader();\n\n inflate_1$1.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = inflate_1$1.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages[status]);\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer): input data\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE\n * flush modes. See constants. Skipped or `false` means Z_NO_FLUSH,\n * `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. If end of stream detected,\n * [[Inflate#onEnd]] will be called.\n *\n * `flush_mode` is not needed for normal operation, because end of stream\n * detected automatically. You may try to use it for advanced things, but\n * this functionality was not tested.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n Inflate.prototype.push = function (data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n\n if (this.ended) return false;\n\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n\n // Convert data if needed\n if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n for (;;) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate_1$1.inflate(strm, _flush_mode);\n\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$1.inflateSetDictionary(strm, dictionary);\n\n if (status === Z_OK) {\n status = inflate_1$1.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n // Replace code with more verbose\n status = Z_NEED_DICT;\n }\n }\n\n // Skip snyc markers if more data follows and not raw mode\n while (strm.avail_in > 0 &&\n status === Z_STREAM_END &&\n strm.state.wrap > 0 &&\n data[strm.next_in] !== 0)\n {\n inflate_1$1.inflateReset(strm);\n status = inflate_1$1.inflate(strm, _flush_mode);\n }\n\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n // Remember real `avail_out` value, because we may patch out buffer content\n // to align utf8 strings boundaries.\n last_avail_out = strm.avail_out;\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n\n if (this.options.to === 'string') {\n\n let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail & realign counters\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n\n this.onData(utf8str);\n\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n\n // Must repeat iteration if out buffer is full\n if (status === Z_OK && last_avail_out === 0) continue;\n\n // Finalize if end of stream reached.\n if (status === Z_STREAM_END) {\n status = inflate_1$1.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n\n if (strm.avail_in === 0) break;\n }\n\n return true;\n };\n\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|String): output data. When string output requested,\n * each chunk will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n Inflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n };\n\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n Inflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = common.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n\n\n /**\n * inflate(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako');\n * const input = pako.deflate(new Uint8Array([1,2,3,4,5,6,7,8,9]));\n * let output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err) {\n * console.log(err);\n * }\n * ```\n **/\n function inflate(input, options) {\n const inflator = new Inflate(options);\n\n inflator.push(input);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) throw inflator.msg || messages[inflator.err];\n\n return inflator.result;\n }\n\n\n /**\n * inflateRaw(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n }\n\n\n /**\n * ungzip(data[, options]) -> Uint8Array|String\n * - data (Uint8Array): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\n var Inflate_1 = Inflate;\n var inflate_2 = inflate;\n var inflateRaw_1 = inflateRaw;\n var ungzip = inflate;\n var constants = constants$1;\n\n var inflate_1 = {\n \tInflate: Inflate_1,\n \tinflate: inflate_2,\n \tinflateRaw: inflateRaw_1,\n \tungzip: ungzip,\n \tconstants: constants\n };\n\n exports.Inflate = Inflate_1;\n exports.constants = constants;\n exports['default'] = inflate_1;\n exports.inflate = inflate_2;\n exports.inflateRaw = inflateRaw_1;\n exports.ungzip = ungzip;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n","/* noCompress */",e.substring(e.indexOf("{")+1,e.lastIndexOf("}")),"/* gzipCompress */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}")),"/* parseChunk */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n"),"","/* worker */",m_].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}return()=>new Worker(this.workerSourceURL)}_createMeshByStream(e,t){const n=new Zn;n.setIndex(new Rn(e.indice,1)),n.setAttribute("position",new Rn(e.position,3)),n.setAttribute("normal",new Rn(e.normal,3,!0)),n.setAttribute("uv",new Rn(e.texcoord,2));for(let i=0;i<e.sub_mesh.length;i++){const r=e.sub_mesh[i],{uuid:s,start:o,count:a}=r,l=this.loadedMaterialsMap.get(s);if(l){const{materialIndex:e}=l;n.addGroup(o,a,e)}else console.warn("no material",s,t)}n.computeBoundingBox(),n.computeBoundsTree();const i=new fi(n,this.loadedMaterials);return i.castShadow=!0,i.receiveShadow=!0,i}async _createMaterial(e){const t=e+"textureIndex.json";if(this.loadedTextures.has(t))return;const n=await Pd(t).then((e=>e.json()));this.loadedTextures.add(t),Object.entries(n).forEach((([t,n])=>{if(this.loadedMaterialsMap.has(t))return;const{name:i,base_map:r,nor_map:s,alphamode:o,color:a={r:1,g:1,b:1,a:1},metallic:l=.5,roughness:c=.5}=n;let h=null,d=null;if(r){const t=e+r;h=(new Pc).load(t,(e=>{e.needsUpdate=!0,Lv.needsUpdate=!0})),h.encoding=de,h.wrapS=u,h.wrapT=u,h.minFilter=1008,h.magFilter=v,h.flipY=!0}if(s){const t=e+s;d=(new Pc).load(t,(e=>{e.needsUpdate=!0,Lv.needsUpdate=!0})),d.encoding=de,d.wrapS=u,d.wrapT=u,d.flipY=!0}const{r:p,g:f,b:m,a:g}=a,y=0!==o,x=new Kl({name:i,color:new Ke(p,f,m),side:2,map:h,normalMap:d,metalness:l,roughness:c,opacity:g,transparent:y,depthWrite:!y}),w=this.loadedMaterials.push(x)-1;this.loadedMaterialsMap.set(t,{material:x,materialIndex:w})}))}}class v_ extends ly{constructor(e,t){super("Model",e,t),this.viewport=e,this.modelMaps=new Map,this.loadingManager=new _c,this.datLoader=new g_,this.gltfLoader=new lb(this.loadingManager),this.fbxLoader=new Gw(this.loadingManager),this.dracoDecoderPath=null,this.store=hy.createInstance({name:"soonspace",storeName:"modelData"}),this._initLoadingManager(this.loadingManager)}_initLoadingManager(e){e.addHandler(/\.tga$/i,new ab)}_setModelMpas(e,t){if(!this.modelMaps.has(e)){const n=t.sClone();this.modelMaps.set(e,n)}}async _parseSbmx(e,t,n){const i=Fd(e,0,8),r=new DataView(e.slice(8));if("SBMG----"===i){for(let e=0;e<r.byteLength;e++){const t=r.getUint8(e),n=(t>>4&15)+(t<<4&240);r.setUint8(e,n)}await this._parseGltf(r.buffer,t,n)}else"SBMD----"===i?await this._parseDat(r.buffer,t,n):await this._parseGltf(e,t,n)}async _parseDat(e,t,n){const i=await this.datLoader.parseAsync(e,t);i&&n.add(i)}_parseGltf(e,t,n){return new Promise(((i,r)=>{this.gltfLoader.parse(e,t,(e=>{const{animations:t}=e;t&&t.length>0&&(n.animations=t),e.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof fi&&e.geometry.computeBoundsTree()})),n.add(e.scene),i(n)}),(e=>{r(e)}))}))}_parseFbx(e,t,n){const i=this.fbxLoader.parse(e,t),{animations:r}=i;r&&r.length>0&&(n.animations=r),i.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0,e instanceof fi&&e.geometry.computeBoundsTree()})),n.add(i)}setDracoDecoderPath(e){this.dracoDecoderPath=e;const t=new c_;t.setDecoderPath(e),this.gltfLoader.setDRACOLoader(t),this.datLoader.dracoDecoderPath=e}load(e){return this._loadItem(e)}async _loadItem(e,t=this.scene){var n;const{url:i}=e,{useIndexedDB:r}=this.viewport.options,s=i.slice(i.lastIndexOf(".")+1),o=this.modelMaps.get(i);let a=null;if(o)return this.clone(o,e,t);r&&(a=await this.store.getItem(i)),a||(a=await this._fetchBuffer(e));const l=await this.parse(s,a,e);return null===(n=l.onLoad)||void 0===n||n.call(l,l),this.setObjectsCache(l),null!==t&&this.viewport.scener.addObject(l,t),l}async parse(e,t,n){const i=new Xv({format:e,...n}),{url:r}=n,s=Td(r),o=e.toLocaleUpperCase();if("SBMX"===o)await this._parseSbmx(t,s,i);else if("DAT"===o)await this._parseDat(t,s,i);else if("GLTF"===o||"GLB"===o)await this._parseGltf(t,s,i);else{if("FBX"!==o)throw new TypeError(`In soonspacejs: 加载通用模型资源(id:${n.id}, url:${r})格式错误,当前支持 fbx、gltf、glb !`);this._parseFbx(t,s,i)}return this._setModelMpas(r,i),i}clone(e,t,n){return new Promise(((i,r)=>{"Model"!==e.stype&&r("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:s,name:o,level:a,visible:l,position:c,rotation:h,scale:u,onClick:d,onDblClick:p,onRightClick:f,onLoad:m,userData:g}=t;function v(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)v(e.children[i],t.children[i],n)}const y=function(e){const t=new Map,n=new Map,i=e.sClone();return v(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(e instanceof Xo){const i=e,r=t.get(e),s=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=s.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)}})),i}(e);y.animations=y.animations.map((e=>e.clone())),s&&(y.sid=s),o&&(y.name=o),a&&(y.level=a),!1===l&&y.hide(),c&&y.position.set(c.x,c.y,c.z),h&&y.rotation.set(h.x,h.y,h.z),u&&y.scale.set(u.x,u.y,u.z),y.onClick=d?d.bind(y):null,y.onDblClick=p?p.bind(y):null,y.onRightClick=f?f.bind(y):null,y.onLoad=m?m.bind(y):null,y.onLoad&&y.onLoad(y),g&&(y.userData=g),this.setObjectsCache(y),null!==n&&this.viewport.scener.addObject(y,n||e.parent||this.scene),i(y)}))}async loadToGroup(e,t){const n=this.createGroup(e,null);for(let e=0;e<t.length;e++)try{const i=await this._loadItem(t[e],null);n.add(i)}catch(e){console.error(e)}return this.viewport.scener.addObject(n,this.scene),n}async addForGroup(e,t){const n=this.getById(e,"Group");if(n)for(let e=0;e<t.length;e++)try{const i=await this._loadItem(t[e],null);this.viewport.scener.addObject(i,n)}catch(e){console.error(e)}return n}clearIdb(){return this.store.clear()}dispose(){var e;null===(e=this.gltfLoader.dracoLoader)||void 0===e||e.dispose(),this.datLoader.workerPool.dispose()}async _fetchBuffer(e){const{url:t}=e,{useIndexedDB:n}=this.viewport.options;return Pd(t).then((e=>e.arrayBuffer())).then((e=>(n&&this.store.setItem(t,e),e)))}}class y_ extends ly{constructor(e,t){super("Poi",e,t),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new qv(t,e);return this.setObjectsCache(n),this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:i,name:r,level:s,visible:o,position:a,rotation:l,scale:c,onClick:h,onDblClick:u,onRightClick:d,userData:p}=t,f=e.sClone(!1);return this._copyMaterial(f),i&&(f.sid=i),r&&(f.name=r),s&&(f.level=s),Ld(o)&&(f.visible=o),a&&f.position.set(a.x,a.y,a.z),l&&f.rotation.set(l.x,l.y,l.z),c&&f.scale.set(c.x,c.y,c.z),f.onClick=h?h.bind(f):null,f.onDblClick=u?u.bind(f):null,f.onRightClick=d?d.bind(f):null,p&&(f.userData=p),this.setObjectsCache(f),null!==n&&this.viewport.scener.addObject(f,n||this.scene||e.parent),f}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this._createMaterial(e.url),i=new qv(t,e);this.setObjectsCache(i),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&(t.forEach((e=>{const t=this._createMaterial(e.url),i=new qv(t,e);this.setObjectsCache(i),n.add(i)})),this.viewport.scener.addObject(n,this.scene)),n}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new Pc).load(e);t.flipY=!0;const n=new _o({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof fi||e instanceof No)&&(Od(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof Cn&&(e.material=e.material.clone()))}))}}class x_ extends ly{constructor(e,t){super("PoiNode",e,t)}create(e){this._openEnableRenderCss(e);const t=new Gv(e);return this.setObjectsCache(t),this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new Gv(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&(t.forEach((e=>{this._openEnableRenderCss(e);const t=new Gv(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class w_ extends ly{constructor(e,t){super("Canvas3D",e,t)}create(e){const t=new sy(e);return this.setObjectsCache(t),this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=new sy(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&(t.forEach((e=>{const t=new sy(e);this.setObjectsCache(t),n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}}class b_{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(e){if(!Od(e))return console.error("In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph isn't an array )");if(!(e.length<1))for(let t=0;t<e.length;t++){const n=e[t];if(2!==n.length)return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph item must be an array and contain 2 values [name, vertices], Failed at index: ${t} )`);const i=n[0],r=n[1];this.graph[i]=[];for(let e=0;e<r.length;e++){const t=r[e],n=t[0],s=t[1];this.graph[i][n]=s}}}getPath(e,t){if(void 0===this.graph[e])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method source ${e} doesn't exist )`),[];if(void 0===this.graph[t])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method target ${t} doesn't exist )`),[];if(e===t)return[];let n;for(this.queue=new Sd,this.queue.add(e,0),this.previous[e]=null;n=this.queue.shift();){if(n===t){const e=[];for(;Bd(n)&&null!==this.previous[n];)e.unshift(n),n=this.previous[n];return e}const e=this.queue.getDistance(n);if(e===1/0)return[];for(const t in this.graph[n]){const i=this.queue.getDistance(Number(t)),r=e+this.graph[n][t];r<i&&(this.queue.update(Number(t),r),this.previous[t]=n)}}return[]}}class __ extends ly{constructor(e,t){super("Topology",e,t),this.dijkstra=new b_}createFromGml(e){const{url:t,linkWidth:n=20,linkColor:i=65280,renderNode:r=!0,nodeColor:s=255}=e;return vy(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const o=[],a=new Map;let l=[],c=[];const h=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;Od(h)?h.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...h.state],c=[...c,...h.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],i=e.State.topoNode["gml:Node"].node_name;o.push({id:Rd(n)?n:"",name:Rd(i)?i:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),a.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],i=e.Transition.topoEdge["gml:Edge"].length["#text"],r=e.Transition.topoEdge["gml:Edge"].restrict["#text"],s=e.Transition.topoEdge["gml:Edge"].passable["#text"],l=a.get(t),c=a.get(n),h=e.Transition._attributes["gml:id"],u=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==l&&void 0!==c&&("2"!==s&&"3"!==s&&o[l].graphs.push({targetNodeId:n,linkInfo:{id:h,name:u},enable:!0,length:parseInt(i),restrict:parseInt(r),passable:parseInt(s)}),"1"!==s&&"3"!==s&&o[c].graphs.push({targetNodeId:t,linkInfo:{id:h,name:u},enable:!0,length:parseInt(i),restrict:parseInt(r),passable:parseInt(s)}))})),this.setDijkstraGraph(o);const u=new ey({...e,type:"network",nodes:o,linkWidth:n,renderLink:!0,linkColor:i,renderNode:r,nodeColor:s});return this.setObjectsCache(u),this.viewport.scener.addObject(u,this.scene),Promise.resolve(u)}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const n=new ey(t);return this.setObjectsCache(n),this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs({...e.info,nodes:t});return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=this.createGroup(e,null);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const i=new ey(t);this.setObjectsCache(i),n.add(i)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getById(e,"Group");return n&&t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const i=new ey(t);this.setObjectsCache(i),n.add(i)})),n}getShortestPath(e,t){const n=Cd(e.info.nodes),i=gd(t.start),r=gd(t.end);let s=null,o=1/0,a=null,l=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const n=e.nodes.find((e=>e.sid===t.id));if(n){const e=_d(n).position,c=e.distanceTo(i),h=e.distanceTo(r);c<o&&(o=c,s=t),h<l&&(l=h,a=t)}}})),null!==s&&null!==a){const i=+s.id,r=+a.id,o=this.dijkstra.getPath(i,r);if(o.length>0){const i=[s];o.forEach((e=>{const t=n.find((t=>t.id==e));t&&i.push(t)}));for(let e=0;e<i.length;e++)i[e].position.y+=1;const r={...t,type:"line",nodes:i,...e.getSpaceAttribute(!0)};this.generateLineTopologyInfoNodeGraphs(r);const a=new ey(r);return this.setObjectsCache(a),this.viewport.scener.addObject(a,this.scene),a}}return null}getShortestPathByMultipleStartPoints(e,t){const{nodes:n}=e.info,i=[];t.start.forEach((e=>{const r=gd(e),s=gd(t.end);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=gd(e.position),n=t.distanceTo(r),i=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),i<c&&(c=i,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:r,graphs:[]}];t.forEach(((t,i)=>{const s=n.find((e=>e.id==t));s&&(e+=0===i?gd(s.position).distanceTo(r):gd(s.position).distanceTo(gd(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(gd(o[o.length-1].position)),i.push({nodeInfo:o,pathLength:e})}}}));let r=[],s=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,r=e)})),r.length){for(let e=0;e<r.length;e++)r[e].position.y+=1;const n={...t,type:"line",nodes:r,position:e.getWorldPosition(new dt),rotation:(new $t).setFromQuaternion(e.getWorldQuaternion(new ut)),scale:e.getWorldScale(new dt)};this.generateLineTopologyInfoNodeGraphs(n);const i=new ey(n);return this.setObjectsCache(i),this.viewport.scener.addObject(i,this.scene),i}return null}getShortestPathByMultipleEndPoints(e,t){const{nodes:n}=e.info,i=[];t.end.forEach((e=>{const r=gd(t.start),s=gd(e);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=gd(e.position),n=t.distanceTo(r),i=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),i<c&&(c=i,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:r,graphs:[]}];t.forEach(((t,i)=>{const s=n.find((e=>e.id==t));s&&(e+=0===i?gd(s.position).distanceTo(r):gd(s.position).distanceTo(gd(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(gd(o[o.length-1].position)),i.push({nodeInfo:o,pathLength:e})}}}));let r=[],s=1/0;if(i.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,r=e)})),r.length){for(let e=0;e<r.length;e++)r[e].position.y+=1;const n={...t,type:"line",nodes:r,position:e.getWorldPosition(new dt),rotation:(new $t).setFromQuaternion(e.getWorldQuaternion(new ut)),scale:e.getWorldScale(new dt)};this.generateLineTopologyInfoNodeGraphs(n);const i=new ey(n);return this.setObjectsCache(i),this.viewport.scener.addObject(i,this.scene),i}return null}setDijkstraGraph(e){const t=[];e.forEach((n=>{if(n.graphs&&n.graphs.length>0){const i=[];n.graphs.forEach((t=>{const r=e.find((e=>e.id===t.targetNodeId));r&&i.push([Number(t.targetNodeId),t.length||gd(n.position).distanceTo(gd(r.position))])})),t.push([Number(n.id),i])}})),t.length>0&&this.dijkstra.setGraph(t)}generateLineTopologyInfoNodeGraphs(e){if("line"===e.type)for(let t=0;t<e.nodes.length;t++)if(t===e.nodes.length-1)e.nodes[t].graphs=[];else{const n=e.nodes[t],i=e.nodes[t+1];e.nodes[t].graphs=[{targetNodeId:i.id,linkInfo:{id:`${n.id}_to_${i.id}`,name:`${n.name||n.id}_to_${i.name||i.id}`},enable:!0,length:gd(e.nodes[t].position).distanceTo(gd(i.position)),restrict:0,passable:0}]}return e}}class A_ extends ha{constructor(e,t){const n=new Zn;n.setAttribute("position",new Hn([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new ra({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Zn;i.setAttribute("position",new Hn([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new fi(i,new In({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class S_ extends ly{constructor(e,t){super("Helper",e,t)}addGridHelper(e){const{id:t,size:n=1e3,divisions:i=20,color:r="#fff",position:s={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:a={x:1,y:1,z:1}}=e,l=new lu(n,i,r,r);return l.position.set(s.x,s.y,s.z),l.rotation.set(o.x,o.y,o.z),l.scale.set(a.x,a.y,a.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,i=new _u(n);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addBoxHelper(e){const{id:t,box:n,color:i="#00ff00"}=e,r=new yu(n,new Ke(i));return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPlaneHelper(e){const{id:t,width:n=500,height:i=500,color:r="#00ff00",opacity:s=.2,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new kv(new Ni(n,i),new In({color:r,opacity:s,transparent:s<1,side:2}),{id:t,position:o,rotation:a,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:i=500,height:r=500,opacity:s=1,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,h=(new Pc).load(t),d=new Ni(i,r);d.computeBoundingBox();const p=new Kl({side:2,map:h,transparent:s<1,opacity:s,roughness:.8});p.map&&(p.map.repeat.set(c.x,c.x),p.map.wrapS=u,p.map.wrapT=u,p.map.version++),a.x-=Math.PI/2,p.version++;const f=new oy(d,p,{id:n,position:o,rotation:a,scale:l});return f.userData.sid=n,f.userData.stype="Helper",this.viewport.scener.addObject(f,this.scene),f}addDirectionalLightHelper(e){const{id:t,light:n,color:i,size:r=50}=e,s=new du(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new au(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(e){const{id:t,light:n,color:i}=e,r=new Kh(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addPointLightHelper(e){const{id:t,light:n,color:i,size:r=20}=e,s=new iu(n,r,i);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addRectAreaLightHelper(e){const{id:t,light:n,color:i}=e,r=new A_(n,i);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}}class M_ extends ly{constructor(e,t){super("PluginObject",e,t)}createObject(e,t){const n=new Hv(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){const n=this.getById(e);return n?(this.viewport.scener.addObject(t,n),n):null}}class E_ extends ly{constructor(e,t){super("Group",e,t)}}class T_{constructor(e){this.viewport=e,this.scene=new Uv({id:"sceneManage"}),this.store={groupManager:new E_(e,this.scene),lightManager:new cy(e,this.scene),sbmManager:new xy(e,this.scene),modelManager:new v_(e,this.scene),poiManager:new y_(e,this.scene),poiNodeManager:new x_(e,this.scene),canvas3DManager:new w_(e,this.scene),topologyManager:new __(e,this.scene),helperManager:new S_(e,this.scene),pluginObjectManager:new M_(e,this.scene)},e.postUpdate.set("ManagerRender",this.update.bind(this)),e.scene.add(this.scene)}levelUpdate(){if(!this.viewport.options.levelEnabled)return;const e=(e,t)=>{e.visible!==t&&(e instanceof Gv&&e._setElementDisplay(t),e.visible=t,e.matrixAutoUpdate=t,e.autoUpdate=!0)},t=t=>{const{level:n,handleHide:i,autoUpdate:r}=t,{max:s=null,min:o=null}=n;if(r)t.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!i&&(s||o)){const n=this.viewport.camera.position.distanceTo(t.position);e(t,!(s&&n>s)&&!(o&&n<o))}};this.scene.traverse((e=>{(e instanceof Fv||e instanceof kv)&&t(e)}))}update(){if(0===this.scene.children.length)return;const e=performance.now();this.levelUpdate(),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}clearObject(){this.store.sbmManager.clear(),this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.lightManager.clear()}dispose(){this.store.modelManager.dispose()}}self.THREE=Bu;class C_{constructor(e){this.THREE=Bu,this.THREE_PLUGINS={TransformControls:ju,Lensflare:{Lensflare:pd,LensflareElement:fd}},this.version=t,this.animation=ip,this.library=ay,this.utils=zd,this.plugins={};const{el:n,options:i={},events:r={}}=e;if(this.domElement=document.querySelector(n),this.options={showInfo:!1,showStats:!1,showViewHelper:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{},hoverEnabled:!1,levelEnabled:!1,closeInfoLog:!1,closeWarnLog:!0,useIndexedDB:!0,logarithmicDepthBuffer:!0,...i},this.viewport=new Nv(this.options),this.signals=this.viewport.signals,this.manager=new T_(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(r),this._initDefaultSettings()}_init(){const{showGrid:t,background:n,fog:i,controls:r,closeInfoLog:s,closeWarnLog:o,useIndexedDB:a}=this.options;if(!s){md(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),md(e,{color:"#3eaf7c","font-size":"24px"}),md(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),md("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),md("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),md("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?Rd(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):Nd(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),i&&this.openSceneFog(!0===i?void 0:i),r&&this.setControlsOptions(r),o&&(window.console.warn=function(){}),a&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:i,modelRightClick:r,modelDblClick:s,poiHover:o,poiUnHover:a,poiClick:l,poiRightClick:c,poiDblClick:h,selectPosition:u,sceneClick:d,resize:p}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),i&&this.signals.modelClick.add(i),r&&this.signals.modelRightClick.add(r),s&&this.signals.modelDblClick.add(s),o&&this.signals.poiHover.add(o),a&&this.signals.poiUnHover.add(a),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),h&&this.signals.poiDblClick.add(h),u&&this.signals.selectPosition.add(u),d&&this.signals.sceneClick.add(d),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultSettings(){this.setEnvironment(),this.setColorSpace("sRGB"),this.setToneMapping({type:"Linear",exposure:.8})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){return this.manager.store.pluginObjectManager.addToObject(e,t)}getPluginObjectById(e){return this.manager.store.pluginObjectManager.getById(e)}getPluginObjectByName(e){return this.manager.store.pluginObjectManager.getByName(e)}removePluginObjectById(e){return this.manager.store.pluginObjectManager.removeById(e)}setSobel(){this.viewport.setSobel()}setBloom(){this.viewport.setBloom()}setSSAO(e){this.viewport.setSSAO(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setToneMapping(e){this.viewport.setToneMapping(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundImage(e){this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){return this.clear(),this.clearSignals(),this.manager.dispose(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e,t="frontTop",n){return this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e,t="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e,t="frontTop",n){return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(e="frontTop",t){return this.flyToObj(this.manager.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e,t="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.lightManager.createAmbientLight(e)}setAmbientLight(e){return this.manager.store.lightManager.setAmbientLight(e)}createDirectionalLight(e){return this.manager.store.lightManager.createDirectionalLight(e)}setDirectionalLight(e){return this.manager.store.lightManager.setDirectionalLight(e)}createHemisphereLight(e){return this.manager.store.lightManager.createHemisphereLight(e)}setHemisphereLight(e){return this.manager.store.lightManager.setHemisphereLight(e)}createSpotLight(e){return this.manager.store.lightManager.createSpotLight(e)}setSpotLight(e){return this.manager.store.lightManager.setSpotLight(e)}createPointLight(e){return this.manager.store.lightManager.createPointLight(e)}setPointLight(e){return this.manager.store.lightManager.setPointLight(e)}createRectAreaLight(e){return this.manager.store.lightManager.createRectAreaLight(e)}setRectAreaLight(e){return this.manager.store.lightManager.setRectAreaLight(e)}getLightById(e){return this.manager.store.lightManager.getById(e)}removeLightById(e){return this.manager.store.lightManager.removeById(e)}getAllLight(){return this.manager.store.lightManager.getAll()}clearLight(){return this.manager.store.lightManager.clear()}showAllLight(){return this.manager.store.lightManager.showAll()}hideAllLight(){return this.manager.store.lightManager.hideAll()}updateAllShadow(){return this.manager.store.lightManager.updateAllShadow()}createGroup(e){return this.manager.store.groupManager.createGroup(e)}getGroupById(e){return this.manager.store.groupManager.getById(e)}getGroupByName(e){return this.manager.store.groupManager.getByName(e)}getAllGroup(){return this.manager.store.groupManager.getAll()}removeGroupById(e){return this.manager.store.groupManager.removeById(e)}loadSbm(e,t){return this.manager.store.sbmManager.load(e,t)}parseSbm(e,t,n){return this.manager.store.sbmManager.parse(e,t,n)}cloneSbm(e,t,n){return this.manager.store.sbmManager.clone(e,t,n)}getSbmById(e){return this.manager.store.sbmManager.getById(e)}getSbmByName(e){return this.manager.store.sbmManager.getByName(e)}getSbmByUserDataProperty(e,t){return this.manager.store.sbmManager.getByUserDataProperty(e,t)}removeSbmById(e){return this.manager.store.sbmManager.removeById(e)}createGroupForSbm(e){return console.warn("createGroupForSbm is deprecated, use createGroup instead"),this.createGroup(e)}loadSbmToGroup(e,t,n){return this.manager.store.sbmManager.loadToGroup(e,t,n)}addSbmForGroup(e,t,n){return this.manager.store.sbmManager.addForGroup(e,t,n)}createSbmGroupFromXml(e,t){return this.manager.store.sbmManager.createGroupFromXml(e,t)}getSbmGroupById(e){return console.warn("getSbmGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getSbmGroupByName(e){return console.warn("getSbmGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllSbmGroup(){return console.warn("getAllSbmGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeSbmGroupById(e){return console.warn("removeSbmGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearSbm(){return this.manager.store.sbmManager.clear()}getAllSbm(){return this.manager.store.sbmManager.getAll()}showAllSbm(){return this.manager.store.sbmManager.showAll()}hideAllSbm(){return this.manager.store.sbmManager.hideAll()}getSbmModelMaps(){return this.manager.store.sbmManager.modelMaps}setSbmModelMaps(e){this.manager.store.sbmManager.modelMaps=e}clearIdb(){return Promise.all([this.manager.store.sbmManager.clearIdb(),this.manager.store.modelManager.clearIdb()])}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return this.manager.store.modelManager.getById(e)}getModelByName(e){return this.manager.store.modelManager.getByName(e)}getModelByUserDataProperty(e,t){return this.manager.store.modelManager.getByUserDataProperty(e,t)}removeModelById(e){return this.manager.store.modelManager.removeById(e)}createGroupForModel(e){return console.warn("createGroupForModel is deprecated, use createGroup instead"),this.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){return this.manager.store.modelManager.addForGroup(e,t)}getModelGroupById(e){return console.warn("getModelGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getModelGroupByName(e){return console.warn("getModelGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllModelGroup(){return console.warn("getAllModelGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeModelGroupById(e){return console.warn("removeModelGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return this.manager.store.poiManager.getById(e)}getPoiByName(e){return this.manager.store.poiManager.getByName(e)}getPoiByUserDataProperty(e,t){return this.manager.store.poiManager.getByUserDataProperty(e,t)}removePoiById(e){return this.manager.store.poiManager.removeById(e)}createGroupForPoi(e){return console.warn("createGroupForPoi is deprecated, use createGroup instead"),this.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){return this.manager.store.poiManager.addForGroup(e,t)}getPoiGroupById(e){return console.warn("getPoiGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getPoiGroupByName(e){return console.warn("getPoiGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllPoiGroup(){return console.warn("getAllPoiGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiGroupById(e){return console.warn("removePoiGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return this.manager.store.poiNodeManager.getById(e)}getPoiNodeByName(e){return this.manager.store.poiNodeManager.getByName(e)}getPoiNodeByUserDataProperty(e,t){return this.manager.store.poiNodeManager.getByUserDataProperty(e,t)}removePoiNodeById(e){return this.manager.store.poiNodeManager.removeById(e)}createGroupForPoiNode(e){return console.warn("createGroupForPoiNode is deprecated, use createGroup instead"),this.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){return this.manager.store.poiNodeManager.addForGroup(e,t)}getPoiNodeGroupById(e){return console.warn("getPoiNodeGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getPoiNodeGroupByName(e){return console.warn("getPoiNodeGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllPoiNodeGroup(){return console.warn("getAllPoiNodeGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removePoiNodeGroupById(e){return console.warn("removePoiNodeGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return this.manager.store.canvas3DManager.getById(e)}getCanvas3DByName(e){return this.manager.store.canvas3DManager.getByName(e)}getCanvas3DByUserDataProperty(e,t){return this.manager.store.canvas3DManager.getByUserDataProperty(e,t)}removeCanvas3DById(e){return this.manager.store.canvas3DManager.removeById(e)}createGroupForCanvas3D(e){return console.warn("createGroupForCanvas3D is deprecated, use createGroup instead"),this.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){return this.manager.store.canvas3DManager.addForGroup(e,t)}getCanvas3DGroupById(e){return console.warn("getCanvas3DGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getCanvas3DGroupByName(e){return console.warn("getCanvas3DGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllCanvas3DGroup(){return console.warn("getAllCanvas3DGroup is deprecated, use getAllGroup instead"),this.getAllGroup()}removeCanvas3DGroupById(e){return console.warn("removeCanvas3DGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return this.manager.store.topologyManager.getById(e)}getTopologyByName(e){return this.manager.store.topologyManager.getByName(e)}getTopologyByUserDataProperty(e,t){return this.manager.store.topologyManager.getByUserDataProperty(e,t)}removeTopologyById(e){return this.manager.store.topologyManager.removeById(e)}createGroupForTopology(e){return console.warn("createGroupForTopology is deprecated, use createGroup instead"),this.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){return this.manager.store.topologyManager.addForGroup(e,t)}getTopologyGroupById(e){return console.warn("getTopologyGroupById is deprecated, use getGroupById instead"),this.getGroupById(e)}getTopologyGroupByName(e){return console.warn("getTopologyGroupByName is deprecated, use getGroupByName instead"),this.getGroupByName(e)}getAllTopologyGroup(){return console.warn("getAllTopologyGroup is deprecated, use getAllGroups instead"),this.getAllGroup()}removeTopologyGroupById(e){return console.warn("removeTopologyGroupById is deprecated, use removeGroupById instead"),this.removeGroupById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return console.warn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return this.manager.store.helperManager.getById(e)}removeHelperById(e){return this.manager.store.helperManager.removeById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}}return C_.THREE=Bu,C_}));