@openheart/tavio-renderer 2.2.12-without-wasm → 2.2.13-without-wasm
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/build/esm/index.js +834 -130
- package/build/esm/types/camera/orbitControls.d.ts +16 -5
- package/build/esm/types/viewer/canvas.d.ts +53 -32
- package/build/esm/types/viewer/tavioMesh.d.ts +60 -2
- package/build/esm/wasm/pkg/no-thread/tavio.d.ts +13 -13
- package/build/esm/wasm/pkg/no-thread/tavio.js +92 -92
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm.d.ts +13 -13
- package/build/esm/wasm/pkg/thread/tavio.d.ts +12 -12
- package/build/esm/wasm/pkg/thread/tavio.js +117 -117
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm.d.ts +12 -12
- package/package.json +1 -1
package/build/esm/index.js
CHANGED
|
@@ -33353,7 +33353,7 @@ class Pane extends RootApi {
|
|
|
33353
33353
|
}
|
|
33354
33354
|
}
|
|
33355
33355
|
new Semver("4.0.5");
|
|
33356
|
-
const main$7 = "precision highp float;precision highp int;precision highp usampler2D;uniform highp usampler2D splatTexture;uniform highp usampler2D generalTexture;uniform highp usampler2D transformTexture;uniform highp usampler2D sphericalHarmonicsTexture0;uniform highp usampler2D sphericalHarmonicsTexture1;uniform highp usampler2D sphericalHarmonicsTexture2;uniform highp usampler2D sphericalHarmonicsTexture3;uniform float sphericalHarmonicsIntensity;uniform mat4 projection,view;uniform vec3 eyePosition;uniform vec2 focal;uniform vec2 inverseViewport;uniform float gaussianScale;uniform float effectMinimumScale;uniform float effectDistance;uniform float effectDistanceMax;uniform float effectDistanceRange;uniform float effectDistanceColor;uniform float effectDistanceColorNear;uniform float effectSonar;uniform float effectSonarRange;uniform vec3 worldOrigin;uniform float additionAlpha;uniform float multiplicationAlpha;uniform float blur;uniform float sharpness;uniform vec4 scaleAlphaMin;uniform vec4 scaleAlphaMax;uniform uint transformTextureWidth;in vec2 localPosition;in uint indices;out vec4 vColor;out vec2 vPosition;out float vGeneralR;out float vColorEffectFactor;out float vSonarFactor;out vec3 vWorldPosition;const float PI=3.14159265358979;const float PI2=PI*2.0;const float INV_255=1.0/255.0;vec3 unpack(uint bits){return vec3((uvec3(bits)>>uvec3(21u,11u,0u))&uvec3(0x7ffu,0x3ffu,0x7ffu))/vec3(2047.0,1023.0,2047.0)*2.0-1.0;}void readV(in uvec4 i,out vec3 v,out vec3 w,out vec3 x,out vec3 y){v=unpack(i.x);w=unpack(i.y);x=unpack(i.z);y=unpack(i.w);}void readVF(in uvec4 i,out vec3 v,out vec3 w,out vec3 x,out float f){v=unpack(i.x);w=unpack(i.y);x=unpack(i.z);f=uintBitsToFloat(i.w);}vec3 calculateSH(ivec2 uv,vec3 eye){float scale;vec3 sh[15];readV(texelFetch(sphericalHarmonicsTexture0,uv,0),sh[0],sh[1],sh[2],sh[3]);readV(texelFetch(sphericalHarmonicsTexture1,uv,0),sh[4],sh[5],sh[6],sh[7]);readV(texelFetch(sphericalHarmonicsTexture2,uv,0),sh[8],sh[9],sh[10],sh[11]);readVF(texelFetch(sphericalHarmonicsTexture3,uv,0),sh[12],sh[13],sh[14],scale);vec3 result=0.4886025119029199*(-sh[0]*eye.y+sh[1]*eye.z-sh[2]*eye.x);float x2=eye.x*eye.x;float y2=eye.y*eye.y;float z2=eye.z*eye.z;float xy=eye.x*eye.y;float yz=eye.y*eye.z;float xz=eye.x*eye.z;result+=sh[3]*(1.0925484305920792*xy)+sh[4]*(-1.0925484305920792*yz)+sh[5]*(0.31539156525252005*(2.0*z2-x2-y2))+sh[6]*(-1.0925484305920792*xz)+sh[7]*(0.5462742152960396*(x2-y2));result+=sh[8]*(-0.5900435899266435*eye.y*(3.0*x2-y2))+sh[9]*(2.890611442640554*xy*eye.z)+sh[10]*(-0.4570457994644658*eye.y*(4.0*z2-x2-y2))+sh[11]*(0.3731763325901154*eye.z*(2.0*z2-3.0*x2-3.0*y2))+sh[12]*(-0.4570457994644658*eye.x*(4.0*z2-x2-y2))+sh[13]*(1.445305721320277*eye.z*(x2-y2))+sh[14]*(-0.5900435899266435*eye.x*(x2-3.0*y2));return result*scale;}vec4 revertQuaternion(uint converted){uint u=converted&0xffu;uint v=(converted>>8u)&0xffu;uint w=(converted>>16u)&0xffu;float x=(float(u)*INV_255)*2.0-1.0;float y=(float(v)*INV_255)*2.0-1.0;float z=1.0-abs(x)-abs(y);float m=max(-z,0.0);x+=(x>=0.0)?-m : m;y+=(y>=0.0)?-m : m;vec3 axis=normalize(vec3(x,y,z));float theta=(float(w)*INV_255)*PI;float halfTheta=theta*0.5;float s=sin(halfTheta);float c=cos(halfTheta);return vec4(axis*s,c);}mat3 generateSigma(vec3 s,vec4 q){return mat3(s.x*(1.0-2.0*(q.y*q.y+q.z*q.z)),s.x*(2.0*(q.x*q.y+q.w*q.z)),s.x*(2.0*(q.x*q.z-q.w*q.y)),s.y*(2.0*(q.x*q.y-q.w*q.z)),s.y*(1.0-2.0*(q.x*q.x+q.z*q.z)),s.y*(2.0*(q.y*q.z+q.w*q.x)),s.z*(2.0*(q.x*q.z+q.w*q.y)),s.z*(2.0*(q.y*q.z-q.w*q.x)),s.z*(1.0-2.0*(q.x*q.x+q.y*q.y)));}mat3 generateRotationScaleMatrix(vec4 q,float s){float x=q.x;float y=q.y;float z=q.z;float w=q.w;float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float xz=x*z;float yz=y*z;float wx=w*x;float wy=w*y;float wz=w*z;return mat3(1.0-2.0*(yy+zz),2.0*(xy+wz),2.0*(xz-wy),2.0*(xy-wz),1.0-2.0*(xx+zz),2.0*(yz+wx),2.0*(xz+wy),2.0*(yz-wx),1.0-2.0*(xx+yy))*s;}void restoreTransform(in uint index,in uint width,out vec3 t,out float s,out vec4 q){uint u=index % width;uint v=uint(floor(float(index)/float(width)));uvec4 transform=texelFetch(transformTexture,ivec2(u,v),0);vec2 r=unpackHalf2x16(transform.x);vec2 g=unpackHalf2x16(transform.y);vec2 b=unpackHalf2x16(transform.z);vec2 a=unpackHalf2x16(transform.w);t=vec3(-r,g.x);s=g.y;q=vec4(b,a);}vec4 multiplyQuaternion(vec4 qA,vec4 qB){float wA=qA.w;vec3 vA=qA.xyz;float wB=qB.w;vec3 vB=qB.xyz;float wC=wA*wB-dot(vA,vB);vec3 vC=cross(vA,vB)+wA*vB+wB*vA;return vec4(vC,wC);}vec4 axisAngleQuaternion(vec3 axis,float angle){vec3 n=normalize(axis);float h=0.5*angle;float s=sin(h);return vec4(n.x*s,n.y*s,n.z*s,cos(h));}void unpack4to8(in uint packed,out uint high,out uint low){high=(packed>>4u)&0xFu;low=packed&0xFu;}void main(){uint u=indices&0x3ffu;uint v=indices>>10;ivec2 uv=ivec2(u,v);uvec4 packed=texelFetch(splatTexture,uv,0);uvec4 general=texelFetch(generalTexture,uv,0);vec3 tPosition=vec3(0.0);float tScale=1.0;vec4 tRotation=vec4(0.0);uint high,low;unpack4to8(general.a,high,low);restoreTransform(low,transformTextureWidth,tPosition,tScale,tRotation);vec3 revertedPosition=vec4(unpackHalf2x16(packed.x),unpackHalf2x16(packed.y&0xffffu)).xyz;uvec3 uScale=uvec3(packed.z&0xffu,(packed.z>>8u)&0xffu,(packed.z>>16u)&0xffu);float invScale=1.0/255.0;vec3 scaleRange=scaleAlphaMax.xyz-scaleAlphaMin.xyz;vec3 scale=vec3(
|
|
33356
|
+
const main$7 = "precision highp float;precision highp int;precision highp usampler2D;uniform highp usampler2D splatTexture;uniform highp usampler2D generalTexture;uniform highp usampler2D transformTexture;uniform highp usampler2D sphericalHarmonicsTexture0;uniform highp usampler2D sphericalHarmonicsTexture1;uniform highp usampler2D sphericalHarmonicsTexture2;uniform highp usampler2D sphericalHarmonicsTexture3;uniform float sphericalHarmonicsIntensity;uniform mat4 projection,view;uniform vec3 eyePosition;uniform vec2 focal;uniform vec2 inverseViewport;uniform float gaussianScale;uniform float effectMinimumScale;uniform float effectDistance;uniform float effectDistanceMax;uniform float effectDistanceRange;uniform float effectDistanceColor;uniform float effectDistanceColorNear;uniform float effectSonar;uniform float effectSonarRange;uniform vec3 worldOrigin;uniform float additionAlpha;uniform float multiplicationAlpha;uniform float blur;uniform float sharpness;uniform vec4 scaleAlphaMin;uniform vec4 scaleAlphaMax;uniform uint transformTextureWidth;in vec2 localPosition;in uint indices;out vec4 vColor;out vec2 vPosition;out float vGeneralR;out float vColorEffectFactor;out float vSonarFactor;out vec3 vWorldPosition;const float PI=3.14159265358979;const float PI2=PI*2.0;const float INV_255=1.0/255.0;vec3 unpack(uint bits){return vec3((uvec3(bits)>>uvec3(21u,11u,0u))&uvec3(0x7ffu,0x3ffu,0x7ffu))/vec3(2047.0,1023.0,2047.0)*2.0-1.0;}void readV(in uvec4 i,out vec3 v,out vec3 w,out vec3 x,out vec3 y){v=unpack(i.x);w=unpack(i.y);x=unpack(i.z);y=unpack(i.w);}void readVF(in uvec4 i,out vec3 v,out vec3 w,out vec3 x,out float f){v=unpack(i.x);w=unpack(i.y);x=unpack(i.z);f=uintBitsToFloat(i.w);}vec3 calculateSH(ivec2 uv,vec3 eye){float scale;vec3 sh[15];readV(texelFetch(sphericalHarmonicsTexture0,uv,0),sh[0],sh[1],sh[2],sh[3]);readV(texelFetch(sphericalHarmonicsTexture1,uv,0),sh[4],sh[5],sh[6],sh[7]);readV(texelFetch(sphericalHarmonicsTexture2,uv,0),sh[8],sh[9],sh[10],sh[11]);readVF(texelFetch(sphericalHarmonicsTexture3,uv,0),sh[12],sh[13],sh[14],scale);vec3 result=0.4886025119029199*(-sh[0]*eye.y+sh[1]*eye.z-sh[2]*eye.x);float x2=eye.x*eye.x;float y2=eye.y*eye.y;float z2=eye.z*eye.z;float xy=eye.x*eye.y;float yz=eye.y*eye.z;float xz=eye.x*eye.z;result+=sh[3]*(1.0925484305920792*xy)+sh[4]*(-1.0925484305920792*yz)+sh[5]*(0.31539156525252005*(2.0*z2-x2-y2))+sh[6]*(-1.0925484305920792*xz)+sh[7]*(0.5462742152960396*(x2-y2));result+=sh[8]*(-0.5900435899266435*eye.y*(3.0*x2-y2))+sh[9]*(2.890611442640554*xy*eye.z)+sh[10]*(-0.4570457994644658*eye.y*(4.0*z2-x2-y2))+sh[11]*(0.3731763325901154*eye.z*(2.0*z2-3.0*x2-3.0*y2))+sh[12]*(-0.4570457994644658*eye.x*(4.0*z2-x2-y2))+sh[13]*(1.445305721320277*eye.z*(x2-y2))+sh[14]*(-0.5900435899266435*eye.x*(x2-3.0*y2));return result*scale;}vec4 revertQuaternion(uint converted){uint u=converted&0xffu;uint v=(converted>>8u)&0xffu;uint w=(converted>>16u)&0xffu;float x=(float(u)*INV_255)*2.0-1.0;float y=(float(v)*INV_255)*2.0-1.0;float z=1.0-abs(x)-abs(y);float m=max(-z,0.0);x+=(x>=0.0)?-m : m;y+=(y>=0.0)?-m : m;vec3 axis=normalize(vec3(x,y,z));float theta=(float(w)*INV_255)*PI;float halfTheta=theta*0.5;float s=sin(halfTheta);float c=cos(halfTheta);return vec4(axis*s,c);}mat3 generateSigma(vec3 s,vec4 q){return mat3(s.x*(1.0-2.0*(q.y*q.y+q.z*q.z)),s.x*(2.0*(q.x*q.y+q.w*q.z)),s.x*(2.0*(q.x*q.z-q.w*q.y)),s.y*(2.0*(q.x*q.y-q.w*q.z)),s.y*(1.0-2.0*(q.x*q.x+q.z*q.z)),s.y*(2.0*(q.y*q.z+q.w*q.x)),s.z*(2.0*(q.x*q.z+q.w*q.y)),s.z*(2.0*(q.y*q.z-q.w*q.x)),s.z*(1.0-2.0*(q.x*q.x+q.y*q.y)));}mat3 generateRotationScaleMatrix(vec4 q,float s){float x=q.x;float y=q.y;float z=q.z;float w=q.w;float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float xz=x*z;float yz=y*z;float wx=w*x;float wy=w*y;float wz=w*z;return mat3(1.0-2.0*(yy+zz),2.0*(xy+wz),2.0*(xz-wy),2.0*(xy-wz),1.0-2.0*(xx+zz),2.0*(yz+wx),2.0*(xz+wy),2.0*(yz-wx),1.0-2.0*(xx+yy))*s;}void restoreTransform(in uint index,in uint width,out vec3 t,out float s,out vec4 q){uint u=index % width;uint v=uint(floor(float(index)/float(width)));uvec4 transform=texelFetch(transformTexture,ivec2(u,v),0);vec2 r=unpackHalf2x16(transform.x);vec2 g=unpackHalf2x16(transform.y);vec2 b=unpackHalf2x16(transform.z);vec2 a=unpackHalf2x16(transform.w);t=vec3(-r,g.x);s=g.y;q=vec4(b,a);}vec4 multiplyQuaternion(vec4 qA,vec4 qB){float wA=qA.w;vec3 vA=qA.xyz;float wB=qB.w;vec3 vB=qB.xyz;float wC=wA*wB-dot(vA,vB);vec3 vC=cross(vA,vB)+wA*vB+wB*vA;return vec4(vC,wC);}vec4 axisAngleQuaternion(vec3 axis,float angle){vec3 n=normalize(axis);float h=0.5*angle;float s=sin(h);return vec4(n.x*s,n.y*s,n.z*s,cos(h));}void unpack4to8(in uint packed,out uint high,out uint low){high=(packed>>4u)&0xFu;low=packed&0xFu;}void main(){uint u=indices&0x3ffu;uint v=indices>>10;ivec2 uv=ivec2(u,v);uvec4 packed=texelFetch(splatTexture,uv,0);uvec4 general=texelFetch(generalTexture,uv,0);vec3 tPosition=vec3(0.0);float tScale=1.0;vec4 tRotation=vec4(0.0);uint high,low;unpack4to8(general.a,high,low);restoreTransform(low,transformTextureWidth,tPosition,tScale,tRotation);vec3 revertedPosition=vec4(unpackHalf2x16(packed.x),unpackHalf2x16(packed.y&0xffffu)).xyz;uvec3 uScale=uvec3(packed.z&0xffu,(packed.z>>8u)&0xffu,(packed.z>>16u)&0xffu);float invScale=1.0/255.0;vec3 scaleRange=scaleAlphaMax.xyz-scaleAlphaMin.xyz;vec3 scale=vec3(exp(float(uScale.x)*invScale*scaleRange.x+scaleAlphaMin.x)*2.0,exp(float(uScale.y)*invScale*scaleRange.y+scaleAlphaMin.y)*2.0,exp(float(uScale.z)*invScale*scaleRange.z+scaleAlphaMin.z)*2.0);uint rotation=(packed.y>>16u)&0xffffu|(packed.z>>8u)&0xff0000u;vec4 quaternion=revertQuaternion(rotation);uvec4 uintRGBA=uvec4(packed.w&0xffu,(packed.w>>8u)&0xffu,(packed.w>>16u)&0xffu,(packed.w>>24u)&0xffu);vec4 rgba=vec4(uintRGBA)/255.0;float alphaRange=scaleAlphaMax.w-scaleAlphaMin.w;float rawAlpha=(float(general.b)/255.0)*alphaRange+scaleAlphaMin.w;mat3 modelMatrix=generateRotationScaleMatrix(tRotation,tScale);revertedPosition=modelMatrix*revertedPosition+tPosition;scale*=tScale;quaternion=multiplyQuaternion(tRotation,quaternion);vec4 viewPosition=view*vec4(revertedPosition,1.0);vec4 clipPosition=projection*viewPosition;float clip=1.2*clipPosition.w;if(clipPosition.z<-clip||clipPosition.x<-clip||clipPosition.x>clip||clipPosition.y<-clip||clipPosition.y>clip){gl_Position=vec4(0.0,0.0,2.0,1.0);return;}mat3 sigma=generateSigma(scale,quaternion);mat3 Vrk=sigma*transpose(sigma);float vpz=1.0/(viewPosition.z*viewPosition.z);mat3 J=mat3(focal.x/viewPosition.z,0.0,-(focal.x*viewPosition.x)*vpz,0.0,focal.y/viewPosition.z,-(focal.y*viewPosition.y)*vpz,0.0,0.0,0.0);mat3 mat3view=mat3(view);mat3 T=transpose(mat3view)*J;mat3 cov2d=transpose(T)*Vrk*T;float d00=cov2d[0][0]+sharpness;float d01=cov2d[0][1];float d11=cov2d[1][1]+sharpness;float mid=(d00+d11)/2.0;float radius=length(vec2((d00-d11)/2.0,d01));float lambda1=mid+radius,lambda2=mid-radius;if(lambda2<0.0){return;}vec2 diagonalVector=normalize(vec2(d01,lambda1-d00));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);float toCenter=length(revertedPosition-worldOrigin)/effectDistanceMax;float threshold=effectDistance;float range=max(effectDistanceRange,0.0001);float normalizedDistance=(toCenter-threshold)/(range*threshold+0.0001);float ease=effectDistance>=1.0 ? 1.0 :(1.0-min(max(normalizedDistance,0.0),1.0));ease=max(ease,effectMinimumScale);float circularScale=1.0-min(toCenter,1.0);vec2 circularMajorAxis=normalize(majorAxis)*circularScale;vec2 circularMinorAxis=normalize(minorAxis)*circularScale;vec2 finalMajorAxis=mix(circularMajorAxis,majorAxis,ease);vec2 finalMinorAxis=mix(circularMinorAxis,minorAxis,ease);vec4 normalizedColor=rgba;normalizedColor.a=1.0/(1.0+exp(-(rawAlpha*multiplicationAlpha+additionAlpha)));float a=cov2d[0][0];float d=cov2d[1][1];float b=cov2d[0][1];float dPrevious=a*d-b*b;a+=blur;d+=blur;float det=a*d-b*b;float blurAdjust=sqrt(max(0.0,dPrevious/det));normalizedColor.a*=blurAdjust;vPosition=localPosition;vec3 shColor=calculateSH(uv,normalize(eyePosition-revertedPosition));normalizedColor+=vec4(shColor,0.0)*sphericalHarmonicsIntensity;vColor=clamp(clipPosition.z/clipPosition.w+1.0,0.0,1.0)*normalizedColor;vGeneralR=sign(float(general.r));float generalG=1.0-sign(float(general.g));vColor=mix(vColor,vec4(1.0,0.1,1.0,1.0),vGeneralR);float toCenterColor=toCenter;float thresholdColor=effectDistanceColor*(1.0+effectDistanceRange);float farColor=clamp(thresholdColor-toCenterColor,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdColorNear=effectDistanceColorNear*(1.0+effectDistanceRange);float nearColor=1.0-(clamp(thresholdColorNear-toCenterColor,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001));vColorEffectFactor=nearColor*farColor;float outerRadius=effectSonar;float innerRadius=max(0.0,effectSonar-effectSonarRange);float factor=0.0;if(toCenter<=outerRadius&&toCenter>=innerRadius&&effectSonarRange>0.0){float range=outerRadius-innerRadius;factor=range>0.0001 ?(toCenter-innerRadius)/range : 1.0;}vSonarFactor=factor;vec2 center=vec2(clipPosition);vec2 major=localPosition.x*finalMajorAxis*inverseViewport;vec2 minor=localPosition.y*finalMinorAxis*inverseViewport;vec3 worldPosition=vec3(center+(major+minor)*clipPosition.w*gaussianScale*generalG*ease,clipPosition.z);vWorldPosition=revertedPosition;gl_Position=vec4(worldPosition,clipPosition.w);}";
|
|
33357
33357
|
const main$6 = "precision highp float;uniform float temperature;uniform float tint;uniform float contrastIntensity;uniform vec3 hsv;uniform vec3 rgb;uniform float effectSonar;in vec4 vColor;in vec2 vPosition;in float vGeneralR;in float vColorEffectFactor;in float vSonarFactor;in vec3 vWorldPosition;uniform vec3 worldOrigin;out vec4 fragColor;const float EDGE=0.95;const float COLLISION_ALPHA=0.25;const float EPS=1.0e-8;const float DIV=10.0/6.0;const mat3 LIN_2_LMS_MAT=mat3(3.90405e-1,5.49941e-1,8.92632e-3,7.08416e-2,9.63172e-1,1.35775e-3,2.31082e-2,1.28021e-1,9.36245e-1);const mat3 LMS_2_LIN_MAT=mat3(2.85847e+0,-1.62879e+0,-2.48910e-2,-2.10182e-1,1.15820e+0,3.24281e-4,-4.18120e-2,-1.18169e-1,1.06867e+0);vec3 whiteBalance(vec3 diffuse,float te,float ti){float t1=te*DIV;float t2=ti*DIV;float x=0.31271-t1*(t1<0.0 ? 0.1 : 0.05);float standardIlluminantY=2.87*x-3.0*x*x-0.27509507;float y=standardIlluminantY+t2*0.05;vec3 w1=vec3(0.949237,1.03542,1.08728);float X=x/y;float Z=(1.0-x-y)/y;float L=0.7328*X+0.4296-0.1624*Z;float M=-0.7036*X+1.6975+0.0061*Z;float S=0.0030*X+0.0136+0.9834*Z;vec3 w2=vec3(L,M,S);vec3 balance=vec3(w1.x/w2.x,w1.y/w2.y,w1.z/w2.z);vec3 lms=LIN_2_LMS_MAT*diffuse;lms*=balance;return LMS_2_LIN_MAT*lms;}vec3 RGB2HSV(vec3 color){vec3 c=min(color,1.0);vec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);vec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));vec4 q=mix(vec4(p.xyw,c.r),vec4(c.r,p.yzx),step(p.x,c.r));float d=q.x-min(q.w,q.y);return vec3(abs(q.z+(q.w-q.y)/(6.0*d+EPS)),d/(q.x+EPS),q.x);}vec3 HSV2RGB(vec3 color){vec3 c=min(color,1.0);vec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);vec3 p=abs(fract(c.xxx+K.xyz)*6.0-K.www);return c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);}vec3 contrast(vec3 color,float base){float b=(base*2.0-1.0)*0.5;return color+vec3(atan((color.r*2.0-1.0)*b),atan((color.g*2.0-1.0)*b),atan((color.b*2.0-1.0)*b));}vec3 grading(vec3 color){vec3 balanced=whiteBalance(color,temperature,tint);vec3 contrasted=contrast(balanced,contrastIntensity);vec3 hsvColor=RGB2HSV(contrasted);hsvColor.x=fract(hsvColor.x+hsv.x);hsvColor.y=clamp(hsvColor.y+hsv.y,0.0,1.0);hsvColor.z=clamp(hsvColor.z+hsv.z,0.0,1.0);vec3 rgbAdjusted=HSV2RGB(hsvColor);rgbAdjusted.r=clamp(rgbAdjusted.r+rgb.r,0.0,1.0);rgbAdjusted.g=clamp(rgbAdjusted.g+rgb.g,0.0,1.0);rgbAdjusted.b=clamp(rgbAdjusted.b+rgb.b,0.0,1.0);return rgbAdjusted;}void main(){float A=-dot(vPosition,vPosition);if(A<-4.0){discard;}float B=exp(A)*vColor.a;float l=length(vPosition);float f=smoothstep(0.5,1.0,0.01/abs(l-EDGE));float C=f+sign(max(-l+EDGE,0.0))*COLLISION_ALPHA;vec3 originalColor=vColor.rgb;vec3 gradedColor=grading(originalColor);vec3 finalColor=mix(originalColor,gradedColor,vColorEffectFactor);if(vSonarFactor>0.0){float sonarStrength=2.0;vec3 sonarColor=finalColor;float whiteAreaFactor=smoothstep(0.25,1.0,vSonarFactor);vec3 whiteColor=sonarColor;whiteColor.rgb+=whiteAreaFactor*sonarStrength*0.4;whiteColor=clamp(whiteColor,0.0,1.0);finalColor=mix(finalColor,whiteColor,vSonarFactor);}float alpha=mix(B,C,vGeneralR);fragColor=vec4(finalColor*alpha,alpha);}";
|
|
33358
33358
|
const main$5 = "precision highp float;precision highp int;precision highp usampler2D;uniform highp usampler2D splatTexture;uniform highp usampler2D generalTexture;uniform highp usampler2D transformTexture;uniform mat4 projection,view;uniform vec2 focal;uniform vec2 inverseViewport;uniform float gaussianScale;uniform float effectMinimumScale;uniform float effectDistance;uniform float effectDistanceMax;uniform float effectDistanceRange;uniform float effectDistanceColor;uniform float effectDistanceColorNear;uniform float effectSonar;uniform float effectSonarRange;uniform vec3 worldOrigin;uniform vec4 scaleAlphaMin;uniform vec4 scaleAlphaMax;uniform uint transformTextureWidth;in vec2 localPosition;in uint indices;out vec4 vColor;flat out uint vGeneralA;const float PI=3.14159265358979;const float PI2=PI*2.0;const float INV_255=1.0/255.0;vec4 revertQuaternion(uint converted){uint u=converted&0xffu;uint v=(converted>>8u)&0xffu;uint w=(converted>>16u)&0xffu;float x=(float(u)*INV_255)*2.0-1.0;float y=(float(v)*INV_255)*2.0-1.0;float z=1.0-abs(x)-abs(y);float m=max(-z,0.0);x+=(x>=0.0)?-m : m;y+=(y>=0.0)?-m : m;vec3 axis=normalize(vec3(x,y,z));float theta=(float(w)*INV_255)*PI;float halfTheta=theta*0.5;float s=sin(halfTheta);float c=cos(halfTheta);return vec4(axis*s,c);}mat3 generateSigma(vec3 s,vec4 q){return mat3(s.x*(1.0-2.0*(q.y*q.y+q.z*q.z)),s.x*(2.0*(q.x*q.y+q.w*q.z)),s.x*(2.0*(q.x*q.z-q.w*q.y)),s.y*(2.0*(q.x*q.y-q.w*q.z)),s.y*(1.0-2.0*(q.x*q.x+q.z*q.z)),s.y*(2.0*(q.y*q.z+q.w*q.x)),s.z*(2.0*(q.x*q.z+q.w*q.y)),s.z*(2.0*(q.y*q.z-q.w*q.x)),s.z*(1.0-2.0*(q.x*q.x+q.y*q.y)));}mat3 generateRotationScaleMatrix(vec4 q,float s){float x=q.x;float y=q.y;float z=q.z;float w=q.w;float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float xz=x*z;float yz=y*z;float wx=w*x;float wy=w*y;float wz=w*z;return mat3(1.0-2.0*(yy+zz),2.0*(xy+wz),2.0*(xz-wy),2.0*(xy-wz),1.0-2.0*(xx+zz),2.0*(yz+wx),2.0*(xz+wy),2.0*(yz-wx),1.0-2.0*(xx+yy))*s;}void restoreTransform(in uint index,in uint width,out vec3 t,out float s,out vec4 q){uint u=index % width;uint v=uint(floor(float(index)/float(width)));uvec4 transform=texelFetch(transformTexture,ivec2(u,v),0);vec2 r=unpackHalf2x16(transform.x);vec2 g=unpackHalf2x16(transform.y);vec2 b=unpackHalf2x16(transform.z);vec2 a=unpackHalf2x16(transform.w);t=vec3(-r,g.x);s=g.y;q=vec4(b,a);}vec4 multiplyQuaternion(vec4 qA,vec4 qB){float wA=qA.w;vec3 vA=qA.xyz;float wB=qB.w;vec3 vB=qB.xyz;float wC=wA*wB-dot(vA,vB);vec3 vC=cross(vA,vB)+wA*vB+wB*vA;return vec4(vC,wC);}void unpack4to8(in uint packed,out uint high,out uint low){high=(packed>>4u)&0xFu;low=packed&0xFu;}void main(){uint u=indices&0x3ffu;uint v=indices>>10;ivec2 uv=ivec2(u,v);uvec4 packed=texelFetch(splatTexture,uv,0);uvec4 general=texelFetch(generalTexture,uv,0);vec3 tPosition=vec3(0.0);float tScale=1.0;vec4 tRotation=vec4(0.0);uint high,low;unpack4to8(general.a,high,low);restoreTransform(low,transformTextureWidth,tPosition,tScale,tRotation);vGeneralA=general.a;vec3 revertedPosition=vec4(unpackHalf2x16(packed.x),unpackHalf2x16(packed.y&0xffffu)).xyz;uvec3 uScale=uvec3(packed.z&0xffu,(packed.z>>8u)&0xffu,(packed.z>>16u)&0xffu);float invScale=1.0/255.0;vec3 scaleRange=scaleAlphaMax.xyz-scaleAlphaMin.xyz;vec3 scale=vec3(uScale.x==0u ? 0.0 : exp(float(uScale.x)*invScale*scaleRange.x+scaleAlphaMin.x)*2.0,uScale.y==0u ? 0.0 : exp(float(uScale.y)*invScale*scaleRange.y+scaleAlphaMin.y)*2.0,uScale.z==0u ? 0.0 : exp(float(uScale.z)*invScale*scaleRange.z+scaleAlphaMin.z)*2.0);scale.x=scaleRange.x==0.0 ? 1.0 : scale.x;scale.y=scaleRange.y==0.0 ? 1.0 : scale.y;scale.z=scaleRange.z==0.0 ? 1.0 : scale.z;uint rotation=(packed.y>>16u)&0xffffu|(packed.z>>8u)&0xff0000u;vec4 quaternion=revertQuaternion(rotation);uvec4 uintRGBA=uvec4(packed.w&0xffu,(packed.w>>8u)&0xffu,(packed.w>>16u)&0xffu,(packed.w>>24u)&0xffu);vec4 rgba=vec4(uintRGBA)/255.0;mat3 modelMatrix=generateRotationScaleMatrix(tRotation,tScale);revertedPosition=modelMatrix*revertedPosition+tPosition;scale*=tScale;quaternion=multiplyQuaternion(tRotation,quaternion);vec4 viewPosition=view*vec4(revertedPosition,1.0);vec4 clipPosition=projection*viewPosition;float clip=1.2*clipPosition.w;if(clipPosition.z<-clip||clipPosition.x<-clip||clipPosition.x>clip||clipPosition.y<-clip||clipPosition.y>clip||rgba.a==0.0){gl_Position=vec4(0.0,0.0,2.0,1.0);vColor=vec4(0.0);return;}mat3 sigma=generateSigma(scale,quaternion);mat3 Vrk=sigma*transpose(sigma);float vpz=1.0/(viewPosition.z*viewPosition.z);mat3 J=mat3(focal.x/viewPosition.z,0.0,-(focal.x*viewPosition.x)*vpz,0.0,focal.y/viewPosition.z,-(focal.y*viewPosition.y)*vpz,0.0,0.0,0.0);mat3 mat3view=mat3(view);mat3 T=transpose(mat3view)*J;mat3 cov2d=transpose(T)*Vrk*T;float d00=cov2d[0][0];float d01=cov2d[0][1];float d11=cov2d[1][1];float mid=(d00+d11)/2.0;float radius=length(vec2((d00-d11)/2.0,d01));float lambda1=mid+radius,lambda2=mid-radius;if(lambda2<0.0){return;}vec2 diagonalVector=normalize(vec2(d01,lambda1-d00));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);float toCenter=length(revertedPosition-worldOrigin)/effectDistanceMax;float threshold=effectDistance;float range=max(effectDistanceRange,0.0001);float normalizedDistance=(toCenter-threshold)/(range*threshold+0.0001);float ease=effectDistance>=1.0 ? 1.0 :(1.0-min(max(normalizedDistance,0.0),1.0));ease=max(ease,effectMinimumScale);float circularScale=1.0-min(toCenter,1.0);vec2 circularMajorAxis=normalize(majorAxis)*circularScale;vec2 circularMinorAxis=normalize(minorAxis)*circularScale;vec2 finalMajorAxis=mix(circularMajorAxis,majorAxis,ease);vec2 finalMinorAxis=mix(circularMinorAxis,minorAxis,ease);float generalG=1.0-sign(float(general.g));vec2 center=vec2(clipPosition);vec2 major=localPosition.x*finalMajorAxis*inverseViewport;vec2 minor=localPosition.y*finalMinorAxis*inverseViewport;vec3 worldPosition=vec3(center+(major+minor)*clipPosition.w*gaussianScale*generalG*ease,clipPosition.z);gl_Position=vec4(worldPosition,clipPosition.w);vColor=vec4(revertedPosition,0.0);}";
|
|
33359
33359
|
const main$4 = "precision highp float;in vec4 vColor;flat in uint vGeneralA;out vec4 fragColor;void main(){float toFloat=uintBitsToFloat(vGeneralA);fragColor=vec4(vColor.rgb,toFloat);}";
|
|
@@ -34171,6 +34171,7 @@ class TransferControls extends EventEmitter {
|
|
|
34171
34171
|
setCamera(camera) {
|
|
34172
34172
|
this.camera = camera;
|
|
34173
34173
|
this.syncCameraParameter();
|
|
34174
|
+
this.syncCameraFov();
|
|
34174
34175
|
}
|
|
34175
34176
|
/**
|
|
34176
34177
|
* 設定されているカメラの座標を各プロパティに反映する
|
|
@@ -34209,7 +34210,6 @@ class TransferControls extends EventEmitter {
|
|
|
34209
34210
|
syncCameraParameter() {
|
|
34210
34211
|
this.syncCameraPosition();
|
|
34211
34212
|
this.syncCameraRotation();
|
|
34212
|
-
this.syncCameraFov();
|
|
34213
34213
|
}
|
|
34214
34214
|
/**
|
|
34215
34215
|
* 減衰係数を設定する
|
|
@@ -34416,7 +34416,7 @@ class TransferControls extends EventEmitter {
|
|
|
34416
34416
|
*/
|
|
34417
34417
|
_updateFov() {
|
|
34418
34418
|
const range = this.targetFov - this.currentFov;
|
|
34419
|
-
const changed = range > 0;
|
|
34419
|
+
const changed = Math.abs(range) > 0;
|
|
34420
34420
|
this.currentFov = this.currentFov + (range - range * this.attenuation);
|
|
34421
34421
|
if (Math.abs(this.currentFov - this.targetFov) < EPS$3) {
|
|
34422
34422
|
this.currentFov = this.targetFov;
|
|
@@ -34528,6 +34528,18 @@ class OrbitControls extends EventEmitter {
|
|
|
34528
34528
|
"change"
|
|
34529
34529
|
// なにかしらの変更があった
|
|
34530
34530
|
];
|
|
34531
|
+
/**
|
|
34532
|
+
* 与えられた三次元ベクトル(要正規化)から theta と phi を計算する
|
|
34533
|
+
* @param eye - 正規化されたベクトル
|
|
34534
|
+
*/
|
|
34535
|
+
static calcThetaPhi(eye) {
|
|
34536
|
+
const eyeXZ = new Vector2(eye.x, eye.z).normalize();
|
|
34537
|
+
const s = eyeXZ.cross(CROSS2);
|
|
34538
|
+
const c = Math.acos(eyeXZ.dot(CROSS2));
|
|
34539
|
+
const theta = Math.asin(eye.y);
|
|
34540
|
+
const phi = s > 0 ? PI_2 - c : c;
|
|
34541
|
+
return { theta, phi, eye, eyeXZ };
|
|
34542
|
+
}
|
|
34531
34543
|
/**
|
|
34532
34544
|
* @constructor
|
|
34533
34545
|
* @param camera - 制御の対象となるカメラ
|
|
@@ -34575,18 +34587,6 @@ class OrbitControls extends EventEmitter {
|
|
|
34575
34587
|
this._quatY = new Quaternion();
|
|
34576
34588
|
this.setCamera(camera);
|
|
34577
34589
|
}
|
|
34578
|
-
/**
|
|
34579
|
-
* 現在の視線から theta と phi を計算する
|
|
34580
|
-
*/
|
|
34581
|
-
_getTP() {
|
|
34582
|
-
const eye = this.camera.getWorldDirection(new Vector3());
|
|
34583
|
-
const eyeXZ = new Vector2(eye.x, eye.z).normalize();
|
|
34584
|
-
const s = eyeXZ.cross(CROSS2);
|
|
34585
|
-
const c = Math.acos(eyeXZ.dot(CROSS2));
|
|
34586
|
-
const theta = Math.asin(eye.y);
|
|
34587
|
-
const phi = s > 0 ? PI_2 - c : c;
|
|
34588
|
-
return { theta, phi, eye, eyeXZ };
|
|
34589
|
-
}
|
|
34590
34590
|
/**
|
|
34591
34591
|
* 大きなラジアンをクランプする
|
|
34592
34592
|
* @param value - 処理対象となる値
|
|
@@ -34644,7 +34644,8 @@ class OrbitControls extends EventEmitter {
|
|
|
34644
34644
|
if (this.camera == null) {
|
|
34645
34645
|
return;
|
|
34646
34646
|
}
|
|
34647
|
-
const
|
|
34647
|
+
const eye = this.camera.getWorldDirection(new Vector3());
|
|
34648
|
+
const tp = OrbitControls.calcThetaPhi(eye);
|
|
34648
34649
|
this.currentTheta = tp.theta;
|
|
34649
34650
|
this.targetTheta = tp.theta;
|
|
34650
34651
|
this.currentPhi = tp.phi;
|
|
@@ -34667,6 +34668,17 @@ class OrbitControls extends EventEmitter {
|
|
|
34667
34668
|
direction.multiplyScalar(distance);
|
|
34668
34669
|
this.camera.position.copy(this.center.clone().add(direction));
|
|
34669
34670
|
}
|
|
34671
|
+
/**
|
|
34672
|
+
* 現在の向き(ラジアンでの緯度経度)
|
|
34673
|
+
*/
|
|
34674
|
+
getAngle() {
|
|
34675
|
+
const eye = this.camera.getWorldDirection(new Vector3());
|
|
34676
|
+
const tp = OrbitControls.calcThetaPhi(eye);
|
|
34677
|
+
return {
|
|
34678
|
+
theta: tp.theta,
|
|
34679
|
+
phi: tp.phi
|
|
34680
|
+
};
|
|
34681
|
+
}
|
|
34670
34682
|
/**
|
|
34671
34683
|
* 前後移動(相対指定)
|
|
34672
34684
|
* @param value - 距離
|
|
@@ -37418,7 +37430,7 @@ const main$3 = "uniform float size;uniform float scale;uniform float effectDista
|
|
|
37418
37430
|
const main$2 = "uniform vec3 diffuse;uniform float opacity;uniform float temperature;uniform float tint;uniform float contrastIntensity;uniform vec3 hsv;uniform vec3 rgb;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying float vAlpha;varying float vColorEffectFactor;varying float vSonarFactor;varying vec3 vWorldPosition;uniform vec3 worldOrigin;uniform float effectSonar;const float EPS=1.0e-8;const float DIV=10.0/6.0;const mat3 LIN_2_LMS_MAT=mat3(3.90405e-1,5.49941e-1,8.92632e-3,7.08416e-2,9.63172e-1,1.35775e-3,2.31082e-2,1.28021e-1,9.36245e-1);const mat3 LMS_2_LIN_MAT=mat3(2.85847e+0,-1.62879e+0,-2.48910e-2,-2.10182e-1,1.15820e+0,3.24281e-4,-4.18120e-2,-1.18169e-1,1.06867e+0);vec3 whiteBalance(vec3 diffuse,float te,float ti){float t1=te*DIV;float t2=ti*DIV;float x=0.31271-t1*(t1<0.0 ? 0.1 : 0.05);float standardIlluminantY=2.87*x-3.0*x*x-0.27509507;float y=standardIlluminantY+t2*0.05;vec3 w1=vec3(0.949237,1.03542,1.08728);float X=x/y;float Z=(1.0-x-y)/y;float L=0.7328*X+0.4296-0.1624*Z;float M=-0.7036*X+1.6975+0.0061*Z;float S=0.0030*X+0.0136+0.9834*Z;vec3 w2=vec3(L,M,S);vec3 balance=vec3(w1.x/w2.x,w1.y/w2.y,w1.z/w2.z);vec3 lms=LIN_2_LMS_MAT*diffuse;lms*=balance;return LMS_2_LIN_MAT*lms;}vec3 RGB2HSV(vec3 color){vec3 c=min(color,1.0);vec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);vec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));vec4 q=mix(vec4(p.xyw,c.r),vec4(c.r,p.yzx),step(p.x,c.r));float d=q.x-min(q.w,q.y);return vec3(abs(q.z+(q.w-q.y)/(6.0*d+EPS)),d/(q.x+EPS),q.x);}vec3 HSV2RGB(vec3 color){vec3 c=min(color,1.0);vec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);vec3 p=abs(fract(c.xxx+K.xyz)*6.0-K.www);return c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);}vec3 contrast(vec3 color,float base){float b=(base*2.0-1.0)*0.5;return color+vec3(atan((color.r*2.0-1.0)*b),atan((color.g*2.0-1.0)*b),atan((color.b*2.0-1.0)*b));}vec3 grading(vec3 color){vec3 balanced=whiteBalance(color,temperature,tint);vec3 contrasted=contrast(balanced,contrastIntensity);vec3 hsvColor=RGB2HSV(contrasted);hsvColor.x=fract(hsvColor.x+hsv.x);hsvColor.y=clamp(hsvColor.y+hsv.y,0.0,1.0);hsvColor.z=clamp(hsvColor.z+hsv.z,0.0,1.0);vec3 rgbAdjusted=HSV2RGB(hsvColor);rgbAdjusted.r=clamp(rgbAdjusted.r+rgb.r,0.0,1.0);rgbAdjusted.g=clamp(rgbAdjusted.g+rgb.g,0.0,1.0);rgbAdjusted.b=clamp(rgbAdjusted.b+rgb.b,0.0,1.0);return rgbAdjusted;}void main(){vec4 diffuseColor=vec4(diffuse,opacity);\n#include <clipping_planes_fragment>\nvec3 outgoingLight=vec3(0.0);\n#include <logdepthbuf_fragment>\n#include <map_particle_fragment>\n#include <color_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\nvec3 originalColor=diffuseColor.rgb;vec3 gradedColor=grading(originalColor);vec3 finalColor=mix(originalColor,gradedColor,vColorEffectFactor);if(vSonarFactor>0.0){float sonarStrength=2.0;vec3 sonarColor=finalColor;float whiteAreaFactor=smoothstep(0.25,1.0,vSonarFactor);vec3 whiteColor=sonarColor;whiteColor.rgb+=whiteAreaFactor*sonarStrength*0.4;whiteColor=clamp(whiteColor,0.0,1.0);finalColor=mix(finalColor,whiteColor,vSonarFactor);}outgoingLight=finalColor;\n#include <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\ngl_FragColor.a*=vAlpha;}";
|
|
37419
37431
|
const main$1 = "in vec3 position;void main(){gl_Position=vec4(position,1.0);}";
|
|
37420
37432
|
const main = "precision highp float;precision highp int;uniform vec3 viewOrigin;uniform uint vertexCount;uniform highp usampler2D splatTexture;uniform highp usampler2D generalTexture;uniform highp usampler2D transformTexture;uniform uint transformTextureWidth;out vec4 fragColor;const uint TEXTURE_WIDTH=1024u;const float INV_255=1.0/255.0;const float INF=1.0/0.0;ivec2 getSplatCoord(uint indices){uint u=indices&0x3ffu;uint v=indices>>10;return ivec2(u,v);}vec3 getPosition(uvec4 packed){return vec4(unpackHalf2x16(packed.x),unpackHalf2x16(packed.y&0xffffu)).xyz;}mat3 generateRotationScaleMatrix(vec4 q,float s){float x=q.x;float y=q.y;float z=q.z;float w=q.w;float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float xz=x*z;float yz=y*z;float wx=w*x;float wy=w*y;float wz=w*z;return mat3(1.0-2.0*(yy+zz),2.0*(xy+wz),2.0*(xz-wy),2.0*(xy-wz),1.0-2.0*(xx+zz),2.0*(yz+wx),2.0*(xz+wy),2.0*(yz-wx),1.0-2.0*(xx+yy))*s;}void restoreTransform(in uint index,in uint width,out vec3 t,out float s,out vec4 q){uint u=index % width;uint v=uint(floor(float(index)/float(width)));uvec4 transform=texelFetch(transformTexture,ivec2(u,v),0);vec2 r=unpackHalf2x16(transform.x);vec2 g=unpackHalf2x16(transform.y);vec2 b=unpackHalf2x16(transform.z);vec2 a=unpackHalf2x16(transform.w);t=vec3(-r,g.x);s=g.y;q=vec4(b,a);}void unpack4to8(in uint packed,out uint high,out uint low){high=(packed>>4u)&0xFu;low=packed&0xFu;}float getDistance(uint indices){if(indices>=vertexCount){return INF;}ivec2 uv=getSplatCoord(indices);uvec4 packed=texelFetch(splatTexture,uv,0);uvec4 general=texelFetch(generalTexture,uv,0);vec3 tPosition=vec3(0.0);float tScale=1.0;vec4 tRotation=vec4(0.0);uint high,low;unpack4to8(general.a,high,low);restoreTransform(low,transformTextureWidth,tPosition,tScale,tRotation);mat3 mm=generateRotationScaleMatrix(tRotation,tScale);vec3 position=getPosition(packed);position=mm*position+tPosition;return length(position-viewOrigin);}void main(){uvec2 u=uvec2(gl_FragCoord.st);uint indices=(u.s+u.t*TEXTURE_WIDTH)*2u;float distance1=getDistance(indices);float distance2=getDistance(indices+1u);vec2 combine=vec2(distance1,distance2);uint packedUint=packHalf2x16(combine);uvec4 rgba=uvec4(packedUint&0xffu,(packedUint>>8u)&0xffu,(packedUint>>16u)&0xffu,(packedUint>>24u)&0xffu);fragColor=vec4(rgba)*INV_255;}";
|
|
37421
|
-
const jsContent$1 = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\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_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\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 return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (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;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\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 let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\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 dmax = state.dmax;\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 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 here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\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 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 dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\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 if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\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 from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\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 } else {\n from = _out - dist;\n do {\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 } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\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};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\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 root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\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 }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\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 if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\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 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 sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\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 state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\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 } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* 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 if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\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 _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\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 & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\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 }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n 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 & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n 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 & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\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 while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\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 return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\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) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\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 state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\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];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\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 & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\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 if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\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 inffast$1(strm, _out);\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 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];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\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 n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\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];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\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 n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\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 }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\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 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 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (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 & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (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};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\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};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\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 return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.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 if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\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 status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\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 last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\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 this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([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])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([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])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\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 /* 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 /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\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 /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\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 return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\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 strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\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 if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\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 dmax = state.dmax;\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 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 here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\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 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 dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\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 if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\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 } else {\n from = _out - dist;\n do {\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 } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\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 return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\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 if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\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 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 sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\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 } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* 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 if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\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 _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\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 }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\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 = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\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 return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\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 inflate_fast2(strm, _out);\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 if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\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 = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\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 if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(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 & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\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 if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\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 status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\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 this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const x = currentBufferFloatView[fIndex + 0];\n const y = currentBufferFloatView[fIndex + 1];\n const z = currentBufferFloatView[fIndex + 2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.collision);\n }\n};\n';
|
|
37433
|
+
const jsContent$1 = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\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_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\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 return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (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;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\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 let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\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 dmax = state.dmax;\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 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 here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\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 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 dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\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 if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\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 from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\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 } else {\n from = _out - dist;\n do {\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 } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\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};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\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 root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\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 }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\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 if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\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 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 sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\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 state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\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 } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* 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 if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\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 _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\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 & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\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 }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n 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 & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n 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 & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\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 while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\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 return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\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) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\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 state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\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];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\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 & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\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 if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\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 inffast$1(strm, _out);\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 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];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\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 n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\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];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\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 n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\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 }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\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 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 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (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 & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (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};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\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};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\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 return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.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 if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\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 status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\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 last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\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 this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([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])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([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])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\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 /* 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 /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\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 /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\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 return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\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 strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\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 if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\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 dmax = state.dmax;\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 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 here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\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 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 dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\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 if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\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 } else {\n from = _out - dist;\n do {\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 } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\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 return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\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 if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\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 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 sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\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 } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* 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 if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\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 _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\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 }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\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 = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\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 return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\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 inflate_fast2(strm, _out);\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 if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\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 = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\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 if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(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 & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\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 if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\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 status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\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 this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction unpack8to4(value) {\n const high = value >> 4 & 15;\n const low = value & 15;\n return [high, low];\n}\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst create4x4 = (translation, rotation, scale) => {\n const sx = Math.sin(rotation[0]);\n const sy = Math.sin(rotation[1]);\n const sz = Math.sin(rotation[2]);\n const cx = Math.cos(rotation[0]);\n const cy = Math.cos(rotation[1]);\n const cz = Math.cos(rotation[2]);\n const ae = cx * cz;\n const af = cx * sz;\n const be = sx * cz;\n const bf = sx * sz;\n const mat = new Float32Array(16);\n mat[0] = cy * cz * scale;\n mat[1] = (af + be * sy) * scale;\n mat[2] = (bf - ae * sy) * scale;\n mat[3] = 0;\n mat[4] = -cy * sz * scale;\n mat[5] = (ae - bf * sy) * scale;\n mat[6] = (be + af * sy) * scale;\n mat[7] = 0;\n mat[8] = sy * scale;\n mat[9] = -sx * cy * scale;\n mat[10] = cx * cy * scale;\n mat[11] = 0;\n mat[12] = translation[0];\n mat[13] = translation[1];\n mat[14] = translation[2];\n mat[15] = 1;\n return mat;\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (sourceTransform, target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n const sources = Array.isArray(sourceTransform) === true ? sourceTransform : [sourceTransform];\n const modelMatrix = sources.map((source) => {\n const t = [-source.translation.x, -source.translation.y, source.translation.z];\n const r = [source.rotation.x, source.rotation.y, source.rotation.z];\n const s = source.scale;\n return create4x4(t, r, s);\n });\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n const [meshIndex, instanceIndex] = unpack8to4(A);\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const tx = currentBufferFloatView[fIndex + 0];\n const ty = currentBufferFloatView[fIndex + 1];\n const tz = currentBufferFloatView[fIndex + 2];\n const transformed = apply4x4(modelMatrix[instanceIndex], tx, ty, tz);\n const x = transformed[0];\n const y = transformed[1];\n const z = transformed[2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.source, e.data.collision);\n }\n};\n';
|
|
37422
37434
|
const blob$1 = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent$1], { type: "text/javascript;charset=utf-8" });
|
|
37423
37435
|
function WorkerWrapper$1(options) {
|
|
37424
37436
|
let objURL;
|
|
@@ -37597,6 +37609,7 @@ const DEPTH_RENDER_TEXTURE_WIDTH_BASE = 1024;
|
|
|
37597
37609
|
const ROW_LENGTH_SPLAT = 3 * 4 + 3 * 4 + 4 + 4;
|
|
37598
37610
|
const ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;
|
|
37599
37611
|
const UPDATE_DEPTH_THRESHOLD = 5e-3;
|
|
37612
|
+
const POINT_BASE_RADIUS = 0.8;
|
|
37600
37613
|
const FEATURE_BACKGROUND_EXISTS = "background-sphere-exists";
|
|
37601
37614
|
const FEATURE_BITS = [FEATURE_BACKGROUND_EXISTS];
|
|
37602
37615
|
const CHUNK_INDEX_BACKGROUND = 0;
|
|
@@ -37616,6 +37629,9 @@ const _getDepthRenderTextureWidth = (count) => {
|
|
|
37616
37629
|
const height = Math.ceil(Math.ceil(count / 2) / width);
|
|
37617
37630
|
return { width, height };
|
|
37618
37631
|
};
|
|
37632
|
+
const dummyObject3D = new Object3D();
|
|
37633
|
+
const dummyVector3 = new Vector3();
|
|
37634
|
+
const dummyQuaternion = new Quaternion();
|
|
37619
37635
|
class TavioMesh extends EventEmitter {
|
|
37620
37636
|
perspectiveCamera;
|
|
37621
37637
|
// カメラ
|
|
@@ -37730,6 +37746,8 @@ class TavioMesh extends EventEmitter {
|
|
|
37730
37746
|
// wasmソート用ワーカークライアント
|
|
37731
37747
|
isSorting;
|
|
37732
37748
|
// ソート処理中かどうかのフラグ
|
|
37749
|
+
hasBillboard;
|
|
37750
|
+
// ビルボード処理するインスタンスを内包しているかどうか
|
|
37733
37751
|
lastViewProjectionMatrix;
|
|
37734
37752
|
// 直近のビュープロジェクション行列を保持
|
|
37735
37753
|
depthRenderTarget;
|
|
@@ -37820,6 +37838,7 @@ class TavioMesh extends EventEmitter {
|
|
|
37820
37838
|
this.mainProperties = null;
|
|
37821
37839
|
this.useWasmSort = false;
|
|
37822
37840
|
this.isSorting = false;
|
|
37841
|
+
this.hasBillboard = false;
|
|
37823
37842
|
this.lastViewProjectionMatrix = [];
|
|
37824
37843
|
this.lastViewProjectionMatrix[2] = 0;
|
|
37825
37844
|
this.lastViewProjectionMatrix[6] = 0;
|
|
@@ -37867,6 +37886,7 @@ class TavioMesh extends EventEmitter {
|
|
|
37867
37886
|
* @param option - ロード・パース関連のオプション
|
|
37868
37887
|
*/
|
|
37869
37888
|
async loadTavio(url, option) {
|
|
37889
|
+
this.setupFlags();
|
|
37870
37890
|
this.setupTavioWorker();
|
|
37871
37891
|
this.setUsingSphericalHarmonics(option?.useSphericalHarmonics ?? true);
|
|
37872
37892
|
this.setUsingWasmSort(false);
|
|
@@ -37905,7 +37925,8 @@ class TavioMesh extends EventEmitter {
|
|
|
37905
37925
|
translation: new Vector3(0, 0, 0),
|
|
37906
37926
|
rotation: new Euler(0, 0, 0),
|
|
37907
37927
|
scale: 1
|
|
37908
|
-
}
|
|
37928
|
+
},
|
|
37929
|
+
billboard: false
|
|
37909
37930
|
});
|
|
37910
37931
|
const getPropertyInfo = async (start, data) => {
|
|
37911
37932
|
const view = new DataView(data.buffer);
|
|
@@ -38435,6 +38456,7 @@ class TavioMesh extends EventEmitter {
|
|
|
38435
38456
|
* @param option - ロード・パース関連のオプション
|
|
38436
38457
|
*/
|
|
38437
38458
|
async loadPly(url, option) {
|
|
38459
|
+
this.setupFlags();
|
|
38438
38460
|
this.setupTavioWorker();
|
|
38439
38461
|
this.setUsingSphericalHarmonics(option?.useSphericalHarmonics ?? true);
|
|
38440
38462
|
this.setUsingWasmSort(false);
|
|
@@ -38465,7 +38487,8 @@ class TavioMesh extends EventEmitter {
|
|
|
38465
38487
|
translation: new Vector3(0, 0, 0),
|
|
38466
38488
|
rotation: new Euler(0, 0, 0),
|
|
38467
38489
|
scale: 1
|
|
38468
|
-
}
|
|
38490
|
+
},
|
|
38491
|
+
billboard: false
|
|
38469
38492
|
});
|
|
38470
38493
|
const onFirstRead = (data) => {
|
|
38471
38494
|
header = PlyDecoder.decodeHeader(data.buffer);
|
|
@@ -38648,6 +38671,7 @@ class TavioMesh extends EventEmitter {
|
|
|
38648
38671
|
* @param url - 読み込む .splat ファイル
|
|
38649
38672
|
*/
|
|
38650
38673
|
async loadSplat(url) {
|
|
38674
|
+
this.setupFlags();
|
|
38651
38675
|
this.setupTavioWorker();
|
|
38652
38676
|
this.setUsingSphericalHarmonics(false);
|
|
38653
38677
|
this.setUsingWasmSort(false);
|
|
@@ -38678,7 +38702,8 @@ class TavioMesh extends EventEmitter {
|
|
|
38678
38702
|
translation: new Vector3(0, 0, 0),
|
|
38679
38703
|
rotation: new Euler(0, 0, 0),
|
|
38680
38704
|
scale: 1
|
|
38681
|
-
}
|
|
38705
|
+
},
|
|
38706
|
+
billboard: false
|
|
38682
38707
|
});
|
|
38683
38708
|
const loader = new StreamLoader();
|
|
38684
38709
|
loader.on("getcontentbytelength", (byte) => {
|
|
@@ -38949,6 +38974,208 @@ class TavioMesh extends EventEmitter {
|
|
|
38949
38974
|
await loader.load(url);
|
|
38950
38975
|
});
|
|
38951
38976
|
}
|
|
38977
|
+
/**
|
|
38978
|
+
* 画像形式のリソースをロードする
|
|
38979
|
+
* @param url - 読み込む画像ファイル
|
|
38980
|
+
*/
|
|
38981
|
+
async loadImage(url) {
|
|
38982
|
+
this.setupFlags();
|
|
38983
|
+
this.setupTavioWorker();
|
|
38984
|
+
this.setUsingSphericalHarmonics(false);
|
|
38985
|
+
this.setUsingWasmSort(false);
|
|
38986
|
+
return new Promise(async (resolve, reject) => {
|
|
38987
|
+
let currentOffset = 0;
|
|
38988
|
+
let countOfPoints = 0;
|
|
38989
|
+
const index = this.sourceProperty.length;
|
|
38990
|
+
const isFirst = index === 0;
|
|
38991
|
+
if (isFirst !== true) {
|
|
38992
|
+
this.sourceProperty.forEach((prop) => {
|
|
38993
|
+
currentOffset += prop.vertexCount;
|
|
38994
|
+
});
|
|
38995
|
+
}
|
|
38996
|
+
this.sourceProperty.push({
|
|
38997
|
+
ready: false,
|
|
38998
|
+
index,
|
|
38999
|
+
type: "image",
|
|
39000
|
+
vertexCount: 0,
|
|
39001
|
+
vertexOffset: currentOffset,
|
|
39002
|
+
featureBits: null,
|
|
39003
|
+
containmentRadius: null,
|
|
39004
|
+
magicNumber: "",
|
|
39005
|
+
majorVersion: 0,
|
|
39006
|
+
minorVersion: 0,
|
|
39007
|
+
transform: {
|
|
39008
|
+
translation: new Vector3(0, 0, 0),
|
|
39009
|
+
rotation: new Euler(0, 0, 0),
|
|
39010
|
+
scale: 1
|
|
39011
|
+
},
|
|
39012
|
+
billboard: false
|
|
39013
|
+
});
|
|
39014
|
+
const response = await fetch(url);
|
|
39015
|
+
const blob2 = await response.blob();
|
|
39016
|
+
const byte = blob2.size;
|
|
39017
|
+
this.emit("getcontentbytelength", { byte });
|
|
39018
|
+
const img = new Image();
|
|
39019
|
+
img.addEventListener("load", () => {
|
|
39020
|
+
const splatSource = this.convertImageSource(img);
|
|
39021
|
+
countOfPoints = splatSource.count;
|
|
39022
|
+
if (countOfPoints === 0) {
|
|
39023
|
+
throw new Error("[TavioMesh]: Invalid resource");
|
|
39024
|
+
}
|
|
39025
|
+
this.gaussianCount = currentOffset + countOfPoints;
|
|
39026
|
+
this.setupGeometry(this.gaussianCount);
|
|
39027
|
+
this.sourceProperty[index].vertexCount = countOfPoints;
|
|
39028
|
+
const isEncodeEnabled = false;
|
|
39029
|
+
if (this.usingSharedArrayBuffer === true) {
|
|
39030
|
+
this.sharedData = this.allocateSharedData(
|
|
39031
|
+
index,
|
|
39032
|
+
currentOffset,
|
|
39033
|
+
0,
|
|
39034
|
+
countOfPoints,
|
|
39035
|
+
isEncodeEnabled
|
|
39036
|
+
);
|
|
39037
|
+
this.gaussianData = this.sharedData.gaussianData;
|
|
39038
|
+
this.gaussianIndexData = this.sharedData.gaussianIndexData;
|
|
39039
|
+
this.gaussianOrderData = this.sharedData.gaussianOrderData;
|
|
39040
|
+
this.gaussianGeneralData = this.sharedData.gaussianGeneralData;
|
|
39041
|
+
this.sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
|
|
39042
|
+
this.currentSelectionCount = 0;
|
|
39043
|
+
this.worker.postMessage({
|
|
39044
|
+
buffer: this.gaussianData.buffer,
|
|
39045
|
+
indexBuffer: this.gaussianIndexData.buffer,
|
|
39046
|
+
orderBuffer: this.gaussianOrderData.buffer,
|
|
39047
|
+
shBuffer: this.sphericalHarmonicsData.buffer,
|
|
39048
|
+
generalBuffer: this.gaussianGeneralData.buffer,
|
|
39049
|
+
vertexCount: this.gaussianCount,
|
|
39050
|
+
usingSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39051
|
+
offset: currentOffset
|
|
39052
|
+
});
|
|
39053
|
+
} else {
|
|
39054
|
+
const textureWidth = TEXTURE_WIDTH_BASE;
|
|
39055
|
+
const textureHeight = Math.ceil(this.gaussianCount / textureWidth);
|
|
39056
|
+
const gaussianDataSize = this.gaussianCount * ROW_LENGTH_TAVIO;
|
|
39057
|
+
const generalDataSize = textureWidth * textureHeight * 4;
|
|
39058
|
+
const shDataSize = this.gaussianCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4;
|
|
39059
|
+
this.gaussianData = null;
|
|
39060
|
+
this.sphericalHarmonicsData = null;
|
|
39061
|
+
if (currentOffset > 0) {
|
|
39062
|
+
const previousGeneralData = this.gaussianGeneralData;
|
|
39063
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
39064
|
+
this.gaussianGeneralData.set(previousGeneralData);
|
|
39065
|
+
} else {
|
|
39066
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
39067
|
+
}
|
|
39068
|
+
this.gaussianIndexData = null;
|
|
39069
|
+
const { width, height } = _getDepthRenderTextureWidth(this.gaussianCount);
|
|
39070
|
+
this.gaussianOrderData = new Uint8Array(width * height * 4);
|
|
39071
|
+
this.currentSelectionCount = 0;
|
|
39072
|
+
this.worker.postMessage({
|
|
39073
|
+
vertexCount: this.gaussianCount,
|
|
39074
|
+
usingSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39075
|
+
offset: currentOffset,
|
|
39076
|
+
gaussianDataSize,
|
|
39077
|
+
generalDataSize,
|
|
39078
|
+
shDataSize
|
|
39079
|
+
});
|
|
39080
|
+
}
|
|
39081
|
+
this.setupTransformData(index, currentOffset, this.gaussianCount);
|
|
39082
|
+
this.emit("convert", { count: this.gaussianCount });
|
|
39083
|
+
this.setupPoints(splatSource.position32);
|
|
39084
|
+
this.setColorIntoPoints(splatSource.color8);
|
|
39085
|
+
if (isFirst === true) {
|
|
39086
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = splatSource.min.scale.x;
|
|
39087
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = splatSource.min.scale.y;
|
|
39088
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = splatSource.min.scale.z;
|
|
39089
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = splatSource.min.alpha;
|
|
39090
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = splatSource.max.scale.x;
|
|
39091
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = splatSource.max.scale.y;
|
|
39092
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = splatSource.max.scale.z;
|
|
39093
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = splatSource.max.alpha;
|
|
39094
|
+
this.worker.postMessage({
|
|
39095
|
+
updateTexture: true,
|
|
39096
|
+
buffer: splatSource.converted.buffer
|
|
39097
|
+
});
|
|
39098
|
+
} else {
|
|
39099
|
+
const preMinX = this.gaussianMaterial.uniforms.scaleAlphaMin.value.x;
|
|
39100
|
+
const preMinY = this.gaussianMaterial.uniforms.scaleAlphaMin.value.y;
|
|
39101
|
+
const preMinZ = this.gaussianMaterial.uniforms.scaleAlphaMin.value.z;
|
|
39102
|
+
const preMaxX = this.gaussianMaterial.uniforms.scaleAlphaMax.value.x;
|
|
39103
|
+
const preMaxY = this.gaussianMaterial.uniforms.scaleAlphaMax.value.y;
|
|
39104
|
+
const preMaxZ = this.gaussianMaterial.uniforms.scaleAlphaMax.value.z;
|
|
39105
|
+
const previousScale = {
|
|
39106
|
+
min: [
|
|
39107
|
+
preMinX,
|
|
39108
|
+
preMinY,
|
|
39109
|
+
preMinZ
|
|
39110
|
+
],
|
|
39111
|
+
max: [
|
|
39112
|
+
preMaxX,
|
|
39113
|
+
preMaxY,
|
|
39114
|
+
preMaxZ
|
|
39115
|
+
]
|
|
39116
|
+
};
|
|
39117
|
+
const currentScale = {
|
|
39118
|
+
min: [
|
|
39119
|
+
splatSource.min.scale.x,
|
|
39120
|
+
splatSource.min.scale.y,
|
|
39121
|
+
splatSource.min.scale.z
|
|
39122
|
+
],
|
|
39123
|
+
max: [
|
|
39124
|
+
splatSource.max.scale.x,
|
|
39125
|
+
splatSource.max.scale.y,
|
|
39126
|
+
splatSource.max.scale.z
|
|
39127
|
+
]
|
|
39128
|
+
};
|
|
39129
|
+
const curMinX = Math.min(splatSource.min.scale.x, preMinX);
|
|
39130
|
+
const curMinY = Math.min(splatSource.min.scale.y, preMinY);
|
|
39131
|
+
const curMinZ = Math.min(splatSource.min.scale.z, preMinZ);
|
|
39132
|
+
const curMaxX = Math.max(splatSource.max.scale.x, preMaxX);
|
|
39133
|
+
const curMaxY = Math.max(splatSource.max.scale.y, preMaxY);
|
|
39134
|
+
const curMaxZ = Math.max(splatSource.max.scale.z, preMaxZ);
|
|
39135
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = curMinX;
|
|
39136
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = curMinY;
|
|
39137
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = curMinZ;
|
|
39138
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = curMaxX;
|
|
39139
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = curMaxY;
|
|
39140
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = curMaxZ;
|
|
39141
|
+
const preMin = this.gaussianMaterial.uniforms.scaleAlphaMin.value.w;
|
|
39142
|
+
const preMax = this.gaussianMaterial.uniforms.scaleAlphaMax.value.w;
|
|
39143
|
+
const previousAlpha = {
|
|
39144
|
+
min: [preMin],
|
|
39145
|
+
max: [preMax]
|
|
39146
|
+
};
|
|
39147
|
+
const currentAlpha = {
|
|
39148
|
+
min: [splatSource.min.alpha],
|
|
39149
|
+
max: [splatSource.max.alpha]
|
|
39150
|
+
};
|
|
39151
|
+
const curMin = Math.min(splatSource.min.alpha, preMin);
|
|
39152
|
+
const curMax = Math.max(splatSource.max.alpha, preMax);
|
|
39153
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = curMin;
|
|
39154
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = curMax;
|
|
39155
|
+
this.worker.postMessage({
|
|
39156
|
+
updateTexture: true,
|
|
39157
|
+
buffer: splatSource.converted.buffer,
|
|
39158
|
+
scale: currentScale,
|
|
39159
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39160
|
+
alpha: currentAlpha,
|
|
39161
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39162
|
+
previousScale,
|
|
39163
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39164
|
+
previousAlpha
|
|
39165
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39166
|
+
});
|
|
39167
|
+
}
|
|
39168
|
+
this.emit("load", { length: byte });
|
|
39169
|
+
}, false);
|
|
39170
|
+
const listener = () => {
|
|
39171
|
+
this.sourceProperty[index].ready = true;
|
|
39172
|
+
resolve();
|
|
39173
|
+
};
|
|
39174
|
+
this.once("finallyupdate", listener);
|
|
39175
|
+
const objectURL = URL.createObjectURL(blob2);
|
|
39176
|
+
img.src = objectURL;
|
|
39177
|
+
});
|
|
39178
|
+
}
|
|
38952
39179
|
/**
|
|
38953
39180
|
* tavio 形式のリソースをロードする
|
|
38954
39181
|
* @param url - 読み込む .tavio ファイル
|
|
@@ -38965,6 +39192,7 @@ class TavioMesh extends EventEmitter {
|
|
|
38965
39192
|
useSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
38966
39193
|
threadCount
|
|
38967
39194
|
});
|
|
39195
|
+
this.setupFlags();
|
|
38968
39196
|
this.setupTavioWorker();
|
|
38969
39197
|
this.setUsingSphericalHarmonics(options?.useSphericalHarmonics ?? true);
|
|
38970
39198
|
this.setUsingWasmSort(true);
|
|
@@ -39135,6 +39363,347 @@ class TavioMesh extends EventEmitter {
|
|
|
39135
39363
|
async saveTavioWasm(filename, options) {
|
|
39136
39364
|
throw new Error("実装されていません");
|
|
39137
39365
|
}
|
|
39366
|
+
/**
|
|
39367
|
+
* canvas 要素からガウシアンを生成してシーンに追加する
|
|
39368
|
+
* @param canvas - 対象となる canvas 要素
|
|
39369
|
+
*/
|
|
39370
|
+
async loadCanvas(canvas) {
|
|
39371
|
+
this.setupFlags();
|
|
39372
|
+
this.setupTavioWorker();
|
|
39373
|
+
this.setUsingSphericalHarmonics(false);
|
|
39374
|
+
this.setUsingWasmSort(false);
|
|
39375
|
+
return new Promise((resolve) => {
|
|
39376
|
+
const listener = () => {
|
|
39377
|
+
this.sourceProperty[index].ready = true;
|
|
39378
|
+
resolve();
|
|
39379
|
+
};
|
|
39380
|
+
this.once("finallyupdate", listener);
|
|
39381
|
+
let currentOffset = 0;
|
|
39382
|
+
let countOfPoints = 0;
|
|
39383
|
+
const index = this.sourceProperty.length;
|
|
39384
|
+
const isFirst = index === 0;
|
|
39385
|
+
if (isFirst !== true) {
|
|
39386
|
+
this.sourceProperty.forEach((prop) => {
|
|
39387
|
+
currentOffset += prop.vertexCount;
|
|
39388
|
+
});
|
|
39389
|
+
}
|
|
39390
|
+
this.sourceProperty.push({
|
|
39391
|
+
ready: false,
|
|
39392
|
+
index,
|
|
39393
|
+
type: "canvas",
|
|
39394
|
+
vertexCount: 0,
|
|
39395
|
+
vertexOffset: currentOffset,
|
|
39396
|
+
featureBits: null,
|
|
39397
|
+
containmentRadius: null,
|
|
39398
|
+
magicNumber: "",
|
|
39399
|
+
majorVersion: 0,
|
|
39400
|
+
minorVersion: 0,
|
|
39401
|
+
transform: {
|
|
39402
|
+
translation: new Vector3(0, 0, 0),
|
|
39403
|
+
rotation: new Euler(0, 0, 0),
|
|
39404
|
+
scale: 1
|
|
39405
|
+
},
|
|
39406
|
+
billboard: false
|
|
39407
|
+
});
|
|
39408
|
+
this.emit("getcontentbytelength", null);
|
|
39409
|
+
const splatSource = this.convertImageSource(canvas);
|
|
39410
|
+
countOfPoints = splatSource.count;
|
|
39411
|
+
if (countOfPoints === 0) {
|
|
39412
|
+
throw new Error("[TavioMesh]: Invalid resource");
|
|
39413
|
+
}
|
|
39414
|
+
this.gaussianCount = currentOffset + countOfPoints;
|
|
39415
|
+
this.setupGeometry(this.gaussianCount);
|
|
39416
|
+
this.sourceProperty[index].vertexCount = countOfPoints;
|
|
39417
|
+
const isEncodeEnabled = false;
|
|
39418
|
+
if (this.usingSharedArrayBuffer === true) {
|
|
39419
|
+
this.sharedData = this.allocateSharedData(
|
|
39420
|
+
index,
|
|
39421
|
+
currentOffset,
|
|
39422
|
+
0,
|
|
39423
|
+
countOfPoints,
|
|
39424
|
+
isEncodeEnabled
|
|
39425
|
+
);
|
|
39426
|
+
this.gaussianData = this.sharedData.gaussianData;
|
|
39427
|
+
this.gaussianIndexData = this.sharedData.gaussianIndexData;
|
|
39428
|
+
this.gaussianOrderData = this.sharedData.gaussianOrderData;
|
|
39429
|
+
this.gaussianGeneralData = this.sharedData.gaussianGeneralData;
|
|
39430
|
+
this.sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
|
|
39431
|
+
this.currentSelectionCount = 0;
|
|
39432
|
+
this.worker.postMessage({
|
|
39433
|
+
buffer: this.gaussianData.buffer,
|
|
39434
|
+
indexBuffer: this.gaussianIndexData.buffer,
|
|
39435
|
+
orderBuffer: this.gaussianOrderData.buffer,
|
|
39436
|
+
shBuffer: this.sphericalHarmonicsData.buffer,
|
|
39437
|
+
generalBuffer: this.gaussianGeneralData.buffer,
|
|
39438
|
+
vertexCount: this.gaussianCount,
|
|
39439
|
+
usingSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39440
|
+
offset: currentOffset
|
|
39441
|
+
});
|
|
39442
|
+
} else {
|
|
39443
|
+
const textureWidth = TEXTURE_WIDTH_BASE;
|
|
39444
|
+
const textureHeight = Math.ceil(this.gaussianCount / textureWidth);
|
|
39445
|
+
const gaussianDataSize = this.gaussianCount * ROW_LENGTH_TAVIO;
|
|
39446
|
+
const generalDataSize = textureWidth * textureHeight * 4;
|
|
39447
|
+
const shDataSize = this.gaussianCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4;
|
|
39448
|
+
this.gaussianData = null;
|
|
39449
|
+
this.sphericalHarmonicsData = null;
|
|
39450
|
+
if (currentOffset > 0) {
|
|
39451
|
+
const previousGeneralData = this.gaussianGeneralData;
|
|
39452
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
39453
|
+
this.gaussianGeneralData.set(previousGeneralData);
|
|
39454
|
+
} else {
|
|
39455
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
39456
|
+
}
|
|
39457
|
+
this.gaussianIndexData = null;
|
|
39458
|
+
const { width, height } = _getDepthRenderTextureWidth(this.gaussianCount);
|
|
39459
|
+
this.gaussianOrderData = new Uint8Array(width * height * 4);
|
|
39460
|
+
this.currentSelectionCount = 0;
|
|
39461
|
+
this.worker.postMessage({
|
|
39462
|
+
vertexCount: this.gaussianCount,
|
|
39463
|
+
usingSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39464
|
+
offset: currentOffset,
|
|
39465
|
+
gaussianDataSize,
|
|
39466
|
+
generalDataSize,
|
|
39467
|
+
shDataSize
|
|
39468
|
+
});
|
|
39469
|
+
}
|
|
39470
|
+
this.setupTransformData(index, currentOffset, this.gaussianCount);
|
|
39471
|
+
this.emit("convert", { count: this.gaussianCount });
|
|
39472
|
+
this.setupPoints(splatSource.position32);
|
|
39473
|
+
this.setColorIntoPoints(splatSource.color8);
|
|
39474
|
+
if (isFirst === true) {
|
|
39475
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = splatSource.min.scale.x;
|
|
39476
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = splatSource.min.scale.y;
|
|
39477
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = splatSource.min.scale.z;
|
|
39478
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = splatSource.min.alpha;
|
|
39479
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = splatSource.max.scale.x;
|
|
39480
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = splatSource.max.scale.y;
|
|
39481
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = splatSource.max.scale.z;
|
|
39482
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = splatSource.max.alpha;
|
|
39483
|
+
this.worker.postMessage({
|
|
39484
|
+
updateTexture: true,
|
|
39485
|
+
buffer: splatSource.converted.buffer
|
|
39486
|
+
});
|
|
39487
|
+
} else {
|
|
39488
|
+
const preMinX = this.gaussianMaterial.uniforms.scaleAlphaMin.value.x;
|
|
39489
|
+
const preMinY = this.gaussianMaterial.uniforms.scaleAlphaMin.value.y;
|
|
39490
|
+
const preMinZ = this.gaussianMaterial.uniforms.scaleAlphaMin.value.z;
|
|
39491
|
+
const preMaxX = this.gaussianMaterial.uniforms.scaleAlphaMax.value.x;
|
|
39492
|
+
const preMaxY = this.gaussianMaterial.uniforms.scaleAlphaMax.value.y;
|
|
39493
|
+
const preMaxZ = this.gaussianMaterial.uniforms.scaleAlphaMax.value.z;
|
|
39494
|
+
const previousScale = {
|
|
39495
|
+
min: [
|
|
39496
|
+
preMinX,
|
|
39497
|
+
preMinY,
|
|
39498
|
+
preMinZ
|
|
39499
|
+
],
|
|
39500
|
+
max: [
|
|
39501
|
+
preMaxX,
|
|
39502
|
+
preMaxY,
|
|
39503
|
+
preMaxZ
|
|
39504
|
+
]
|
|
39505
|
+
};
|
|
39506
|
+
const currentScale = {
|
|
39507
|
+
min: [
|
|
39508
|
+
splatSource.min.scale.x,
|
|
39509
|
+
splatSource.min.scale.y,
|
|
39510
|
+
splatSource.min.scale.z
|
|
39511
|
+
],
|
|
39512
|
+
max: [
|
|
39513
|
+
splatSource.max.scale.x,
|
|
39514
|
+
splatSource.max.scale.y,
|
|
39515
|
+
splatSource.max.scale.z
|
|
39516
|
+
]
|
|
39517
|
+
};
|
|
39518
|
+
const curMinX = Math.min(splatSource.min.scale.x, preMinX);
|
|
39519
|
+
const curMinY = Math.min(splatSource.min.scale.y, preMinY);
|
|
39520
|
+
const curMinZ = Math.min(splatSource.min.scale.z, preMinZ);
|
|
39521
|
+
const curMaxX = Math.max(splatSource.max.scale.x, preMaxX);
|
|
39522
|
+
const curMaxY = Math.max(splatSource.max.scale.y, preMaxY);
|
|
39523
|
+
const curMaxZ = Math.max(splatSource.max.scale.z, preMaxZ);
|
|
39524
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = curMinX;
|
|
39525
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = curMinY;
|
|
39526
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = curMinZ;
|
|
39527
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = curMaxX;
|
|
39528
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = curMaxY;
|
|
39529
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = curMaxZ;
|
|
39530
|
+
const preMin = this.gaussianMaterial.uniforms.scaleAlphaMin.value.w;
|
|
39531
|
+
const preMax = this.gaussianMaterial.uniforms.scaleAlphaMax.value.w;
|
|
39532
|
+
const previousAlpha = {
|
|
39533
|
+
min: [preMin],
|
|
39534
|
+
max: [preMax]
|
|
39535
|
+
};
|
|
39536
|
+
const currentAlpha = {
|
|
39537
|
+
min: [splatSource.min.alpha],
|
|
39538
|
+
max: [splatSource.max.alpha]
|
|
39539
|
+
};
|
|
39540
|
+
const curMin = Math.min(splatSource.min.alpha, preMin);
|
|
39541
|
+
const curMax = Math.max(splatSource.max.alpha, preMax);
|
|
39542
|
+
this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = curMin;
|
|
39543
|
+
this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = curMax;
|
|
39544
|
+
this.worker.postMessage({
|
|
39545
|
+
updateTexture: true,
|
|
39546
|
+
buffer: splatSource.converted.buffer,
|
|
39547
|
+
scale: currentScale,
|
|
39548
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39549
|
+
alpha: currentAlpha,
|
|
39550
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39551
|
+
previousScale,
|
|
39552
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39553
|
+
previousAlpha
|
|
39554
|
+
// 既存のデータとの統合時のみ付与されるプロパティ
|
|
39555
|
+
});
|
|
39556
|
+
}
|
|
39557
|
+
});
|
|
39558
|
+
}
|
|
39559
|
+
/**
|
|
39560
|
+
* 画像や canvas 要素をパースし変換する
|
|
39561
|
+
* @param imageSource - 対象となる画像や canvas
|
|
39562
|
+
*/
|
|
39563
|
+
convertImageSource(imageSource) {
|
|
39564
|
+
const isCanvas = imageSource instanceof HTMLCanvasElement;
|
|
39565
|
+
const nWidth = isCanvas === true ? imageSource.width : imageSource.naturalWidth;
|
|
39566
|
+
const nHeight = isCanvas === true ? imageSource.height : imageSource.naturalHeight;
|
|
39567
|
+
const aspect2 = nWidth / nHeight;
|
|
39568
|
+
const cvs = document.createElement("canvas");
|
|
39569
|
+
cvs.width = nWidth;
|
|
39570
|
+
cvs.height = nHeight;
|
|
39571
|
+
const ctx = cvs.getContext("2d");
|
|
39572
|
+
ctx.imageSmoothingEnabled = true;
|
|
39573
|
+
ctx.imageSmoothingQuality = "high";
|
|
39574
|
+
ctx.drawImage(imageSource, 0, 0, nWidth, nHeight);
|
|
39575
|
+
const imageData = ctx.getImageData(0, 0, nWidth, nHeight);
|
|
39576
|
+
const data = imageData.data;
|
|
39577
|
+
let count = 0;
|
|
39578
|
+
for (let _i = 0, _j = data.length; _i < _j; _i += 4) {
|
|
39579
|
+
if (data[_i + 3] > 0) {
|
|
39580
|
+
++count;
|
|
39581
|
+
}
|
|
39582
|
+
}
|
|
39583
|
+
const position32 = new Float32Array(count * 3);
|
|
39584
|
+
const color8 = new Uint8ClampedArray(count * 3);
|
|
39585
|
+
const converted = new Uint8Array(count * ROW_LENGTH_TAVIO);
|
|
39586
|
+
let alphaMin = Infinity;
|
|
39587
|
+
let alphaMax = -Infinity;
|
|
39588
|
+
const nx = [];
|
|
39589
|
+
const ny = [];
|
|
39590
|
+
const nr = [];
|
|
39591
|
+
const ng = [];
|
|
39592
|
+
const nb = [];
|
|
39593
|
+
const na = [];
|
|
39594
|
+
const ra = [];
|
|
39595
|
+
const EPS2 = 1e-4;
|
|
39596
|
+
for (let i = 0; i < nHeight; ++i) {
|
|
39597
|
+
for (let j = 0; j < nWidth; ++j) {
|
|
39598
|
+
const i4 = (i * nWidth + j) * 4;
|
|
39599
|
+
const a = data[i4 + 3];
|
|
39600
|
+
if (a === 0) {
|
|
39601
|
+
continue;
|
|
39602
|
+
}
|
|
39603
|
+
const x = j / (nWidth - 1) - 0.5;
|
|
39604
|
+
const y = i / (nHeight - 1) - 0.5;
|
|
39605
|
+
if (aspect2 >= 1) {
|
|
39606
|
+
nx.push(x);
|
|
39607
|
+
ny.push(y / aspect2);
|
|
39608
|
+
} else {
|
|
39609
|
+
nx.push(x * aspect2);
|
|
39610
|
+
ny.push(y);
|
|
39611
|
+
}
|
|
39612
|
+
const r = data[i4 + 0];
|
|
39613
|
+
const g = data[i4 + 1];
|
|
39614
|
+
const b = data[i4 + 2];
|
|
39615
|
+
nr.push(r);
|
|
39616
|
+
ng.push(g);
|
|
39617
|
+
nb.push(b);
|
|
39618
|
+
na.push(a);
|
|
39619
|
+
const A = Math.min(Math.max(a / 255, EPS2), 1 - EPS2);
|
|
39620
|
+
const raw = Math.log(A / (1 - A));
|
|
39621
|
+
alphaMin = Math.min(alphaMin, raw);
|
|
39622
|
+
alphaMax = Math.max(alphaMax, raw);
|
|
39623
|
+
ra.push(raw);
|
|
39624
|
+
}
|
|
39625
|
+
}
|
|
39626
|
+
const qt = convertQuaternion(1, 0, 0, 0);
|
|
39627
|
+
qt.u *= 255;
|
|
39628
|
+
qt.v *= 255;
|
|
39629
|
+
qt.w *= 255;
|
|
39630
|
+
const max = Math.max(nWidth, nHeight);
|
|
39631
|
+
const scaleX = Math.log(POINT_BASE_RADIUS / max);
|
|
39632
|
+
const scaleY = Math.log(POINT_BASE_RADIUS / max);
|
|
39633
|
+
const scaleZ = Math.log(EPS2);
|
|
39634
|
+
const alphaRange = alphaMax - alphaMin;
|
|
39635
|
+
for (let k = 0; k < count; ++k) {
|
|
39636
|
+
const ir = k * ROW_LENGTH_TAVIO;
|
|
39637
|
+
const viewPosition = new Float16Array(
|
|
39638
|
+
converted.buffer,
|
|
39639
|
+
ir,
|
|
39640
|
+
3
|
|
39641
|
+
);
|
|
39642
|
+
const viewScale = new Uint8ClampedArray(
|
|
39643
|
+
converted.buffer,
|
|
39644
|
+
ir + 6,
|
|
39645
|
+
3
|
|
39646
|
+
);
|
|
39647
|
+
const viewColor = new Uint8ClampedArray(
|
|
39648
|
+
converted.buffer,
|
|
39649
|
+
ir + 9,
|
|
39650
|
+
4
|
|
39651
|
+
);
|
|
39652
|
+
const viewRotation = new Uint8ClampedArray(
|
|
39653
|
+
converted.buffer,
|
|
39654
|
+
ir + 13,
|
|
39655
|
+
3
|
|
39656
|
+
);
|
|
39657
|
+
const viewRawAlpha = new Uint8ClampedArray(
|
|
39658
|
+
converted.buffer,
|
|
39659
|
+
ir + 16,
|
|
39660
|
+
1
|
|
39661
|
+
);
|
|
39662
|
+
viewPosition[0] = nx[k];
|
|
39663
|
+
viewPosition[1] = ny[k];
|
|
39664
|
+
viewPosition[2] = 0;
|
|
39665
|
+
viewScale[0] = 0;
|
|
39666
|
+
viewScale[1] = 0;
|
|
39667
|
+
viewScale[2] = 0;
|
|
39668
|
+
viewColor[0] = nr[k];
|
|
39669
|
+
viewColor[1] = ng[k];
|
|
39670
|
+
viewColor[2] = nb[k];
|
|
39671
|
+
viewColor[3] = na[k];
|
|
39672
|
+
viewRotation[0] = qt.u;
|
|
39673
|
+
viewRotation[1] = qt.v;
|
|
39674
|
+
viewRotation[2] = qt.w;
|
|
39675
|
+
viewRawAlpha[0] = (ra[k] - alphaMin) / alphaRange * 255;
|
|
39676
|
+
const i3 = k * 3;
|
|
39677
|
+
position32[i3 + 0] = nx[k];
|
|
39678
|
+
position32[i3 + 1] = ny[k];
|
|
39679
|
+
position32[i3 + 2] = 0;
|
|
39680
|
+
color8[i3 + 0] = nr[k];
|
|
39681
|
+
color8[i3 + 1] = ng[k];
|
|
39682
|
+
color8[i3 + 2] = nb[k];
|
|
39683
|
+
}
|
|
39684
|
+
return {
|
|
39685
|
+
count,
|
|
39686
|
+
position32,
|
|
39687
|
+
color8,
|
|
39688
|
+
converted,
|
|
39689
|
+
min: {
|
|
39690
|
+
alpha: alphaMin,
|
|
39691
|
+
scale: {
|
|
39692
|
+
x: scaleX,
|
|
39693
|
+
y: scaleY,
|
|
39694
|
+
z: scaleZ
|
|
39695
|
+
}
|
|
39696
|
+
},
|
|
39697
|
+
max: {
|
|
39698
|
+
alpha: alphaMax,
|
|
39699
|
+
scale: {
|
|
39700
|
+
x: scaleX,
|
|
39701
|
+
y: scaleY,
|
|
39702
|
+
z: scaleZ
|
|
39703
|
+
}
|
|
39704
|
+
}
|
|
39705
|
+
};
|
|
39706
|
+
}
|
|
39138
39707
|
/**
|
|
39139
39708
|
* ==========================================================================
|
|
39140
39709
|
* getter / setter
|
|
@@ -39343,8 +39912,9 @@ class TavioMesh extends EventEmitter {
|
|
|
39343
39912
|
* @param translation - 平行移動
|
|
39344
39913
|
* @param rotation - 回転(オイラー角)
|
|
39345
39914
|
* @param scale - 拡大縮小(XYZ で統一のスケール)
|
|
39915
|
+
* @param force - 同時にテクスチャの内容を強制的に書き換えるかどうか
|
|
39346
39916
|
*/
|
|
39347
|
-
setTransform(index, translation, rotation, scale) {
|
|
39917
|
+
setTransform(index, translation, rotation, scale, isForce = true) {
|
|
39348
39918
|
if (this.gaussianTransformData == null || this.sourceProperty[index] == null) {
|
|
39349
39919
|
return;
|
|
39350
39920
|
}
|
|
@@ -39352,7 +39922,6 @@ class TavioMesh extends EventEmitter {
|
|
|
39352
39922
|
this.sourceProperty[index].transform.rotation.copy(rotation);
|
|
39353
39923
|
this.sourceProperty[index].transform.scale = scale;
|
|
39354
39924
|
const transformFloatView = new Float16Array(this.gaussianTransformData.buffer);
|
|
39355
|
-
const width = this.transformTextureWidth;
|
|
39356
39925
|
const q = new Quaternion().setFromEuler(rotation);
|
|
39357
39926
|
const i8 = index * 8;
|
|
39358
39927
|
transformFloatView[i8 + 0] = translation.x;
|
|
@@ -39363,22 +39932,9 @@ class TavioMesh extends EventEmitter {
|
|
|
39363
39932
|
transformFloatView[i8 + 5] = q.y;
|
|
39364
39933
|
transformFloatView[i8 + 6] = q.z;
|
|
39365
39934
|
transformFloatView[i8 + 7] = q.w;
|
|
39366
|
-
if (
|
|
39367
|
-
this.
|
|
39368
|
-
this.gaussianTransformDataTexture.needsUpdate = true;
|
|
39369
|
-
} else {
|
|
39370
|
-
this.gaussianTransformDataTexture = this.setupTransformDataTexture(
|
|
39371
|
-
this.gaussianTransformData,
|
|
39372
|
-
width,
|
|
39373
|
-
width
|
|
39374
|
-
);
|
|
39935
|
+
if (isForce === true) {
|
|
39936
|
+
this._updateTransformData();
|
|
39375
39937
|
}
|
|
39376
|
-
this.gaussianMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
|
|
39377
|
-
this.gaussianMaterial.uniforms.transformTextureWidth.value = width;
|
|
39378
|
-
this.gaussianMaterial.needsUpdate = true;
|
|
39379
|
-
this.depthRenderMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
|
|
39380
|
-
this.depthRenderMaterial.uniforms.transformTextureWidth.value = width;
|
|
39381
|
-
this.depthRenderMaterial.needsUpdate = true;
|
|
39382
39938
|
}
|
|
39383
39939
|
/**
|
|
39384
39940
|
* 指定されたインデックスの座標変換情報を返す
|
|
@@ -39397,6 +39953,69 @@ class TavioMesh extends EventEmitter {
|
|
|
39397
39953
|
scale
|
|
39398
39954
|
};
|
|
39399
39955
|
}
|
|
39956
|
+
/**
|
|
39957
|
+
* インデックスを指定してビルボードの設定を行う
|
|
39958
|
+
* @param index - インデックス
|
|
39959
|
+
* @param flag - ビルボードとして扱うかどうか
|
|
39960
|
+
*/
|
|
39961
|
+
setBillboard(index, flag) {
|
|
39962
|
+
if (this.sourceProperty[index] == null) {
|
|
39963
|
+
return null;
|
|
39964
|
+
}
|
|
39965
|
+
this.sourceProperty[index].billboard = flag;
|
|
39966
|
+
this.hasBillboard = this.sourceProperty.some((prop) => {
|
|
39967
|
+
return prop.billboard;
|
|
39968
|
+
});
|
|
39969
|
+
}
|
|
39970
|
+
/**
|
|
39971
|
+
* ビルボードのための transform 情報の更新を行う
|
|
39972
|
+
* @param camera - カメラのワールド空間上の位置
|
|
39973
|
+
*/
|
|
39974
|
+
updateBillboard(camera) {
|
|
39975
|
+
if (this.hasBillboard !== true) {
|
|
39976
|
+
return;
|
|
39977
|
+
}
|
|
39978
|
+
dummyQuaternion.setFromAxisAngle(dummyVector3.set(1, 0, 0), Math.PI);
|
|
39979
|
+
this.sourceProperty.forEach((prop, index) => {
|
|
39980
|
+
if (prop.billboard === true) {
|
|
39981
|
+
dummyObject3D.quaternion.copy(camera.quaternion);
|
|
39982
|
+
dummyObject3D.quaternion.multiply(dummyQuaternion);
|
|
39983
|
+
dummyObject3D.rotation.setFromQuaternion(dummyObject3D.quaternion);
|
|
39984
|
+
this.setTransform(
|
|
39985
|
+
index,
|
|
39986
|
+
prop.transform.translation,
|
|
39987
|
+
dummyObject3D.rotation,
|
|
39988
|
+
prop.transform.scale,
|
|
39989
|
+
false
|
|
39990
|
+
// 更新は最後にまとめて行う(テクスチャを無駄に複数回更新させないため)
|
|
39991
|
+
);
|
|
39992
|
+
}
|
|
39993
|
+
});
|
|
39994
|
+
this._updateTransformData();
|
|
39995
|
+
}
|
|
39996
|
+
/**
|
|
39997
|
+
* インスタンスごとの transform 情報をテクスチャに適用し更新する
|
|
39998
|
+
* @private
|
|
39999
|
+
*/
|
|
40000
|
+
_updateTransformData() {
|
|
40001
|
+
const width = this.transformTextureWidth;
|
|
40002
|
+
if (this.gaussianTransformDataTexture != null) {
|
|
40003
|
+
this.gaussianTransformDataTexture.source.data.data = this.gaussianTransformData;
|
|
40004
|
+
this.gaussianTransformDataTexture.needsUpdate = true;
|
|
40005
|
+
} else {
|
|
40006
|
+
this.gaussianTransformDataTexture = this.setupTransformDataTexture(
|
|
40007
|
+
this.gaussianTransformData,
|
|
40008
|
+
width,
|
|
40009
|
+
width
|
|
40010
|
+
);
|
|
40011
|
+
}
|
|
40012
|
+
this.gaussianMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
|
|
40013
|
+
this.gaussianMaterial.uniforms.transformTextureWidth.value = width;
|
|
40014
|
+
this.gaussianMaterial.needsUpdate = true;
|
|
40015
|
+
this.depthRenderMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
|
|
40016
|
+
this.depthRenderMaterial.uniforms.transformTextureWidth.value = width;
|
|
40017
|
+
this.depthRenderMaterial.needsUpdate = true;
|
|
40018
|
+
}
|
|
39400
40019
|
/**
|
|
39401
40020
|
* 自身のプロパティの状態に応じて球面調和関数に関連する uniform 変数の更新を行う
|
|
39402
40021
|
* @private
|
|
@@ -39616,6 +40235,17 @@ class TavioMesh extends EventEmitter {
|
|
|
39616
40235
|
* setup
|
|
39617
40236
|
* ==========================================================================
|
|
39618
40237
|
*/
|
|
40238
|
+
/**
|
|
40239
|
+
* データのロード前に各種フラグをセットアップする
|
|
40240
|
+
*/
|
|
40241
|
+
setupFlags() {
|
|
40242
|
+
this.initialized = false;
|
|
40243
|
+
this.initializedPoints = false;
|
|
40244
|
+
this.initializedBackground = false;
|
|
40245
|
+
this.sorted = false;
|
|
40246
|
+
this.initializedTexture = false;
|
|
40247
|
+
this.initializedColorTexture = false;
|
|
40248
|
+
}
|
|
39619
40249
|
/**
|
|
39620
40250
|
* tavio 形式用の worker をセットアップする
|
|
39621
40251
|
*/
|
|
@@ -40106,8 +40736,26 @@ class TavioMesh extends EventEmitter {
|
|
|
40106
40736
|
* @param collision - 設定する衝突判定、またはその配列
|
|
40107
40737
|
*/
|
|
40108
40738
|
setCollision(collision) {
|
|
40739
|
+
const sources = this.sourceProperty.map((prop) => {
|
|
40740
|
+
return {
|
|
40741
|
+
translation: {
|
|
40742
|
+
x: prop.transform.translation.x,
|
|
40743
|
+
y: prop.transform.translation.y,
|
|
40744
|
+
z: prop.transform.translation.z
|
|
40745
|
+
},
|
|
40746
|
+
rotation: {
|
|
40747
|
+
x: prop.transform.rotation.x,
|
|
40748
|
+
y: prop.transform.rotation.y,
|
|
40749
|
+
z: prop.transform.rotation.z
|
|
40750
|
+
},
|
|
40751
|
+
scale: prop.transform.scale
|
|
40752
|
+
};
|
|
40753
|
+
});
|
|
40109
40754
|
const collisions = Array.isArray(collision) === true ? collision : [collision];
|
|
40110
|
-
this.worker.postMessage({
|
|
40755
|
+
this.worker.postMessage({
|
|
40756
|
+
source: sources,
|
|
40757
|
+
collision: collisions
|
|
40758
|
+
});
|
|
40111
40759
|
}
|
|
40112
40760
|
/**
|
|
40113
40761
|
* 現在の衝突判定を解除する
|
|
@@ -41265,69 +41913,70 @@ class Core extends EventEmitter {
|
|
|
41265
41913
|
colorFolder.addBinding(this.parameters, "sharpness", { min: 0, max: 1 }).on("change", (v) => {
|
|
41266
41914
|
this.setColorSharpness(v.value);
|
|
41267
41915
|
});
|
|
41916
|
+
const transformTargetIndex = 0;
|
|
41268
41917
|
const transformFolder = pane.addFolder({ title: "transform" });
|
|
41269
41918
|
transformFolder.addBinding(this.parameters, "position-x", {
|
|
41270
41919
|
min: -2,
|
|
41271
41920
|
max: 2
|
|
41272
41921
|
}).on("change", (v) => {
|
|
41273
41922
|
const key = this.meshMap.keys().next().value;
|
|
41274
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41923
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41275
41924
|
prev.translation.x = v.value;
|
|
41276
|
-
this.setTransform(key,
|
|
41925
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41277
41926
|
});
|
|
41278
41927
|
transformFolder.addBinding(this.parameters, "position-y", {
|
|
41279
41928
|
min: -2,
|
|
41280
41929
|
max: 2
|
|
41281
41930
|
}).on("change", (v) => {
|
|
41282
41931
|
const key = this.meshMap.keys().next().value;
|
|
41283
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41932
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41284
41933
|
prev.translation.y = v.value;
|
|
41285
|
-
this.setTransform(key,
|
|
41934
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41286
41935
|
});
|
|
41287
41936
|
transformFolder.addBinding(this.parameters, "position-z", {
|
|
41288
41937
|
min: -2,
|
|
41289
41938
|
max: 2
|
|
41290
41939
|
}).on("change", (v) => {
|
|
41291
41940
|
const key = this.meshMap.keys().next().value;
|
|
41292
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41941
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41293
41942
|
prev.translation.z = v.value;
|
|
41294
|
-
this.setTransform(key,
|
|
41943
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41295
41944
|
});
|
|
41296
41945
|
transformFolder.addBinding(this.parameters, "rotation-x", {
|
|
41297
41946
|
min: -Math.PI,
|
|
41298
41947
|
max: Math.PI
|
|
41299
41948
|
}).on("change", (v) => {
|
|
41300
41949
|
const key = this.meshMap.keys().next().value;
|
|
41301
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41950
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41302
41951
|
prev.rotation.x = v.value;
|
|
41303
|
-
this.setTransform(key,
|
|
41952
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41304
41953
|
});
|
|
41305
41954
|
transformFolder.addBinding(this.parameters, "rotation-y", {
|
|
41306
41955
|
min: -Math.PI,
|
|
41307
41956
|
max: Math.PI
|
|
41308
41957
|
}).on("change", (v) => {
|
|
41309
41958
|
const key = this.meshMap.keys().next().value;
|
|
41310
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41959
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41311
41960
|
prev.rotation.y = v.value;
|
|
41312
|
-
this.setTransform(key,
|
|
41961
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41313
41962
|
});
|
|
41314
41963
|
transformFolder.addBinding(this.parameters, "rotation-z", {
|
|
41315
41964
|
min: -Math.PI,
|
|
41316
41965
|
max: Math.PI
|
|
41317
41966
|
}).on("change", (v) => {
|
|
41318
41967
|
const key = this.meshMap.keys().next().value;
|
|
41319
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41968
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41320
41969
|
prev.rotation.z = v.value;
|
|
41321
|
-
this.setTransform(key,
|
|
41970
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41322
41971
|
});
|
|
41323
41972
|
transformFolder.addBinding(this.parameters, "scale", {
|
|
41324
41973
|
min: 0,
|
|
41325
41974
|
max: 2
|
|
41326
41975
|
}).on("change", (v) => {
|
|
41327
41976
|
const key = this.meshMap.keys().next().value;
|
|
41328
|
-
const prev = this.meshMap.get(key).getTransform(
|
|
41977
|
+
const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
|
|
41329
41978
|
prev.scale = v.value;
|
|
41330
|
-
this.setTransform(key,
|
|
41979
|
+
this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
|
|
41331
41980
|
});
|
|
41332
41981
|
}
|
|
41333
41982
|
/**
|
|
@@ -41367,6 +42016,10 @@ class Core extends EventEmitter {
|
|
|
41367
42016
|
this.perspectiveCamera.updateProjectionMatrix();
|
|
41368
42017
|
this._updateViewportUniforms();
|
|
41369
42018
|
}
|
|
42019
|
+
setTimeout(() => {
|
|
42020
|
+
const force = true;
|
|
42021
|
+
this._renderDepthRenderTarget(force);
|
|
42022
|
+
});
|
|
41370
42023
|
});
|
|
41371
42024
|
tavioMesh.on("updatecollision", () => {
|
|
41372
42025
|
this.start();
|
|
@@ -41437,7 +42090,7 @@ class Core extends EventEmitter {
|
|
|
41437
42090
|
/**
|
|
41438
42091
|
* 既存の TavioMesh のインスタンスにデータを統合する
|
|
41439
42092
|
* @param name - このメッシュの固有名
|
|
41440
|
-
* @param url - 読み込む .
|
|
42093
|
+
* @param url - 読み込む .ply ファイル
|
|
41441
42094
|
* @param option - ロード・パース関連のオプション
|
|
41442
42095
|
*/
|
|
41443
42096
|
async concatPly(name, url, option) {
|
|
@@ -41462,8 +42115,7 @@ class Core extends EventEmitter {
|
|
|
41462
42115
|
/**
|
|
41463
42116
|
* 既存の TavioMesh のインスタンスにデータを統合する
|
|
41464
42117
|
* @param name - このメッシュの固有名
|
|
41465
|
-
* @param url - 読み込む .
|
|
41466
|
-
* @param option - ロード・パース関連のオプション
|
|
42118
|
+
* @param url - 読み込む .splat ファイル
|
|
41467
42119
|
*/
|
|
41468
42120
|
async concatSplat(name, url) {
|
|
41469
42121
|
const tavioMesh = this.meshMap.get(name);
|
|
@@ -41474,6 +42126,54 @@ class Core extends EventEmitter {
|
|
|
41474
42126
|
await tavioMesh.loadSplat(url);
|
|
41475
42127
|
await this._afterLoadMesh(name);
|
|
41476
42128
|
}
|
|
42129
|
+
/**
|
|
42130
|
+
* TavioMesh のインスタンスを生成し画像形式のリソースをロード、シーンに追加する
|
|
42131
|
+
* @param name - このメッシュの固有名
|
|
42132
|
+
* @param url - 読み込む画像ファイル
|
|
42133
|
+
*/
|
|
42134
|
+
async loadImage(name, url) {
|
|
42135
|
+
const tavioMesh = this._beforeLoadMesh(name);
|
|
42136
|
+
await tavioMesh.loadImage(url);
|
|
42137
|
+
await this._afterLoadMesh(name);
|
|
42138
|
+
}
|
|
42139
|
+
/**
|
|
42140
|
+
* 既存の TavioMesh のインスタンスにデータを統合する
|
|
42141
|
+
* @param name - このメッシュの固有名
|
|
42142
|
+
* @param url - 読み込む画像ファイル
|
|
42143
|
+
*/
|
|
42144
|
+
async concatImage(name, url) {
|
|
42145
|
+
const tavioMesh = this.meshMap.get(name);
|
|
42146
|
+
if (tavioMesh == null) {
|
|
42147
|
+
return;
|
|
42148
|
+
}
|
|
42149
|
+
this.removeTavioMesh(name);
|
|
42150
|
+
await tavioMesh.loadImage(url);
|
|
42151
|
+
await this._afterLoadMesh(name);
|
|
42152
|
+
}
|
|
42153
|
+
/**
|
|
42154
|
+
* canvas 要素から TavioMesh のインスタンスを生成し、シーンに追加する
|
|
42155
|
+
* @param name - このメッシュの固有名
|
|
42156
|
+
* @param canvas - 処理の対象となる canvas 要素
|
|
42157
|
+
*/
|
|
42158
|
+
async loadCanvas(name, canvas) {
|
|
42159
|
+
const tavioMesh = this._beforeLoadMesh(name);
|
|
42160
|
+
await tavioMesh.loadCanvas(canvas);
|
|
42161
|
+
await this._afterLoadMesh(name);
|
|
42162
|
+
}
|
|
42163
|
+
/**
|
|
42164
|
+
* 既存の TavioMesh のインスタンスにデータを統合する
|
|
42165
|
+
* @param name - このメッシュの固有名
|
|
42166
|
+
* @param canvas - 処理の対象となる canvas 要素
|
|
42167
|
+
*/
|
|
42168
|
+
async concatCanvas(name, canvas) {
|
|
42169
|
+
const tavioMesh = this.meshMap.get(name);
|
|
42170
|
+
if (tavioMesh == null) {
|
|
42171
|
+
return;
|
|
42172
|
+
}
|
|
42173
|
+
this.removeTavioMesh(name);
|
|
42174
|
+
await tavioMesh.loadCanvas(canvas);
|
|
42175
|
+
await this._afterLoadMesh(name);
|
|
42176
|
+
}
|
|
41477
42177
|
/**
|
|
41478
42178
|
* tavio 形式のリソースをロードする
|
|
41479
42179
|
* @param name - このメッシュの固有名
|
|
@@ -41611,7 +42311,7 @@ class Core extends EventEmitter {
|
|
|
41611
42311
|
}
|
|
41612
42312
|
/**
|
|
41613
42313
|
* 名前を指定した TavioMesh に含まれるインスタンスを、インデックスで指定して動かす
|
|
41614
|
-
* ※ここでいうインデックスとは load/concat
|
|
42314
|
+
* ※ここでいうインデックスとは load/concat した順番を意味する整数値(concat していない場合常に 0)
|
|
41615
42315
|
* @param name - 対象の名前
|
|
41616
42316
|
* @param index - インデックス
|
|
41617
42317
|
* @param translation - 平行移動
|
|
@@ -41623,28 +42323,19 @@ class Core extends EventEmitter {
|
|
|
41623
42323
|
if (tavioMesh == null) {
|
|
41624
42324
|
return;
|
|
41625
42325
|
}
|
|
42326
|
+
const t = new Vector3(translation.x, translation.y, translation.z);
|
|
42327
|
+
const r = new Euler(rotation.x, rotation.y, rotation.z);
|
|
41626
42328
|
tavioMesh.setTransform(
|
|
41627
42329
|
index,
|
|
41628
|
-
|
|
41629
|
-
|
|
42330
|
+
t,
|
|
42331
|
+
r,
|
|
41630
42332
|
scale
|
|
41631
42333
|
);
|
|
41632
42334
|
tavioMesh.once("sort", () => {
|
|
41633
42335
|
this.start();
|
|
41634
42336
|
});
|
|
41635
|
-
const cameraPosition = this.perspectiveCamera.position.clone();
|
|
41636
|
-
const vMatrix = this.perspectiveCamera.matrixWorldInverse;
|
|
41637
|
-
const pMatrix = this.perspectiveCamera.projectionMatrix;
|
|
41638
|
-
const vpMatrix = pMatrix.clone().multiply(vMatrix);
|
|
41639
|
-
const vpElements = vpMatrix.elements;
|
|
41640
|
-
const cpElements = cameraPosition.toArray();
|
|
41641
42337
|
const force = true;
|
|
41642
|
-
|
|
41643
|
-
vpElements,
|
|
41644
|
-
cpElements,
|
|
41645
|
-
this.renderer,
|
|
41646
|
-
force
|
|
41647
|
-
);
|
|
42338
|
+
this._renderDepthRenderTarget(force);
|
|
41648
42339
|
}
|
|
41649
42340
|
/**
|
|
41650
42341
|
* 名前を指定した TavioMesh に含まれるインスタンスの、指定されたインデックスの座標変換情報を返す
|
|
@@ -41659,6 +42350,20 @@ class Core extends EventEmitter {
|
|
|
41659
42350
|
}
|
|
41660
42351
|
return tavioMesh.getTransform(index);
|
|
41661
42352
|
}
|
|
42353
|
+
/**
|
|
42354
|
+
* 名前を指定した TavioMesh に含まれるインスタンスをビルボードとして扱うかどうかを設定する
|
|
42355
|
+
* ※ここでいうインデックスとは load/concat した順番を意味する整数値
|
|
42356
|
+
* @param name - 対象の名前
|
|
42357
|
+
* @param index - インデックス
|
|
42358
|
+
* @param flag - ビルボードとして扱うかどうか
|
|
42359
|
+
*/
|
|
42360
|
+
setBillboard(name, index, flag) {
|
|
42361
|
+
const tavioMesh = this.meshMap.get(name);
|
|
42362
|
+
if (tavioMesh == null) {
|
|
42363
|
+
return;
|
|
42364
|
+
}
|
|
42365
|
+
tavioMesh.setBillboard(index, flag);
|
|
42366
|
+
}
|
|
41662
42367
|
/**
|
|
41663
42368
|
* ==========================================================================
|
|
41664
42369
|
* general
|
|
@@ -41790,6 +42495,7 @@ class Core extends EventEmitter {
|
|
|
41790
42495
|
eyePosition: cameraPosition
|
|
41791
42496
|
};
|
|
41792
42497
|
this.meshMap.forEach((mesh) => {
|
|
42498
|
+
mesh.updateBillboard(this.perspectiveCamera);
|
|
41793
42499
|
mesh.setUniforms(uniforms);
|
|
41794
42500
|
mesh.setCameraParameterForDepthRenderTarget(
|
|
41795
42501
|
vpElements,
|
|
@@ -42057,46 +42763,81 @@ class Core extends EventEmitter {
|
|
|
42057
42763
|
mesh.setUniforms(uniforms);
|
|
42058
42764
|
});
|
|
42059
42765
|
}
|
|
42766
|
+
/**
|
|
42767
|
+
* 座標を焼き込むレンダリング処理を実行しソートを実行させる
|
|
42768
|
+
* @param isForce - 強制的に実行するかどうか
|
|
42769
|
+
*/
|
|
42770
|
+
_renderDepthRenderTarget(isForce = false) {
|
|
42771
|
+
const cameraPosition = this.perspectiveCamera.position.clone();
|
|
42772
|
+
const vMatrix = this.perspectiveCamera.matrixWorldInverse;
|
|
42773
|
+
const pMatrix = this.perspectiveCamera.projectionMatrix;
|
|
42774
|
+
const vpMatrix = pMatrix.clone().multiply(vMatrix);
|
|
42775
|
+
const vpElements = vpMatrix.elements;
|
|
42776
|
+
const cpElements = cameraPosition.toArray();
|
|
42777
|
+
this.meshMap.forEach((tavioMesh) => {
|
|
42778
|
+
tavioMesh.setCameraParameterForDepthRenderTarget(
|
|
42779
|
+
vpElements,
|
|
42780
|
+
cpElements,
|
|
42781
|
+
this.renderer,
|
|
42782
|
+
isForce
|
|
42783
|
+
);
|
|
42784
|
+
});
|
|
42785
|
+
}
|
|
42060
42786
|
/**
|
|
42061
42787
|
* ==========================================================================
|
|
42062
42788
|
* camera
|
|
42063
42789
|
* ==========================================================================
|
|
42064
42790
|
*/
|
|
42065
42791
|
/**
|
|
42066
|
-
*
|
|
42792
|
+
* カメラの現在の座標と視線方向、視野角を取得する
|
|
42067
42793
|
*/
|
|
42068
42794
|
getCameraParameter() {
|
|
42069
42795
|
const position = this.perspectiveCamera.getWorldPosition(new Vector3());
|
|
42070
42796
|
const eye = position.clone().add(this.perspectiveCamera.getWorldDirection(new Vector3()));
|
|
42797
|
+
const orbitControls = this.controlsMap.get(
|
|
42798
|
+
CONTROLS_TYPE_ORBIT
|
|
42799
|
+
);
|
|
42800
|
+
const target = orbitControls.getTarget();
|
|
42071
42801
|
const fov2 = this.perspectiveCamera.fov;
|
|
42072
|
-
return {
|
|
42802
|
+
return {
|
|
42803
|
+
position: position.toArray(),
|
|
42804
|
+
eye: eye.toArray(),
|
|
42805
|
+
target: target.toArray(),
|
|
42806
|
+
fov: fov2
|
|
42807
|
+
};
|
|
42073
42808
|
}
|
|
42074
42809
|
/**
|
|
42075
|
-
*
|
|
42810
|
+
* カメラの現在の座標と注視点、視野角を設定する
|
|
42811
|
+
* ※このメソッドは設定時、その値が即座に反映される
|
|
42076
42812
|
* @param position - 設定する座標
|
|
42077
|
-
* @param
|
|
42813
|
+
* @param target - 設定する注視点
|
|
42078
42814
|
* @param fov - 設定する視野角
|
|
42079
42815
|
*/
|
|
42080
|
-
setCameraParameter(position,
|
|
42816
|
+
setCameraParameter(position, target, fov2) {
|
|
42081
42817
|
if (this.currentControlsType === CONTROLS_TYPE_PATH) {
|
|
42082
42818
|
return;
|
|
42083
42819
|
}
|
|
42084
|
-
const p = new Vector3(position.x, position.y, position.z);
|
|
42085
|
-
const e = new Vector3(eye.x, eye.y, eye.z);
|
|
42086
|
-
const f = fov2 ?? this.perspectiveCamera.fov;
|
|
42087
|
-
this.perspectiveCamera.position.copy(p);
|
|
42088
|
-
this.perspectiveCamera.lookAt(e);
|
|
42089
|
-
const force = true;
|
|
42090
|
-
this.setTransferPosition(p, force);
|
|
42091
|
-
this.setTransferFov(f, force);
|
|
42092
42820
|
const orbitControls = this.controlsMap.get(
|
|
42093
42821
|
CONTROLS_TYPE_ORBIT
|
|
42094
42822
|
);
|
|
42095
|
-
orbitControls.setTarget(e);
|
|
42096
|
-
orbitControls.syncCameraParameter();
|
|
42097
42823
|
const flightControls = this.controlsMap.get(
|
|
42098
42824
|
CONTROLS_TYPE_FLIGHT
|
|
42099
42825
|
);
|
|
42826
|
+
if (position != null) {
|
|
42827
|
+
const p = new Vector3(position.x, position.y, position.z);
|
|
42828
|
+
this.setTransferPosition(p);
|
|
42829
|
+
this.perspectiveCamera.position.copy(p);
|
|
42830
|
+
}
|
|
42831
|
+
if (target != null) {
|
|
42832
|
+
const t = new Vector3(target.x, target.y, target.z);
|
|
42833
|
+
orbitControls.setTarget(t);
|
|
42834
|
+
this.perspectiveCamera.lookAt(t);
|
|
42835
|
+
}
|
|
42836
|
+
if (fov2 != null) {
|
|
42837
|
+
const force = true;
|
|
42838
|
+
this.setTransferFov(fov2, force);
|
|
42839
|
+
}
|
|
42840
|
+
orbitControls.syncCameraParameter();
|
|
42100
42841
|
flightControls.syncCameraParameter();
|
|
42101
42842
|
this.start();
|
|
42102
42843
|
}
|
|
@@ -42211,43 +42952,6 @@ class Core extends EventEmitter {
|
|
|
42211
42952
|
* orbit controls
|
|
42212
42953
|
* ==========================================================================
|
|
42213
42954
|
*/
|
|
42214
|
-
/**
|
|
42215
|
-
* オービットコントロールの注視点の座標を取得する
|
|
42216
|
-
* @returns 注視点の座標
|
|
42217
|
-
*/
|
|
42218
|
-
getOrbitTarget() {
|
|
42219
|
-
const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
|
|
42220
|
-
const target = controls.getTarget();
|
|
42221
|
-
return {
|
|
42222
|
-
x: target.x,
|
|
42223
|
-
y: target.y,
|
|
42224
|
-
z: target.z
|
|
42225
|
-
};
|
|
42226
|
-
}
|
|
42227
|
-
/**
|
|
42228
|
-
* オービットコントロールの注視点と座標を設定する
|
|
42229
|
-
* @param position - カメラの座標
|
|
42230
|
-
* @param target - 注視点の座標
|
|
42231
|
-
* setTransferPositionのみ呼び出した場合、見た目が変わらなかったため本関数を作成。
|
|
42232
|
-
*/
|
|
42233
|
-
setOrbitPositionAndTarget(position, target) {
|
|
42234
|
-
const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
|
|
42235
|
-
this.perspectiveCamera.position.set(position.x, position.y, position.z);
|
|
42236
|
-
controls.setTarget(new Vector3(target.x, target.y, target.z));
|
|
42237
|
-
controls.syncCameraParameter();
|
|
42238
|
-
this.transferControls.syncCameraParameter();
|
|
42239
|
-
this.start();
|
|
42240
|
-
}
|
|
42241
|
-
/**
|
|
42242
|
-
* オービットコントロールの注視点を設定する
|
|
42243
|
-
* @param target - 注視点の座標
|
|
42244
|
-
*/
|
|
42245
|
-
setOrbitTarget(target) {
|
|
42246
|
-
const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
|
|
42247
|
-
controls.setTarget(new Vector3(target.x, target.y, target.z));
|
|
42248
|
-
controls.syncCameraParameter();
|
|
42249
|
-
this.start();
|
|
42250
|
-
}
|
|
42251
42955
|
/**
|
|
42252
42956
|
* オービットコントロールのズーム使用可否を設定する
|
|
42253
42957
|
* @param enable - 使用可否を意味する真偽値
|
|
@@ -42694,6 +43398,14 @@ class Core extends EventEmitter {
|
|
|
42694
43398
|
p.z += position.z;
|
|
42695
43399
|
this.transferControls.setPosition(p, isForce);
|
|
42696
43400
|
}
|
|
43401
|
+
/**
|
|
43402
|
+
* TransferControls に fov を設定する
|
|
43403
|
+
* @param fov - 設定する fov
|
|
43404
|
+
* @param isForce - トランジションせず即座に強制上書きするかどうか
|
|
43405
|
+
*/
|
|
43406
|
+
setTransferFov(fov2, isForce) {
|
|
43407
|
+
this.transferControls.setFov(fov2, isForce);
|
|
43408
|
+
}
|
|
42697
43409
|
/**
|
|
42698
43410
|
* TransferControls に、現在の位置と向きに応じて移動するよう設定する
|
|
42699
43411
|
* @param offset - 移動する量
|
|
@@ -42731,14 +43443,6 @@ class Core extends EventEmitter {
|
|
|
42731
43443
|
moveTransferToBottom(scale, isForce) {
|
|
42732
43444
|
this.transferControls.moveToBottom(scale, isForce);
|
|
42733
43445
|
}
|
|
42734
|
-
/**
|
|
42735
|
-
* TransferControls に fov を設定する
|
|
42736
|
-
* @param fov - 設定する fov
|
|
42737
|
-
* @param isForce - トランジションせず即座に強制上書きするかどうか
|
|
42738
|
-
*/
|
|
42739
|
-
setTransferFov(fov2, isForce) {
|
|
42740
|
-
this.transferControls.setFov(fov2, isForce);
|
|
42741
|
-
}
|
|
42742
43446
|
/**
|
|
42743
43447
|
* ==========================================================================
|
|
42744
43448
|
* camera collider
|