@openheart/tavio-renderer 2.2.11-without-wasm → 2.2.12-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 +222 -45
- package/build/esm/types/camera/orbitControls.d.ts +13 -0
- package/build/esm/types/utility/utility.d.ts +11 -0
- package/build/esm/types/viewer/canvas.d.ts +28 -2
- package/build/esm/types/viewer/tavioMesh.d.ts +8 -4
- package/build/esm/types/worker/tavioWorker.d.ts +2 -0
- package/build/esm/wasm/pkg/no-thread/tavio.d.ts +10 -7
- package/build/esm/wasm/pkg/no-thread/tavio.js +122 -111
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm.d.ts +10 -7
- package/build/esm/wasm/pkg/thread/tavio.d.ts +12 -8
- package/build/esm/wasm/pkg/thread/tavio.js +169 -131
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm.d.ts +12 -8
- package/package.json +1 -1
package/build/esm/index.js
CHANGED
|
@@ -33353,10 +33353,10 @@ 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 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);
|
|
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(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;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
|
-
const main$5 = "precision highp float;precision highp int;uniform highp usampler2D splatTexture;uniform
|
|
33359
|
-
const main$4 = "precision highp float;in vec4 vColor;out vec4 fragColor;void main(){fragColor=vColor;}";
|
|
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
|
+
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);}";
|
|
33360
33360
|
function saturate(t) {
|
|
33361
33361
|
return Math.min(Math.max(t, 0), 1);
|
|
33362
33362
|
}
|
|
@@ -34475,6 +34475,8 @@ class OrbitControls extends EventEmitter {
|
|
|
34475
34475
|
// 平行移動が有効かどうか
|
|
34476
34476
|
enableLimit;
|
|
34477
34477
|
// 回転範囲の制限が有効かどうか
|
|
34478
|
+
enableZoomLimit;
|
|
34479
|
+
// ズーム範囲の制限が有効かどうか
|
|
34478
34480
|
/**
|
|
34479
34481
|
* 範囲を制限する処理では、東西南北のそれぞれの方向に対して制限範囲を設定できる
|
|
34480
34482
|
* カメラが北極方向に近づく北緯方向を上、向かって左に流れていく方向を西経方向とする
|
|
@@ -34499,6 +34501,10 @@ class OrbitControls extends EventEmitter {
|
|
|
34499
34501
|
// 左(西経)方向の可動範囲(最大 1.0 PI)
|
|
34500
34502
|
rightLimit;
|
|
34501
34503
|
// 右(東経)方向の可動範囲(最大 1.0 PI)
|
|
34504
|
+
zoomInLimit;
|
|
34505
|
+
// ズーム制限が有効な場合の最短距離
|
|
34506
|
+
zoomOutLimit;
|
|
34507
|
+
// ズーム制限が有効な場合の最長距離
|
|
34502
34508
|
isDown;
|
|
34503
34509
|
// ポインターが押し込まれているかどうか
|
|
34504
34510
|
overflow;
|
|
@@ -34532,6 +34538,7 @@ class OrbitControls extends EventEmitter {
|
|
|
34532
34538
|
this.enableZoom = true;
|
|
34533
34539
|
this.enablePan = true;
|
|
34534
34540
|
this.enableLimit = false;
|
|
34541
|
+
this.enableZoomLimit = false;
|
|
34535
34542
|
this.attenuation = DEFAULT_ATTENUATION;
|
|
34536
34543
|
this.state = null;
|
|
34537
34544
|
this.center = new Vector3(0, 0, 0);
|
|
@@ -34553,6 +34560,8 @@ class OrbitControls extends EventEmitter {
|
|
|
34553
34560
|
this.downLimit = PI_HALF;
|
|
34554
34561
|
this.leftLimit = Math.PI;
|
|
34555
34562
|
this.rightLimit = Math.PI;
|
|
34563
|
+
this.zoomInLimit = EPS$2;
|
|
34564
|
+
this.zoomOutLimit = Infinity;
|
|
34556
34565
|
this.isDown = false;
|
|
34557
34566
|
this.overflow = 0.5;
|
|
34558
34567
|
this.upOver = 0;
|
|
@@ -34757,6 +34766,20 @@ class OrbitControls extends EventEmitter {
|
|
|
34757
34766
|
setRightLimit(value) {
|
|
34758
34767
|
this.rightLimit = Math.min(Math.max(0, value), Math.PI);
|
|
34759
34768
|
}
|
|
34769
|
+
/**
|
|
34770
|
+
* ズームの最短距離
|
|
34771
|
+
* @param value - 設定する値
|
|
34772
|
+
*/
|
|
34773
|
+
setZoomInLimit(value) {
|
|
34774
|
+
this.zoomInLimit = Math.max(EPS$2, value);
|
|
34775
|
+
}
|
|
34776
|
+
/**
|
|
34777
|
+
* ズームの最長距離
|
|
34778
|
+
* @param value - 設定する値
|
|
34779
|
+
*/
|
|
34780
|
+
setZoomOutLimit(value) {
|
|
34781
|
+
this.zoomOutLimit = value;
|
|
34782
|
+
}
|
|
34760
34783
|
/**
|
|
34761
34784
|
* 状態を更新し、変更があったかどうかを真偽値で返す
|
|
34762
34785
|
*/
|
|
@@ -34781,6 +34804,10 @@ class OrbitControls extends EventEmitter {
|
|
|
34781
34804
|
if (this.relativeDistance !== 0) {
|
|
34782
34805
|
this.targetDistance = currentDistance + this.relativeDistance * distanceUnit;
|
|
34783
34806
|
}
|
|
34807
|
+
if (this.enableZoomLimit === true) {
|
|
34808
|
+
const maxDistance = Math.max(this.zoomInLimit, this.zoomOutLimit);
|
|
34809
|
+
this.targetDistance = Math.min(Math.max(this.zoomInLimit, this.targetDistance), maxDistance);
|
|
34810
|
+
}
|
|
34784
34811
|
this.distanceRange = this.targetDistance - currentDistance;
|
|
34785
34812
|
const distance = currentDistance + (this.distanceRange - this.distanceRange * this.attenuation);
|
|
34786
34813
|
const scale = Math.max(0.1, distance);
|
|
@@ -34798,8 +34825,10 @@ class OrbitControls extends EventEmitter {
|
|
|
34798
34825
|
if (rotationChanged === true) {
|
|
34799
34826
|
if (this.enableLimit === true) {
|
|
34800
34827
|
const rTarget = this.targetTheta + this.relativeTheta;
|
|
34801
|
-
const
|
|
34802
|
-
const
|
|
34828
|
+
const upOverflow = Math.min(this.upLimit - EPS$2, this.overflow);
|
|
34829
|
+
const downOverflow = Math.min(this.downLimit - EPS$2, this.overflow);
|
|
34830
|
+
const maxTheta = Math.min(PI_HALF - EPS$2, this.upLimit) - upOverflow;
|
|
34831
|
+
const minTheta = -Math.min(PI_HALF - EPS$2, this.downLimit) + downOverflow;
|
|
34803
34832
|
if (this.relativeTheta !== 0) {
|
|
34804
34833
|
const overUp = rTarget > maxTheta && this.overflow > 0;
|
|
34805
34834
|
const overDown = rTarget < minTheta && this.overflow > 0;
|
|
@@ -34818,8 +34847,10 @@ class OrbitControls extends EventEmitter {
|
|
|
34818
34847
|
if (this.relativePhi !== 0) {
|
|
34819
34848
|
const angle = (this.targetPhi - this.limitBase) % PI_2;
|
|
34820
34849
|
const rTarget2 = angle + this.relativePhi;
|
|
34821
|
-
const
|
|
34822
|
-
const
|
|
34850
|
+
const rightOverflow = Math.min(this.rightLimit - EPS$2, this.overflow);
|
|
34851
|
+
const leftOverflow = Math.min(this.leftLimit - EPS$2, this.overflow);
|
|
34852
|
+
const maxPhi = this.rightLimit - rightOverflow;
|
|
34853
|
+
const minPhi = this.leftLimit - leftOverflow;
|
|
34823
34854
|
const overRight = rTarget2 > maxPhi && this.overflow > 0;
|
|
34824
34855
|
const overLeft = rTarget2 < -minPhi && this.overflow > 0;
|
|
34825
34856
|
if (overRight === true) {
|
|
@@ -37039,6 +37070,16 @@ function checkBit(value, target) {
|
|
|
37039
37070
|
const mask = 1 << target;
|
|
37040
37071
|
return (value & mask) !== 0;
|
|
37041
37072
|
}
|
|
37073
|
+
function pack4to8(high, low) {
|
|
37074
|
+
const h = Math.min(Math.max(high, 0), 15);
|
|
37075
|
+
const l = Math.min(Math.max(low, 0), 15);
|
|
37076
|
+
return (h & 15) << 4 | l & 15;
|
|
37077
|
+
}
|
|
37078
|
+
function unpack8to4(value) {
|
|
37079
|
+
const high = value >> 4 & 15;
|
|
37080
|
+
const low = value & 15;
|
|
37081
|
+
return [high, low];
|
|
37082
|
+
}
|
|
37042
37083
|
function convertQuaternion(w, x, y, z) {
|
|
37043
37084
|
let qw = w;
|
|
37044
37085
|
let qx = x;
|
|
@@ -37376,8 +37417,8 @@ class PlyDecoder {
|
|
|
37376
37417
|
const main$3 = "uniform float size;uniform float scale;uniform float effectDistanceNear;uniform float effectDistance;uniform float effectDistanceMax;uniform float effectDistanceRange;uniform float effectDistanceColor;uniform float effectDistanceColorNear;uniform float effectSonar;uniform float effectSonarRange;uniform vec3 worldOrigin;varying float vAlpha;varying float vColorEffectFactor;varying float vSonarFactor;varying vec3 vWorldPosition;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\nvarying vec2 vUv;uniform mat3 uvTransform;\n#endif\nvoid main(){\n#ifdef USE_POINTS_UV\nvUv=(uvTransform*vec3(uv,1)).xy;\n#endif\n#if defined( USE_COLOR_ALPHA )\nvColor=vec4(1.0);\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\nvColor=vec3(1.0);\n#endif\n#ifdef USE_COLOR\nvColor*=color;\n#endif\n#ifdef USE_INSTANCING_COLOR\nvColor.xyz*=instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\nvec3 batchingColor=getBatchingColor(getIndirectIndex(gl_DrawID));vColor.xyz*=batchingColor.xyz;\n#endif\n#include <morphinstance_vertex>\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\ngl_PointSize=size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)gl_PointSize*=(scale/-mvPosition.z);\n#endif\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\nvec4 floatPosition=modelMatrix*vec4(position,1.0);float toCenter=min(length(floatPosition.xyz-worldOrigin)/effectDistanceMax,1.0);float threshold=effectDistance*(1.0+effectDistanceRange);float far=clamp(threshold-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdNear=effectDistanceNear*(1.0+effectDistanceRange);float near=1.0-(clamp(thresholdNear-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001));vAlpha=near*far;float thresholdColor=effectDistanceColor*(1.0+effectDistanceRange);float farColor=clamp(thresholdColor-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdColorNear=effectDistanceColorNear*(1.0+effectDistanceRange);float nearColor=1.0-(clamp(thresholdColorNear-toCenter,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;vWorldPosition=floatPosition.xyz;}";
|
|
37377
37418
|
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;}";
|
|
37378
37419
|
const main$1 = "in vec3 position;void main(){gl_Position=vec4(position,1.0);}";
|
|
37379
|
-
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);}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);
|
|
37380
|
-
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 return -w <= l[0] && l[0] <= w && (-w <= l[1] && l[1] <= w) && (-w <= l[2] && l[2] <= w);\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';
|
|
37420
|
+
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';
|
|
37381
37422
|
const blob$1 = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent$1], { type: "text/javascript;charset=utf-8" });
|
|
37382
37423
|
function WorkerWrapper$1(options) {
|
|
37383
37424
|
let objURL;
|
|
@@ -37580,6 +37621,8 @@ class TavioMesh extends EventEmitter {
|
|
|
37580
37621
|
// カメラ
|
|
37581
37622
|
worker;
|
|
37582
37623
|
// worker のインスタンス
|
|
37624
|
+
meshIndex;
|
|
37625
|
+
// プロジェクト全体で何番目のメッシュかを意味するインデックス
|
|
37583
37626
|
featureBits;
|
|
37584
37627
|
// 特性フラグの状態
|
|
37585
37628
|
majorVersionNumber = 0;
|
|
@@ -37649,6 +37692,8 @@ class TavioMesh extends EventEmitter {
|
|
|
37649
37692
|
// 点描画用の Points が初期化できているかどうか
|
|
37650
37693
|
initializedBackground;
|
|
37651
37694
|
// 背景球の初期化ができているかどうか
|
|
37695
|
+
sorted;
|
|
37696
|
+
// 最初のソート処理が実行されたかどうか
|
|
37652
37697
|
positionAttribute;
|
|
37653
37698
|
// ガウシアン1つあたり4つの頂点属性を用いる
|
|
37654
37699
|
indexAttribute;
|
|
@@ -37705,7 +37750,9 @@ class TavioMesh extends EventEmitter {
|
|
|
37705
37750
|
* R は選択されているかどうかを意味し、Uint8 の各ビットがどのセレクターによるものかを意味する
|
|
37706
37751
|
* G は削除されているかどうかを意味し、将来的に undo/redo に対応するため削除操作のたびにインクリメントする
|
|
37707
37752
|
* B は tavio 形式時の生アルファを保持し、min-max で復元する前の状態のままシェーダに送る
|
|
37708
|
-
* A
|
|
37753
|
+
* A は何番目のメッシュなのか、を意味する整数と……
|
|
37754
|
+
* 1つのメッシュに対して複数のデータを統合する際に何番目のデータであるかの整数インデックスを保持する
|
|
37755
|
+
* データは 8bit のアルファチャンネル1つに対して 4bit 整数を2つパックして詰め込む
|
|
37709
37756
|
*/
|
|
37710
37757
|
/**
|
|
37711
37758
|
* this.gaussianTransformData についての覚書
|
|
@@ -37747,13 +37794,15 @@ class TavioMesh extends EventEmitter {
|
|
|
37747
37794
|
];
|
|
37748
37795
|
/**
|
|
37749
37796
|
* @constructor
|
|
37797
|
+
* @param index - プロジェクト全体として何番目のメッシュのインスタンスかを意味するインデックス
|
|
37750
37798
|
* @param camera - worker の更新のためにカメラのインスタンスが必要
|
|
37751
37799
|
* @param material - メッシュの生成に使うマテリアルは上の層から指定されたものを使う
|
|
37752
37800
|
* @param pickingMaterial - メッシュの生成に使うマテリアルは上の層から指定されたものを使う
|
|
37753
37801
|
*/
|
|
37754
|
-
constructor(camera, material, pinckingMaterial, viewerOption) {
|
|
37802
|
+
constructor(index, camera, material, pinckingMaterial, viewerOption) {
|
|
37755
37803
|
super();
|
|
37756
37804
|
this.usingSharedArrayBuffer = viewerOption.usingSharedArrayBuffer ?? false;
|
|
37805
|
+
this.meshIndex = index;
|
|
37757
37806
|
this.featureBits = null;
|
|
37758
37807
|
this.containmentRadius = { per100: null };
|
|
37759
37808
|
this.sourceProperty = [];
|
|
@@ -37761,6 +37810,7 @@ class TavioMesh extends EventEmitter {
|
|
|
37761
37810
|
this.initialized = false;
|
|
37762
37811
|
this.initializedPoints = false;
|
|
37763
37812
|
this.initializedBackground = false;
|
|
37813
|
+
this.sorted = false;
|
|
37764
37814
|
this.initializedTexture = false;
|
|
37765
37815
|
this.initializedColorTexture = false;
|
|
37766
37816
|
this.perspectiveCamera = camera;
|
|
@@ -38112,7 +38162,13 @@ class TavioMesh extends EventEmitter {
|
|
|
38112
38162
|
this.gaussianIndexData = null;
|
|
38113
38163
|
const { width, height } = _getDepthRenderTextureWidth(this.gaussianCount);
|
|
38114
38164
|
this.gaussianOrderData = new Uint8Array(width * height * 4);
|
|
38115
|
-
|
|
38165
|
+
if (currentOffset > 0) {
|
|
38166
|
+
const previousGeneralData = this.gaussianGeneralData;
|
|
38167
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
38168
|
+
this.gaussianGeneralData.set(previousGeneralData);
|
|
38169
|
+
} else {
|
|
38170
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
38171
|
+
}
|
|
38116
38172
|
this.sphericalHarmonicsData = null;
|
|
38117
38173
|
this.currentSelectionCount = 0;
|
|
38118
38174
|
this.worker.postMessage({
|
|
@@ -39369,19 +39425,30 @@ class TavioMesh extends EventEmitter {
|
|
|
39369
39425
|
*/
|
|
39370
39426
|
/**
|
|
39371
39427
|
* picking 用マテリアルに uniform 変数を同期する
|
|
39372
|
-
* @param div - ピッキング用フレームバッファの大きさに対する除数
|
|
39373
39428
|
*/
|
|
39374
|
-
syncPinckingMaterial(
|
|
39429
|
+
syncPinckingMaterial() {
|
|
39375
39430
|
const projection = this.perspectiveCamera.projectionMatrix;
|
|
39376
39431
|
const view = this.perspectiveCamera.matrixWorldInverse;
|
|
39377
|
-
|
|
39432
|
+
this.gaussianPickingMaterial.uniforms.splatTexture.value = this.gaussianMaterial.uniforms.splatTexture.value;
|
|
39433
|
+
this.gaussianPickingMaterial.uniforms.generalTexture.value = this.gaussianMaterial.uniforms.generalTexture.value;
|
|
39434
|
+
this.gaussianPickingMaterial.uniforms.transformTexture.value = this.gaussianMaterial.uniforms.transformTexture.value;
|
|
39378
39435
|
this.gaussianPickingMaterial.uniforms.projection.value = projection;
|
|
39379
39436
|
this.gaussianPickingMaterial.uniforms.view.value = view;
|
|
39380
|
-
this.gaussianPickingMaterial.uniforms.
|
|
39381
|
-
this.gaussianPickingMaterial.uniforms.
|
|
39382
|
-
this.gaussianPickingMaterial.uniforms.inverseViewport.value = this.gaussianMaterial.uniforms.inverseViewport.value.clone().multiplyScalar(1 / div);
|
|
39383
|
-
this.gaussianPickingMaterial.uniforms.splatTexture.value = this.gaussianMaterial.uniforms.splatTexture.value;
|
|
39437
|
+
this.gaussianPickingMaterial.uniforms.focal.value = this.gaussianMaterial.uniforms.focal.value.clone();
|
|
39438
|
+
this.gaussianPickingMaterial.uniforms.inverseViewport.value = this.gaussianMaterial.uniforms.inverseViewport.value.clone();
|
|
39384
39439
|
this.gaussianPickingMaterial.uniforms.gaussianScale.value = this.gaussianMaterial.uniforms.gaussianScale.value;
|
|
39440
|
+
this.gaussianPickingMaterial.uniforms.effectMinimumScale.value = this.gaussianMaterial.uniforms.effectMinimumScale.value;
|
|
39441
|
+
this.gaussianPickingMaterial.uniforms.effectDistance.value = this.gaussianMaterial.uniforms.effectDistance.value;
|
|
39442
|
+
this.gaussianPickingMaterial.uniforms.effectDistanceMax.value = this.gaussianMaterial.uniforms.effectDistanceMax.value;
|
|
39443
|
+
this.gaussianPickingMaterial.uniforms.effectDistanceRange.value = this.gaussianMaterial.uniforms.effectDistanceRange.value;
|
|
39444
|
+
this.gaussianPickingMaterial.uniforms.effectDistanceColor.value = this.gaussianMaterial.uniforms.effectDistanceColor.value;
|
|
39445
|
+
this.gaussianPickingMaterial.uniforms.effectDistanceColorNear.value = this.gaussianMaterial.uniforms.effectDistanceColorNear.value;
|
|
39446
|
+
this.gaussianPickingMaterial.uniforms.effectSonar.value = this.gaussianMaterial.uniforms.effectSonar.value;
|
|
39447
|
+
this.gaussianPickingMaterial.uniforms.effectSonarRange.value = this.gaussianMaterial.uniforms.effectSonarRange.value;
|
|
39448
|
+
this.gaussianPickingMaterial.uniforms.worldOrigin.value = this.gaussianMaterial.uniforms.worldOrigin.value.clone();
|
|
39449
|
+
this.gaussianPickingMaterial.uniforms.scaleAlphaMin.value = this.gaussianMaterial.uniforms.scaleAlphaMin.value.clone();
|
|
39450
|
+
this.gaussianPickingMaterial.uniforms.scaleAlphaMax.value = this.gaussianMaterial.uniforms.scaleAlphaMax.value.clone();
|
|
39451
|
+
this.gaussianPickingMaterial.uniforms.transformTextureWidth.value = this.gaussianMaterial.uniforms.transformTextureWidth.value;
|
|
39385
39452
|
}
|
|
39386
39453
|
/**
|
|
39387
39454
|
* ソートを実行する
|
|
@@ -39669,7 +39736,6 @@ class TavioMesh extends EventEmitter {
|
|
|
39669
39736
|
});
|
|
39670
39737
|
if (textureWidth * textureHeight >= this.gaussianCount) {
|
|
39671
39738
|
this.initialized = true;
|
|
39672
|
-
this.emit("finallyupdate", this.gaussianCount);
|
|
39673
39739
|
}
|
|
39674
39740
|
} else if (evt.data.updateIndex != null) {
|
|
39675
39741
|
const { currentVertexCount, time } = evt.data;
|
|
@@ -39678,6 +39744,10 @@ class TavioMesh extends EventEmitter {
|
|
|
39678
39744
|
}
|
|
39679
39745
|
this.currentVertexCount = currentVertexCount;
|
|
39680
39746
|
this._onSort(currentVertexCount, time);
|
|
39747
|
+
if (this.sorted !== true) {
|
|
39748
|
+
this.sorted = true;
|
|
39749
|
+
this.emit("finallyupdate", this.gaussianCount);
|
|
39750
|
+
}
|
|
39681
39751
|
} else if (evt.data.compressedSH != null) {
|
|
39682
39752
|
afterConvert(evt.data.compressedSH);
|
|
39683
39753
|
} else if (evt.data.updateCollision != null) {
|
|
@@ -39884,18 +39954,16 @@ class TavioMesh extends EventEmitter {
|
|
|
39884
39954
|
const rotation = new Euler(0, 0, 0);
|
|
39885
39955
|
const scale = 1;
|
|
39886
39956
|
this.setTransform(index, translation, rotation, scale);
|
|
39887
|
-
const
|
|
39957
|
+
const packed = pack4to8(this.meshIndex, index);
|
|
39888
39958
|
for (let j = offset; j < totalCount; ++j) {
|
|
39889
39959
|
const i4 = j * 4;
|
|
39890
|
-
|
|
39960
|
+
this.gaussianGeneralData[i4 + 3] = packed;
|
|
39891
39961
|
}
|
|
39892
|
-
if (
|
|
39893
|
-
|
|
39894
|
-
|
|
39895
|
-
|
|
39896
|
-
|
|
39897
|
-
});
|
|
39898
|
-
}
|
|
39962
|
+
if (this.usingSharedArrayBuffer !== true) {
|
|
39963
|
+
this.worker.postMessage({
|
|
39964
|
+
updateGeneralData: true,
|
|
39965
|
+
generalBuffer: this.gaussianGeneralData.buffer
|
|
39966
|
+
});
|
|
39899
39967
|
}
|
|
39900
39968
|
}
|
|
39901
39969
|
/**
|
|
@@ -40866,13 +40934,32 @@ class Core extends EventEmitter {
|
|
|
40866
40934
|
});
|
|
40867
40935
|
this.gaussianPickingMaterial = new RawShaderMaterial({
|
|
40868
40936
|
uniforms: {
|
|
40937
|
+
splatTexture: { value: null },
|
|
40938
|
+
generalTexture: { value: null },
|
|
40939
|
+
transformTexture: { value: null },
|
|
40869
40940
|
projection: { value: new Matrix4() },
|
|
40870
40941
|
view: { value: new Matrix4() },
|
|
40871
|
-
inverseViewProjection: { value: new Matrix4() },
|
|
40872
40942
|
focal: { value: new Vector2() },
|
|
40873
40943
|
inverseViewport: { value: new Vector2() },
|
|
40874
|
-
|
|
40875
|
-
|
|
40944
|
+
gaussianScale: { value: 1 },
|
|
40945
|
+
effectMinimumScale: { value: this.viewerOption.minimumScale },
|
|
40946
|
+
effectDistance: { value: this.viewerOption.distanceEffectBase },
|
|
40947
|
+
effectDistanceMax: { value: 0 },
|
|
40948
|
+
effectDistanceRange: { value: this.viewerOption.distanceEffectRange },
|
|
40949
|
+
effectDistanceColor: { value: this.viewerOption.distanceColorEffect },
|
|
40950
|
+
effectDistanceColorNear: { value: this.viewerOption.distanceColorEffectNear },
|
|
40951
|
+
effectSonar: { value: this.viewerOption.effectSonar },
|
|
40952
|
+
effectSonarRange: { value: this.viewerOption.effectSonarRange },
|
|
40953
|
+
worldOrigin: {
|
|
40954
|
+
value: new Vector3(
|
|
40955
|
+
this.viewerOption.worldOrigin.x,
|
|
40956
|
+
this.viewerOption.worldOrigin.y,
|
|
40957
|
+
this.viewerOption.worldOrigin.z
|
|
40958
|
+
)
|
|
40959
|
+
},
|
|
40960
|
+
scaleAlphaMin: { value: new Vector4(0, 0, 0, 0) },
|
|
40961
|
+
scaleAlphaMax: { value: new Vector4(1, 1, 1, 1) },
|
|
40962
|
+
transformTextureWidth: { value: 2 }
|
|
40876
40963
|
},
|
|
40877
40964
|
vertexShader: main$5,
|
|
40878
40965
|
fragmentShader: main$4,
|
|
@@ -40916,7 +41003,6 @@ class Core extends EventEmitter {
|
|
|
40916
41003
|
const controls = new OrbitControls(this.perspectiveCamera);
|
|
40917
41004
|
controls.enabled = false;
|
|
40918
41005
|
controls.update();
|
|
40919
|
-
controls.saveState();
|
|
40920
41006
|
this.orbitCursorGeometry = new TorusGeometry(0.03, 1e-3, 16, 32);
|
|
40921
41007
|
this.orbitCursorMaterial = new MeshBasicMaterial({
|
|
40922
41008
|
color: 16777215,
|
|
@@ -41256,7 +41342,9 @@ class Core extends EventEmitter {
|
|
|
41256
41342
|
*/
|
|
41257
41343
|
_beforeLoadMesh(name) {
|
|
41258
41344
|
this.isLoading = true;
|
|
41345
|
+
const meshIndex = this.meshMap.size;
|
|
41259
41346
|
const tavioMesh = new TavioMesh(
|
|
41347
|
+
meshIndex,
|
|
41260
41348
|
this.perspectiveCamera,
|
|
41261
41349
|
this.gaussianMaterial.clone(),
|
|
41262
41350
|
this.gaussianPickingMaterial.clone(),
|
|
@@ -41798,20 +41886,44 @@ class Core extends EventEmitter {
|
|
|
41798
41886
|
* フレームバッファに 3DGS のワールド座標をレンダリングし指定されたスクリーン座標から取得する
|
|
41799
41887
|
* @param x - 取得する X 座標(スクリーン空間を -1.0 ~ 1.0 に正規化した座標)
|
|
41800
41888
|
* @param y - 取得する Y 座標(スクリーン空間を -1.0 ~ 1.0 に正規化した座標, Y-down)
|
|
41889
|
+
* @param isDebug - デバッグモード(有効化するとピッキングバッファを可視化)
|
|
41801
41890
|
*/
|
|
41802
|
-
async getWorldPositionByScreen(x, y) {
|
|
41803
|
-
const
|
|
41804
|
-
const
|
|
41805
|
-
const width = this.canvas.width
|
|
41806
|
-
const height = this.canvas.height
|
|
41891
|
+
async getWorldPositionByScreen(x, y, isDebug = false) {
|
|
41892
|
+
const floatBuffer = new Float32Array(4);
|
|
41893
|
+
const uintBuffer = new Uint32Array(floatBuffer.buffer);
|
|
41894
|
+
const width = this.canvas.width;
|
|
41895
|
+
const height = this.canvas.height;
|
|
41807
41896
|
this.pickingRenderTarget.setSize(width, height);
|
|
41808
41897
|
this.meshMap.forEach((mesh) => {
|
|
41809
|
-
mesh.syncPinckingMaterial(
|
|
41898
|
+
mesh.syncPinckingMaterial();
|
|
41810
41899
|
});
|
|
41811
41900
|
this.renderer.setRenderTarget(this.pickingRenderTarget);
|
|
41812
41901
|
this.renderer.clear();
|
|
41813
41902
|
this.renderer.render(this.pickingScene, this.perspectiveCamera);
|
|
41814
41903
|
this.renderer.setRenderTarget(null);
|
|
41904
|
+
if (isDebug === true) {
|
|
41905
|
+
setTimeout(() => {
|
|
41906
|
+
const scene = new Scene();
|
|
41907
|
+
const camera = new Camera();
|
|
41908
|
+
const geometry = new PlaneGeometry(2, 2);
|
|
41909
|
+
const material = new MeshBasicMaterial({ map: this.pickingRenderTarget.texture });
|
|
41910
|
+
const mesh = new Mesh(geometry, material);
|
|
41911
|
+
scene.add(mesh);
|
|
41912
|
+
const prevResolution = this.renderer.getSize(new Vector2());
|
|
41913
|
+
const prevClearColor = this.renderer.getClearColor(new Color());
|
|
41914
|
+
const prevClearAlpha = this.renderer.getClearAlpha();
|
|
41915
|
+
const prevAutoClear = this.renderer.autoClear;
|
|
41916
|
+
this.renderer.setSize(window.innerWidth, window.innerHeight);
|
|
41917
|
+
this.renderer.setClearColor(0, 0);
|
|
41918
|
+
this.renderer.autoClear = true;
|
|
41919
|
+
this.renderer.render(scene, camera);
|
|
41920
|
+
this.renderer.setSize(prevResolution.x, prevResolution.y);
|
|
41921
|
+
this.renderer.setClearColor(prevClearColor, prevClearAlpha);
|
|
41922
|
+
this.renderer.autoClear = prevAutoClear;
|
|
41923
|
+
geometry.dispose();
|
|
41924
|
+
material.dispose();
|
|
41925
|
+
}, 100);
|
|
41926
|
+
}
|
|
41815
41927
|
const nx = (x * 0.5 + 0.5) * width;
|
|
41816
41928
|
const ny = (-y * 0.5 + 0.5) * height;
|
|
41817
41929
|
await this.renderer.readRenderTargetPixelsAsync(
|
|
@@ -41820,9 +41932,30 @@ class Core extends EventEmitter {
|
|
|
41820
41932
|
ny,
|
|
41821
41933
|
1,
|
|
41822
41934
|
1,
|
|
41823
|
-
|
|
41935
|
+
floatBuffer
|
|
41824
41936
|
);
|
|
41825
|
-
|
|
41937
|
+
if (floatBuffer[0] === 0 && floatBuffer[1] === 0 && floatBuffer[2] === 0 && floatBuffer[3] === 0) {
|
|
41938
|
+
return null;
|
|
41939
|
+
} else {
|
|
41940
|
+
const [high, low] = unpack8to4(uintBuffer[3]);
|
|
41941
|
+
let name = "";
|
|
41942
|
+
let counter = 0;
|
|
41943
|
+
this.meshMap.forEach((value, key) => {
|
|
41944
|
+
if (high === counter) {
|
|
41945
|
+
name = key;
|
|
41946
|
+
}
|
|
41947
|
+
++counter;
|
|
41948
|
+
});
|
|
41949
|
+
return {
|
|
41950
|
+
name,
|
|
41951
|
+
index: low,
|
|
41952
|
+
target: {
|
|
41953
|
+
x: floatBuffer[0],
|
|
41954
|
+
y: floatBuffer[1],
|
|
41955
|
+
z: floatBuffer[2]
|
|
41956
|
+
}
|
|
41957
|
+
};
|
|
41958
|
+
}
|
|
41826
41959
|
}
|
|
41827
41960
|
/**
|
|
41828
41961
|
* 各種リソースを解放する
|
|
@@ -42047,7 +42180,7 @@ class Core extends EventEmitter {
|
|
|
42047
42180
|
this.updateCameraPath(cameraPathControls.getTime());
|
|
42048
42181
|
break;
|
|
42049
42182
|
}
|
|
42050
|
-
if (previousControls === CONTROLS_TYPE_ORBIT) {
|
|
42183
|
+
if (type !== CONTROLS_TYPE_ORBIT && previousControls === CONTROLS_TYPE_ORBIT) {
|
|
42051
42184
|
const orbitControls = this.controlsMap.get(
|
|
42052
42185
|
CONTROLS_TYPE_ORBIT
|
|
42053
42186
|
);
|
|
@@ -42142,6 +42275,14 @@ class Core extends EventEmitter {
|
|
|
42142
42275
|
controls.syncLimitBase();
|
|
42143
42276
|
}
|
|
42144
42277
|
}
|
|
42278
|
+
/**
|
|
42279
|
+
* オービットコントロールのズーム範囲制限の可否を設定する
|
|
42280
|
+
* @param enable - 使用可否を意味する真偽値
|
|
42281
|
+
*/
|
|
42282
|
+
setOrbitEnableZoomLimit(enable) {
|
|
42283
|
+
const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
|
|
42284
|
+
controls.enableZoomLimit = enable;
|
|
42285
|
+
}
|
|
42145
42286
|
/**
|
|
42146
42287
|
* オービットコントロールの注視点と座標の距離を取得する
|
|
42147
42288
|
* @returns 注視点と座標の距離
|
|
@@ -42286,6 +42427,26 @@ class Core extends EventEmitter {
|
|
|
42286
42427
|
);
|
|
42287
42428
|
orbitControls.setRightLimit(value);
|
|
42288
42429
|
}
|
|
42430
|
+
/**
|
|
42431
|
+
* オービットコントロールのズームの最短距離を設定する
|
|
42432
|
+
* @param value - 設定する値
|
|
42433
|
+
*/
|
|
42434
|
+
setOrbitZoomInLimit(value) {
|
|
42435
|
+
const orbitControls = this.controlsMap.get(
|
|
42436
|
+
CONTROLS_TYPE_ORBIT
|
|
42437
|
+
);
|
|
42438
|
+
orbitControls.setZoomInLimit(value);
|
|
42439
|
+
}
|
|
42440
|
+
/**
|
|
42441
|
+
* オービットコントロールのズームの最長距離を設定する
|
|
42442
|
+
* @param value - 設定する値
|
|
42443
|
+
*/
|
|
42444
|
+
setOrbitZoomOutLimit(value) {
|
|
42445
|
+
const orbitControls = this.controlsMap.get(
|
|
42446
|
+
CONTROLS_TYPE_ORBIT
|
|
42447
|
+
);
|
|
42448
|
+
orbitControls.setZoomOutLimit(value);
|
|
42449
|
+
}
|
|
42289
42450
|
/**
|
|
42290
42451
|
* ==========================================================================
|
|
42291
42452
|
* camera path controls
|
|
@@ -42616,7 +42777,11 @@ class Core extends EventEmitter {
|
|
|
42616
42777
|
this.meshMap.forEach((mesh) => {
|
|
42617
42778
|
const pointUniforms = mesh.getPointsUniforms();
|
|
42618
42779
|
Object.entries(uniforms).forEach(([key, value]) => {
|
|
42619
|
-
pointUniforms[key]
|
|
42780
|
+
if (pointUniforms[key] != null) {
|
|
42781
|
+
pointUniforms[key].value = value;
|
|
42782
|
+
} else {
|
|
42783
|
+
this.console.warn(`"${key}" property not found in pointUniforms`);
|
|
42784
|
+
}
|
|
42620
42785
|
});
|
|
42621
42786
|
});
|
|
42622
42787
|
}
|
|
@@ -43010,12 +43175,16 @@ class Core extends EventEmitter {
|
|
|
43010
43175
|
*/
|
|
43011
43176
|
_createCollisionBoxFromSelector(selector) {
|
|
43012
43177
|
const width = selector.getWidth();
|
|
43178
|
+
const height = selector.getHeight();
|
|
43179
|
+
const depth = selector.getDepth();
|
|
43013
43180
|
const position = selector.getPosition();
|
|
43014
43181
|
const scale = selector.getScale();
|
|
43015
43182
|
const inverseMatrix = selector.getInverseMatrix();
|
|
43016
43183
|
const reversed = this.reversedCollision;
|
|
43017
43184
|
return this.createCollisionBox(
|
|
43018
43185
|
width,
|
|
43186
|
+
height,
|
|
43187
|
+
depth,
|
|
43019
43188
|
position,
|
|
43020
43189
|
scale,
|
|
43021
43190
|
inverseMatrix,
|
|
@@ -43187,16 +43356,20 @@ class Core extends EventEmitter {
|
|
|
43187
43356
|
/**
|
|
43188
43357
|
* 箱の衝突判定パラメータ(Worker に渡すフォーマット)を生成する
|
|
43189
43358
|
* @param width - 一辺の幅
|
|
43359
|
+
* @param height - 一辺の高さ
|
|
43360
|
+
* @param depth - 一辺の奥行き
|
|
43190
43361
|
* @param position - ワールド空間における位置
|
|
43191
43362
|
* @param scale - ワールド空間における拡大縮小(スケール)
|
|
43192
43363
|
* @param inverseMatrix - ワールド変換の逆行列
|
|
43193
43364
|
* @param reversed - 判定の反転(球に内包されている状態を規定とし、それを反転するかどうか)
|
|
43194
43365
|
*/
|
|
43195
|
-
createCollisionBox(width, position, scale, inverseMatrix, reversed = false) {
|
|
43366
|
+
createCollisionBox(width, height, depth, position, scale, inverseMatrix, reversed = false) {
|
|
43196
43367
|
return {
|
|
43197
43368
|
type: "box",
|
|
43198
43369
|
target: {
|
|
43199
43370
|
width,
|
|
43371
|
+
height,
|
|
43372
|
+
depth,
|
|
43200
43373
|
position: [position.x, position.y, position.z],
|
|
43201
43374
|
scale: [scale.x, scale.y, scale.z],
|
|
43202
43375
|
inverse4x4: inverseMatrix.elements
|
|
@@ -43225,7 +43398,9 @@ class Core extends EventEmitter {
|
|
|
43225
43398
|
rotation: { x: r.x, y: r.y, z: r.z },
|
|
43226
43399
|
scale: { x: s.x, y: s.y, z: s.z },
|
|
43227
43400
|
radius: null,
|
|
43228
|
-
width: null
|
|
43401
|
+
width: null,
|
|
43402
|
+
height: null,
|
|
43403
|
+
depth: null
|
|
43229
43404
|
};
|
|
43230
43405
|
switch (true) {
|
|
43231
43406
|
case selector instanceof SphereSelector:
|
|
@@ -43238,6 +43413,8 @@ class Core extends EventEmitter {
|
|
|
43238
43413
|
{
|
|
43239
43414
|
const s2 = selector;
|
|
43240
43415
|
info.width = s2.getWidth();
|
|
43416
|
+
info.height = s2.getHeight();
|
|
43417
|
+
info.depth = s2.getDepth();
|
|
43241
43418
|
}
|
|
43242
43419
|
break;
|
|
43243
43420
|
}
|