@openheart/tavio-renderer 2.2.13-without-wasm → 2.3.2-with-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 +1172 -279
- package/build/esm/types/types/global.d.ts +8 -4
- package/build/esm/types/viewer/canvas.d.ts +86 -5
- package/build/esm/types/viewer/materialGenerator.d.ts +120 -0
- package/build/esm/types/viewer/tavioMesh.d.ts +15 -27
- package/build/esm/types/wasm-bindings/wasm-handlers.d.ts +37 -0
- package/build/esm/types/wasm-bindings/wasm-pkg-base-url.d.ts +6 -0
- package/build/esm/types/wasm-bindings/wasm-worker-client.d.ts +68 -11
- package/build/esm/wasm/pkg/no-thread/tavio.d.ts +35 -20
- package/build/esm/wasm/pkg/no-thread/tavio.js +354 -98
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm.d.ts +18 -11
- package/build/esm/wasm/pkg/thread/tavio.d.ts +38 -23
- package/build/esm/wasm/pkg/thread/tavio.js +398 -141
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm.d.ts +21 -14
- package/build/esm/wasm-worker-CEuC2YyS.js +117 -0
- package/package.json +2 -1
package/build/esm/index.js
CHANGED
|
@@ -16002,25 +16002,25 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
|
|
|
16002
16002
|
}
|
|
16003
16003
|
return true;
|
|
16004
16004
|
}
|
|
16005
|
-
function getMaxPrecision(
|
|
16006
|
-
if (
|
|
16005
|
+
function getMaxPrecision(precision3) {
|
|
16006
|
+
if (precision3 === "highp") {
|
|
16007
16007
|
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT).precision > 0 && gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision > 0) {
|
|
16008
16008
|
return "highp";
|
|
16009
16009
|
}
|
|
16010
|
-
|
|
16010
|
+
precision3 = "mediump";
|
|
16011
16011
|
}
|
|
16012
|
-
if (
|
|
16012
|
+
if (precision3 === "mediump") {
|
|
16013
16013
|
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision > 0 && gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT).precision > 0) {
|
|
16014
16014
|
return "mediump";
|
|
16015
16015
|
}
|
|
16016
16016
|
}
|
|
16017
16017
|
return "lowp";
|
|
16018
16018
|
}
|
|
16019
|
-
let
|
|
16020
|
-
const maxPrecision = getMaxPrecision(
|
|
16021
|
-
if (maxPrecision !==
|
|
16022
|
-
warn("WebGLRenderer:",
|
|
16023
|
-
|
|
16019
|
+
let precision2 = parameters.precision !== void 0 ? parameters.precision : "highp";
|
|
16020
|
+
const maxPrecision = getMaxPrecision(precision2);
|
|
16021
|
+
if (maxPrecision !== precision2) {
|
|
16022
|
+
warn("WebGLRenderer:", precision2, "not supported, using", maxPrecision, "instead.");
|
|
16023
|
+
precision2 = maxPrecision;
|
|
16024
16024
|
}
|
|
16025
16025
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
16026
16026
|
const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has("EXT_clip_control");
|
|
@@ -16041,7 +16041,7 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
|
|
|
16041
16041
|
getMaxPrecision,
|
|
16042
16042
|
textureFormatReadable,
|
|
16043
16043
|
textureTypeReadable,
|
|
16044
|
-
precision,
|
|
16044
|
+
precision: precision2,
|
|
16045
16045
|
logarithmicDepthBuffer,
|
|
16046
16046
|
reversedDepthBuffer,
|
|
16047
16047
|
maxTextures,
|
|
@@ -18989,7 +18989,7 @@ function WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities,
|
|
|
18989
18989
|
const programs = [];
|
|
18990
18990
|
const programsMap = /* @__PURE__ */ new Map();
|
|
18991
18991
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
18992
|
-
let
|
|
18992
|
+
let precision2 = capabilities.precision;
|
|
18993
18993
|
const shaderIDs = {
|
|
18994
18994
|
MeshDepthMaterial: "depth",
|
|
18995
18995
|
MeshDistanceMaterial: "distance",
|
|
@@ -19020,9 +19020,9 @@ function WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities,
|
|
|
19020
19020
|
const envMapCubeUVHeight = !!envMap && envMap.mapping === CubeUVReflectionMapping ? envMap.image.height : null;
|
|
19021
19021
|
const shaderID = shaderIDs[material.type];
|
|
19022
19022
|
if (material.precision !== null) {
|
|
19023
|
-
|
|
19024
|
-
if (
|
|
19025
|
-
warn("WebGLProgram.getParameters:", material.precision, "not supported, using",
|
|
19023
|
+
precision2 = capabilities.getMaxPrecision(material.precision);
|
|
19024
|
+
if (precision2 !== material.precision) {
|
|
19025
|
+
warn("WebGLProgram.getParameters:", material.precision, "not supported, using", precision2, "instead.");
|
|
19026
19026
|
}
|
|
19027
19027
|
}
|
|
19028
19028
|
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
@@ -19100,7 +19100,7 @@ function WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities,
|
|
|
19100
19100
|
customFragmentShaderID,
|
|
19101
19101
|
isRawShaderMaterial: material.isRawShaderMaterial === true,
|
|
19102
19102
|
glslVersion: material.glslVersion,
|
|
19103
|
-
precision,
|
|
19103
|
+
precision: precision2,
|
|
19104
19104
|
batching: IS_BATCHEDMESH,
|
|
19105
19105
|
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
|
|
19106
19106
|
instancing: IS_INSTANCEDMESH,
|
|
@@ -33353,10 +33353,6 @@ class Pane extends RootApi {
|
|
|
33353
33353
|
}
|
|
33354
33354
|
}
|
|
33355
33355
|
new Semver("4.0.5");
|
|
33356
|
-
const main$7 = "precision highp float;precision highp int;precision highp usampler2D;uniform highp usampler2D splatTexture;uniform highp usampler2D generalTexture;uniform highp usampler2D transformTexture;uniform highp usampler2D sphericalHarmonicsTexture0;uniform highp usampler2D sphericalHarmonicsTexture1;uniform highp usampler2D sphericalHarmonicsTexture2;uniform highp usampler2D sphericalHarmonicsTexture3;uniform float sphericalHarmonicsIntensity;uniform mat4 projection,view;uniform vec3 eyePosition;uniform vec2 focal;uniform vec2 inverseViewport;uniform float gaussianScale;uniform float effectMinimumScale;uniform float effectDistance;uniform float effectDistanceMax;uniform float effectDistanceRange;uniform float effectDistanceColor;uniform float effectDistanceColorNear;uniform float effectSonar;uniform float effectSonarRange;uniform vec3 worldOrigin;uniform float additionAlpha;uniform float multiplicationAlpha;uniform float blur;uniform float sharpness;uniform vec4 scaleAlphaMin;uniform vec4 scaleAlphaMax;uniform uint transformTextureWidth;in vec2 localPosition;in uint indices;out vec4 vColor;out vec2 vPosition;out float vGeneralR;out float vColorEffectFactor;out float vSonarFactor;out vec3 vWorldPosition;const float PI=3.14159265358979;const float PI2=PI*2.0;const float INV_255=1.0/255.0;vec3 unpack(uint bits){return vec3((uvec3(bits)>>uvec3(21u,11u,0u))&uvec3(0x7ffu,0x3ffu,0x7ffu))/vec3(2047.0,1023.0,2047.0)*2.0-1.0;}void readV(in uvec4 i,out vec3 v,out vec3 w,out vec3 x,out vec3 y){v=unpack(i.x);w=unpack(i.y);x=unpack(i.z);y=unpack(i.w);}void readVF(in uvec4 i,out vec3 v,out vec3 w,out vec3 x,out float f){v=unpack(i.x);w=unpack(i.y);x=unpack(i.z);f=uintBitsToFloat(i.w);}vec3 calculateSH(ivec2 uv,vec3 eye){float scale;vec3 sh[15];readV(texelFetch(sphericalHarmonicsTexture0,uv,0),sh[0],sh[1],sh[2],sh[3]);readV(texelFetch(sphericalHarmonicsTexture1,uv,0),sh[4],sh[5],sh[6],sh[7]);readV(texelFetch(sphericalHarmonicsTexture2,uv,0),sh[8],sh[9],sh[10],sh[11]);readVF(texelFetch(sphericalHarmonicsTexture3,uv,0),sh[12],sh[13],sh[14],scale);vec3 result=0.4886025119029199*(-sh[0]*eye.y+sh[1]*eye.z-sh[2]*eye.x);float x2=eye.x*eye.x;float y2=eye.y*eye.y;float z2=eye.z*eye.z;float xy=eye.x*eye.y;float yz=eye.y*eye.z;float xz=eye.x*eye.z;result+=sh[3]*(1.0925484305920792*xy)+sh[4]*(-1.0925484305920792*yz)+sh[5]*(0.31539156525252005*(2.0*z2-x2-y2))+sh[6]*(-1.0925484305920792*xz)+sh[7]*(0.5462742152960396*(x2-y2));result+=sh[8]*(-0.5900435899266435*eye.y*(3.0*x2-y2))+sh[9]*(2.890611442640554*xy*eye.z)+sh[10]*(-0.4570457994644658*eye.y*(4.0*z2-x2-y2))+sh[11]*(0.3731763325901154*eye.z*(2.0*z2-3.0*x2-3.0*y2))+sh[12]*(-0.4570457994644658*eye.x*(4.0*z2-x2-y2))+sh[13]*(1.445305721320277*eye.z*(x2-y2))+sh[14]*(-0.5900435899266435*eye.x*(x2-3.0*y2));return result*scale;}vec4 revertQuaternion(uint converted){uint u=converted&0xffu;uint v=(converted>>8u)&0xffu;uint w=(converted>>16u)&0xffu;float x=(float(u)*INV_255)*2.0-1.0;float y=(float(v)*INV_255)*2.0-1.0;float z=1.0-abs(x)-abs(y);float m=max(-z,0.0);x+=(x>=0.0)?-m : m;y+=(y>=0.0)?-m : m;vec3 axis=normalize(vec3(x,y,z));float theta=(float(w)*INV_255)*PI;float halfTheta=theta*0.5;float s=sin(halfTheta);float c=cos(halfTheta);return vec4(axis*s,c);}mat3 generateSigma(vec3 s,vec4 q){return mat3(s.x*(1.0-2.0*(q.y*q.y+q.z*q.z)),s.x*(2.0*(q.x*q.y+q.w*q.z)),s.x*(2.0*(q.x*q.z-q.w*q.y)),s.y*(2.0*(q.x*q.y-q.w*q.z)),s.y*(1.0-2.0*(q.x*q.x+q.z*q.z)),s.y*(2.0*(q.y*q.z+q.w*q.x)),s.z*(2.0*(q.x*q.z+q.w*q.y)),s.z*(2.0*(q.y*q.z-q.w*q.x)),s.z*(1.0-2.0*(q.x*q.x+q.y*q.y)));}mat3 generateRotationScaleMatrix(vec4 q,float s){float x=q.x;float y=q.y;float z=q.z;float w=q.w;float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float xz=x*z;float yz=y*z;float wx=w*x;float wy=w*y;float wz=w*z;return mat3(1.0-2.0*(yy+zz),2.0*(xy+wz),2.0*(xz-wy),2.0*(xy-wz),1.0-2.0*(xx+zz),2.0*(yz+wx),2.0*(xz+wy),2.0*(yz-wx),1.0-2.0*(xx+yy))*s;}void restoreTransform(in uint index,in uint width,out vec3 t,out float s,out vec4 q){uint u=index % width;uint v=uint(floor(float(index)/float(width)));uvec4 transform=texelFetch(transformTexture,ivec2(u,v),0);vec2 r=unpackHalf2x16(transform.x);vec2 g=unpackHalf2x16(transform.y);vec2 b=unpackHalf2x16(transform.z);vec2 a=unpackHalf2x16(transform.w);t=vec3(-r,g.x);s=g.y;q=vec4(b,a);}vec4 multiplyQuaternion(vec4 qA,vec4 qB){float wA=qA.w;vec3 vA=qA.xyz;float wB=qB.w;vec3 vB=qB.xyz;float wC=wA*wB-dot(vA,vB);vec3 vC=cross(vA,vB)+wA*vB+wB*vA;return vec4(vC,wC);}vec4 axisAngleQuaternion(vec3 axis,float angle){vec3 n=normalize(axis);float h=0.5*angle;float s=sin(h);return vec4(n.x*s,n.y*s,n.z*s,cos(h));}void unpack4to8(in uint packed,out uint high,out uint low){high=(packed>>4u)&0xFu;low=packed&0xFu;}void main(){uint u=indices&0x3ffu;uint v=indices>>10;ivec2 uv=ivec2(u,v);uvec4 packed=texelFetch(splatTexture,uv,0);uvec4 general=texelFetch(generalTexture,uv,0);vec3 tPosition=vec3(0.0);float tScale=1.0;vec4 tRotation=vec4(0.0);uint high,low;unpack4to8(general.a,high,low);restoreTransform(low,transformTextureWidth,tPosition,tScale,tRotation);vec3 revertedPosition=vec4(unpackHalf2x16(packed.x),unpackHalf2x16(packed.y&0xffffu)).xyz;uvec3 uScale=uvec3(packed.z&0xffu,(packed.z>>8u)&0xffu,(packed.z>>16u)&0xffu);float invScale=1.0/255.0;vec3 scaleRange=scaleAlphaMax.xyz-scaleAlphaMin.xyz;vec3 scale=vec3(exp(float(uScale.x)*invScale*scaleRange.x+scaleAlphaMin.x)*2.0,exp(float(uScale.y)*invScale*scaleRange.y+scaleAlphaMin.y)*2.0,exp(float(uScale.z)*invScale*scaleRange.z+scaleAlphaMin.z)*2.0);uint rotation=(packed.y>>16u)&0xffffu|(packed.z>>8u)&0xff0000u;vec4 quaternion=revertQuaternion(rotation);uvec4 uintRGBA=uvec4(packed.w&0xffu,(packed.w>>8u)&0xffu,(packed.w>>16u)&0xffu,(packed.w>>24u)&0xffu);vec4 rgba=vec4(uintRGBA)/255.0;float alphaRange=scaleAlphaMax.w-scaleAlphaMin.w;float rawAlpha=(float(general.b)/255.0)*alphaRange+scaleAlphaMin.w;mat3 modelMatrix=generateRotationScaleMatrix(tRotation,tScale);revertedPosition=modelMatrix*revertedPosition+tPosition;scale*=tScale;quaternion=multiplyQuaternion(tRotation,quaternion);vec4 viewPosition=view*vec4(revertedPosition,1.0);vec4 clipPosition=projection*viewPosition;float clip=1.2*clipPosition.w;if(clipPosition.z<-clip||clipPosition.x<-clip||clipPosition.x>clip||clipPosition.y<-clip||clipPosition.y>clip){gl_Position=vec4(0.0,0.0,2.0,1.0);return;}mat3 sigma=generateSigma(scale,quaternion);mat3 Vrk=sigma*transpose(sigma);float vpz=1.0/(viewPosition.z*viewPosition.z);mat3 J=mat3(focal.x/viewPosition.z,0.0,-(focal.x*viewPosition.x)*vpz,0.0,focal.y/viewPosition.z,-(focal.y*viewPosition.y)*vpz,0.0,0.0,0.0);mat3 mat3view=mat3(view);mat3 T=transpose(mat3view)*J;mat3 cov2d=transpose(T)*Vrk*T;float d00=cov2d[0][0]+sharpness;float d01=cov2d[0][1];float d11=cov2d[1][1]+sharpness;float mid=(d00+d11)/2.0;float radius=length(vec2((d00-d11)/2.0,d01));float lambda1=mid+radius,lambda2=mid-radius;if(lambda2<0.0){return;}vec2 diagonalVector=normalize(vec2(d01,lambda1-d00));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);float toCenter=length(revertedPosition-worldOrigin)/effectDistanceMax;float threshold=effectDistance;float range=max(effectDistanceRange,0.0001);float normalizedDistance=(toCenter-threshold)/(range*threshold+0.0001);float ease=effectDistance>=1.0 ? 1.0 :(1.0-min(max(normalizedDistance,0.0),1.0));ease=max(ease,effectMinimumScale);float circularScale=1.0-min(toCenter,1.0);vec2 circularMajorAxis=normalize(majorAxis)*circularScale;vec2 circularMinorAxis=normalize(minorAxis)*circularScale;vec2 finalMajorAxis=mix(circularMajorAxis,majorAxis,ease);vec2 finalMinorAxis=mix(circularMinorAxis,minorAxis,ease);vec4 normalizedColor=rgba;normalizedColor.a=1.0/(1.0+exp(-(rawAlpha*multiplicationAlpha+additionAlpha)));float a=cov2d[0][0];float d=cov2d[1][1];float b=cov2d[0][1];float dPrevious=a*d-b*b;a+=blur;d+=blur;float det=a*d-b*b;float blurAdjust=sqrt(max(0.0,dPrevious/det));normalizedColor.a*=blurAdjust;vPosition=localPosition;vec3 shColor=calculateSH(uv,normalize(eyePosition-revertedPosition));normalizedColor+=vec4(shColor,0.0)*sphericalHarmonicsIntensity;vColor=clamp(clipPosition.z/clipPosition.w+1.0,0.0,1.0)*normalizedColor;vGeneralR=sign(float(general.r));float generalG=1.0-sign(float(general.g));vColor=mix(vColor,vec4(1.0,0.1,1.0,1.0),vGeneralR);float toCenterColor=toCenter;float thresholdColor=effectDistanceColor*(1.0+effectDistanceRange);float farColor=clamp(thresholdColor-toCenterColor,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdColorNear=effectDistanceColorNear*(1.0+effectDistanceRange);float nearColor=1.0-(clamp(thresholdColorNear-toCenterColor,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001));vColorEffectFactor=nearColor*farColor;float outerRadius=effectSonar;float innerRadius=max(0.0,effectSonar-effectSonarRange);float factor=0.0;if(toCenter<=outerRadius&&toCenter>=innerRadius&&effectSonarRange>0.0){float range=outerRadius-innerRadius;factor=range>0.0001 ?(toCenter-innerRadius)/range : 1.0;}vSonarFactor=factor;vec2 center=vec2(clipPosition);vec2 major=localPosition.x*finalMajorAxis*inverseViewport;vec2 minor=localPosition.y*finalMinorAxis*inverseViewport;vec3 worldPosition=vec3(center+(major+minor)*clipPosition.w*gaussianScale*generalG*ease,clipPosition.z);vWorldPosition=revertedPosition;gl_Position=vec4(worldPosition,clipPosition.w);}";
|
|
33357
|
-
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;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
33356
|
function saturate(t) {
|
|
33361
33357
|
return Math.min(Math.max(t, 0), 1);
|
|
33362
33358
|
}
|
|
@@ -36839,7 +36835,19 @@ class StreamLoader extends EventEmitter {
|
|
|
36839
36835
|
if (response.status !== 200) {
|
|
36840
36836
|
throw new Error(`failed to load: [ ${response.status} ]`);
|
|
36841
36837
|
}
|
|
36842
|
-
const
|
|
36838
|
+
const clHeader = response.headers.get("content-length");
|
|
36839
|
+
const parsed = clHeader != null ? +clHeader : NaN;
|
|
36840
|
+
const hasKnownLength = Number.isFinite(parsed) && parsed > 0;
|
|
36841
|
+
if (!hasKnownLength) {
|
|
36842
|
+
const ab = await response.arrayBuffer();
|
|
36843
|
+
const contentLength2 = ab.byteLength;
|
|
36844
|
+
this.emit("getcontentbytelength", contentLength2);
|
|
36845
|
+
this.emit("read", new Uint8Array(ab));
|
|
36846
|
+
this.emit("load", void 0);
|
|
36847
|
+
resolve();
|
|
36848
|
+
return;
|
|
36849
|
+
}
|
|
36850
|
+
const contentLength = parsed;
|
|
36843
36851
|
this.emit("getcontentbytelength", contentLength);
|
|
36844
36852
|
const readableStreamReader = response.body.getReader();
|
|
36845
36853
|
while (true) {
|
|
@@ -37426,16 +37434,16 @@ class PlyDecoder {
|
|
|
37426
37434
|
};
|
|
37427
37435
|
}
|
|
37428
37436
|
}
|
|
37429
|
-
const main$3 = "uniform float size
|
|
37430
|
-
const main$2 = "uniform vec3 diffuse
|
|
37431
|
-
const main$1 = "
|
|
37432
|
-
const main = "
|
|
37433
|
-
const jsContent$1 = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (let q = 0; q < 256; q++) {\n _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n}\n_utf8len[254] = _utf8len[254] = 1;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inffast$1(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n };\n return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inflate_fast2(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\n }\n }\n Inflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction unpack8to4(value) {\n const high = value >> 4 & 15;\n const low = value & 15;\n return [high, low];\n}\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst create4x4 = (translation, rotation, scale) => {\n const sx = Math.sin(rotation[0]);\n const sy = Math.sin(rotation[1]);\n const sz = Math.sin(rotation[2]);\n const cx = Math.cos(rotation[0]);\n const cy = Math.cos(rotation[1]);\n const cz = Math.cos(rotation[2]);\n const ae = cx * cz;\n const af = cx * sz;\n const be = sx * cz;\n const bf = sx * sz;\n const mat = new Float32Array(16);\n mat[0] = cy * cz * scale;\n mat[1] = (af + be * sy) * scale;\n mat[2] = (bf - ae * sy) * scale;\n mat[3] = 0;\n mat[4] = -cy * sz * scale;\n mat[5] = (ae - bf * sy) * scale;\n mat[6] = (be + af * sy) * scale;\n mat[7] = 0;\n mat[8] = sy * scale;\n mat[9] = -sx * cy * scale;\n mat[10] = cx * cy * scale;\n mat[11] = 0;\n mat[12] = translation[0];\n mat[13] = translation[1];\n mat[14] = translation[2];\n mat[15] = 1;\n return mat;\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (sourceTransform, target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n const sources = Array.isArray(sourceTransform) === true ? sourceTransform : [sourceTransform];\n const modelMatrix = sources.map((source) => {\n const t = [-source.translation.x, -source.translation.y, source.translation.z];\n const r = [source.rotation.x, source.rotation.y, source.rotation.z];\n const s = source.scale;\n return create4x4(t, r, s);\n });\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n const [meshIndex, instanceIndex] = unpack8to4(A);\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const tx = currentBufferFloatView[fIndex + 0];\n const ty = currentBufferFloatView[fIndex + 1];\n const tz = currentBufferFloatView[fIndex + 2];\n const transformed = apply4x4(modelMatrix[instanceIndex], tx, ty, tz);\n const x = transformed[0];\n const y = transformed[1];\n const z = transformed[2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.source, e.data.collision);\n }\n};\n';
|
|
37434
|
-
const blob
|
|
37437
|
+
const main$3 = "uniform float size;\nuniform float scale;\nuniform float effectDistanceNear;\nuniform float effectDistance;\nuniform float effectDistanceMax;\nuniform float effectDistanceRange;\nuniform float effectDistanceColor; // 色エフェクト(可視部分の外側)\nuniform float effectDistanceColorNear; // 色エフェクト(可視部分の内側)\nuniform float effectSonar; // ソナーエフェクト(外側の円の半径)\nuniform float effectSonarRange; // ソナーエフェクトの範囲\nuniform vec3 worldOrigin;\nvarying float vAlpha;\nvarying float vColorEffectFactor; // 色エフェクトの係数(0.0~1.0)\nvarying float vSonarFactor; // ソナーエフェクトの係数(0.0~1.0)\nvarying vec3 vWorldPosition; // ワールド座標(角度計算用)\n\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\n#ifdef USE_POINTS_UV\n\n varying vec2 vUv;\n uniform mat3 uvTransform;\n\n#endif\n\nvoid main() {\n\n #ifdef USE_POINTS_UV\n\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n #endif\n\n#if defined( USE_COLOR_ALPHA )\n\n vColor = vec4( 1.0 );\n\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\n vColor = vec3( 1.0 );\n\n#endif\n\n#ifdef USE_COLOR\n\n vColor *= color;\n\n#endif\n\n#ifdef USE_INSTANCING_COLOR\n\n vColor.xyz *= instanceColor.xyz;\n\n#endif\n\n#ifdef USE_BATCHING_COLOR\n\n vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\n vColor.xyz *= batchingColor.xyz;\n\n#endif\n\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n\n gl_PointSize = size;\n\n #ifdef USE_SIZEATTENUATION\n\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n #endif\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n\n vec4 floatPosition = modelMatrix * vec4(position, 1.0);\n float toCenter = min(length(floatPosition.xyz - worldOrigin) / effectDistanceMax, 1.0);\n\n float threshold = effectDistance * (1.0 + effectDistanceRange);\n float far = clamp(threshold - toCenter, 0.0, effectDistanceRange) / max(effectDistanceRange, 0.0001);\n float thresholdNear = effectDistanceNear * (1.0 + effectDistanceRange);\n float near = 1.0 - (clamp(thresholdNear - toCenter, 0.0, effectDistanceRange) / max(effectDistanceRange, 0.0001));\n vAlpha = near * far;\n\n // 色エフェクトの距離係数を計算\n float thresholdColor = effectDistanceColor * (1.0 + effectDistanceRange);\n float farColor = clamp(thresholdColor - toCenter, 0.0, effectDistanceRange) / max(effectDistanceRange, 0.0001);\n float thresholdColorNear = effectDistanceColorNear * (1.0 + effectDistanceRange);\n float nearColor = 1.0 - (clamp(thresholdColorNear - toCenter, 0.0, effectDistanceRange) / max(effectDistanceRange, 0.0001));\n vColorEffectFactor = nearColor * farColor;\n\n // ソナーエフェクトの距離係数を計算(ドーナツ形状)\n // 外側の円の半径: effectSonar (0.0~1.0)\n // 内側の円の半径: effectSonar - effectSonarRange\n float outerRadius = effectSonar;\n float innerRadius = max(0.0, effectSonar - effectSonarRange);\n\n // エフェクト範囲内かどうかを判定\n float factor = 0.0;\n if (toCenter <= outerRadius && toCenter >= innerRadius && effectSonarRange > 0.0) {\n // ドーナツ形状の範囲内:距離に基づいて0.0~1.0の係数を計算\n // 外側(outerRadius)で1.0、内側(innerRadius)で0.0\n float range = outerRadius - innerRadius;\n factor = range > 0.0001 ? (toCenter - innerRadius) / range : 1.0;\n }\n vSonarFactor = factor;\n\n // ワールド座標を保存\n vWorldPosition = floatPosition.xyz;\n}";
|
|
37438
|
+
const main$2 = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float temperature;\nuniform float tint;\nuniform float contrastIntensity;\nuniform vec3 hsv;\nuniform vec3 rgb;\n\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;\nvarying float vColorEffectFactor; // 色エフェクトの係数(0.0~1.0)\nvarying float vSonarFactor; // ソナーエフェクトの係数(0.0~1.0)\nvarying vec3 vWorldPosition; // ワールド座標(角度計算用)\nuniform vec3 worldOrigin;\nuniform float effectSonar; // ソナーエフェクト(歪みの回転に使用)\n\nconst float EPS = 1.0e-8;\nconst float DIV = 10.0 / 6.0;\nconst mat3 LIN_2_LMS_MAT = mat3(\n 3.90405e-1, 5.49941e-1, 8.92632e-3,\n 7.08416e-2, 9.63172e-1, 1.35775e-3,\n 2.31082e-2, 1.28021e-1, 9.36245e-1\n);\nconst mat3 LMS_2_LIN_MAT = mat3(\n 2.85847e+0, -1.62879e+0, -2.48910e-2,\n -2.10182e-1, 1.15820e+0, 3.24281e-4,\n -4.18120e-2, -1.18169e-1, 1.06867e+0\n);\n\nvec3 whiteBalance(vec3 diffuse, float te, float ti) {\n // Range ~[-1.67 : 1.67] works best\n float t1 = te * DIV;\n float t2 = ti * DIV;\n float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);\n float standardIlluminantY = 2.87 * x - 3.0 * x * x - 0.27509507;\n float y = standardIlluminantY + t2 * 0.05;\n vec3 w1 = vec3(0.949237, 1.03542, 1.08728);\n\n // CIExyToLMS\n float X = x / y;\n float Z = (1.0 - x - y) / y;\n float L = 0.7328 * X + 0.4296 - 0.1624 * Z;\n float M = -0.7036 * X + 1.6975 + 0.0061 * Z;\n float S = 0.0030 * X + 0.0136 + 0.9834 * Z;\n vec3 w2 = vec3(L, M, S);\n\n vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);\n vec3 lms = LIN_2_LMS_MAT * diffuse;\n lms *= balance;\n return LMS_2_LIN_MAT * lms;\n}\n\nvec3 RGB2HSV(vec3 color) {\n vec3 c = min(color, 1.0);\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + EPS)), d / (q.x + EPS), q.x);\n}\n\nvec3 HSV2RGB(vec3 color) {\n vec3 c = min(color, 1.0);\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\nvec3 contrast(vec3 color, float base) {\n float b = (base * 2.0 - 1.0) * 0.5;\n return color + vec3(\n atan((color.r * 2.0 - 1.0) * b),\n atan((color.g * 2.0 - 1.0) * b),\n atan((color.b * 2.0 - 1.0) * b)\n );\n}\n\nvec3 grading(vec3 color) {\n vec3 balanced = whiteBalance(color, temperature, tint);\n vec3 contrasted = contrast(balanced, contrastIntensity);\n vec3 hsvColor = RGB2HSV(contrasted);\n hsvColor.x = fract(hsvColor.x + hsv.x);\n hsvColor.y = clamp(hsvColor.y + hsv.y, 0.0, 1.0);\n hsvColor.z = clamp(hsvColor.z + hsv.z, 0.0, 1.0);\n vec3 rgbAdjusted = HSV2RGB(hsvColor);\n rgbAdjusted.r = clamp(rgbAdjusted.r + rgb.r, 0.0, 1.0);\n rgbAdjusted.g = clamp(rgbAdjusted.g + rgb.g, 0.0, 1.0);\n rgbAdjusted.b = clamp(rgbAdjusted.b + rgb.b, 0.0, 1.0);\n return rgbAdjusted;\n}\n\nvoid main() {\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n\n vec3 outgoingLight = vec3( 0.0 );\n\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n\n // 距離係数に基づいてHSV/RGBの影響を制御\n // color_fragmentの後、diffuseColorには頂点カラーが適用された値が含まれている\n vec3 originalColor = diffuseColor.rgb;\n vec3 gradedColor = grading(originalColor);\n vec3 finalColor = mix(originalColor, gradedColor, vColorEffectFactor);\n\n // ソナーエフェクト:範囲内を白で強調\n // vSonarFactor: 外側で1.0、内側で0.0の係数\n if (vSonarFactor > 0.0) {\n float sonarStrength = 2.0; // 強度\n vec3 sonarColor = finalColor;\n\n // 白エリアの処理\n float whiteAreaFactor = smoothstep(0.25, 1.0, vSonarFactor);\n vec3 whiteColor = sonarColor;\n whiteColor.rgb += whiteAreaFactor * sonarStrength * 0.4;\n\n // 色をクランプ\n whiteColor = clamp(whiteColor, 0.0, 1.0);\n\n // エフェクト範囲内でのみ適用\n finalColor = mix(finalColor, whiteColor, vSonarFactor);\n }\n\n outgoingLight = finalColor;\n\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n\n gl_FragColor.a *= vAlpha;\n}";
|
|
37439
|
+
const main$1 = "// #version 300 es\nin vec3 position;\nvoid main() {\n gl_Position = vec4(position, 1.0);\n}\n";
|
|
37440
|
+
const main = "// #version 300 es\nprecision highp float;\nprecision highp int;\n\nuniform vec3 viewOrigin;\nuniform uint vertexCount;\n// splats (position, scale, rotation... etc.)\nuniform highp usampler2D splatTexture;\n// general (selection etc.)\nuniform highp usampler2D generalTexture;\n// transform (position, scale, rotation)\nuniform highp usampler2D transformTexture;\n// transform texture width\nuniform uint transformTextureWidth;\n\nout vec4 fragColor;\n\nconst uint TEXTURE_WIDTH = 1024u;\nconst float INV_255 = 1.0 / 255.0;\nconst float INF = 1.0 / 0.0;\n\nivec2 getSplatCoord(uint indices) {\n uint u = indices & 0x3ffu;\n uint v = indices >> 10;\n return ivec2(u, v);\n}\nvec3 getPosition(uvec4 packed) {\n return vec4(\n unpackHalf2x16(packed.x),\n unpackHalf2x16(packed.y & 0xffffu)\n ).xyz;\n}\nmat3 generateRotationScaleMatrix(vec4 q, float s) {\n float x = q.x;\n float y = q.y;\n float z = q.z;\n float w = q.w;\n float xx = x * x;\n float yy = y * y;\n float zz = z * z;\n float xy = x * y;\n float xz = x * z;\n float yz = y * z;\n float wx = w * x;\n float wy = w * y;\n float wz = w * z;\n return mat3(\n 1.0 - 2.0 * (yy + zz), 2.0 * (xy + wz), 2.0 * (xz - wy),\n 2.0 * (xy - wz), 1.0 - 2.0 * (xx + zz), 2.0 * (yz + wx),\n 2.0 * (xz + wy), 2.0 * (yz - wx), 1.0 - 2.0 * (xx + yy)\n ) * s;\n}\nvoid restoreTransform(in uint index, in uint width, out vec3 t, out float s, out vec4 q) {\n uint u = index % width;\n uint v = uint(floor(float(index) / float(width)));\n uvec4 transform = texelFetch(transformTexture, ivec2(u, v), 0);\n vec2 r = unpackHalf2x16(transform.x);\n vec2 g = unpackHalf2x16(transform.y);\n vec2 b = unpackHalf2x16(transform.z);\n vec2 a = unpackHalf2x16(transform.w);\n t = vec3(-r, g.x);\n s = g.y;\n q = vec4(b, a);\n}\nvoid unpack4to8(in uint packed, out uint high, out uint low) {\n high = (packed >> 4u) & 0xFu;\n low = packed & 0xFu;\n}\nfloat getDistance(uint indices) {\n if (indices >= vertexCount) {\n return INF;\n }\n ivec2 uv = getSplatCoord(indices);\n uvec4 packed = texelFetch(splatTexture, uv, 0);\n uvec4 general = texelFetch(generalTexture, uv, 0);\n vec3 tPosition = vec3(0.0);\n float tScale = 1.0;\n vec4 tRotation = vec4(0.0);\n uint high, low;\n unpack4to8(general.a, high, low);\n restoreTransform(low, transformTextureWidth, tPosition, tScale, tRotation);\n mat3 mm = generateRotationScaleMatrix(tRotation, tScale);\n vec3 position = getPosition(packed);\n position = mm * position + tPosition;\n return length(position - viewOrigin);\n}\n\nvoid main () {\n uvec2 u = uvec2(gl_FragCoord.st);\n uint indices = (u.s + u.t * TEXTURE_WIDTH) * 2u;\n float distance1 = getDistance(indices);\n float distance2 = getDistance(indices + 1u);\n\n vec2 combine = vec2(distance1, distance2);\n uint packedUint = packHalf2x16(combine);\n uvec4 rgba = uvec4(\n packedUint & 0xffu,\n (packedUint >> 8u) & 0xffu,\n (packedUint >> 16u) & 0xffu,\n (packedUint >> 24u) & 0xffu\n );\n fragColor = vec4(rgba) * INV_255;\n}\n";
|
|
37441
|
+
const jsContent = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (let q = 0; q < 256; q++) {\n _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n}\n_utf8len[254] = _utf8len[254] = 1;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inffast$1(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n };\n return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inflate_fast2(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\n }\n }\n Inflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction unpack8to4(value) {\n const high = value >> 4 & 15;\n const low = value & 15;\n return [high, low];\n}\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst create4x4 = (translation, rotation, scale) => {\n const sx = Math.sin(rotation[0]);\n const sy = Math.sin(rotation[1]);\n const sz = Math.sin(rotation[2]);\n const cx = Math.cos(rotation[0]);\n const cy = Math.cos(rotation[1]);\n const cz = Math.cos(rotation[2]);\n const ae = cx * cz;\n const af = cx * sz;\n const be = sx * cz;\n const bf = sx * sz;\n const mat = new Float32Array(16);\n mat[0] = cy * cz * scale;\n mat[1] = (af + be * sy) * scale;\n mat[2] = (bf - ae * sy) * scale;\n mat[3] = 0;\n mat[4] = -cy * sz * scale;\n mat[5] = (ae - bf * sy) * scale;\n mat[6] = (be + af * sy) * scale;\n mat[7] = 0;\n mat[8] = sy * scale;\n mat[9] = -sx * cy * scale;\n mat[10] = cx * cy * scale;\n mat[11] = 0;\n mat[12] = translation[0];\n mat[13] = translation[1];\n mat[14] = translation[2];\n mat[15] = 1;\n return mat;\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (sourceTransform, target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n const sources = Array.isArray(sourceTransform) === true ? sourceTransform : [sourceTransform];\n const modelMatrix = sources.map((source) => {\n const t = [-source.translation.x, -source.translation.y, source.translation.z];\n const r = [source.rotation.x, source.rotation.y, source.rotation.z];\n const s = source.scale;\n return create4x4(t, r, s);\n });\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n const [meshIndex, instanceIndex] = unpack8to4(A);\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const tx = currentBufferFloatView[fIndex + 0];\n const ty = currentBufferFloatView[fIndex + 1];\n const tz = currentBufferFloatView[fIndex + 2];\n const transformed = apply4x4(modelMatrix[instanceIndex], tx, ty, tz);\n const x = transformed[0];\n const y = transformed[1];\n const z = transformed[2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.source, e.data.collision);\n } else if (e.ports.length > 0 && e.data.requestBuffer != null) {\n const port = e.ports[0];\n const gaussianData = new Uint8Array(currentBuffer).slice();\n const sphericalHarmonicsData = new Float32Array(currentSHBuffer).slice();\n port.postMessage({\n gaussianData,\n sphericalHarmonicsData\n }, [\n gaussianData.buffer,\n sphericalHarmonicsData.buffer\n ]);\n }\n};\n';
|
|
37442
|
+
const blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
37435
37443
|
function WorkerWrapper$1(options) {
|
|
37436
37444
|
let objURL;
|
|
37437
37445
|
try {
|
|
37438
|
-
objURL = blob
|
|
37446
|
+
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
|
|
37439
37447
|
if (!objURL) throw "";
|
|
37440
37448
|
const worker = new Worker(objURL, {
|
|
37441
37449
|
type: "module",
|
|
@@ -37447,7 +37455,7 @@ function WorkerWrapper$1(options) {
|
|
|
37447
37455
|
return worker;
|
|
37448
37456
|
} catch (e) {
|
|
37449
37457
|
return new Worker(
|
|
37450
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent
|
|
37458
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
37451
37459
|
{
|
|
37452
37460
|
type: "module",
|
|
37453
37461
|
name: options?.name
|
|
@@ -37463,10 +37471,10 @@ const TavioWasm = /* @__PURE__ */ (() => {
|
|
|
37463
37471
|
const isThreadSupported = false;
|
|
37464
37472
|
const instance = isThreadSupported ? (
|
|
37465
37473
|
// @ts-ignore
|
|
37466
|
-
await import("./wasm/pkg/thread")
|
|
37474
|
+
await import("./wasm/pkg/thread/tavio.js")
|
|
37467
37475
|
) : (
|
|
37468
37476
|
// @ts-ignore
|
|
37469
|
-
await import("./wasm/pkg/no-thread")
|
|
37477
|
+
await import("./wasm/pkg/no-thread/tavio.js")
|
|
37470
37478
|
);
|
|
37471
37479
|
console.info("[TavioMesh] Initializing WASM...");
|
|
37472
37480
|
try {
|
|
@@ -37493,30 +37501,14 @@ const TavioWasm = /* @__PURE__ */ (() => {
|
|
|
37493
37501
|
return instancePromise;
|
|
37494
37502
|
};
|
|
37495
37503
|
})();
|
|
37496
|
-
const jsContent = 'let wasm = null;\nself.onmessage = async (e) => {\n switch (e.data.kind) {\n case "init":\n await init(e.data.options);\n break;\n case "registerEventHandler":\n wasm.registerEventHandler((e2) => {\n const message = {\n category: "wasmCallback",\n data: e2\n };\n postMessage(message, collectTransferables(e2));\n });\n break;\n default:\n if ("id" in e.data && "args" in e.data) {\n const { kind, id, args } = e.data;\n try {\n const fn = wasm[kind];\n const result = await fn(...args);\n const message = { kind, id, result };\n postMessage(message);\n } catch (error) {\n const message = {\n category: "wasmError",\n id,\n error\n };\n postMessage(message);\n }\n }\n break;\n }\n};\nasync function init(options) {\n const useSharedArrayBuffer = options?.useSharedArrayBuffer == true;\n const threadCount = Math.min(\n options?.threadCount ?? 1,\n navigator.hardwareConcurrency\n );\n const isParallel = useSharedArrayBuffer && threadCount > 1;\n wasm = useSharedArrayBuffer ? (\n // @ts-ignore\n await import("./wasm/pkg/thread")\n ) : (\n // @ts-ignore\n await import("./wasm/pkg/no-thread")\n );\n try {\n await wasm.default();\n console.info(\n ` WASM${useSharedArrayBuffer ? " (thread)" : "(no-thread)"} initialized successfully`\n );\n } catch (e) {\n console.error("[WasmWorker] Failed to initialize WASM (tavio_bg.wasm):", e);\n console.error("[WasmWorker] This error typically occurs when:");\n console.error(\n " 1. The tavio_bg.wasm file is not deployed to the correct path"\n );\n console.error(" 2. CORS policy is blocking the WASM file");\n console.error(\n " 3. The WASM file has incorrect MIME type (should be application/wasm)"\n );\n throw e;\n }\n if (isParallel) {\n try {\n console.info(\n `[WasmWorker] Initializing thread pool with ${threadCount} threads...`\n );\n wasm.initThreadPool(threadCount);\n console.info("[WasmWorker] Thread pool initialized successfully");\n } catch (e) {\n console.error("[WasmWorker] Failed to initialize thread pool:", e);\n console.error("[WasmWorker] This error typically occurs when:");\n console.error(\n " 1. workerHelpers.js is not deployed to the correct path"\n );\n console.error(\n " 2. SharedArrayBuffer is not available (requires secure context and COOP/COEP headers)"\n );\n throw e;\n }\n }\n postMessage({ category: "wasmLoaded" });\n}\nfunction collectTransferables(value) {\n if (!value || typeof value !== "object") return [];\n const set = /* @__PURE__ */ new Set();\n for (const v of Object.values(value)) {\n if (v instanceof ArrayBuffer) {\n set.add(v);\n } else if (ArrayBuffer.isView(v)) {\n set.add(v.buffer);\n }\n }\n return Array.from(set);\n}\n';
|
|
37497
|
-
const blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
37498
37504
|
function WorkerWrapper(options) {
|
|
37499
|
-
|
|
37500
|
-
|
|
37501
|
-
|
|
37502
|
-
if (!objURL) throw "";
|
|
37503
|
-
const worker = new Worker(objURL, {
|
|
37505
|
+
return new Worker(
|
|
37506
|
+
"" + new URL("wasm-worker-CEuC2YyS.js", import.meta.url).href,
|
|
37507
|
+
{
|
|
37504
37508
|
type: "module",
|
|
37505
37509
|
name: options?.name
|
|
37506
|
-
}
|
|
37507
|
-
|
|
37508
|
-
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
37509
|
-
});
|
|
37510
|
-
return worker;
|
|
37511
|
-
} catch (e) {
|
|
37512
|
-
return new Worker(
|
|
37513
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
37514
|
-
{
|
|
37515
|
-
type: "module",
|
|
37516
|
-
name: options?.name
|
|
37517
|
-
}
|
|
37518
|
-
);
|
|
37519
|
-
}
|
|
37510
|
+
}
|
|
37511
|
+
);
|
|
37520
37512
|
}
|
|
37521
37513
|
class TavioWasmWorkerClient {
|
|
37522
37514
|
worker = new WorkerWrapper();
|
|
@@ -37603,6 +37595,177 @@ class TavioWasmWorkerClient {
|
|
|
37603
37595
|
});
|
|
37604
37596
|
}
|
|
37605
37597
|
}
|
|
37598
|
+
function wasmBuildSourceProperty(event, sourceIndex, sourceVertexOffset) {
|
|
37599
|
+
let magicNumber = "";
|
|
37600
|
+
let majorVersion = 0;
|
|
37601
|
+
let minorVersion = 0;
|
|
37602
|
+
switch (event.format) {
|
|
37603
|
+
case "splat":
|
|
37604
|
+
magicNumber = "";
|
|
37605
|
+
majorVersion = 0;
|
|
37606
|
+
minorVersion = 0;
|
|
37607
|
+
break;
|
|
37608
|
+
case "ply":
|
|
37609
|
+
magicNumber = "ply";
|
|
37610
|
+
majorVersion = event.header.majorVersion;
|
|
37611
|
+
minorVersion = event.header.minorVersion;
|
|
37612
|
+
break;
|
|
37613
|
+
case "spz":
|
|
37614
|
+
magicNumber = event.header.magic;
|
|
37615
|
+
majorVersion = event.header.version;
|
|
37616
|
+
minorVersion = 0;
|
|
37617
|
+
break;
|
|
37618
|
+
case "sog":
|
|
37619
|
+
magicNumber = "";
|
|
37620
|
+
majorVersion = event.header.version;
|
|
37621
|
+
minorVersion = 0;
|
|
37622
|
+
break;
|
|
37623
|
+
}
|
|
37624
|
+
return {
|
|
37625
|
+
ready: false,
|
|
37626
|
+
index: sourceIndex,
|
|
37627
|
+
type: event.format,
|
|
37628
|
+
vertexCount: event.totalPointCount,
|
|
37629
|
+
vertexOffset: sourceVertexOffset,
|
|
37630
|
+
featureBits: 0,
|
|
37631
|
+
containmentRadius: { per100: null },
|
|
37632
|
+
magicNumber,
|
|
37633
|
+
majorVersion,
|
|
37634
|
+
minorVersion,
|
|
37635
|
+
transform: {
|
|
37636
|
+
translation: new Vector3(0, 0, 0),
|
|
37637
|
+
rotation: new Euler(0, 0, 0),
|
|
37638
|
+
scale: 1
|
|
37639
|
+
},
|
|
37640
|
+
billboard: false
|
|
37641
|
+
};
|
|
37642
|
+
}
|
|
37643
|
+
function wasmBuildSharedData(event, prototype, gaussianCount, generalDataSize, orderDataSize) {
|
|
37644
|
+
const sharedData = Object.create(prototype);
|
|
37645
|
+
sharedData.sharedGaussianData = event.sharedGaussianBuffer;
|
|
37646
|
+
sharedData.sharedSphericalHarmonicsData = event.sharedShBuffer;
|
|
37647
|
+
sharedData.sharedGaussianIndexData = new SharedArrayBuffer(gaussianCount * 4);
|
|
37648
|
+
sharedData.sharedGaussianOrderData = new SharedArrayBuffer(orderDataSize);
|
|
37649
|
+
sharedData.sharedGaussianGeneralData = new SharedArrayBuffer(generalDataSize);
|
|
37650
|
+
return sharedData;
|
|
37651
|
+
}
|
|
37652
|
+
function wasmBuildWorkerUpdateMessage(event, uniforms, sourceIndex, usingSharedArrayBuffer) {
|
|
37653
|
+
const message = {
|
|
37654
|
+
updateTexture: true
|
|
37655
|
+
};
|
|
37656
|
+
if (sourceIndex > 0) {
|
|
37657
|
+
message.previousScale = {
|
|
37658
|
+
min: [
|
|
37659
|
+
uniforms.scaleAlphaMin.value.x,
|
|
37660
|
+
uniforms.scaleAlphaMin.value.y,
|
|
37661
|
+
uniforms.scaleAlphaMin.value.z
|
|
37662
|
+
],
|
|
37663
|
+
max: [
|
|
37664
|
+
uniforms.scaleAlphaMax.value.x,
|
|
37665
|
+
uniforms.scaleAlphaMax.value.y,
|
|
37666
|
+
uniforms.scaleAlphaMax.value.z
|
|
37667
|
+
]
|
|
37668
|
+
};
|
|
37669
|
+
message.previousAlpha = {
|
|
37670
|
+
min: [uniforms.scaleAlphaMin.value.w],
|
|
37671
|
+
max: [uniforms.scaleAlphaMax.value.w]
|
|
37672
|
+
};
|
|
37673
|
+
message.scale = {
|
|
37674
|
+
min: event.scaleMinValues,
|
|
37675
|
+
max: event.scaleMaxValues
|
|
37676
|
+
};
|
|
37677
|
+
message.alpha = {
|
|
37678
|
+
min: [event.alphaMinValue],
|
|
37679
|
+
max: [event.alphaMaxValue]
|
|
37680
|
+
};
|
|
37681
|
+
}
|
|
37682
|
+
if (usingSharedArrayBuffer) {
|
|
37683
|
+
return {
|
|
37684
|
+
message: {
|
|
37685
|
+
buffer: new ArrayBuffer(0),
|
|
37686
|
+
// workaround for mergeBuffer
|
|
37687
|
+
shBuffer: new ArrayBuffer(0),
|
|
37688
|
+
// workaround for mergeBuffer
|
|
37689
|
+
...message
|
|
37690
|
+
},
|
|
37691
|
+
transfer: []
|
|
37692
|
+
};
|
|
37693
|
+
} else {
|
|
37694
|
+
const transfer = [event.gaussianBuffer.buffer];
|
|
37695
|
+
if (event.shBuffer != null) {
|
|
37696
|
+
message.shBuffer = event.shBuffer.buffer;
|
|
37697
|
+
transfer.push(event.shBuffer.buffer);
|
|
37698
|
+
}
|
|
37699
|
+
return {
|
|
37700
|
+
message: {
|
|
37701
|
+
buffer: event.gaussianBuffer.buffer,
|
|
37702
|
+
...message
|
|
37703
|
+
},
|
|
37704
|
+
transfer
|
|
37705
|
+
};
|
|
37706
|
+
}
|
|
37707
|
+
}
|
|
37708
|
+
function wasmUpdateUniforms(event, uniforms, sourceIndex) {
|
|
37709
|
+
if (sourceIndex > 0) {
|
|
37710
|
+
uniforms.scaleAlphaMin.value.x = Math.min(
|
|
37711
|
+
event.scaleMinValues[0],
|
|
37712
|
+
uniforms.scaleAlphaMin.value.x
|
|
37713
|
+
);
|
|
37714
|
+
uniforms.scaleAlphaMin.value.y = Math.min(
|
|
37715
|
+
event.scaleMinValues[1],
|
|
37716
|
+
uniforms.scaleAlphaMin.value.y
|
|
37717
|
+
);
|
|
37718
|
+
uniforms.scaleAlphaMin.value.z = Math.min(
|
|
37719
|
+
event.scaleMinValues[2],
|
|
37720
|
+
uniforms.scaleAlphaMin.value.z
|
|
37721
|
+
);
|
|
37722
|
+
uniforms.scaleAlphaMin.value.w = Math.min(
|
|
37723
|
+
event.alphaMinValue,
|
|
37724
|
+
uniforms.scaleAlphaMin.value.w
|
|
37725
|
+
);
|
|
37726
|
+
uniforms.scaleAlphaMax.value.x = Math.max(
|
|
37727
|
+
event.scaleMaxValues[0],
|
|
37728
|
+
uniforms.scaleAlphaMax.value.x
|
|
37729
|
+
);
|
|
37730
|
+
uniforms.scaleAlphaMax.value.y = Math.max(
|
|
37731
|
+
event.scaleMaxValues[1],
|
|
37732
|
+
uniforms.scaleAlphaMax.value.y
|
|
37733
|
+
);
|
|
37734
|
+
uniforms.scaleAlphaMax.value.z = Math.max(
|
|
37735
|
+
event.scaleMaxValues[2],
|
|
37736
|
+
uniforms.scaleAlphaMax.value.z
|
|
37737
|
+
);
|
|
37738
|
+
uniforms.scaleAlphaMax.value.w = Math.max(
|
|
37739
|
+
event.alphaMaxValue,
|
|
37740
|
+
uniforms.scaleAlphaMax.value.w
|
|
37741
|
+
);
|
|
37742
|
+
} else {
|
|
37743
|
+
uniforms.scaleAlphaMin.value.x = event.scaleMinValues[0];
|
|
37744
|
+
uniforms.scaleAlphaMin.value.y = event.scaleMinValues[1];
|
|
37745
|
+
uniforms.scaleAlphaMin.value.z = event.scaleMinValues[2];
|
|
37746
|
+
uniforms.scaleAlphaMin.value.w = event.alphaMinValue;
|
|
37747
|
+
uniforms.scaleAlphaMax.value.x = event.scaleMaxValues[0];
|
|
37748
|
+
uniforms.scaleAlphaMax.value.y = event.scaleMaxValues[1];
|
|
37749
|
+
uniforms.scaleAlphaMax.value.z = event.scaleMaxValues[2];
|
|
37750
|
+
uniforms.scaleAlphaMax.value.w = event.alphaMaxValue;
|
|
37751
|
+
}
|
|
37752
|
+
}
|
|
37753
|
+
async function requestWorkerBuffer(worker) {
|
|
37754
|
+
return new Promise((resolve) => {
|
|
37755
|
+
const messageChannel = new MessageChannel();
|
|
37756
|
+
messageChannel.port1.onmessage = (evt) => resolve(evt.data);
|
|
37757
|
+
worker.postMessage({ requestBuffer: true }, [messageChannel.port2]);
|
|
37758
|
+
});
|
|
37759
|
+
}
|
|
37760
|
+
function downloadAsFile(bytes, filename) {
|
|
37761
|
+
const blob2 = new Blob([bytes], { type: "application/octet-stream" });
|
|
37762
|
+
const url = URL.createObjectURL(blob2);
|
|
37763
|
+
const a = document.createElement("a");
|
|
37764
|
+
a.href = url;
|
|
37765
|
+
a.download = filename;
|
|
37766
|
+
a.click();
|
|
37767
|
+
URL.revokeObjectURL(url);
|
|
37768
|
+
}
|
|
37606
37769
|
const SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;
|
|
37607
37770
|
const TEXTURE_WIDTH_BASE = 1024;
|
|
37608
37771
|
const DEPTH_RENDER_TEXTURE_WIDTH_BASE = 1024;
|
|
@@ -37817,7 +37980,7 @@ class TavioMesh extends EventEmitter {
|
|
|
37817
37980
|
* @param material - メッシュの生成に使うマテリアルは上の層から指定されたものを使う
|
|
37818
37981
|
* @param pickingMaterial - メッシュの生成に使うマテリアルは上の層から指定されたものを使う
|
|
37819
37982
|
*/
|
|
37820
|
-
constructor(index, camera, material,
|
|
37983
|
+
constructor(index, camera, material, pickingMaterial, viewerOption) {
|
|
37821
37984
|
super();
|
|
37822
37985
|
this.usingSharedArrayBuffer = viewerOption.usingSharedArrayBuffer ?? false;
|
|
37823
37986
|
this.meshIndex = index;
|
|
@@ -37833,7 +37996,7 @@ class TavioMesh extends EventEmitter {
|
|
|
37833
37996
|
this.initializedColorTexture = false;
|
|
37834
37997
|
this.perspectiveCamera = camera;
|
|
37835
37998
|
this.gaussianMaterial = material;
|
|
37836
|
-
this.gaussianPickingMaterial =
|
|
37999
|
+
this.gaussianPickingMaterial = pickingMaterial;
|
|
37837
38000
|
this.maxDistance = 0;
|
|
37838
38001
|
this.mainProperties = null;
|
|
37839
38002
|
this.useWasmSort = false;
|
|
@@ -39187,6 +39350,9 @@ class TavioMesh extends EventEmitter {
|
|
|
39187
39350
|
* @param options.isEncodeEnabled - エンコードを有効にする. 有効にするとエンコード時に必要なデータを読み込む
|
|
39188
39351
|
*/
|
|
39189
39352
|
async loadTavioWasm(url, options) {
|
|
39353
|
+
const decodeMode = options?.decodeMode ?? "sync";
|
|
39354
|
+
const useSphericalHarmonics = options?.useSphericalHarmonics ?? true;
|
|
39355
|
+
const maxDecodePoints = options?.maxDecodePoints ?? Number.POSITIVE_INFINITY;
|
|
39190
39356
|
const threadCount = options?.decodeMode === "parallel" ? options.maxThreads ?? navigator.hardwareConcurrency : 1;
|
|
39191
39357
|
const tavioWasmClient = await TavioWasmWorkerClient.create({
|
|
39192
39358
|
useSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
@@ -39194,17 +39360,17 @@ class TavioMesh extends EventEmitter {
|
|
|
39194
39360
|
});
|
|
39195
39361
|
this.setupFlags();
|
|
39196
39362
|
this.setupTavioWorker();
|
|
39197
|
-
this.setUsingSphericalHarmonics(
|
|
39363
|
+
this.setUsingSphericalHarmonics(useSphericalHarmonics);
|
|
39198
39364
|
this.setUsingWasmSort(true);
|
|
39199
|
-
this.gaussianMaterial.defines = {
|
|
39200
|
-
// この定数が定義されている場合 sigmoid の計算をシェーダ内で行う
|
|
39201
|
-
// ただし、そのためにはテクスチャ(position.w の位置)に変換前の生のアルファを含める必要がある
|
|
39202
|
-
FORMAT_TAVIO: ""
|
|
39203
|
-
};
|
|
39204
39365
|
this.gaussianMaterial.needsUpdate = true;
|
|
39205
39366
|
let contentLength = 0;
|
|
39206
39367
|
let header = null;
|
|
39207
39368
|
let shBuffer = null;
|
|
39369
|
+
const sourceIndex = this.sourceProperty.length;
|
|
39370
|
+
const sourceVertexOffset = this.sourceProperty.reduce(
|
|
39371
|
+
(acc, prop) => acc + prop.vertexCount,
|
|
39372
|
+
0
|
|
39373
|
+
);
|
|
39208
39374
|
tavioWasmClient.registerEventHandler((e) => {
|
|
39209
39375
|
switch (e.type) {
|
|
39210
39376
|
case "decode:fileSize":
|
|
@@ -39213,31 +39379,44 @@ class TavioMesh extends EventEmitter {
|
|
|
39213
39379
|
break;
|
|
39214
39380
|
case "decode:header":
|
|
39215
39381
|
{
|
|
39216
|
-
header = e.
|
|
39382
|
+
header = e.header;
|
|
39217
39383
|
let totalPointCount;
|
|
39218
|
-
|
|
39219
|
-
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39225
|
-
this.
|
|
39226
|
-
this.
|
|
39227
|
-
this.featureBits = this._getFeatureBits(e.data.featureFlags);
|
|
39228
|
-
this.containmentRadius.per50 = e.data.radius50percent;
|
|
39229
|
-
this.containmentRadius.per70 = e.data.radius70percent;
|
|
39230
|
-
this.containmentRadius.per90 = e.data.radius90percent;
|
|
39231
|
-
this.gaussianCountInChunk = e.data.chunkInfo.map(
|
|
39384
|
+
totalPointCount = Math.min(maxDecodePoints, header.totalPointCount);
|
|
39385
|
+
const chunkCount = header.chunkInfo.length;
|
|
39386
|
+
this.majorVersionNumber = parseInt(header.version[0]);
|
|
39387
|
+
this.minorVersionNumber = parseInt(header.version[1]);
|
|
39388
|
+
this.featureBits = this._getFeatureBits(header.featureFlags);
|
|
39389
|
+
this.containmentRadius.per50 = header.radius50percent;
|
|
39390
|
+
this.containmentRadius.per70 = header.radius70percent;
|
|
39391
|
+
this.containmentRadius.per90 = header.radius90percent;
|
|
39392
|
+
this.gaussianCountInChunk = header.chunkInfo.map(
|
|
39232
39393
|
(c) => c.pointCount
|
|
39233
39394
|
);
|
|
39234
|
-
this.
|
|
39235
|
-
this.gaussianCount
|
|
39395
|
+
this.gaussianCount = sourceVertexOffset + totalPointCount;
|
|
39396
|
+
this.setupGeometry(this.gaussianCount);
|
|
39397
|
+
this.sourceProperty.push({
|
|
39398
|
+
ready: false,
|
|
39399
|
+
index: sourceIndex,
|
|
39400
|
+
type: "tavio",
|
|
39401
|
+
vertexCount: totalPointCount,
|
|
39402
|
+
vertexOffset: sourceVertexOffset,
|
|
39403
|
+
featureBits: this.featureBits,
|
|
39404
|
+
containmentRadius: this.containmentRadius,
|
|
39405
|
+
magicNumber: "TC",
|
|
39406
|
+
majorVersion: this.majorVersionNumber,
|
|
39407
|
+
minorVersion: this.minorVersionNumber,
|
|
39408
|
+
transform: {
|
|
39409
|
+
translation: new Vector3(0, 0, 0),
|
|
39410
|
+
rotation: new Euler(0, 0, 0),
|
|
39411
|
+
scale: 1
|
|
39412
|
+
},
|
|
39413
|
+
billboard: false
|
|
39414
|
+
});
|
|
39236
39415
|
const textureWidth = TEXTURE_WIDTH_BASE;
|
|
39237
39416
|
const textureHeight = Math.ceil(totalPointCount / textureWidth);
|
|
39238
|
-
const gaussianDataSize =
|
|
39417
|
+
const gaussianDataSize = header.totalPointCount * ROW_LENGTH_TAVIO;
|
|
39239
39418
|
const generalDataSize = textureWidth * textureHeight * 4;
|
|
39240
|
-
this.currentVertexCount =
|
|
39419
|
+
this.currentVertexCount = sourceVertexOffset;
|
|
39241
39420
|
this.currentSelectionCount = 0;
|
|
39242
39421
|
if (this.usingSharedArrayBuffer) {
|
|
39243
39422
|
this.sharedData = new SharedData(
|
|
@@ -39259,7 +39438,8 @@ class TavioMesh extends EventEmitter {
|
|
|
39259
39438
|
shBuffer: this.sphericalHarmonicsData.buffer,
|
|
39260
39439
|
generalBuffer: this.gaussianGeneralData.buffer,
|
|
39261
39440
|
vertexCount: totalPointCount,
|
|
39262
|
-
usingSharedArrayBuffer: this.usingSharedArrayBuffer
|
|
39441
|
+
usingSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39442
|
+
offset: sourceVertexOffset
|
|
39263
39443
|
});
|
|
39264
39444
|
} else {
|
|
39265
39445
|
const { width, height } = _getDepthRenderTextureWidth(totalPointCount);
|
|
@@ -39269,18 +39449,24 @@ class TavioMesh extends EventEmitter {
|
|
|
39269
39449
|
this.worker.postMessage({
|
|
39270
39450
|
vertexCount: totalPointCount,
|
|
39271
39451
|
usingSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39452
|
+
offset: sourceVertexOffset,
|
|
39272
39453
|
gaussianDataSize,
|
|
39273
39454
|
generalDataSize,
|
|
39274
39455
|
shDataSize: totalPointCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4
|
|
39275
39456
|
});
|
|
39276
39457
|
}
|
|
39458
|
+
this.setupTransformData(
|
|
39459
|
+
sourceIndex,
|
|
39460
|
+
sourceVertexOffset,
|
|
39461
|
+
this.gaussianCount
|
|
39462
|
+
);
|
|
39277
39463
|
}
|
|
39278
39464
|
break;
|
|
39279
39465
|
case "decode:point":
|
|
39280
|
-
this.setupPoints(
|
|
39466
|
+
this.setupPoints(e.data);
|
|
39281
39467
|
break;
|
|
39282
39468
|
case "decode:color":
|
|
39283
|
-
this.setColorIntoPoints(
|
|
39469
|
+
this.setColorIntoPoints(e.data);
|
|
39284
39470
|
break;
|
|
39285
39471
|
case "decode:chunkMain":
|
|
39286
39472
|
{
|
|
@@ -39288,12 +39474,11 @@ class TavioMesh extends EventEmitter {
|
|
|
39288
39474
|
uniforms.scaleAlphaMin.value.x = e.scaleMinValues[0];
|
|
39289
39475
|
uniforms.scaleAlphaMin.value.y = e.scaleMinValues[1];
|
|
39290
39476
|
uniforms.scaleAlphaMin.value.z = e.scaleMinValues[2];
|
|
39291
|
-
uniforms.scaleAlphaMin.value.w = e.
|
|
39477
|
+
uniforms.scaleAlphaMin.value.w = e.alphaMinValue;
|
|
39292
39478
|
uniforms.scaleAlphaMax.value.x = e.scaleMaxValues[0];
|
|
39293
39479
|
uniforms.scaleAlphaMax.value.y = e.scaleMaxValues[1];
|
|
39294
39480
|
uniforms.scaleAlphaMax.value.z = e.scaleMaxValues[2];
|
|
39295
|
-
uniforms.scaleAlphaMax.value.w = e.
|
|
39296
|
-
this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = e.alphaMaxValues[0];
|
|
39481
|
+
uniforms.scaleAlphaMax.value.w = e.alphaMaxValue;
|
|
39297
39482
|
this.currentVertexCount += e.pointCount;
|
|
39298
39483
|
this.emit("convert");
|
|
39299
39484
|
if (shBuffer != null) {
|
|
@@ -39331,37 +39516,289 @@ class TavioMesh extends EventEmitter {
|
|
|
39331
39516
|
}
|
|
39332
39517
|
});
|
|
39333
39518
|
const convertedUrl = new URL(url, location.origin).toString();
|
|
39519
|
+
const waitForFinally = new Promise((resolve) => {
|
|
39520
|
+
this.once("sort", () => {
|
|
39521
|
+
this.sourceProperty[sourceIndex].ready = true;
|
|
39522
|
+
if (!this.sorted) {
|
|
39523
|
+
this.sorted = true;
|
|
39524
|
+
this.emit("finallyupdate", this.gaussianCount);
|
|
39525
|
+
}
|
|
39526
|
+
resolve();
|
|
39527
|
+
});
|
|
39528
|
+
});
|
|
39334
39529
|
await tavioWasmClient.api.decodeTavio(convertedUrl, {
|
|
39335
|
-
decodeMode
|
|
39336
|
-
maxDecodePoints
|
|
39337
|
-
useSphericalHarmonics
|
|
39530
|
+
decodeMode,
|
|
39531
|
+
maxDecodePoints,
|
|
39532
|
+
useSphericalHarmonics
|
|
39338
39533
|
});
|
|
39339
39534
|
this.emit("load", { length: contentLength });
|
|
39340
39535
|
tavioWasmClient.dispose();
|
|
39536
|
+
await waitForFinally;
|
|
39341
39537
|
}
|
|
39342
39538
|
/**
|
|
39343
|
-
*
|
|
39344
|
-
* @param url -
|
|
39345
|
-
* @param
|
|
39346
|
-
* @param options
|
|
39347
|
-
* @param options.maxThreads - decodeMode が "parallel" のときに使用されるスレッド数の上限
|
|
39348
|
-
* @param options.maxDecodePoints - 最大デコード点数. これを超える点は読み込まれない
|
|
39539
|
+
* 様々な形式のリソースをロードする
|
|
39540
|
+
* @param url - 読み込むファイル
|
|
39541
|
+
* @param format - ファイル形式
|
|
39542
|
+
* @param options - ロード・パース関連のオプション
|
|
39349
39543
|
* @param options.useSphericalHarmonics - 球面調和関数を使用
|
|
39350
39544
|
*/
|
|
39351
|
-
async
|
|
39352
|
-
|
|
39545
|
+
async loadMeshWasm(url, format, options) {
|
|
39546
|
+
const useSphericalHarmonics = options?.useSphericalHarmonics ?? true;
|
|
39547
|
+
const tavioWasmClient = await TavioWasmWorkerClient.create({
|
|
39548
|
+
useSharedArrayBuffer: this.usingSharedArrayBuffer
|
|
39549
|
+
});
|
|
39550
|
+
this.setupTavioWorker();
|
|
39551
|
+
this.setUsingSphericalHarmonics(useSphericalHarmonics);
|
|
39552
|
+
this.setUsingWasmSort(true);
|
|
39553
|
+
this.gaussianMaterial.needsUpdate = true;
|
|
39554
|
+
let contentLength = 0;
|
|
39555
|
+
const sourceIndex = this.sourceProperty.length;
|
|
39556
|
+
const sourceVertexOffset = this.sourceProperty.reduce((acc, prop) => {
|
|
39557
|
+
return acc + prop.vertexCount;
|
|
39558
|
+
}, 0);
|
|
39559
|
+
tavioWasmClient.registerEventHandler((e) => {
|
|
39560
|
+
switch (e.type) {
|
|
39561
|
+
case "decode:fileSize":
|
|
39562
|
+
contentLength = e.fileSize;
|
|
39563
|
+
this.emit("getcontentbytelength", { byte: contentLength });
|
|
39564
|
+
break;
|
|
39565
|
+
case "decode:header":
|
|
39566
|
+
{
|
|
39567
|
+
this.gaussianCount = sourceVertexOffset + e.totalPointCount;
|
|
39568
|
+
this.setupGeometry(this.gaussianCount);
|
|
39569
|
+
this.currentVertexCount = sourceVertexOffset;
|
|
39570
|
+
this.currentSelectionCount = 0;
|
|
39571
|
+
const sourceProperty = wasmBuildSourceProperty(
|
|
39572
|
+
e,
|
|
39573
|
+
sourceIndex,
|
|
39574
|
+
sourceVertexOffset
|
|
39575
|
+
);
|
|
39576
|
+
this.sourceProperty.push(sourceProperty);
|
|
39577
|
+
const generalDataSize = (() => {
|
|
39578
|
+
const textureWidth = TEXTURE_WIDTH_BASE;
|
|
39579
|
+
const textureHeight = Math.ceil(this.gaussianCount / textureWidth);
|
|
39580
|
+
return textureWidth * textureHeight * 4;
|
|
39581
|
+
})();
|
|
39582
|
+
const orderDataSize = (() => {
|
|
39583
|
+
const { width, height } = _getDepthRenderTextureWidth(
|
|
39584
|
+
this.gaussianCount
|
|
39585
|
+
);
|
|
39586
|
+
return width * height * 4;
|
|
39587
|
+
})();
|
|
39588
|
+
if (this.usingSharedArrayBuffer) {
|
|
39589
|
+
const sharedData = wasmBuildSharedData(
|
|
39590
|
+
e,
|
|
39591
|
+
SharedData.prototype,
|
|
39592
|
+
this.gaussianCount,
|
|
39593
|
+
generalDataSize,
|
|
39594
|
+
orderDataSize
|
|
39595
|
+
);
|
|
39596
|
+
this.sharedData = sharedData;
|
|
39597
|
+
this.gaussianData = this.sharedData.gaussianData;
|
|
39598
|
+
this.gaussianIndexData = this.sharedData.gaussianIndexData;
|
|
39599
|
+
this.gaussianOrderData = this.sharedData.gaussianOrderData;
|
|
39600
|
+
this.gaussianGeneralData = this.sharedData.gaussianGeneralData;
|
|
39601
|
+
this.sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
|
|
39602
|
+
this.worker.postMessage({
|
|
39603
|
+
buffer: sharedData.gaussianData.buffer,
|
|
39604
|
+
indexBuffer: sharedData.gaussianIndexData.buffer,
|
|
39605
|
+
orderBuffer: sharedData.gaussianOrderData.buffer,
|
|
39606
|
+
shBuffer: sharedData.sphericalHarmonicsData.buffer,
|
|
39607
|
+
generalBuffer: sharedData.gaussianGeneralData.buffer,
|
|
39608
|
+
vertexCount: this.gaussianCount,
|
|
39609
|
+
usingSharedArrayBuffer: true,
|
|
39610
|
+
offset: sourceVertexOffset
|
|
39611
|
+
});
|
|
39612
|
+
} else {
|
|
39613
|
+
this.gaussianIndexData = new Uint32Array(this.gaussianCount);
|
|
39614
|
+
this.gaussianOrderData = new Uint8Array(orderDataSize);
|
|
39615
|
+
this.gaussianGeneralData = new Uint8Array(generalDataSize);
|
|
39616
|
+
this.worker.postMessage({
|
|
39617
|
+
vertexCount: this.gaussianCount,
|
|
39618
|
+
usingSharedArrayBuffer: false,
|
|
39619
|
+
offset: sourceVertexOffset,
|
|
39620
|
+
gaussianDataSize: this.gaussianCount * ROW_LENGTH_TAVIO,
|
|
39621
|
+
generalDataSize,
|
|
39622
|
+
shDataSize: this.gaussianCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4
|
|
39623
|
+
});
|
|
39624
|
+
}
|
|
39625
|
+
this.setupTransformData(
|
|
39626
|
+
sourceIndex,
|
|
39627
|
+
sourceVertexOffset,
|
|
39628
|
+
this.gaussianCount
|
|
39629
|
+
);
|
|
39630
|
+
}
|
|
39631
|
+
break;
|
|
39632
|
+
case "decode:body":
|
|
39633
|
+
{
|
|
39634
|
+
this.setupPoints(e.point);
|
|
39635
|
+
this.setColorIntoPoints(e.color);
|
|
39636
|
+
this.currentVertexCount += e.pointCount;
|
|
39637
|
+
this.emit("convert");
|
|
39638
|
+
const uniforms = this.gaussianMaterial.uniforms;
|
|
39639
|
+
const { message, transfer } = wasmBuildWorkerUpdateMessage(
|
|
39640
|
+
e,
|
|
39641
|
+
uniforms,
|
|
39642
|
+
sourceIndex,
|
|
39643
|
+
this.usingSharedArrayBuffer
|
|
39644
|
+
);
|
|
39645
|
+
wasmUpdateUniforms(e, uniforms, sourceIndex);
|
|
39646
|
+
this.worker.postMessage(message, transfer);
|
|
39647
|
+
}
|
|
39648
|
+
break;
|
|
39649
|
+
}
|
|
39650
|
+
});
|
|
39651
|
+
const convertedUrl = new URL(url, location.origin).toString();
|
|
39652
|
+
const waitForFinally = new Promise((resolve) => {
|
|
39653
|
+
this.once("sort", () => {
|
|
39654
|
+
this.sourceProperty[sourceIndex].ready = true;
|
|
39655
|
+
if (!this.sorted) {
|
|
39656
|
+
this.sorted = true;
|
|
39657
|
+
this.emit("finallyupdate", this.gaussianCount);
|
|
39658
|
+
}
|
|
39659
|
+
resolve();
|
|
39660
|
+
});
|
|
39661
|
+
});
|
|
39662
|
+
const decodeOptions = {
|
|
39663
|
+
useSphericalHarmonics,
|
|
39664
|
+
useSharedArrayBuffer: this.usingSharedArrayBuffer,
|
|
39665
|
+
...this.usingSharedArrayBuffer && this.sharedData && {
|
|
39666
|
+
sharedGaussianBuffer: this.sharedData.sharedGaussianData,
|
|
39667
|
+
sharedShBuffer: this.sharedData.sharedSphericalHarmonicsData,
|
|
39668
|
+
gaussianBufferOffset: sourceVertexOffset,
|
|
39669
|
+
shBufferOffset: sourceVertexOffset
|
|
39670
|
+
}
|
|
39671
|
+
};
|
|
39672
|
+
switch (format) {
|
|
39673
|
+
case "splat":
|
|
39674
|
+
await tavioWasmClient.api.decodeSplat(convertedUrl, decodeOptions);
|
|
39675
|
+
break;
|
|
39676
|
+
case "ply":
|
|
39677
|
+
await tavioWasmClient.api.decodePly(convertedUrl, decodeOptions);
|
|
39678
|
+
break;
|
|
39679
|
+
case "spz":
|
|
39680
|
+
await tavioWasmClient.api.decodeSpz(convertedUrl, decodeOptions);
|
|
39681
|
+
break;
|
|
39682
|
+
case "sog":
|
|
39683
|
+
await tavioWasmClient.api.decodeSog(convertedUrl, decodeOptions);
|
|
39684
|
+
break;
|
|
39685
|
+
default:
|
|
39686
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
39687
|
+
}
|
|
39688
|
+
this.emit("load", { length: contentLength });
|
|
39689
|
+
tavioWasmClient.dispose();
|
|
39690
|
+
await waitForFinally;
|
|
39353
39691
|
}
|
|
39354
39692
|
/**
|
|
39355
|
-
*
|
|
39356
|
-
* @param filename -
|
|
39357
|
-
* @param option - セーブ関連のオプション
|
|
39358
|
-
* @param option.version - バージョン番号
|
|
39359
|
-
* @param option.useSphericalHarmonics - 球面調和関数を使用する
|
|
39360
|
-
* @param option.useGeneralData - 編集データを反映する
|
|
39361
|
-
* @param option.featureFlags - tavio形式のフィーチャーフラグ
|
|
39693
|
+
* 様々な形式のリソースをセーブする
|
|
39694
|
+
* @param filename - 保存ファイル名
|
|
39362
39695
|
*/
|
|
39363
|
-
async saveTavioWasm(filename
|
|
39364
|
-
|
|
39696
|
+
async saveTavioWasm(filename) {
|
|
39697
|
+
const tavioWasmClient = await TavioWasmWorkerClient.create({
|
|
39698
|
+
useSharedArrayBuffer: this.usingSharedArrayBuffer
|
|
39699
|
+
});
|
|
39700
|
+
let gaussianData;
|
|
39701
|
+
let sphericalHarmonicsData;
|
|
39702
|
+
if (this.usingSharedArrayBuffer) {
|
|
39703
|
+
gaussianData = this.sharedData.gaussianData;
|
|
39704
|
+
sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
|
|
39705
|
+
} else {
|
|
39706
|
+
({ gaussianData, sphericalHarmonicsData } = await requestWorkerBuffer(this.worker));
|
|
39707
|
+
}
|
|
39708
|
+
const uniforms = this.gaussianMaterial.uniforms;
|
|
39709
|
+
const scaleMinValues = new Float32Array([
|
|
39710
|
+
uniforms.scaleAlphaMin.value.x,
|
|
39711
|
+
uniforms.scaleAlphaMin.value.y,
|
|
39712
|
+
uniforms.scaleAlphaMin.value.z
|
|
39713
|
+
]);
|
|
39714
|
+
const scaleMaxValues = new Float32Array([
|
|
39715
|
+
uniforms.scaleAlphaMax.value.x,
|
|
39716
|
+
uniforms.scaleAlphaMax.value.y,
|
|
39717
|
+
uniforms.scaleAlphaMax.value.z
|
|
39718
|
+
]);
|
|
39719
|
+
const alphaMin = uniforms.scaleAlphaMin.value.w;
|
|
39720
|
+
const alphaMax = uniforms.scaleAlphaMax.value.w;
|
|
39721
|
+
const bytes = await tavioWasmClient.api.encodeTavio(
|
|
39722
|
+
this.gaussianCount,
|
|
39723
|
+
gaussianData,
|
|
39724
|
+
sphericalHarmonicsData,
|
|
39725
|
+
scaleMinValues,
|
|
39726
|
+
scaleMaxValues,
|
|
39727
|
+
alphaMin,
|
|
39728
|
+
alphaMax
|
|
39729
|
+
);
|
|
39730
|
+
downloadAsFile(bytes, filename);
|
|
39731
|
+
tavioWasmClient.dispose();
|
|
39732
|
+
}
|
|
39733
|
+
/**
|
|
39734
|
+
* 様々な形式のリソースをセーブする
|
|
39735
|
+
* @param filename - 保存ファイル名
|
|
39736
|
+
* @param format - ファイル形式
|
|
39737
|
+
*/
|
|
39738
|
+
async saveMeshWasm(filename, format) {
|
|
39739
|
+
const tavioWasmClient = await TavioWasmWorkerClient.create({
|
|
39740
|
+
useSharedArrayBuffer: this.usingSharedArrayBuffer
|
|
39741
|
+
});
|
|
39742
|
+
let gaussianData;
|
|
39743
|
+
let sphericalHarmonicsData;
|
|
39744
|
+
if (this.usingSharedArrayBuffer) {
|
|
39745
|
+
gaussianData = this.sharedData.gaussianData;
|
|
39746
|
+
sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
|
|
39747
|
+
} else {
|
|
39748
|
+
({ gaussianData, sphericalHarmonicsData } = await requestWorkerBuffer(this.worker));
|
|
39749
|
+
}
|
|
39750
|
+
const uniforms = this.gaussianMaterial.uniforms;
|
|
39751
|
+
const scaleMinValues = new Float32Array([
|
|
39752
|
+
uniforms.scaleAlphaMin.value.x,
|
|
39753
|
+
uniforms.scaleAlphaMin.value.y,
|
|
39754
|
+
uniforms.scaleAlphaMin.value.z
|
|
39755
|
+
]);
|
|
39756
|
+
const scaleMaxValues = new Float32Array([
|
|
39757
|
+
uniforms.scaleAlphaMax.value.x,
|
|
39758
|
+
uniforms.scaleAlphaMax.value.y,
|
|
39759
|
+
uniforms.scaleAlphaMax.value.z
|
|
39760
|
+
]);
|
|
39761
|
+
const alphaMin = uniforms.scaleAlphaMin.value.w;
|
|
39762
|
+
const alphaMax = uniforms.scaleAlphaMax.value.w;
|
|
39763
|
+
let bytes;
|
|
39764
|
+
switch (format) {
|
|
39765
|
+
case "splat":
|
|
39766
|
+
bytes = await tavioWasmClient.api.encodeSplat(
|
|
39767
|
+
this.gaussianCount,
|
|
39768
|
+
gaussianData,
|
|
39769
|
+
scaleMinValues,
|
|
39770
|
+
scaleMaxValues,
|
|
39771
|
+
alphaMin,
|
|
39772
|
+
alphaMax
|
|
39773
|
+
);
|
|
39774
|
+
break;
|
|
39775
|
+
case "ply":
|
|
39776
|
+
bytes = await tavioWasmClient.api.encodePly(
|
|
39777
|
+
this.gaussianCount,
|
|
39778
|
+
gaussianData,
|
|
39779
|
+
sphericalHarmonicsData,
|
|
39780
|
+
scaleMinValues,
|
|
39781
|
+
scaleMaxValues,
|
|
39782
|
+
alphaMin,
|
|
39783
|
+
alphaMax
|
|
39784
|
+
);
|
|
39785
|
+
break;
|
|
39786
|
+
case "spz":
|
|
39787
|
+
bytes = await tavioWasmClient.api.encodeSpz(
|
|
39788
|
+
this.gaussianCount,
|
|
39789
|
+
gaussianData,
|
|
39790
|
+
sphericalHarmonicsData,
|
|
39791
|
+
scaleMinValues,
|
|
39792
|
+
scaleMaxValues,
|
|
39793
|
+
alphaMin,
|
|
39794
|
+
alphaMax
|
|
39795
|
+
);
|
|
39796
|
+
break;
|
|
39797
|
+
default:
|
|
39798
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
39799
|
+
}
|
|
39800
|
+
downloadAsFile(bytes, filename);
|
|
39801
|
+
tavioWasmClient.dispose();
|
|
39365
39802
|
}
|
|
39366
39803
|
/**
|
|
39367
39804
|
* canvas 要素からガウシアンを生成してシーンに追加する
|
|
@@ -39792,6 +40229,9 @@ class TavioMesh extends EventEmitter {
|
|
|
39792
40229
|
*/
|
|
39793
40230
|
setUniforms(values) {
|
|
39794
40231
|
Object.entries(values).forEach(([key, value]) => {
|
|
40232
|
+
if (this.gaussianMaterial.uniforms[key] == null) {
|
|
40233
|
+
return;
|
|
40234
|
+
}
|
|
39795
40235
|
this.gaussianMaterial.uniforms[key].value = value;
|
|
39796
40236
|
});
|
|
39797
40237
|
}
|
|
@@ -40010,10 +40450,10 @@ class TavioMesh extends EventEmitter {
|
|
|
40010
40450
|
);
|
|
40011
40451
|
}
|
|
40012
40452
|
this.gaussianMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
|
|
40013
|
-
this.gaussianMaterial.uniforms.transformTextureWidth.value =
|
|
40453
|
+
this.gaussianMaterial.uniforms.transformTextureWidth.value = this.transformTextureWidth;
|
|
40014
40454
|
this.gaussianMaterial.needsUpdate = true;
|
|
40015
40455
|
this.depthRenderMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
|
|
40016
|
-
this.depthRenderMaterial.uniforms.transformTextureWidth.value =
|
|
40456
|
+
this.depthRenderMaterial.uniforms.transformTextureWidth.value = this.transformTextureWidth;
|
|
40017
40457
|
this.depthRenderMaterial.needsUpdate = true;
|
|
40018
40458
|
}
|
|
40019
40459
|
/**
|
|
@@ -40021,8 +40461,12 @@ class TavioMesh extends EventEmitter {
|
|
|
40021
40461
|
* @private
|
|
40022
40462
|
*/
|
|
40023
40463
|
_updateUniformsForSphericalHarmonics() {
|
|
40024
|
-
this.gaussianMaterial.uniforms.sphericalHarmonicsCalculation
|
|
40025
|
-
|
|
40464
|
+
if (this.gaussianMaterial.uniforms.sphericalHarmonicsCalculation != null) {
|
|
40465
|
+
this.gaussianMaterial.uniforms.sphericalHarmonicsCalculation.value = this.usingSphericalHarmonics === true;
|
|
40466
|
+
}
|
|
40467
|
+
if (this.gaussianMaterial.uniforms.sphericalHarmonicsIntensity != null) {
|
|
40468
|
+
this.gaussianMaterial.uniforms.sphericalHarmonicsIntensity.value = this.usingSphericalHarmonics !== true ? 0 : 1;
|
|
40469
|
+
}
|
|
40026
40470
|
}
|
|
40027
40471
|
/**
|
|
40028
40472
|
* tavio 形式の特性フラグを取得する
|
|
@@ -40056,15 +40500,6 @@ class TavioMesh extends EventEmitter {
|
|
|
40056
40500
|
this.gaussianPickingMaterial.uniforms.focal.value = this.gaussianMaterial.uniforms.focal.value.clone();
|
|
40057
40501
|
this.gaussianPickingMaterial.uniforms.inverseViewport.value = this.gaussianMaterial.uniforms.inverseViewport.value.clone();
|
|
40058
40502
|
this.gaussianPickingMaterial.uniforms.gaussianScale.value = this.gaussianMaterial.uniforms.gaussianScale.value;
|
|
40059
|
-
this.gaussianPickingMaterial.uniforms.effectMinimumScale.value = this.gaussianMaterial.uniforms.effectMinimumScale.value;
|
|
40060
|
-
this.gaussianPickingMaterial.uniforms.effectDistance.value = this.gaussianMaterial.uniforms.effectDistance.value;
|
|
40061
|
-
this.gaussianPickingMaterial.uniforms.effectDistanceMax.value = this.gaussianMaterial.uniforms.effectDistanceMax.value;
|
|
40062
|
-
this.gaussianPickingMaterial.uniforms.effectDistanceRange.value = this.gaussianMaterial.uniforms.effectDistanceRange.value;
|
|
40063
|
-
this.gaussianPickingMaterial.uniforms.effectDistanceColor.value = this.gaussianMaterial.uniforms.effectDistanceColor.value;
|
|
40064
|
-
this.gaussianPickingMaterial.uniforms.effectDistanceColorNear.value = this.gaussianMaterial.uniforms.effectDistanceColorNear.value;
|
|
40065
|
-
this.gaussianPickingMaterial.uniforms.effectSonar.value = this.gaussianMaterial.uniforms.effectSonar.value;
|
|
40066
|
-
this.gaussianPickingMaterial.uniforms.effectSonarRange.value = this.gaussianMaterial.uniforms.effectSonarRange.value;
|
|
40067
|
-
this.gaussianPickingMaterial.uniforms.worldOrigin.value = this.gaussianMaterial.uniforms.worldOrigin.value.clone();
|
|
40068
40503
|
this.gaussianPickingMaterial.uniforms.scaleAlphaMin.value = this.gaussianMaterial.uniforms.scaleAlphaMin.value.clone();
|
|
40069
40504
|
this.gaussianPickingMaterial.uniforms.scaleAlphaMax.value = this.gaussianMaterial.uniforms.scaleAlphaMax.value.clone();
|
|
40070
40505
|
this.gaussianPickingMaterial.uniforms.transformTextureWidth.value = this.gaussianMaterial.uniforms.transformTextureWidth.value;
|
|
@@ -40300,10 +40735,12 @@ class TavioMesh extends EventEmitter {
|
|
|
40300
40735
|
this.gaussianCompressedDataTexture1 = this.setupCompressedColorDataTexture(packedSH1, width, height);
|
|
40301
40736
|
this.gaussianCompressedDataTexture2 = this.setupCompressedColorDataTexture(packedSH2, width, height);
|
|
40302
40737
|
this.gaussianCompressedDataTexture3 = this.setupCompressedColorDataTexture(packedSH3, width, height);
|
|
40303
|
-
uniforms.sphericalHarmonicsTexture0
|
|
40304
|
-
|
|
40305
|
-
|
|
40306
|
-
|
|
40738
|
+
if (uniforms.sphericalHarmonicsTexture0 != null) {
|
|
40739
|
+
uniforms.sphericalHarmonicsTexture0.value = this.gaussianCompressedDataTexture0;
|
|
40740
|
+
uniforms.sphericalHarmonicsTexture1.value = this.gaussianCompressedDataTexture1;
|
|
40741
|
+
uniforms.sphericalHarmonicsTexture2.value = this.gaussianCompressedDataTexture2;
|
|
40742
|
+
uniforms.sphericalHarmonicsTexture3.value = this.gaussianCompressedDataTexture3;
|
|
40743
|
+
}
|
|
40307
40744
|
this.initializedColorTexture = true;
|
|
40308
40745
|
if (this._getInitialized() === true && this.listenerInitializedTexture != null) {
|
|
40309
40746
|
this.listenerInitializedTexture();
|
|
@@ -40417,7 +40854,9 @@ class TavioMesh extends EventEmitter {
|
|
|
40417
40854
|
this.maxDistance = this._getMaxDistance(position);
|
|
40418
40855
|
this.containmentRadius.per100 = this.maxDistance;
|
|
40419
40856
|
const uniforms = this.gaussianMaterial.uniforms;
|
|
40420
|
-
uniforms.effectDistanceMax
|
|
40857
|
+
if (uniforms.effectDistanceMax != null) {
|
|
40858
|
+
uniforms.effectDistanceMax.value = this.maxDistance;
|
|
40859
|
+
}
|
|
40421
40860
|
const exists = this.gaussianPoints != null;
|
|
40422
40861
|
let positionArray = null;
|
|
40423
40862
|
let colorArray = null;
|
|
@@ -40432,12 +40871,15 @@ class TavioMesh extends EventEmitter {
|
|
|
40432
40871
|
opacity: this.viewerOption.opacityPoints
|
|
40433
40872
|
});
|
|
40434
40873
|
const uniforms2 = this.gaussianMaterial.uniforms;
|
|
40874
|
+
const effectDistanceMax2 = uniforms2.effectDistanceMax?.value;
|
|
40875
|
+
const effectDistanceRange2 = uniforms2.effectDistanceRange?.value;
|
|
40876
|
+
const worldOrigin2 = uniforms2.worldOrigin?.value.clone() ?? new Vector3();
|
|
40435
40877
|
this.gaussianPointUniforms = {
|
|
40436
40878
|
effectDistance: { value: this.viewerOption.distanceEffectPoint },
|
|
40437
40879
|
effectDistanceNear: { value: this.viewerOption.distanceEffectPointNear },
|
|
40438
|
-
effectDistanceMax: { value:
|
|
40439
|
-
effectDistanceRange: { value:
|
|
40440
|
-
worldOrigin: { value:
|
|
40880
|
+
effectDistanceMax: { value: effectDistanceMax2 },
|
|
40881
|
+
effectDistanceRange: { value: effectDistanceRange2 },
|
|
40882
|
+
worldOrigin: { value: worldOrigin2 }
|
|
40441
40883
|
};
|
|
40442
40884
|
this.gaussianPointMaterial.onBeforeCompile = (shader) => {
|
|
40443
40885
|
shader.vertexShader = main$3;
|
|
@@ -40474,18 +40916,21 @@ class TavioMesh extends EventEmitter {
|
|
|
40474
40916
|
transparent: true,
|
|
40475
40917
|
opacity: this.viewerOption.opacityPoints
|
|
40476
40918
|
});
|
|
40919
|
+
const effectDistanceMax = uniforms.effectDistanceMax?.value;
|
|
40920
|
+
const effectDistanceRange = uniforms.effectDistanceRange?.value;
|
|
40921
|
+
const worldOrigin = uniforms.worldOrigin?.value.clone() ?? new Vector3();
|
|
40477
40922
|
this.gaussianPointUniforms = {
|
|
40478
40923
|
effectDistance: { value: this.viewerOption.distanceEffectPoint },
|
|
40479
40924
|
effectDistanceNear: { value: this.viewerOption.distanceEffectPointNear },
|
|
40480
|
-
effectDistanceMax: { value:
|
|
40481
|
-
effectDistanceRange: { value:
|
|
40925
|
+
effectDistanceMax: { value: effectDistanceMax },
|
|
40926
|
+
effectDistanceRange: { value: effectDistanceRange },
|
|
40482
40927
|
effectDistanceColor: { value: this.viewerOption.distanceColorEffect },
|
|
40483
40928
|
effectDistanceColorNear: {
|
|
40484
40929
|
value: this.viewerOption.distanceColorEffectNear
|
|
40485
40930
|
},
|
|
40486
40931
|
effectSonar: { value: this.viewerOption.effectSonar },
|
|
40487
40932
|
effectSonarRange: { value: this.viewerOption.effectSonarRange },
|
|
40488
|
-
worldOrigin: { value:
|
|
40933
|
+
worldOrigin: { value: worldOrigin },
|
|
40489
40934
|
temperature: { value: this.viewerOption.colorTemperature },
|
|
40490
40935
|
tint: { value: this.viewerOption.colorTint },
|
|
40491
40936
|
contrastIntensity: { value: this.viewerOption.colorContrast },
|
|
@@ -40543,8 +40988,8 @@ class TavioMesh extends EventEmitter {
|
|
|
40543
40988
|
this.indexAttribute.setUsage(DynamicDrawUsage);
|
|
40544
40989
|
this.indexAttribute.needsUpdate = true;
|
|
40545
40990
|
this.gaussianGeometry = new InstancedBufferGeometry();
|
|
40546
|
-
this.gaussianGeometry.setAttribute("
|
|
40547
|
-
this.gaussianGeometry.setAttribute("
|
|
40991
|
+
this.gaussianGeometry.setAttribute("aLocalPosition", this.positionAttribute);
|
|
40992
|
+
this.gaussianGeometry.setAttribute("aIndices", this.indexAttribute);
|
|
40548
40993
|
this.gaussianGeometry.setIndex(triangleIndex);
|
|
40549
40994
|
this.gaussianMesh = new InstancedMeshEX(
|
|
40550
40995
|
this.gaussianGeometry,
|
|
@@ -41143,6 +41588,341 @@ class AnimationController extends EventEmitter {
|
|
|
41143
41588
|
this.callbacks.start();
|
|
41144
41589
|
}
|
|
41145
41590
|
}
|
|
41591
|
+
const mainBegin = "void main() {\n";
|
|
41592
|
+
const mainEnd = "}\n";
|
|
41593
|
+
const precision$1 = "// #version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp usampler2D;\n";
|
|
41594
|
+
const declaration$7 = "// splats (position, scale, rotation... etc.)\nuniform highp usampler2D splatTexture;\n// general (selection etc.)\nuniform highp usampler2D generalTexture;\n// transform (position, scale, rotation)\nuniform highp usampler2D transformTexture;\nuniform mat4 projection, view;\nuniform vec2 focal;\nuniform vec2 inverseViewport;\nuniform float gaussianScale;\n// アルファの変換は頂点シェーダ側で行う\nuniform float additionAlpha;\nuniform float multiplicationAlpha;\n// blur and sharpness\nuniform float blur;\nuniform float sharpness;\n// min-max\nuniform vec4 scaleAlphaMin;\nuniform vec4 scaleAlphaMax;\n// transform texture width\nuniform uint transformTextureWidth;\n\nin vec2 aLocalPosition;\nin uint aIndices;\n\nconst float PI = 3.14159265358979;\nconst float PI2 = PI * 2.0;\nconst float INV_255 = 1.0 / 255.0;\nconst float INF = 1.0 / 0.0;\n";
|
|
41595
|
+
const _function$3 = "// octahedral quaternion\nvec4 revertQuaternion(uint converted) {\n uint u = converted & 0xffu;\n uint v = (converted >> 8u) & 0xffu;\n uint w = (converted >> 16u) & 0xffu;\n\n float x = (float(u) * INV_255) * 2.0 - 1.0;\n float y = (float(v) * INV_255) * 2.0 - 1.0;\n float z = 1.0 - abs(x) - abs(y);\n float m = max(-z, 0.0);\n x += (x >= 0.0) ? -m : m;\n y += (y >= 0.0) ? -m : m;\n vec3 axis = normalize(vec3(x, y, z));\n\n float theta = (float(w) * INV_255) * PI;\n float halfTheta = theta * 0.5;\n float s = sin(halfTheta);\n float c = cos(halfTheta);\n\n return vec4(axis * s, c);\n}\n// generate sigma\nmat3 generateSigma(vec3 s, vec4 q) {\n return mat3(\n s.x * (1.0 - 2.0 * (q.y * q.y + q.z * q.z)),\n s.x * (2.0 * (q.x * q.y + q.w * q.z)),\n s.x * (2.0 * (q.x * q.z - q.w * q.y)),\n s.y * (2.0 * (q.x * q.y - q.w * q.z)),\n s.y * (1.0 - 2.0 * (q.x * q.x + q.z * q.z)),\n s.y * (2.0 * (q.y * q.z + q.w * q.x)),\n s.z * (2.0 * (q.x * q.z + q.w * q.y)),\n s.z * (2.0 * (q.y * q.z - q.w * q.x)),\n s.z * (1.0 - 2.0 * (q.x * q.x + q.y * q.y))\n );\n}\n// mat3 from quat\nmat3 generateRotationScaleMatrix(vec4 q, float s) {\n float x = q.x;\n float y = q.y;\n float z = q.z;\n float w = q.w;\n float xx = x * x;\n float yy = y * y;\n float zz = z * z;\n float xy = x * y;\n float xz = x * z;\n float yz = y * z;\n float wx = w * x;\n float wy = w * y;\n float wz = w * z;\n return mat3(\n 1.0 - 2.0 * (yy + zz), 2.0 * (xy + wz), 2.0 * (xz - wy),\n 2.0 * (xy - wz), 1.0 - 2.0 * (xx + zz), 2.0 * (yz + wx),\n 2.0 * (xz + wy), 2.0 * (yz - wx), 1.0 - 2.0 * (xx + yy)\n ) * s;\n}\n// transform\nvoid restoreTransform(in uint index, in uint width, out vec3 t, out float s, out vec4 q) {\n uint u = index % width;\n uint v = uint(floor(float(index) / float(width)));\n uvec4 transform = texelFetch(transformTexture, ivec2(u, v), 0);\n vec2 r = unpackHalf2x16(transform.x);\n vec2 g = unpackHalf2x16(transform.y);\n vec2 b = unpackHalf2x16(transform.z);\n vec2 a = unpackHalf2x16(transform.w);\n t = vec3(-r, g.x);\n s = g.y;\n q = vec4(b, a);\n}\nvec4 multiplyQuaternion(vec4 qA, vec4 qB) {\n float wA = qA.w;\n vec3 vA = qA.xyz;\n float wB = qB.w;\n vec3 vB = qB.xyz;\n float wC = wA * wB - dot(vA, vB);\n vec3 vC = cross(vA, vB) + wA * vB + wB * vA;\n return vec4(vC, wC);\n}\nvoid unpack4to8(in uint packed, out uint high, out uint low) {\n high = (packed >> 4u) & 0xFu;\n low = packed & 0xFu;\n}\n";
|
|
41596
|
+
const mainTransform$1 = " ivec2 uv = ivec2(aIndices & 0x3ffu, aIndices >> 10);\n uvec4 packed = texelFetch(splatTexture, uv, 0);\n uvec4 general = texelFetch(generalTexture, uv, 0);\n\n vec3 tPosition = vec3(0.0);\n float tScale = 1.0;\n vec4 tRotation = vec4(0.0);\n uint high, low;\n unpack4to8(general.a, high, low);\n restoreTransform(low, transformTextureWidth, tPosition, tScale, tRotation);\n\n vec3 revertedPosition = vec4(\n unpackHalf2x16(packed.x),\n unpackHalf2x16(packed.y & 0xffffu)\n ).xyz;\n uvec3 uScale = uvec3(\n packed.z & 0xffu,\n (packed.z >> 8u) & 0xffu,\n (packed.z >> 16u) & 0xffu\n );\n vec3 scaleRange = scaleAlphaMax.xyz - scaleAlphaMin.xyz;\n vec3 scale = vec3(\n uScale.x == 0u ? 0.0 : exp(float(uScale.x) * INV_255 * scaleRange.x + scaleAlphaMin.x) * 2.0,\n uScale.y == 0u ? 0.0 : exp(float(uScale.y) * INV_255 * scaleRange.y + scaleAlphaMin.y) * 2.0,\n uScale.z == 0u ? 0.0 : exp(float(uScale.z) * INV_255 * scaleRange.z + scaleAlphaMin.z) * 2.0\n );\n scale.x = scaleRange.x == 0.0 ? 1.0 : scale.x;\n scale.y = scaleRange.y == 0.0 ? 1.0 : scale.y;\n scale.z = scaleRange.z == 0.0 ? 1.0 : scale.z;\n uint uRotation = (packed.y >> 16u) & 0xffffu | (packed.z >> 8u) & 0xff0000u;\n vec4 quaternion = revertQuaternion(uRotation);\n uvec4 uRGBA = uvec4(\n packed.w & 0xffu,\n (packed.w >> 8u) & 0xffu,\n (packed.w >> 16u) & 0xffu,\n (packed.w >> 24u) & 0xffu\n );\n vec4 normalizedColor = vec4(uRGBA) * INV_255;\n float alphaRange = scaleAlphaMax.w - scaleAlphaMin.w;\n float rawAlpha = (float(general.b) * INV_255) * alphaRange + scaleAlphaMin.w;\n normalizedColor.a = 1.0 / (1.0 + exp(-(rawAlpha * multiplicationAlpha + additionAlpha)));\n\n // インスタンスごとの固有のワールド変換を、ガウシアンのローカル位置に対して適用する\n mat3 modelMatrix = generateRotationScaleMatrix(tRotation, tScale);\n vec3 transformedCenter = modelMatrix * revertedPosition + tPosition;\n // シグマ生成にも影響が反映されるように変換を加える\n scale *= tScale;\n quaternion = multiplyQuaternion(tRotation, quaternion);\n // 最終的に出力時に適用されるスケール\n float generalG = 1.0 - sign(float(general.g));\n float globalScale = gaussianScale * generalG;\n\n // ビュー空間における位置\n vec4 viewPosition = view * vec4(transformedCenter, 1.0);\n // クリップ空間における位置\n vec4 clipPosition = projection * viewPosition;\n // カリング\n float clip = 1.2 * clipPosition.w;\n if (\n clipPosition.z < -clip ||\n clipPosition.x < -clip ||\n clipPosition.x > clip ||\n clipPosition.y < -clip ||\n clipPosition.y > clip\n ) {\n // 範囲外にあるとみなす\n gl_Position = vec4(0.0, 0.0, 2.0, 1.0);\n return;\n }\n";
|
|
41597
|
+
const mainSigma$2 = " // generate sigma\n mat3 sigma = generateSigma(scale, quaternion);\n mat3 Vrk = sigma * transpose(sigma);\n \n // Jacobian\n float vpz = 1.0 / (viewPosition.z * viewPosition.z);\n mat3 J = mat3(\n focal.x / viewPosition.z, 0.0, -(focal.x * viewPosition.x) * vpz, \n 0.0, focal.y / viewPosition.z, -(focal.y * viewPosition.y) * vpz, \n 0.0, 0.0, 0.0\n );\n\n // covariance matrix in ray space\n mat3 mat3view = mat3(view);\n mat3 T = transpose(mat3view) * J;\n mat3 cov2d = transpose(T) * Vrk * T;\n\n // TODO: ???\n float d00 = cov2d[0][0] + sharpness;\n float d01 = cov2d[0][1];\n float d11 = cov2d[1][1] + sharpness;\n float mid = (d00 + d11) / 2.0;\n float radius = length(vec2((d00 - d11) / 2.0, d01));\n float lambda1 = mid + radius, lambda2 = mid - radius;\n if (lambda2 < 0.0) {\n gl_Position = vec4(0.0, 0.0, 2.0, 1.0);\n return;\n }\n vec2 diagonalVector = normalize(vec2(d01, lambda1 - d00));\n vec2 majorAxis = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;\n vec2 minorAxis = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);\n\n float a = cov2d[0][0];\n float d = cov2d[1][1];\n float b = cov2d[0][1];\n float dPrevious = a * d - b * b;\n a += blur;\n d += blur;\n float det = a * d - b * b;\n float blurAdjust = sqrt(max(0.0, dPrevious / det));\n normalizedColor.a *= blurAdjust;\n";
|
|
41598
|
+
const mainOut$2 = " // この時点で position2D.w で割ることはせず、かつ最終的な gl_Position の出力時に逆に (major + minor) に乗算する\n // そうすることで、平面にプロットされるガウシアンを立体的な座標を保ったまま出力する\n vec2 clipCenter = vec2(clipPosition);\n vec2 major = aLocalPosition.x * majorAxis * inverseViewport;\n vec2 minor = aLocalPosition.y * minorAxis * inverseViewport;\n vec3 worldPosition = vec3(clipCenter + (major + minor) * clipPosition.w * globalScale, clipPosition.z);\n gl_Position = vec4(worldPosition, clipPosition.w);\n";
|
|
41599
|
+
const precision = "// #version 300 es\nprecision highp float;\n";
|
|
41600
|
+
const declaration$6 = "out vec4 fragColor;\n";
|
|
41601
|
+
const _function$2 = "";
|
|
41602
|
+
const mainIn$2 = " float finalAlpha = 1.0;\n vec3 finalColor = vec3(0.0);\n";
|
|
41603
|
+
const mainOut$1 = " fragColor = vec4(finalColor * finalAlpha, finalAlpha);\n";
|
|
41604
|
+
const CHUNK_TARGET = {
|
|
41605
|
+
ANY: 0,
|
|
41606
|
+
// すべてに反映する
|
|
41607
|
+
BASIC: 1,
|
|
41608
|
+
// 描画用シェーダ
|
|
41609
|
+
PICKING: 2
|
|
41610
|
+
// ピッキング用シェーダ
|
|
41611
|
+
};
|
|
41612
|
+
const SHADER_STAGE = {
|
|
41613
|
+
VERTEX_PRECISION: 0,
|
|
41614
|
+
// 精度修飾子
|
|
41615
|
+
VERTEX_DECLARATION: 1,
|
|
41616
|
+
// 変数宣言
|
|
41617
|
+
VERTEX_FUNCTION: 2,
|
|
41618
|
+
// 関数定義
|
|
41619
|
+
VERTEX_MAIN_BEGIN: 3,
|
|
41620
|
+
// main() の開始
|
|
41621
|
+
VERTEX_MAIN_TRANSFORM: 4,
|
|
41622
|
+
// main() 内の座標変換処理
|
|
41623
|
+
VERTEX_MAIN_SIGMA: 5,
|
|
41624
|
+
// main() 内のシグマ生成箇所
|
|
41625
|
+
VERTEX_MAIN_OUT: 6,
|
|
41626
|
+
// main() 内の変換結果の出力
|
|
41627
|
+
VERTEX_MAIN_END: 7,
|
|
41628
|
+
// main() の終了
|
|
41629
|
+
FRAGMENT_PRECISION: 8,
|
|
41630
|
+
// 精度修飾子
|
|
41631
|
+
FRAGMENT_DECLARATION: 9,
|
|
41632
|
+
// 変数宣言
|
|
41633
|
+
FRAGMENT_FUNCTION: 10,
|
|
41634
|
+
// 関数定義
|
|
41635
|
+
FRAGMENT_MAIN_BEGIN: 11,
|
|
41636
|
+
// main() の開始
|
|
41637
|
+
FRAGMENT_MAIN_IN: 12,
|
|
41638
|
+
// main() 内の開始
|
|
41639
|
+
FRAGMENT_MAIN_OUT: 13,
|
|
41640
|
+
// main() 内の終了
|
|
41641
|
+
FRAGMENT_MAIN_END: 14
|
|
41642
|
+
// main() の終了
|
|
41643
|
+
};
|
|
41644
|
+
const SHADER_STAGE_COUNT = 15;
|
|
41645
|
+
class MaterialGenerator {
|
|
41646
|
+
/**
|
|
41647
|
+
* shaderChunk/common に含まれる頂点シェーダのチャンクをセットした Map オブジェクトを生成する
|
|
41648
|
+
*/
|
|
41649
|
+
static _createVertexMap() {
|
|
41650
|
+
const map = /* @__PURE__ */ new Map();
|
|
41651
|
+
map.set(SHADER_STAGE.VERTEX_PRECISION, precision$1);
|
|
41652
|
+
map.set(SHADER_STAGE.VERTEX_DECLARATION, declaration$7);
|
|
41653
|
+
map.set(SHADER_STAGE.VERTEX_FUNCTION, _function$3);
|
|
41654
|
+
map.set(SHADER_STAGE.VERTEX_MAIN_BEGIN, mainBegin);
|
|
41655
|
+
map.set(SHADER_STAGE.VERTEX_MAIN_TRANSFORM, mainTransform$1);
|
|
41656
|
+
map.set(SHADER_STAGE.VERTEX_MAIN_SIGMA, mainSigma$2);
|
|
41657
|
+
map.set(SHADER_STAGE.VERTEX_MAIN_OUT, mainOut$2);
|
|
41658
|
+
map.set(SHADER_STAGE.VERTEX_MAIN_END, mainEnd);
|
|
41659
|
+
return map;
|
|
41660
|
+
}
|
|
41661
|
+
/**
|
|
41662
|
+
* shaderChunk/common に含まれるフラグメントシェーダのチャンクをセットした Map オブジェクトを生成する
|
|
41663
|
+
*/
|
|
41664
|
+
static _createFragmentMap() {
|
|
41665
|
+
const map = /* @__PURE__ */ new Map();
|
|
41666
|
+
map.set(SHADER_STAGE.FRAGMENT_PRECISION, precision);
|
|
41667
|
+
map.set(SHADER_STAGE.FRAGMENT_DECLARATION, declaration$6);
|
|
41668
|
+
map.set(SHADER_STAGE.FRAGMENT_FUNCTION, _function$2);
|
|
41669
|
+
map.set(SHADER_STAGE.FRAGMENT_MAIN_BEGIN, mainBegin);
|
|
41670
|
+
map.set(SHADER_STAGE.FRAGMENT_MAIN_IN, mainIn$2);
|
|
41671
|
+
map.set(SHADER_STAGE.FRAGMENT_MAIN_OUT, mainOut$1);
|
|
41672
|
+
map.set(SHADER_STAGE.FRAGMENT_MAIN_END, mainEnd);
|
|
41673
|
+
return map;
|
|
41674
|
+
}
|
|
41675
|
+
/**
|
|
41676
|
+
* シェーダチャンクに iMaterialOption.vertex / fragment に含まれるソースコードを結合する
|
|
41677
|
+
* @param option - シェーダチャンクを含むマテリアルオプション
|
|
41678
|
+
* @param vsMap - 頂点シェーダ用
|
|
41679
|
+
* @param fsMap - フラグメントシェーダ用
|
|
41680
|
+
* @return 各ステージに何回チャンクが結合されたかを表す配列
|
|
41681
|
+
*/
|
|
41682
|
+
static _mergeShaderSource(option, vsMap, fsMap) {
|
|
41683
|
+
const chunkCount = new Array(SHADER_STAGE_COUNT).fill(0);
|
|
41684
|
+
if (option.vertex != null) {
|
|
41685
|
+
const vsArray = Array.isArray(option.vertex) === true ? option.vertex : [option.vertex];
|
|
41686
|
+
vsArray.forEach((opt) => {
|
|
41687
|
+
if (opt.source == null || opt.source === "") {
|
|
41688
|
+
return;
|
|
41689
|
+
}
|
|
41690
|
+
switch (opt.stage) {
|
|
41691
|
+
case SHADER_STAGE.VERTEX_PRECISION:
|
|
41692
|
+
case SHADER_STAGE.VERTEX_DECLARATION:
|
|
41693
|
+
case SHADER_STAGE.VERTEX_FUNCTION:
|
|
41694
|
+
case SHADER_STAGE.VERTEX_MAIN_BEGIN:
|
|
41695
|
+
case SHADER_STAGE.VERTEX_MAIN_TRANSFORM:
|
|
41696
|
+
case SHADER_STAGE.VERTEX_MAIN_SIGMA:
|
|
41697
|
+
case SHADER_STAGE.VERTEX_MAIN_OUT:
|
|
41698
|
+
case SHADER_STAGE.VERTEX_MAIN_END:
|
|
41699
|
+
const source = vsMap.get(opt.stage) + "\n" + opt.source + "\n";
|
|
41700
|
+
vsMap.set(opt.stage, source);
|
|
41701
|
+
++chunkCount[opt.stage];
|
|
41702
|
+
break;
|
|
41703
|
+
default:
|
|
41704
|
+
throw new Error(`invalid SHADER_STAGE: ${opt.stage}`);
|
|
41705
|
+
}
|
|
41706
|
+
});
|
|
41707
|
+
}
|
|
41708
|
+
if (option.fragment != null) {
|
|
41709
|
+
const fsArray = Array.isArray(option.fragment) === true ? option.fragment : [option.fragment];
|
|
41710
|
+
fsArray.forEach((opt) => {
|
|
41711
|
+
if (opt.source == null || opt.source === "") {
|
|
41712
|
+
return;
|
|
41713
|
+
}
|
|
41714
|
+
switch (opt.stage) {
|
|
41715
|
+
case SHADER_STAGE.FRAGMENT_PRECISION:
|
|
41716
|
+
case SHADER_STAGE.FRAGMENT_DECLARATION:
|
|
41717
|
+
case SHADER_STAGE.FRAGMENT_FUNCTION:
|
|
41718
|
+
case SHADER_STAGE.FRAGMENT_MAIN_BEGIN:
|
|
41719
|
+
case SHADER_STAGE.FRAGMENT_MAIN_IN:
|
|
41720
|
+
case SHADER_STAGE.FRAGMENT_MAIN_OUT:
|
|
41721
|
+
case SHADER_STAGE.FRAGMENT_MAIN_END:
|
|
41722
|
+
const source = fsMap.get(opt.stage) + "\n" + opt.source + "\n";
|
|
41723
|
+
fsMap.set(opt.stage, source);
|
|
41724
|
+
++chunkCount[opt.stage];
|
|
41725
|
+
break;
|
|
41726
|
+
default:
|
|
41727
|
+
throw new Error(`invalid SHADER_STAGE: ${opt.stage}`);
|
|
41728
|
+
}
|
|
41729
|
+
});
|
|
41730
|
+
}
|
|
41731
|
+
return chunkCount;
|
|
41732
|
+
}
|
|
41733
|
+
/**
|
|
41734
|
+
* uniform 変数用の雛形を生成する(src/shderChunk/common 以下で定義される最低限のもの)
|
|
41735
|
+
*/
|
|
41736
|
+
static _createUniforms() {
|
|
41737
|
+
return {
|
|
41738
|
+
splatTexture: { value: null },
|
|
41739
|
+
generalTexture: { value: null },
|
|
41740
|
+
transformTexture: { value: null },
|
|
41741
|
+
projection: { value: new Matrix4() },
|
|
41742
|
+
view: { value: new Matrix4() },
|
|
41743
|
+
focal: { value: new Vector2() },
|
|
41744
|
+
inverseViewport: { value: new Vector2() },
|
|
41745
|
+
gaussianScale: { value: 1 },
|
|
41746
|
+
additionAlpha: { value: 0 },
|
|
41747
|
+
multiplicationAlpha: { value: 1 },
|
|
41748
|
+
blur: { value: 0.3 },
|
|
41749
|
+
sharpness: { value: 0.3 },
|
|
41750
|
+
scaleAlphaMin: { value: new Vector4(0, 0, 0, 0) },
|
|
41751
|
+
scaleAlphaMax: { value: new Vector4(1, 1, 1, 1) },
|
|
41752
|
+
transformTextureWidth: { value: 2 }
|
|
41753
|
+
};
|
|
41754
|
+
}
|
|
41755
|
+
/**
|
|
41756
|
+
* Map オブジェクトに含まれるソースコードを結合する
|
|
41757
|
+
* @param map - 処理の対象となる Map オブジェクト
|
|
41758
|
+
* @param isDebug - デバッグ用にコンソールにソースコードを出力するかどうか
|
|
41759
|
+
*/
|
|
41760
|
+
static _createShaderSource(map, chunkCount, isDebug = false) {
|
|
41761
|
+
let source = "";
|
|
41762
|
+
if (isDebug === true) {
|
|
41763
|
+
map.forEach((v, k) => {
|
|
41764
|
+
let key = "";
|
|
41765
|
+
switch (k) {
|
|
41766
|
+
case SHADER_STAGE.VERTEX_PRECISION:
|
|
41767
|
+
key = "VERTEX_PRECISION";
|
|
41768
|
+
break;
|
|
41769
|
+
case SHADER_STAGE.VERTEX_DECLARATION:
|
|
41770
|
+
key = "VERTEX_DECLARATION";
|
|
41771
|
+
break;
|
|
41772
|
+
case SHADER_STAGE.VERTEX_FUNCTION:
|
|
41773
|
+
key = "VERTEX_FUNCTION";
|
|
41774
|
+
break;
|
|
41775
|
+
case SHADER_STAGE.VERTEX_MAIN_BEGIN:
|
|
41776
|
+
key = "VERTEX_MAIN_BEGIN";
|
|
41777
|
+
break;
|
|
41778
|
+
case SHADER_STAGE.VERTEX_MAIN_TRANSFORM:
|
|
41779
|
+
key = "VERTEX_MAIN_TRANSFORM";
|
|
41780
|
+
break;
|
|
41781
|
+
case SHADER_STAGE.VERTEX_MAIN_SIGMA:
|
|
41782
|
+
key = "VERTEX_MAIN_SIGMA";
|
|
41783
|
+
break;
|
|
41784
|
+
case SHADER_STAGE.VERTEX_MAIN_OUT:
|
|
41785
|
+
key = "VERTEX_MAIN_OUT";
|
|
41786
|
+
break;
|
|
41787
|
+
case SHADER_STAGE.VERTEX_MAIN_END:
|
|
41788
|
+
key = "VERTEX_MAIN_END";
|
|
41789
|
+
break;
|
|
41790
|
+
case SHADER_STAGE.FRAGMENT_PRECISION:
|
|
41791
|
+
key = "FRAGMENT_PRECISION";
|
|
41792
|
+
break;
|
|
41793
|
+
case SHADER_STAGE.FRAGMENT_DECLARATION:
|
|
41794
|
+
key = "FRAGMENT_DECLARATION";
|
|
41795
|
+
break;
|
|
41796
|
+
case SHADER_STAGE.FRAGMENT_FUNCTION:
|
|
41797
|
+
key = "FRAGMENT_FUNCTION";
|
|
41798
|
+
break;
|
|
41799
|
+
case SHADER_STAGE.FRAGMENT_MAIN_BEGIN:
|
|
41800
|
+
key = "FRAGMENT_MAIN_BEGIN";
|
|
41801
|
+
break;
|
|
41802
|
+
case SHADER_STAGE.FRAGMENT_MAIN_IN:
|
|
41803
|
+
key = "FRAGMENT_MAIN_IN";
|
|
41804
|
+
break;
|
|
41805
|
+
case SHADER_STAGE.FRAGMENT_MAIN_OUT:
|
|
41806
|
+
key = "FRAGMENT_MAIN_OUT";
|
|
41807
|
+
break;
|
|
41808
|
+
case SHADER_STAGE.FRAGMENT_MAIN_END:
|
|
41809
|
+
key = "FRAGMENT_MAIN_END";
|
|
41810
|
+
break;
|
|
41811
|
+
default:
|
|
41812
|
+
key = "UNKNOWN";
|
|
41813
|
+
}
|
|
41814
|
+
source += `
|
|
41815
|
+
/* ============================== ${key} : [${chunkCount[k]}] ============================== */
|
|
41816
|
+
${v}`;
|
|
41817
|
+
});
|
|
41818
|
+
} else {
|
|
41819
|
+
map.forEach((v) => source += v);
|
|
41820
|
+
}
|
|
41821
|
+
return source;
|
|
41822
|
+
}
|
|
41823
|
+
/**
|
|
41824
|
+
* マテリアルを生成する
|
|
41825
|
+
* @param option - シェーダチャンクなどの情報を含むマテリアルオプション
|
|
41826
|
+
* @param isDebug - デバッグ用にコンソールにソースコードを出力するかどうか
|
|
41827
|
+
*/
|
|
41828
|
+
static generate(option, isDebug = false) {
|
|
41829
|
+
const vsBasicMap = MaterialGenerator._createVertexMap();
|
|
41830
|
+
const fsBasicMap = MaterialGenerator._createFragmentMap();
|
|
41831
|
+
const vsPickingMap = MaterialGenerator._createVertexMap();
|
|
41832
|
+
const fsPickingMap = MaterialGenerator._createFragmentMap();
|
|
41833
|
+
const basicUniforms = MaterialGenerator._createUniforms();
|
|
41834
|
+
const pickingUniforms = MaterialGenerator._createUniforms();
|
|
41835
|
+
const optionArray = Array.isArray(option) === true ? option : [option];
|
|
41836
|
+
const bcc = new Array(optionArray.length);
|
|
41837
|
+
const pcc = new Array(optionArray.length);
|
|
41838
|
+
optionArray.forEach((opt, index) => {
|
|
41839
|
+
if (opt == null) {
|
|
41840
|
+
return;
|
|
41841
|
+
}
|
|
41842
|
+
const isTargetAny = opt.target === CHUNK_TARGET.ANY;
|
|
41843
|
+
const isTargetBasic = checkBit(opt.target, 0);
|
|
41844
|
+
const isTargetPicking = checkBit(opt.target, 1);
|
|
41845
|
+
if (isTargetAny === true || isTargetBasic === true) {
|
|
41846
|
+
bcc[index] = MaterialGenerator._mergeShaderSource(opt, vsBasicMap, fsBasicMap);
|
|
41847
|
+
if (opt.uniforms != null) {
|
|
41848
|
+
Object.assign(basicUniforms, opt.uniforms);
|
|
41849
|
+
}
|
|
41850
|
+
}
|
|
41851
|
+
if (isTargetAny === true || isTargetPicking === true) {
|
|
41852
|
+
pcc[index] = MaterialGenerator._mergeShaderSource(opt, vsPickingMap, fsPickingMap);
|
|
41853
|
+
if (opt.uniforms != null) {
|
|
41854
|
+
Object.assign(pickingUniforms, opt.uniforms);
|
|
41855
|
+
}
|
|
41856
|
+
}
|
|
41857
|
+
});
|
|
41858
|
+
const basicChunkCount = new Array(SHADER_STAGE_COUNT).fill(0);
|
|
41859
|
+
const pickingChunkCount = new Array(SHADER_STAGE_COUNT).fill(0);
|
|
41860
|
+
bcc.forEach((cc) => {
|
|
41861
|
+
cc.forEach((v, i) => {
|
|
41862
|
+
basicChunkCount[i] += v;
|
|
41863
|
+
});
|
|
41864
|
+
});
|
|
41865
|
+
pcc.forEach((cc) => {
|
|
41866
|
+
cc.forEach((v, i) => {
|
|
41867
|
+
pickingChunkCount[i] += v;
|
|
41868
|
+
});
|
|
41869
|
+
});
|
|
41870
|
+
const basicVertexShaderSource = MaterialGenerator._createShaderSource(vsBasicMap, basicChunkCount, isDebug);
|
|
41871
|
+
const basicFragmentShaderSource = MaterialGenerator._createShaderSource(fsBasicMap, basicChunkCount, isDebug);
|
|
41872
|
+
const basic = new RawShaderMaterial({
|
|
41873
|
+
uniforms: basicUniforms,
|
|
41874
|
+
vertexShader: basicVertexShaderSource,
|
|
41875
|
+
fragmentShader: basicFragmentShaderSource,
|
|
41876
|
+
depthTest: true,
|
|
41877
|
+
depthWrite: false,
|
|
41878
|
+
blending: CustomBlending,
|
|
41879
|
+
blendSrc: OneFactor,
|
|
41880
|
+
blendDst: OneMinusSrcAlphaFactor,
|
|
41881
|
+
blendSrcAlpha: OneFactor,
|
|
41882
|
+
blendDstAlpha: OneMinusSrcAlphaFactor,
|
|
41883
|
+
blendEquation: AddEquation,
|
|
41884
|
+
blendEquationAlpha: AddEquation,
|
|
41885
|
+
glslVersion: GLSL3,
|
|
41886
|
+
side: DoubleSide
|
|
41887
|
+
});
|
|
41888
|
+
const pickingVertexShaderSource = MaterialGenerator._createShaderSource(vsPickingMap, pickingChunkCount, isDebug);
|
|
41889
|
+
const pickingFragmentShaderSource = MaterialGenerator._createShaderSource(fsPickingMap, pickingChunkCount, isDebug);
|
|
41890
|
+
const picking = new RawShaderMaterial({
|
|
41891
|
+
uniforms: pickingUniforms,
|
|
41892
|
+
vertexShader: pickingVertexShaderSource,
|
|
41893
|
+
fragmentShader: pickingFragmentShaderSource,
|
|
41894
|
+
depthTest: true,
|
|
41895
|
+
depthWrite: false,
|
|
41896
|
+
glslVersion: GLSL3,
|
|
41897
|
+
side: DoubleSide
|
|
41898
|
+
});
|
|
41899
|
+
if (isDebug === true) {
|
|
41900
|
+
console.log("[ basic-vertex ]");
|
|
41901
|
+
console.log(basicVertexShaderSource);
|
|
41902
|
+
console.log("[ basic-fragment ]");
|
|
41903
|
+
console.log(basicFragmentShaderSource);
|
|
41904
|
+
console.log("[ picking-vertex ]");
|
|
41905
|
+
console.log(pickingVertexShaderSource);
|
|
41906
|
+
console.log("[ picking-fragment ]");
|
|
41907
|
+
console.log(pickingFragmentShaderSource);
|
|
41908
|
+
}
|
|
41909
|
+
return { basic, picking };
|
|
41910
|
+
}
|
|
41911
|
+
}
|
|
41912
|
+
const declaration$5 = "// compressed sh colors (11bit, 10bit, 11bit)\nuniform highp usampler2D sphericalHarmonicsTexture0;\nuniform highp usampler2D sphericalHarmonicsTexture1;\nuniform highp usampler2D sphericalHarmonicsTexture2;\nuniform highp usampler2D sphericalHarmonicsTexture3;\nuniform float sphericalHarmonicsIntensity;\nuniform vec3 eyePosition;\n\nout vec4 vColor;\nout vec2 vPosition;\nout float vGeneralR;\n";
|
|
41913
|
+
const _function$1 = "vec3 unpack(uint bits) {\n // unpack 11bit 10bit 11bit\n return vec3((uvec3(bits) >> uvec3(21u, 11u, 0u)) & uvec3(0x7ffu, 0x3ffu, 0x7ffu)) / vec3(2047.0, 1023.0, 2047.0) * 2.0 - 1.0;\n}\nvoid readV(in uvec4 i, out vec3 v, out vec3 w, out vec3 x, out vec3 y) {\n v = unpack(i.x);\n w = unpack(i.y);\n x = unpack(i.z);\n y = unpack(i.w);\n}\nvoid readVF(in uvec4 i, out vec3 v, out vec3 w, out vec3 x, out float f) {\n v = unpack(i.x);\n w = unpack(i.y);\n x = unpack(i.z);\n // 最後の要素は色のスケーリングに使う係数なのでそのまま float に変換する\n f = uintBitsToFloat(i.w);\n}\n// uv は幅が2倍されていない方のテクセル位置\nvec3 calculateSH(ivec2 uv, vec3 eye) {\n float scale;\n vec3 sh[15];\n readV(texelFetch(sphericalHarmonicsTexture0, uv, 0), sh[0], sh[1], sh[2], sh[3]);\n readV(texelFetch(sphericalHarmonicsTexture1, uv, 0), sh[4], sh[5], sh[6], sh[7]);\n readV(texelFetch(sphericalHarmonicsTexture2, uv, 0), sh[8], sh[9], sh[10], sh[11]);\n readVF(texelFetch(sphericalHarmonicsTexture3, uv, 0), sh[12], sh[13], sh[14], scale);\n // degrees == 1\n vec3 result = 0.4886025119029199 * (-sh[0] * eye.y + sh[1] * eye.z - sh[2] * eye.x);\n // degrees == 2\n float x2 = eye.x * eye.x;\n float y2 = eye.y * eye.y;\n float z2 = eye.z * eye.z;\n float xy = eye.x * eye.y;\n float yz = eye.y * eye.z;\n float xz = eye.x * eye.z;\n result +=\n sh[3] * ( 1.0925484305920792 * xy) +\n sh[4] * (-1.0925484305920792 * yz) +\n sh[5] * ( 0.31539156525252005 * (2.0 * z2 - x2 - y2)) +\n sh[6] * (-1.0925484305920792 * xz) +\n sh[7] * ( 0.5462742152960396 * (x2 - y2));\n // degrees == 3\n result +=\n sh[8] * (-0.5900435899266435 * eye.y * (3.0 * x2 - y2)) +\n sh[9] * ( 2.890611442640554 * xy * eye.z) +\n sh[10] * (-0.4570457994644658 * eye.y * (4.0 * z2 - x2 - y2)) +\n sh[11] * ( 0.3731763325901154 * eye.z * (2.0 * z2 - 3.0 * x2 - 3.0 * y2)) +\n sh[12] * (-0.4570457994644658 * eye.x * (4.0 * z2 - x2 - y2)) +\n sh[13] * ( 1.445305721320277 * eye.z * (x2 - y2)) +\n sh[14] * (-0.5900435899266435 * eye.x * (x2 - 3.0 * y2));\n // finally\n return result * scale;\n}\n";
|
|
41914
|
+
const mainSigma$1 = " vPosition = aLocalPosition;\n\n vec3 shColor = calculateSH(uv, normalize(eyePosition - transformedCenter));\n normalizedColor += vec4(shColor, 0.0) * sphericalHarmonicsIntensity;\n vColor = clamp(clipPosition.z / clipPosition.w + 1.0, 0.0, 1.0) * normalizedColor;\n\n vGeneralR = sign(float(general.r));\n vColor = mix(vColor, vec4(1.0, 0.1, 1.0, 1.0), vGeneralR);\n globalScale *= generalG;\n";
|
|
41915
|
+
const declaration$4 = "in vec4 vColor;\nin vec2 vPosition;\nin float vGeneralR;\n\nconst float EDGE = 0.95;\nconst float COLLISION_ALPHA = 0.25;\n";
|
|
41916
|
+
const mainIn$1 = " float A = -dot(vPosition, vPosition);\n if (A < -4.0) {discard;}\n float B = exp(A) * vColor.a;\n\n float l = length(vPosition);\n float f = smoothstep(0.5, 1.0, 0.01 / abs(l - EDGE));\n float C = f + sign(max(-l + EDGE, 0.0)) * COLLISION_ALPHA;\n\n finalColor = vColor.rgb;\n finalAlpha = mix(B, C, vGeneralR);\n";
|
|
41917
|
+
const declaration$3 = "uniform float effectMinimumScale;\nuniform float effectDistance;\nuniform float effectDistanceMax;\nuniform float effectDistanceRange;\nuniform float effectDistanceColor; // 色エフェクト(可視部分の外側)\nuniform float effectDistanceColorNear; // 色エフェクト(可視部分の内側)\nuniform float effectSonar; // ソナーエフェクト(外側の円の半径)\nuniform float effectSonarRange; // ソナーエフェクトの範囲\nuniform vec3 worldOrigin; // 距離を計測する際の原点位置\n\nout float vColorEffectFactor; // 色エフェクトの係数(0.0~1.0)\nout float vSonarFactor; // ソナーエフェクトの係数(0.0~1.0)\n";
|
|
41918
|
+
const mainSigma = " // 指定された原点からの距離を、与えられた最大距離で割って正規化\n float toCenter = length(transformedCenter - worldOrigin) / effectDistanceMax;\n float threshold = effectDistance;\n float range = max(effectDistanceRange, 0.0001); // 0除算を防ぐ\n // effectDistanceが0に近づくと、normalizedDistanceが大きくなるように調整\n float normalizedDistance = (toCenter - threshold) / (range * threshold + 0.0001);\n float ease = effectDistance >= 1.0 ? 1.0 : (1.0 - min(max(normalizedDistance, 0.0), 1.0));\n ease = max(ease, effectMinimumScale);\n\n globalScale *= ease;\n \n // 距離に応じて小さくなる円を計算: ease=0のとき背景球は表示されなくなる\n float circularScale = 1.0 - min(toCenter, 1.0);\n vec2 circularMajorAxis = normalize(majorAxis) * circularScale;\n vec2 circularMinorAxis = normalize(minorAxis) * circularScale;\n \n // effectDistanceを使用して形状の補間を行う\n // ease=0のとき半径1.0の円、ease=1のとき元の楕円になるように補間\n majorAxis = mix(circularMajorAxis, majorAxis, ease);\n minorAxis = mix(circularMinorAxis, minorAxis, ease);\n globalScale *= ease;\n\n // 色エフェクトの距離係数を計算(pointシェーダーと同じロジック)\n float toCenterColor = toCenter; // 既に計算済みのtoCenterを使用\n float thresholdColor = effectDistanceColor * (1.0 + effectDistanceRange);\n float farColor = clamp(thresholdColor - toCenterColor, 0.0, effectDistanceRange) / max(effectDistanceRange, 0.0001);\n float thresholdColorNear = effectDistanceColorNear * (1.0 + effectDistanceRange);\n float nearColor = 1.0 - (clamp(thresholdColorNear - toCenterColor, 0.0, effectDistanceRange) / max(effectDistanceRange, 0.0001));\n vColorEffectFactor = nearColor * farColor;\n\n // ソナーエフェクトの距離係数を計算(ドーナツ形状)\n // 外側の円の半径: effectSonar (0.0~1.0)\n // 内側の円の半径: effectSonar - effectSonarRange\n float outerRadius = effectSonar;\n float innerRadius = max(0.0, effectSonar - effectSonarRange);\n\n // エフェクト範囲内かどうかを判定\n float factor = 0.0;\n if (toCenter <= outerRadius && toCenter >= innerRadius && effectSonarRange > 0.0) {\n // ドーナツ形状の範囲内:距離に基づいて0.0~1.0の係数を計算\n // 外側(outerRadius)で1.0、内側(innerRadius)で0.0\n float range = outerRadius - innerRadius;\n factor = range > 0.0001 ? (toCenter - innerRadius) / range : 1.0;\n }\n vSonarFactor = factor;\n";
|
|
41919
|
+
const declaration$2 = "uniform float temperature;\nuniform float tint;\nuniform float contrastIntensity;\nuniform vec3 hsv;\nuniform vec3 rgb;\n\nin float vColorEffectFactor; // 色エフェクトの係数(0.0~1.0)\nin float vSonarFactor; // ソナーエフェクトの係数(0.0~1.0)\n\nconst float EPS = 1.0e-8;\nconst float DIV = 10.0 / 6.0;\nconst mat3 LIN_2_LMS_MAT = mat3(\n 3.90405e-1, 5.49941e-1, 8.92632e-3,\n 7.08416e-2, 9.63172e-1, 1.35775e-3,\n 2.31082e-2, 1.28021e-1, 9.36245e-1\n);\nconst mat3 LMS_2_LIN_MAT = mat3(\n 2.85847e+0, -1.62879e+0, -2.48910e-2,\n -2.10182e-1, 1.15820e+0, 3.24281e-4,\n -4.18120e-2, -1.18169e-1, 1.06867e+0\n);\n";
|
|
41920
|
+
const _function = "vec3 whiteBalance(vec3 diffuse, float te, float ti) {\n // Range ~[-1.67 : 1.67] works best\n float t1 = te * DIV;\n float t2 = ti * DIV;\n float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);\n float standardIlluminantY = 2.87 * x - 3.0 * x * x - 0.27509507;\n float y = standardIlluminantY + t2 * 0.05;\n vec3 w1 = vec3(0.949237, 1.03542, 1.08728);\n\n // CIExyToLMS\n float X = x / y;\n float Z = (1.0 - x - y) / y;\n float L = 0.7328 * X + 0.4296 - 0.1624 * Z;\n float M = -0.7036 * X + 1.6975 + 0.0061 * Z;\n float S = 0.0030 * X + 0.0136 + 0.9834 * Z;\n vec3 w2 = vec3(L, M, S);\n\n vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);\n vec3 lms = LIN_2_LMS_MAT * diffuse;\n lms *= balance;\n return LMS_2_LIN_MAT * lms;\n}\n\nvec3 RGB2HSV(vec3 color) {\n vec3 c = min(color, 1.0);\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + EPS)), d / (q.x + EPS), q.x);\n}\n\nvec3 HSV2RGB(vec3 color) {\n vec3 c = min(color, 1.0);\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\nvec3 contrast(vec3 color, float base) {\n float b = (base * 2.0 - 1.0) * 0.5;\n return color + vec3(\n atan((color.r * 2.0 - 1.0) * b),\n atan((color.g * 2.0 - 1.0) * b),\n atan((color.b * 2.0 - 1.0) * b)\n );\n}\n\nvec3 grading(vec3 color) {\n vec3 balanced = whiteBalance(color, temperature, tint);\n vec3 contrasted = contrast(balanced, contrastIntensity);\n vec3 hsvColor = RGB2HSV(contrasted);\n hsvColor.x = fract(hsvColor.x + hsv.x);\n hsvColor.y = clamp(hsvColor.y + hsv.y, 0.0, 1.0);\n hsvColor.z = clamp(hsvColor.z + hsv.z, 0.0, 1.0);\n vec3 rgbAdjusted = HSV2RGB(hsvColor);\n rgbAdjusted.r = clamp(rgbAdjusted.r + rgb.r, 0.0, 1.0);\n rgbAdjusted.g = clamp(rgbAdjusted.g + rgb.g, 0.0, 1.0);\n rgbAdjusted.b = clamp(rgbAdjusted.b + rgb.b, 0.0, 1.0);\n return rgbAdjusted;\n}\n";
|
|
41921
|
+
const mainIn = " // 距離係数に基づいてHSV/RGBの影響を制御\n vec3 gradedColor = grading(finalColor);\n // finalColor = mix(finalColor, gradedColor, vColorEffectFactor);\n finalColor = mix(finalColor, gradedColor, 1.0);\n\n // ソナーエフェクト:白エリアのみ\n // vSonarFactor: 外側で1.0、内側で0.0の係数\n if (vSonarFactor > 0.0) {\n float sonarStrength = 2.0; // 強度\n vec3 sonarColor = finalColor;\n // 白エリアの処理\n float whiteAreaFactor = smoothstep(0.25, 1.0, vSonarFactor);\n vec3 whiteColor = sonarColor;\n whiteColor.rgb += whiteAreaFactor * sonarStrength * 0.4;\n // 色をクランプ\n whiteColor = clamp(whiteColor, 0.0, 1.0);\n // エフェクト範囲内でのみ適用\n finalColor = mix(finalColor, whiteColor, vSonarFactor);\n }\n";
|
|
41922
|
+
const declaration$1 = "out vec4 vColor;\nflat out uint vGeneralA;\n";
|
|
41923
|
+
const mainTransform = " vColor = vec4(transformedCenter, 0.0);\n vGeneralA = general.a;\n";
|
|
41924
|
+
const declaration = "in vec4 vColor;\nflat in uint vGeneralA;\n";
|
|
41925
|
+
const mainOut = " // flat 修飾子で受けた general texture の A 要素をビット列そのままでアルファに焼き込む\n // この値は readPixels で読み取られたあと JS 側で Uint32Array として参照される\n // なお vColor.a としてまとめて受け取らないのはシェーダ間で varying が補間されて誤差が生じないようにするため\n float toFloat = uintBitsToFloat(vGeneralA);\n fragColor = vec4(vColor.rgb, toFloat);\n";
|
|
41146
41926
|
const TavioErrorCode = {
|
|
41147
41927
|
/** Float16Array 未対応環境 */
|
|
41148
41928
|
FLOAT16_NOT_SUPPORTED: "E001"
|
|
@@ -41313,6 +42093,11 @@ class Core extends EventEmitter {
|
|
|
41313
42093
|
CONTROLS_TYPE_PATH,
|
|
41314
42094
|
CONTROLS_TYPE_FLIGHT
|
|
41315
42095
|
];
|
|
42096
|
+
/**
|
|
42097
|
+
* シェーダチャンク関連(定義は MaterialGenerator.ts 内)
|
|
42098
|
+
*/
|
|
42099
|
+
static CHUNK_TARGET = CHUNK_TARGET;
|
|
42100
|
+
static SHADER_STAGE = SHADER_STAGE;
|
|
41316
42101
|
/**
|
|
41317
42102
|
* @constructor
|
|
41318
42103
|
* @param viewerOption - ビューア実装の初期化オプション
|
|
@@ -41452,8 +42237,9 @@ class Core extends EventEmitter {
|
|
|
41452
42237
|
/**
|
|
41453
42238
|
* 各種初期化処理を行う
|
|
41454
42239
|
* @param canvas - WebGL コンテキストを取得する対象となる canvas 要素
|
|
42240
|
+
* @param materialOption - シェーダチャンクなどの情報を含むマテリアルオプション
|
|
41455
42241
|
*/
|
|
41456
|
-
init(canvas) {
|
|
42242
|
+
init(canvas, materialOption) {
|
|
41457
42243
|
this.canvas = canvas;
|
|
41458
42244
|
this.renderer = new WebGLRenderer({
|
|
41459
42245
|
canvas,
|
|
@@ -41461,6 +42247,15 @@ class Core extends EventEmitter {
|
|
|
41461
42247
|
preserveDrawingBuffer: true
|
|
41462
42248
|
});
|
|
41463
42249
|
this.renderer.setClearColor(new Color(0, 0, 0), 0);
|
|
42250
|
+
this.pickingRenderTarget = new WebGLRenderTarget(
|
|
42251
|
+
this.canvas.width,
|
|
42252
|
+
this.canvas.height,
|
|
42253
|
+
{
|
|
42254
|
+
type: FloatType,
|
|
42255
|
+
minFilter: NearestFilter,
|
|
42256
|
+
magFilter: NearestFilter
|
|
42257
|
+
}
|
|
42258
|
+
);
|
|
41464
42259
|
this.scene = new Scene();
|
|
41465
42260
|
this.scene.backgroundRotation.x = Math.PI * 0.5;
|
|
41466
42261
|
this.scene.backgroundIntensity = this.viewerOption.backgroundOpacity;
|
|
@@ -41482,154 +42277,180 @@ class Core extends EventEmitter {
|
|
|
41482
42277
|
this.perspectiveCamera.up.set(0, -1, 0);
|
|
41483
42278
|
this.perspectiveCamera.position.set(0, 0, PERSPECTIVE_POSITION_Z);
|
|
41484
42279
|
this.perspectiveCamera.lookAt(new Vector3(0, 0, 0));
|
|
41485
|
-
this.
|
|
41486
|
-
|
|
41487
|
-
|
|
41488
|
-
|
|
41489
|
-
|
|
41490
|
-
|
|
41491
|
-
|
|
41492
|
-
|
|
41493
|
-
|
|
41494
|
-
|
|
41495
|
-
|
|
41496
|
-
|
|
41497
|
-
|
|
41498
|
-
|
|
41499
|
-
//
|
|
41500
|
-
|
|
41501
|
-
|
|
41502
|
-
|
|
41503
|
-
|
|
41504
|
-
|
|
41505
|
-
|
|
41506
|
-
|
|
41507
|
-
|
|
41508
|
-
sphericalHarmonicsCalculation: { value: false },
|
|
41509
|
-
// is calculation on shader
|
|
41510
|
-
gaussianScale: { value: this.viewerOption.gaussianScale },
|
|
41511
|
-
// ガウシアンの大きさの基本係数
|
|
41512
|
-
effectMinimumScale: { value: this.viewerOption.minimumScale },
|
|
41513
|
-
// 距離に応じた大きさの最小サイズ
|
|
41514
|
-
effectDistance: { value: this.viewerOption.distanceEffectBase },
|
|
41515
|
-
// 距離に応じた大きさの係数(0.0 to 1.0)
|
|
41516
|
-
effectDistanceMax: { value: 0 },
|
|
41517
|
-
// 正規化するための最大距離
|
|
41518
|
-
effectDistanceRange: { value: this.viewerOption.distanceEffectRange },
|
|
41519
|
-
// 正規化済みの値の範囲係数(0.0 < n <= 1.0)
|
|
41520
|
-
effectDistanceColor: { value: this.viewerOption.distanceColorEffect },
|
|
41521
|
-
// 色エフェクト(可視部分の外側)
|
|
41522
|
-
effectDistanceColorNear: {
|
|
41523
|
-
value: this.viewerOption.distanceColorEffectNear
|
|
41524
|
-
},
|
|
41525
|
-
// 色エフェクト(可視部分の内側)
|
|
41526
|
-
effectSonar: { value: this.viewerOption.effectSonar },
|
|
41527
|
-
// ソナーエフェクト(外側の円の半径)
|
|
41528
|
-
effectSonarRange: {
|
|
41529
|
-
value: this.viewerOption.effectSonarRange
|
|
41530
|
-
},
|
|
41531
|
-
// ソナーエフェクトの範囲
|
|
41532
|
-
worldOrigin: {
|
|
41533
|
-
value: new Vector3(
|
|
41534
|
-
this.viewerOption.worldOrigin.x,
|
|
41535
|
-
this.viewerOption.worldOrigin.y,
|
|
41536
|
-
this.viewerOption.worldOrigin.z
|
|
41537
|
-
)
|
|
41538
|
-
},
|
|
41539
|
-
additionAlpha: { value: this.viewerOption.opacityAdditive },
|
|
41540
|
-
multiplicationAlpha: { value: this.viewerOption.opacityMultiplier },
|
|
41541
|
-
temperature: { value: this.viewerOption.colorTemperature },
|
|
41542
|
-
tint: { value: this.viewerOption.colorTint },
|
|
41543
|
-
contrastIntensity: { value: this.viewerOption.colorContrast },
|
|
41544
|
-
hsv: {
|
|
41545
|
-
value: new Vector3(
|
|
41546
|
-
this.viewerOption.colorHSV.x,
|
|
41547
|
-
this.viewerOption.colorHSV.y,
|
|
41548
|
-
this.viewerOption.colorHSV.z
|
|
41549
|
-
)
|
|
41550
|
-
},
|
|
41551
|
-
rgb: {
|
|
41552
|
-
value: new Vector3(
|
|
41553
|
-
this.viewerOption.colorRGB.x,
|
|
41554
|
-
this.viewerOption.colorRGB.y,
|
|
41555
|
-
this.viewerOption.colorRGB.z
|
|
41556
|
-
)
|
|
42280
|
+
this.cameraPathManager = new CameraPathManager();
|
|
42281
|
+
this.meshMap = /* @__PURE__ */ new Map();
|
|
42282
|
+
this.setupMaterial(materialOption);
|
|
42283
|
+
this.setupControls();
|
|
42284
|
+
this.setupSelector();
|
|
42285
|
+
this.setupEvent();
|
|
42286
|
+
}
|
|
42287
|
+
/**
|
|
42288
|
+
* マテリアルをセットアップする
|
|
42289
|
+
* @param option - シェーダチャンクなどの情報を含むマテリアルオプション
|
|
42290
|
+
*/
|
|
42291
|
+
setupMaterial(option) {
|
|
42292
|
+
const materialOption = [
|
|
42293
|
+
{
|
|
42294
|
+
// 交流成分を有効化したうえで RGB を出力し、範囲選択の見た目を変化させる
|
|
42295
|
+
target: CHUNK_TARGET.BASIC,
|
|
42296
|
+
uniforms: {
|
|
42297
|
+
sphericalHarmonicsTexture0: { value: null },
|
|
42298
|
+
sphericalHarmonicsTexture1: { value: null },
|
|
42299
|
+
sphericalHarmonicsTexture2: { value: null },
|
|
42300
|
+
sphericalHarmonicsTexture3: { value: null },
|
|
42301
|
+
sphericalHarmonicsIntensity: { value: 1 },
|
|
42302
|
+
eyePosition: { value: new Vector3(0, 0, 0) }
|
|
41557
42303
|
},
|
|
41558
|
-
|
|
41559
|
-
|
|
41560
|
-
|
|
41561
|
-
|
|
41562
|
-
|
|
41563
|
-
|
|
41564
|
-
|
|
41565
|
-
|
|
41566
|
-
|
|
41567
|
-
|
|
42304
|
+
vertex: [
|
|
42305
|
+
{
|
|
42306
|
+
stage: SHADER_STAGE.VERTEX_DECLARATION,
|
|
42307
|
+
source: declaration$5
|
|
42308
|
+
},
|
|
42309
|
+
{
|
|
42310
|
+
stage: SHADER_STAGE.VERTEX_FUNCTION,
|
|
42311
|
+
source: _function$1
|
|
42312
|
+
},
|
|
42313
|
+
{
|
|
42314
|
+
stage: SHADER_STAGE.VERTEX_MAIN_SIGMA,
|
|
42315
|
+
source: mainSigma$1
|
|
42316
|
+
}
|
|
42317
|
+
],
|
|
42318
|
+
fragment: [
|
|
42319
|
+
{
|
|
42320
|
+
stage: SHADER_STAGE.FRAGMENT_DECLARATION,
|
|
42321
|
+
source: declaration$4
|
|
42322
|
+
},
|
|
42323
|
+
{
|
|
42324
|
+
stage: SHADER_STAGE.FRAGMENT_MAIN_IN,
|
|
42325
|
+
source: mainIn$1
|
|
42326
|
+
}
|
|
42327
|
+
]
|
|
41568
42328
|
},
|
|
41569
|
-
|
|
41570
|
-
|
|
41571
|
-
|
|
41572
|
-
|
|
41573
|
-
|
|
41574
|
-
|
|
41575
|
-
|
|
41576
|
-
|
|
41577
|
-
|
|
41578
|
-
|
|
41579
|
-
|
|
41580
|
-
|
|
41581
|
-
|
|
41582
|
-
|
|
41583
|
-
|
|
41584
|
-
|
|
41585
|
-
|
|
41586
|
-
|
|
41587
|
-
|
|
41588
|
-
|
|
41589
|
-
|
|
41590
|
-
|
|
41591
|
-
|
|
41592
|
-
|
|
41593
|
-
|
|
41594
|
-
|
|
41595
|
-
|
|
41596
|
-
|
|
41597
|
-
|
|
41598
|
-
|
|
41599
|
-
|
|
41600
|
-
|
|
41601
|
-
|
|
41602
|
-
|
|
41603
|
-
|
|
41604
|
-
|
|
41605
|
-
|
|
41606
|
-
|
|
42329
|
+
{
|
|
42330
|
+
// 各種エフェクトやカラーグレーディングに対応させる
|
|
42331
|
+
target: CHUNK_TARGET.BASIC,
|
|
42332
|
+
uniforms: {
|
|
42333
|
+
effectMinimumScale: {
|
|
42334
|
+
value: this.viewerOption.minimumScale
|
|
42335
|
+
// 距離に応じた大きさの最小サイズ
|
|
42336
|
+
},
|
|
42337
|
+
effectDistance: {
|
|
42338
|
+
value: this.viewerOption.distanceEffectBase
|
|
42339
|
+
// 距離に応じた大きさの係数(0.0 to 1.0)
|
|
42340
|
+
},
|
|
42341
|
+
effectDistanceMax: {
|
|
42342
|
+
value: 0
|
|
42343
|
+
// 正規化するための最大距離
|
|
42344
|
+
},
|
|
42345
|
+
effectDistanceRange: {
|
|
42346
|
+
value: this.viewerOption.distanceEffectRange
|
|
42347
|
+
// 正規化済みの値の範囲係数(0.0 < n <= 1.0)
|
|
42348
|
+
},
|
|
42349
|
+
effectDistanceColor: {
|
|
42350
|
+
value: this.viewerOption.distanceColorEffect
|
|
42351
|
+
// 色エフェクト(可視部分の外側)
|
|
42352
|
+
},
|
|
42353
|
+
effectDistanceColorNear: {
|
|
42354
|
+
value: this.viewerOption.distanceColorEffectNear
|
|
42355
|
+
// 色エフェクト(可視部分の内側)
|
|
42356
|
+
},
|
|
42357
|
+
effectSonar: {
|
|
42358
|
+
value: this.viewerOption.effectSonar
|
|
42359
|
+
// ソナーエフェクト(外側の円の半径)
|
|
42360
|
+
},
|
|
42361
|
+
effectSonarRange: {
|
|
42362
|
+
value: this.viewerOption.effectSonarRange
|
|
42363
|
+
// ソナーエフェクトの範囲
|
|
42364
|
+
},
|
|
42365
|
+
worldOrigin: {
|
|
42366
|
+
value: new Vector3(
|
|
42367
|
+
this.viewerOption.worldOrigin.x,
|
|
42368
|
+
this.viewerOption.worldOrigin.y,
|
|
42369
|
+
this.viewerOption.worldOrigin.z
|
|
42370
|
+
)
|
|
42371
|
+
},
|
|
42372
|
+
temperature: { value: this.viewerOption.colorTemperature },
|
|
42373
|
+
tint: { value: this.viewerOption.colorTint },
|
|
42374
|
+
contrastIntensity: { value: this.viewerOption.colorContrast },
|
|
42375
|
+
hsv: {
|
|
42376
|
+
value: new Vector3(
|
|
42377
|
+
this.viewerOption.colorHSV.x,
|
|
42378
|
+
this.viewerOption.colorHSV.y,
|
|
42379
|
+
this.viewerOption.colorHSV.z
|
|
42380
|
+
)
|
|
42381
|
+
},
|
|
42382
|
+
rgb: {
|
|
42383
|
+
value: new Vector3(
|
|
42384
|
+
this.viewerOption.colorRGB.x,
|
|
42385
|
+
this.viewerOption.colorRGB.y,
|
|
42386
|
+
this.viewerOption.colorRGB.z
|
|
42387
|
+
)
|
|
42388
|
+
}
|
|
41607
42389
|
},
|
|
41608
|
-
|
|
41609
|
-
|
|
41610
|
-
|
|
42390
|
+
vertex: [
|
|
42391
|
+
{
|
|
42392
|
+
stage: SHADER_STAGE.VERTEX_DECLARATION,
|
|
42393
|
+
source: declaration$3
|
|
42394
|
+
},
|
|
42395
|
+
{
|
|
42396
|
+
stage: SHADER_STAGE.VERTEX_MAIN_SIGMA,
|
|
42397
|
+
source: mainSigma
|
|
42398
|
+
}
|
|
42399
|
+
],
|
|
42400
|
+
fragment: [
|
|
42401
|
+
{
|
|
42402
|
+
stage: SHADER_STAGE.FRAGMENT_DECLARATION,
|
|
42403
|
+
source: declaration$2
|
|
42404
|
+
},
|
|
42405
|
+
{
|
|
42406
|
+
stage: SHADER_STAGE.FRAGMENT_FUNCTION,
|
|
42407
|
+
source: _function
|
|
42408
|
+
},
|
|
42409
|
+
{
|
|
42410
|
+
stage: SHADER_STAGE.FRAGMENT_MAIN_IN,
|
|
42411
|
+
source: mainIn
|
|
42412
|
+
}
|
|
42413
|
+
]
|
|
41611
42414
|
},
|
|
41612
|
-
vertexShader: main$5,
|
|
41613
|
-
fragmentShader: main$4,
|
|
41614
|
-
depthTest: true,
|
|
41615
|
-
depthWrite: false,
|
|
41616
|
-
glslVersion: GLSL3,
|
|
41617
|
-
side: DoubleSide
|
|
41618
|
-
});
|
|
41619
|
-
this.pickingRenderTarget = new WebGLRenderTarget(
|
|
41620
|
-
this.canvas.width,
|
|
41621
|
-
this.canvas.height,
|
|
41622
42415
|
{
|
|
41623
|
-
|
|
41624
|
-
|
|
41625
|
-
|
|
42416
|
+
// ワールド座標をレンダリングするピッキング用シェーダ
|
|
42417
|
+
target: CHUNK_TARGET.PICKING,
|
|
42418
|
+
vertex: [
|
|
42419
|
+
{
|
|
42420
|
+
stage: SHADER_STAGE.VERTEX_DECLARATION,
|
|
42421
|
+
source: declaration$1
|
|
42422
|
+
},
|
|
42423
|
+
{
|
|
42424
|
+
stage: SHADER_STAGE.VERTEX_MAIN_TRANSFORM,
|
|
42425
|
+
source: mainTransform
|
|
42426
|
+
}
|
|
42427
|
+
],
|
|
42428
|
+
fragment: [
|
|
42429
|
+
{
|
|
42430
|
+
stage: SHADER_STAGE.FRAGMENT_DECLARATION,
|
|
42431
|
+
source: declaration
|
|
42432
|
+
},
|
|
42433
|
+
{
|
|
42434
|
+
stage: SHADER_STAGE.FRAGMENT_MAIN_OUT,
|
|
42435
|
+
source: mainOut
|
|
42436
|
+
}
|
|
42437
|
+
]
|
|
41626
42438
|
}
|
|
41627
|
-
|
|
41628
|
-
|
|
41629
|
-
|
|
41630
|
-
|
|
41631
|
-
|
|
41632
|
-
|
|
42439
|
+
];
|
|
42440
|
+
if (option != null && option.materialOption != null) {
|
|
42441
|
+
const mat = option.materialOption;
|
|
42442
|
+
const opt = Array.isArray(mat) === true ? mat : [mat];
|
|
42443
|
+
opt.forEach((ep) => {
|
|
42444
|
+
materialOption.push(ep);
|
|
42445
|
+
});
|
|
42446
|
+
}
|
|
42447
|
+
const isDebug = option?.isDebug === true;
|
|
42448
|
+
const {
|
|
42449
|
+
basic,
|
|
42450
|
+
picking
|
|
42451
|
+
} = MaterialGenerator.generate(materialOption, isDebug);
|
|
42452
|
+
this.gaussianMaterial = basic;
|
|
42453
|
+
this.gaussianPickingMaterial = picking;
|
|
41633
42454
|
}
|
|
41634
42455
|
/**
|
|
41635
42456
|
* カメラコントロール・カメラコライダーをセットアップする
|
|
@@ -42189,19 +43010,76 @@ class Core extends EventEmitter {
|
|
|
42189
43010
|
* @param name - このメッシュの固有名
|
|
42190
43011
|
* @see {@link TavioMesh.prototype.loadPlyWasm}
|
|
42191
43012
|
*/
|
|
42192
|
-
async loadPlyWasm(name,
|
|
43013
|
+
async loadPlyWasm(name, url, options) {
|
|
43014
|
+
const tavioMesh = this._beforeLoadMesh(name);
|
|
43015
|
+
await tavioMesh.loadMeshWasm(url, "ply", options);
|
|
43016
|
+
await this._afterLoadMesh(name);
|
|
43017
|
+
}
|
|
43018
|
+
/**
|
|
43019
|
+
* splat 形式のリソースをロードする
|
|
43020
|
+
* @param name - このメッシュの固有名
|
|
43021
|
+
* @see {@link TavioMesh.prototype.loadSplatWasm}
|
|
43022
|
+
*/
|
|
43023
|
+
async loadSplatWasm(name, url, options) {
|
|
42193
43024
|
const tavioMesh = this._beforeLoadMesh(name);
|
|
42194
|
-
await tavioMesh.
|
|
43025
|
+
await tavioMesh.loadMeshWasm(url, "splat", options);
|
|
42195
43026
|
await this._afterLoadMesh(name);
|
|
42196
43027
|
}
|
|
42197
43028
|
/**
|
|
42198
|
-
*
|
|
43029
|
+
* spz 形式のリソースをロードする
|
|
42199
43030
|
* @param name - このメッシュの固有名
|
|
42200
|
-
* @see {@link TavioMesh.prototype.
|
|
43031
|
+
* @see {@link TavioMesh.prototype.loadSpzWasm}
|
|
42201
43032
|
*/
|
|
42202
|
-
async
|
|
43033
|
+
async loadSpzWasm(name, url, options) {
|
|
43034
|
+
const tavioMesh = this._beforeLoadMesh(name);
|
|
43035
|
+
await tavioMesh.loadMeshWasm(url, "spz", options);
|
|
43036
|
+
await this._afterLoadMesh(name);
|
|
43037
|
+
}
|
|
43038
|
+
/**
|
|
43039
|
+
* sog 形式のリソースをロードする
|
|
43040
|
+
* @param name - このメッシュの固有名
|
|
43041
|
+
* @see {@link TavioMesh.prototype.loadSogWasm}
|
|
43042
|
+
*/
|
|
43043
|
+
async loadSogWasm(name, url, options) {
|
|
43044
|
+
const tavioMesh = this._beforeLoadMesh(name);
|
|
43045
|
+
await tavioMesh.loadMeshWasm(url, "sog", options);
|
|
43046
|
+
await this._afterLoadMesh(name);
|
|
43047
|
+
}
|
|
43048
|
+
/**
|
|
43049
|
+
* tavio 形式のリソースを保存する
|
|
43050
|
+
* @param name - このメッシュの固有名
|
|
43051
|
+
* @param fileName - 保存ファイル名
|
|
43052
|
+
*/
|
|
43053
|
+
async saveTavioWasm(name, fileName) {
|
|
43054
|
+
const tavioMesh = this.meshMap.get(name);
|
|
43055
|
+
await tavioMesh.saveTavioWasm(fileName);
|
|
43056
|
+
}
|
|
43057
|
+
/**
|
|
43058
|
+
* splat 形式のリソースを保存する
|
|
43059
|
+
* @param name - このメッシュの固有名
|
|
43060
|
+
* @param fileName - 保存ファイル名
|
|
43061
|
+
*/
|
|
43062
|
+
async saveSplatWasm(name, fileName) {
|
|
42203
43063
|
const tavioMesh = this.meshMap.get(name);
|
|
42204
|
-
await tavioMesh.
|
|
43064
|
+
await tavioMesh.saveMeshWasm(fileName, "splat");
|
|
43065
|
+
}
|
|
43066
|
+
/**
|
|
43067
|
+
* ply 形式のリソースを保存する
|
|
43068
|
+
* @param name - このメッシュの固有名
|
|
43069
|
+
* @param fileName - 保存ファイル名
|
|
43070
|
+
*/
|
|
43071
|
+
async savePlyWasm(name, fileName) {
|
|
43072
|
+
const tavioMesh = this.meshMap.get(name);
|
|
43073
|
+
await tavioMesh.saveMeshWasm(fileName, "ply");
|
|
43074
|
+
}
|
|
43075
|
+
/**
|
|
43076
|
+
* spz 形式のリソースを保存する
|
|
43077
|
+
* @param name - このメッシュの固有名
|
|
43078
|
+
* @param fileName - 保存ファイル名
|
|
43079
|
+
*/
|
|
43080
|
+
async saveSpzWasm(name, fileName) {
|
|
43081
|
+
const tavioMesh = this.meshMap.get(name);
|
|
43082
|
+
await tavioMesh.saveMeshWasm(fileName, "spz");
|
|
42205
43083
|
}
|
|
42206
43084
|
/**
|
|
42207
43085
|
* 名前を指定してロード済み TavioMesh をシーンに追加する
|
|
@@ -43489,6 +44367,21 @@ class Core extends EventEmitter {
|
|
|
43489
44367
|
});
|
|
43490
44368
|
});
|
|
43491
44369
|
}
|
|
44370
|
+
/**
|
|
44371
|
+
* MaterialGenerator で独自に拡張した uniform 変数を更新する
|
|
44372
|
+
* @param customUniforms - 設定・更新する uniform 変数
|
|
44373
|
+
*/
|
|
44374
|
+
setCustomUniforms(customUniforms) {
|
|
44375
|
+
const uniforms = {};
|
|
44376
|
+
Object.entries(customUniforms).forEach(([k, v]) => {
|
|
44377
|
+
const _v = v;
|
|
44378
|
+
uniforms[k] = _v.value;
|
|
44379
|
+
});
|
|
44380
|
+
this.meshMap.forEach((mesh) => {
|
|
44381
|
+
mesh.setUniforms(uniforms);
|
|
44382
|
+
});
|
|
44383
|
+
this.start();
|
|
44384
|
+
}
|
|
43492
44385
|
/**
|
|
43493
44386
|
* ガウシアンの大きさの基本係数を設定する
|
|
43494
44387
|
* @param value - 設定する係数(0.0 to 1.0)
|