@openheart/tavio-renderer 2.2.12-without-wasm → 2.3.1-withWasm

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.
@@ -16002,25 +16002,25 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
16002
16002
  }
16003
16003
  return true;
16004
16004
  }
16005
- function getMaxPrecision(precision2) {
16006
- if (precision2 === "highp") {
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
- precision2 = "mediump";
16010
+ precision3 = "mediump";
16011
16011
  }
16012
- if (precision2 === "mediump") {
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 precision = parameters.precision !== void 0 ? parameters.precision : "highp";
16020
- const maxPrecision = getMaxPrecision(precision);
16021
- if (maxPrecision !== precision) {
16022
- warn("WebGLRenderer:", precision, "not supported, using", maxPrecision, "instead.");
16023
- precision = maxPrecision;
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 precision = capabilities.precision;
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
- precision = capabilities.getMaxPrecision(material.precision);
19024
- if (precision !== material.precision) {
19025
- warn("WebGLProgram.getParameters:", material.precision, "not supported, using", precision, "instead.");
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(uScale.x==0u ? 0.0 : exp(float(uScale.x)*invScale*scaleRange.x+scaleAlphaMin.x)*2.0,uScale.y==0u ? 0.0 : exp(float(uScale.y)*invScale*scaleRange.y+scaleAlphaMin.y)*2.0,uScale.z==0u ? 0.0 : exp(float(uScale.z)*invScale*scaleRange.z+scaleAlphaMin.z)*2.0);scale.x=scaleRange.x==0.0 ? 1.0 : scale.x;scale.y=scaleRange.y==0.0 ? 1.0 : scale.y;scale.z=scaleRange.z==0.0 ? 1.0 : scale.z;uint rotation=(packed.y>>16u)&0xffffu|(packed.z>>8u)&0xff0000u;vec4 quaternion=revertQuaternion(rotation);uvec4 uintRGBA=uvec4(packed.w&0xffu,(packed.w>>8u)&0xffu,(packed.w>>16u)&0xffu,(packed.w>>24u)&0xffu);vec4 rgba=vec4(uintRGBA)/255.0;float alphaRange=scaleAlphaMax.w-scaleAlphaMin.w;float rawAlpha=(float(general.b)/255.0)*alphaRange+scaleAlphaMin.w;mat3 modelMatrix=generateRotationScaleMatrix(tRotation,tScale);revertedPosition=modelMatrix*revertedPosition+tPosition;scale*=tScale;quaternion=multiplyQuaternion(tRotation,quaternion);vec4 viewPosition=view*vec4(revertedPosition,1.0);vec4 clipPosition=projection*viewPosition;float clip=1.2*clipPosition.w;if(clipPosition.z<-clip||clipPosition.x<-clip||clipPosition.x>clip||clipPosition.y<-clip||clipPosition.y>clip){gl_Position=vec4(0.0,0.0,2.0,1.0);return;}mat3 sigma=generateSigma(scale,quaternion);mat3 Vrk=sigma*transpose(sigma);float vpz=1.0/(viewPosition.z*viewPosition.z);mat3 J=mat3(focal.x/viewPosition.z,0.0,-(focal.x*viewPosition.x)*vpz,0.0,focal.y/viewPosition.z,-(focal.y*viewPosition.y)*vpz,0.0,0.0,0.0);mat3 mat3view=mat3(view);mat3 T=transpose(mat3view)*J;mat3 cov2d=transpose(T)*Vrk*T;float d00=cov2d[0][0]+sharpness;float d01=cov2d[0][1];float d11=cov2d[1][1]+sharpness;float mid=(d00+d11)/2.0;float radius=length(vec2((d00-d11)/2.0,d01));float lambda1=mid+radius,lambda2=mid-radius;if(lambda2<0.0){return;}vec2 diagonalVector=normalize(vec2(d01,lambda1-d00));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);float toCenter=length(revertedPosition-worldOrigin)/effectDistanceMax;float threshold=effectDistance;float range=max(effectDistanceRange,0.0001);float normalizedDistance=(toCenter-threshold)/(range*threshold+0.0001);float ease=effectDistance>=1.0 ? 1.0 :(1.0-min(max(normalizedDistance,0.0),1.0));ease=max(ease,effectMinimumScale);float circularScale=1.0-min(toCenter,1.0);vec2 circularMajorAxis=normalize(majorAxis)*circularScale;vec2 circularMinorAxis=normalize(minorAxis)*circularScale;vec2 finalMajorAxis=mix(circularMajorAxis,majorAxis,ease);vec2 finalMinorAxis=mix(circularMinorAxis,minorAxis,ease);vec4 normalizedColor=rgba;normalizedColor.a=1.0/(1.0+exp(-(rawAlpha*multiplicationAlpha+additionAlpha)));float a=cov2d[0][0];float d=cov2d[1][1];float b=cov2d[0][1];float dPrevious=a*d-b*b;a+=blur;d+=blur;float det=a*d-b*b;float blurAdjust=sqrt(max(0.0,dPrevious/det));normalizedColor.a*=blurAdjust;vPosition=localPosition;vec3 shColor=calculateSH(uv,normalize(eyePosition-revertedPosition));normalizedColor+=vec4(shColor,0.0)*sphericalHarmonicsIntensity;vColor=clamp(clipPosition.z/clipPosition.w+1.0,0.0,1.0)*normalizedColor;vGeneralR=sign(float(general.r));float generalG=1.0-sign(float(general.g));vColor=mix(vColor,vec4(1.0,0.1,1.0,1.0),vGeneralR);float toCenterColor=toCenter;float thresholdColor=effectDistanceColor*(1.0+effectDistanceRange);float farColor=clamp(thresholdColor-toCenterColor,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdColorNear=effectDistanceColorNear*(1.0+effectDistanceRange);float nearColor=1.0-(clamp(thresholdColorNear-toCenterColor,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001));vColorEffectFactor=nearColor*farColor;float outerRadius=effectSonar;float innerRadius=max(0.0,effectSonar-effectSonarRange);float factor=0.0;if(toCenter<=outerRadius&&toCenter>=innerRadius&&effectSonarRange>0.0){float range=outerRadius-innerRadius;factor=range>0.0001 ?(toCenter-innerRadius)/range : 1.0;}vSonarFactor=factor;vec2 center=vec2(clipPosition);vec2 major=localPosition.x*finalMajorAxis*inverseViewport;vec2 minor=localPosition.y*finalMinorAxis*inverseViewport;vec3 worldPosition=vec3(center+(major+minor)*clipPosition.w*gaussianScale*generalG*ease,clipPosition.z);vWorldPosition=revertedPosition;gl_Position=vec4(worldPosition,clipPosition.w);}";
33357
- 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
  }
@@ -34171,6 +34167,7 @@ class TransferControls extends EventEmitter {
34171
34167
  setCamera(camera) {
34172
34168
  this.camera = camera;
34173
34169
  this.syncCameraParameter();
34170
+ this.syncCameraFov();
34174
34171
  }
34175
34172
  /**
34176
34173
  * 設定されているカメラの座標を各プロパティに反映する
@@ -34209,7 +34206,6 @@ class TransferControls extends EventEmitter {
34209
34206
  syncCameraParameter() {
34210
34207
  this.syncCameraPosition();
34211
34208
  this.syncCameraRotation();
34212
- this.syncCameraFov();
34213
34209
  }
34214
34210
  /**
34215
34211
  * 減衰係数を設定する
@@ -34416,7 +34412,7 @@ class TransferControls extends EventEmitter {
34416
34412
  */
34417
34413
  _updateFov() {
34418
34414
  const range = this.targetFov - this.currentFov;
34419
- const changed = range > 0;
34415
+ const changed = Math.abs(range) > 0;
34420
34416
  this.currentFov = this.currentFov + (range - range * this.attenuation);
34421
34417
  if (Math.abs(this.currentFov - this.targetFov) < EPS$3) {
34422
34418
  this.currentFov = this.targetFov;
@@ -34528,6 +34524,18 @@ class OrbitControls extends EventEmitter {
34528
34524
  "change"
34529
34525
  // なにかしらの変更があった
34530
34526
  ];
34527
+ /**
34528
+ * 与えられた三次元ベクトル(要正規化)から theta と phi を計算する
34529
+ * @param eye - 正規化されたベクトル
34530
+ */
34531
+ static calcThetaPhi(eye) {
34532
+ const eyeXZ = new Vector2(eye.x, eye.z).normalize();
34533
+ const s = eyeXZ.cross(CROSS2);
34534
+ const c = Math.acos(eyeXZ.dot(CROSS2));
34535
+ const theta = Math.asin(eye.y);
34536
+ const phi = s > 0 ? PI_2 - c : c;
34537
+ return { theta, phi, eye, eyeXZ };
34538
+ }
34531
34539
  /**
34532
34540
  * @constructor
34533
34541
  * @param camera - 制御の対象となるカメラ
@@ -34575,18 +34583,6 @@ class OrbitControls extends EventEmitter {
34575
34583
  this._quatY = new Quaternion();
34576
34584
  this.setCamera(camera);
34577
34585
  }
34578
- /**
34579
- * 現在の視線から theta と phi を計算する
34580
- */
34581
- _getTP() {
34582
- const eye = this.camera.getWorldDirection(new Vector3());
34583
- const eyeXZ = new Vector2(eye.x, eye.z).normalize();
34584
- const s = eyeXZ.cross(CROSS2);
34585
- const c = Math.acos(eyeXZ.dot(CROSS2));
34586
- const theta = Math.asin(eye.y);
34587
- const phi = s > 0 ? PI_2 - c : c;
34588
- return { theta, phi, eye, eyeXZ };
34589
- }
34590
34586
  /**
34591
34587
  * 大きなラジアンをクランプする
34592
34588
  * @param value - 処理対象となる値
@@ -34644,7 +34640,8 @@ class OrbitControls extends EventEmitter {
34644
34640
  if (this.camera == null) {
34645
34641
  return;
34646
34642
  }
34647
- const tp = this._getTP();
34643
+ const eye = this.camera.getWorldDirection(new Vector3());
34644
+ const tp = OrbitControls.calcThetaPhi(eye);
34648
34645
  this.currentTheta = tp.theta;
34649
34646
  this.targetTheta = tp.theta;
34650
34647
  this.currentPhi = tp.phi;
@@ -34667,6 +34664,17 @@ class OrbitControls extends EventEmitter {
34667
34664
  direction.multiplyScalar(distance);
34668
34665
  this.camera.position.copy(this.center.clone().add(direction));
34669
34666
  }
34667
+ /**
34668
+ * 現在の向き(ラジアンでの緯度経度)
34669
+ */
34670
+ getAngle() {
34671
+ const eye = this.camera.getWorldDirection(new Vector3());
34672
+ const tp = OrbitControls.calcThetaPhi(eye);
34673
+ return {
34674
+ theta: tp.theta,
34675
+ phi: tp.phi
34676
+ };
34677
+ }
34670
34678
  /**
34671
34679
  * 前後移動(相対指定)
34672
34680
  * @param value - 距離
@@ -37414,11 +37422,11 @@ class PlyDecoder {
37414
37422
  };
37415
37423
  }
37416
37424
  }
37417
- const main$3 = "uniform float size;uniform float scale;uniform float effectDistanceNear;uniform float effectDistance;uniform float effectDistanceMax;uniform float effectDistanceRange;uniform float effectDistanceColor;uniform float effectDistanceColorNear;uniform float effectSonar;uniform float effectSonarRange;uniform vec3 worldOrigin;varying float vAlpha;varying float vColorEffectFactor;varying float vSonarFactor;varying vec3 vWorldPosition;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\nvarying vec2 vUv;uniform mat3 uvTransform;\n#endif\nvoid main(){\n#ifdef USE_POINTS_UV\nvUv=(uvTransform*vec3(uv,1)).xy;\n#endif\n#if defined( USE_COLOR_ALPHA )\nvColor=vec4(1.0);\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\nvColor=vec3(1.0);\n#endif\n#ifdef USE_COLOR\nvColor*=color;\n#endif\n#ifdef USE_INSTANCING_COLOR\nvColor.xyz*=instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\nvec3 batchingColor=getBatchingColor(getIndirectIndex(gl_DrawID));vColor.xyz*=batchingColor.xyz;\n#endif\n#include <morphinstance_vertex>\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\ngl_PointSize=size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)gl_PointSize*=(scale/-mvPosition.z);\n#endif\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\nvec4 floatPosition=modelMatrix*vec4(position,1.0);float toCenter=min(length(floatPosition.xyz-worldOrigin)/effectDistanceMax,1.0);float threshold=effectDistance*(1.0+effectDistanceRange);float far=clamp(threshold-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdNear=effectDistanceNear*(1.0+effectDistanceRange);float near=1.0-(clamp(thresholdNear-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001));vAlpha=near*far;float thresholdColor=effectDistanceColor*(1.0+effectDistanceRange);float farColor=clamp(thresholdColor-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001);float thresholdColorNear=effectDistanceColorNear*(1.0+effectDistanceRange);float nearColor=1.0-(clamp(thresholdColorNear-toCenter,0.0,effectDistanceRange)/max(effectDistanceRange,0.0001));vColorEffectFactor=nearColor*farColor;float outerRadius=effectSonar;float innerRadius=max(0.0,effectSonar-effectSonarRange);float factor=0.0;if(toCenter<=outerRadius&&toCenter>=innerRadius&&effectSonarRange>0.0){float range=outerRadius-innerRadius;factor=range>0.0001 ?(toCenter-innerRadius)/range : 1.0;}vSonarFactor=factor;vWorldPosition=floatPosition.xyz;}";
37418
- const main$2 = "uniform vec3 diffuse;uniform float opacity;uniform float temperature;uniform float tint;uniform float contrastIntensity;uniform vec3 hsv;uniform vec3 rgb;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying float vAlpha;varying float vColorEffectFactor;varying float vSonarFactor;varying vec3 vWorldPosition;uniform vec3 worldOrigin;uniform float effectSonar;const float EPS=1.0e-8;const float DIV=10.0/6.0;const mat3 LIN_2_LMS_MAT=mat3(3.90405e-1,5.49941e-1,8.92632e-3,7.08416e-2,9.63172e-1,1.35775e-3,2.31082e-2,1.28021e-1,9.36245e-1);const mat3 LMS_2_LIN_MAT=mat3(2.85847e+0,-1.62879e+0,-2.48910e-2,-2.10182e-1,1.15820e+0,3.24281e-4,-4.18120e-2,-1.18169e-1,1.06867e+0);vec3 whiteBalance(vec3 diffuse,float te,float ti){float t1=te*DIV;float t2=ti*DIV;float x=0.31271-t1*(t1<0.0 ? 0.1 : 0.05);float standardIlluminantY=2.87*x-3.0*x*x-0.27509507;float y=standardIlluminantY+t2*0.05;vec3 w1=vec3(0.949237,1.03542,1.08728);float X=x/y;float Z=(1.0-x-y)/y;float L=0.7328*X+0.4296-0.1624*Z;float M=-0.7036*X+1.6975+0.0061*Z;float S=0.0030*X+0.0136+0.9834*Z;vec3 w2=vec3(L,M,S);vec3 balance=vec3(w1.x/w2.x,w1.y/w2.y,w1.z/w2.z);vec3 lms=LIN_2_LMS_MAT*diffuse;lms*=balance;return LMS_2_LIN_MAT*lms;}vec3 RGB2HSV(vec3 color){vec3 c=min(color,1.0);vec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);vec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));vec4 q=mix(vec4(p.xyw,c.r),vec4(c.r,p.yzx),step(p.x,c.r));float d=q.x-min(q.w,q.y);return vec3(abs(q.z+(q.w-q.y)/(6.0*d+EPS)),d/(q.x+EPS),q.x);}vec3 HSV2RGB(vec3 color){vec3 c=min(color,1.0);vec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);vec3 p=abs(fract(c.xxx+K.xyz)*6.0-K.www);return c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);}vec3 contrast(vec3 color,float base){float b=(base*2.0-1.0)*0.5;return color+vec3(atan((color.r*2.0-1.0)*b),atan((color.g*2.0-1.0)*b),atan((color.b*2.0-1.0)*b));}vec3 grading(vec3 color){vec3 balanced=whiteBalance(color,temperature,tint);vec3 contrasted=contrast(balanced,contrastIntensity);vec3 hsvColor=RGB2HSV(contrasted);hsvColor.x=fract(hsvColor.x+hsv.x);hsvColor.y=clamp(hsvColor.y+hsv.y,0.0,1.0);hsvColor.z=clamp(hsvColor.z+hsv.z,0.0,1.0);vec3 rgbAdjusted=HSV2RGB(hsvColor);rgbAdjusted.r=clamp(rgbAdjusted.r+rgb.r,0.0,1.0);rgbAdjusted.g=clamp(rgbAdjusted.g+rgb.g,0.0,1.0);rgbAdjusted.b=clamp(rgbAdjusted.b+rgb.b,0.0,1.0);return rgbAdjusted;}void main(){vec4 diffuseColor=vec4(diffuse,opacity);\n#include <clipping_planes_fragment>\nvec3 outgoingLight=vec3(0.0);\n#include <logdepthbuf_fragment>\n#include <map_particle_fragment>\n#include <color_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\nvec3 originalColor=diffuseColor.rgb;vec3 gradedColor=grading(originalColor);vec3 finalColor=mix(originalColor,gradedColor,vColorEffectFactor);if(vSonarFactor>0.0){float sonarStrength=2.0;vec3 sonarColor=finalColor;float whiteAreaFactor=smoothstep(0.25,1.0,vSonarFactor);vec3 whiteColor=sonarColor;whiteColor.rgb+=whiteAreaFactor*sonarStrength*0.4;whiteColor=clamp(whiteColor,0.0,1.0);finalColor=mix(finalColor,whiteColor,vSonarFactor);}outgoingLight=finalColor;\n#include <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\ngl_FragColor.a*=vAlpha;}";
37419
- const main$1 = "in vec3 position;void main(){gl_Position=vec4(position,1.0);}";
37420
- const main = "precision highp float;precision highp int;uniform vec3 viewOrigin;uniform uint vertexCount;uniform highp usampler2D splatTexture;uniform highp usampler2D generalTexture;uniform highp usampler2D transformTexture;uniform uint transformTextureWidth;out vec4 fragColor;const uint TEXTURE_WIDTH=1024u;const float INV_255=1.0/255.0;const float INF=1.0/0.0;ivec2 getSplatCoord(uint indices){uint u=indices&0x3ffu;uint v=indices>>10;return ivec2(u,v);}vec3 getPosition(uvec4 packed){return vec4(unpackHalf2x16(packed.x),unpackHalf2x16(packed.y&0xffffu)).xyz;}mat3 generateRotationScaleMatrix(vec4 q,float s){float x=q.x;float y=q.y;float z=q.z;float w=q.w;float xx=x*x;float yy=y*y;float zz=z*z;float xy=x*y;float xz=x*z;float yz=y*z;float wx=w*x;float wy=w*y;float wz=w*z;return mat3(1.0-2.0*(yy+zz),2.0*(xy+wz),2.0*(xz-wy),2.0*(xy-wz),1.0-2.0*(xx+zz),2.0*(yz+wx),2.0*(xz+wy),2.0*(yz-wx),1.0-2.0*(xx+yy))*s;}void restoreTransform(in uint index,in uint width,out vec3 t,out float s,out vec4 q){uint u=index % width;uint v=uint(floor(float(index)/float(width)));uvec4 transform=texelFetch(transformTexture,ivec2(u,v),0);vec2 r=unpackHalf2x16(transform.x);vec2 g=unpackHalf2x16(transform.y);vec2 b=unpackHalf2x16(transform.z);vec2 a=unpackHalf2x16(transform.w);t=vec3(-r,g.x);s=g.y;q=vec4(b,a);}void unpack4to8(in uint packed,out uint high,out uint low){high=(packed>>4u)&0xFu;low=packed&0xFu;}float getDistance(uint indices){if(indices>=vertexCount){return INF;}ivec2 uv=getSplatCoord(indices);uvec4 packed=texelFetch(splatTexture,uv,0);uvec4 general=texelFetch(generalTexture,uv,0);vec3 tPosition=vec3(0.0);float tScale=1.0;vec4 tRotation=vec4(0.0);uint high,low;unpack4to8(general.a,high,low);restoreTransform(low,transformTextureWidth,tPosition,tScale,tRotation);mat3 mm=generateRotationScaleMatrix(tRotation,tScale);vec3 position=getPosition(packed);position=mm*position+tPosition;return length(position-viewOrigin);}void main(){uvec2 u=uvec2(gl_FragCoord.st);uint indices=(u.s+u.t*TEXTURE_WIDTH)*2u;float distance1=getDistance(indices);float distance2=getDistance(indices+1u);vec2 combine=vec2(distance1,distance2);uint packedUint=packHalf2x16(combine);uvec4 rgba=uvec4(packedUint&0xffu,(packedUint>>8u)&0xffu,(packedUint>>16u)&0xffu,(packedUint>>24u)&0xffu);fragColor=vec4(rgba)*INV_255;}";
37421
- const jsContent$1 = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (let q = 0; q < 256; q++) {\n _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n}\n_utf8len[254] = _utf8len[254] = 1;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inffast$1(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n };\n return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inflate_fast2(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\n }\n }\n Inflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const x = currentBufferFloatView[fIndex + 0];\n const y = currentBufferFloatView[fIndex + 1];\n const z = currentBufferFloatView[fIndex + 2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.collision);\n }\n};\n';
37425
+ 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}";
37426
+ 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}";
37427
+ const main$1 = "// #version 300 es\nin vec3 position;\nvoid main() {\n gl_Position = vec4(position, 1.0);\n}\n";
37428
+ 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";
37429
+ 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 } 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';
37422
37430
  const blob$1 = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent$1], { type: "text/javascript;charset=utf-8" });
37423
37431
  function WorkerWrapper$1(options) {
37424
37432
  let objURL;
@@ -37481,7 +37489,7 @@ const TavioWasm = /* @__PURE__ */ (() => {
37481
37489
  return instancePromise;
37482
37490
  };
37483
37491
  })();
37484
- 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';
37492
+ const jsContent = 'let wasm = null;\nglobalThis.allocateSharedArrayBuffer = (oldSharedArrayBuffer, newByteSize) => {\n const newSharedArrayBuffer = new SharedArrayBuffer(newByteSize);\n if (oldSharedArrayBuffer) {\n new Uint8Array(newSharedArrayBuffer).set(\n new Uint8Array(oldSharedArrayBuffer)\n );\n }\n return newSharedArrayBuffer;\n};\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';
37485
37493
  const blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
37486
37494
  function WorkerWrapper(options) {
37487
37495
  let objURL;
@@ -37591,12 +37599,184 @@ class TavioWasmWorkerClient {
37591
37599
  });
37592
37600
  }
37593
37601
  }
37602
+ function wasmBuildSourceProperty(event, sourceIndex, sourceVertexOffset) {
37603
+ let magicNumber = "";
37604
+ let majorVersion = 0;
37605
+ let minorVersion = 0;
37606
+ switch (event.format) {
37607
+ case "splat":
37608
+ magicNumber = "";
37609
+ majorVersion = 0;
37610
+ minorVersion = 0;
37611
+ break;
37612
+ case "ply":
37613
+ magicNumber = "ply";
37614
+ majorVersion = event.header.majorVersion;
37615
+ minorVersion = event.header.minorVersion;
37616
+ break;
37617
+ case "spz":
37618
+ magicNumber = event.header.magic;
37619
+ majorVersion = event.header.version;
37620
+ minorVersion = 0;
37621
+ break;
37622
+ case "sog":
37623
+ magicNumber = "";
37624
+ majorVersion = event.header.version;
37625
+ minorVersion = 0;
37626
+ break;
37627
+ }
37628
+ return {
37629
+ ready: false,
37630
+ index: sourceIndex,
37631
+ type: event.format,
37632
+ vertexCount: event.totalPointCount,
37633
+ vertexOffset: sourceVertexOffset,
37634
+ featureBits: 0,
37635
+ containmentRadius: { per100: null },
37636
+ magicNumber,
37637
+ majorVersion,
37638
+ minorVersion,
37639
+ transform: {
37640
+ translation: new Vector3(0, 0, 0),
37641
+ rotation: new Euler(0, 0, 0),
37642
+ scale: 1
37643
+ },
37644
+ billboard: false
37645
+ };
37646
+ }
37647
+ function wasmBuildSharedData(event, prototype, gaussianCount, generalDataSize, orderDataSize) {
37648
+ const sharedData = Object.create(prototype);
37649
+ sharedData.sharedGaussianData = event.sharedGaussianBuffer;
37650
+ sharedData.sharedSphericalHarmonicsData = event.sharedShBuffer;
37651
+ sharedData.sharedGaussianIndexData = new SharedArrayBuffer(gaussianCount * 4);
37652
+ sharedData.sharedGaussianOrderData = new SharedArrayBuffer(orderDataSize);
37653
+ sharedData.sharedGaussianGeneralData = new SharedArrayBuffer(generalDataSize);
37654
+ return sharedData;
37655
+ }
37656
+ function wasmBuildWorkerUpdateMessage(event, uniforms, sourceIndex, usingSharedArrayBuffer) {
37657
+ const message = {
37658
+ updateTexture: true
37659
+ };
37660
+ if (sourceIndex > 0) {
37661
+ message.previousScale = {
37662
+ min: [
37663
+ uniforms.scaleAlphaMin.value.x,
37664
+ uniforms.scaleAlphaMin.value.y,
37665
+ uniforms.scaleAlphaMin.value.z
37666
+ ],
37667
+ max: [
37668
+ uniforms.scaleAlphaMax.value.x,
37669
+ uniforms.scaleAlphaMax.value.y,
37670
+ uniforms.scaleAlphaMax.value.z
37671
+ ]
37672
+ };
37673
+ message.previousAlpha = {
37674
+ min: [uniforms.scaleAlphaMin.value.w],
37675
+ max: [uniforms.scaleAlphaMax.value.w]
37676
+ };
37677
+ message.scale = {
37678
+ min: event.scaleMinValues,
37679
+ max: event.scaleMaxValues
37680
+ };
37681
+ message.alpha = {
37682
+ min: [event.alphaMinValue],
37683
+ max: [event.alphaMaxValue]
37684
+ };
37685
+ }
37686
+ if (usingSharedArrayBuffer) {
37687
+ return {
37688
+ message: {
37689
+ buffer: new ArrayBuffer(0),
37690
+ // workaround for mergeBuffer
37691
+ shBuffer: new ArrayBuffer(0),
37692
+ // workaround for mergeBuffer
37693
+ ...message
37694
+ },
37695
+ transfer: []
37696
+ };
37697
+ } else {
37698
+ const transfer = [event.gaussianBuffer.buffer];
37699
+ if (event.shBuffer != null) {
37700
+ message.shBuffer = event.shBuffer.buffer;
37701
+ transfer.push(event.shBuffer.buffer);
37702
+ }
37703
+ return {
37704
+ message: {
37705
+ buffer: event.gaussianBuffer.buffer,
37706
+ ...message
37707
+ },
37708
+ transfer
37709
+ };
37710
+ }
37711
+ }
37712
+ function wasmUpdateUniforms(event, uniforms, sourceIndex) {
37713
+ if (sourceIndex > 0) {
37714
+ uniforms.scaleAlphaMin.value.x = Math.min(
37715
+ event.scaleMinValues[0],
37716
+ uniforms.scaleAlphaMin.value.x
37717
+ );
37718
+ uniforms.scaleAlphaMin.value.y = Math.min(
37719
+ event.scaleMinValues[1],
37720
+ uniforms.scaleAlphaMin.value.y
37721
+ );
37722
+ uniforms.scaleAlphaMin.value.z = Math.min(
37723
+ event.scaleMinValues[2],
37724
+ uniforms.scaleAlphaMin.value.z
37725
+ );
37726
+ uniforms.scaleAlphaMin.value.w = Math.min(
37727
+ event.alphaMinValue,
37728
+ uniforms.scaleAlphaMin.value.w
37729
+ );
37730
+ uniforms.scaleAlphaMax.value.x = Math.max(
37731
+ event.scaleMaxValues[0],
37732
+ uniforms.scaleAlphaMax.value.x
37733
+ );
37734
+ uniforms.scaleAlphaMax.value.y = Math.max(
37735
+ event.scaleMaxValues[1],
37736
+ uniforms.scaleAlphaMax.value.y
37737
+ );
37738
+ uniforms.scaleAlphaMax.value.z = Math.max(
37739
+ event.scaleMaxValues[2],
37740
+ uniforms.scaleAlphaMax.value.z
37741
+ );
37742
+ uniforms.scaleAlphaMax.value.w = Math.max(
37743
+ event.alphaMaxValue,
37744
+ uniforms.scaleAlphaMax.value.w
37745
+ );
37746
+ } else {
37747
+ uniforms.scaleAlphaMin.value.x = event.scaleMinValues[0];
37748
+ uniforms.scaleAlphaMin.value.y = event.scaleMinValues[1];
37749
+ uniforms.scaleAlphaMin.value.z = event.scaleMinValues[2];
37750
+ uniforms.scaleAlphaMin.value.w = event.alphaMinValue;
37751
+ uniforms.scaleAlphaMax.value.x = event.scaleMaxValues[0];
37752
+ uniforms.scaleAlphaMax.value.y = event.scaleMaxValues[1];
37753
+ uniforms.scaleAlphaMax.value.z = event.scaleMaxValues[2];
37754
+ uniforms.scaleAlphaMax.value.w = event.alphaMaxValue;
37755
+ }
37756
+ }
37757
+ async function requestWorkerBuffer(worker) {
37758
+ return new Promise((resolve) => {
37759
+ const messageChannel = new MessageChannel();
37760
+ messageChannel.port1.onmessage = (evt) => resolve(evt.data);
37761
+ worker.postMessage({ requestBuffer: true }, [messageChannel.port2]);
37762
+ });
37763
+ }
37764
+ function downloadAsFile(bytes, filename) {
37765
+ const blob2 = new Blob([bytes], { type: "application/octet-stream" });
37766
+ const url = URL.createObjectURL(blob2);
37767
+ const a = document.createElement("a");
37768
+ a.href = url;
37769
+ a.download = filename;
37770
+ a.click();
37771
+ URL.revokeObjectURL(url);
37772
+ }
37594
37773
  const SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;
37595
37774
  const TEXTURE_WIDTH_BASE = 1024;
37596
37775
  const DEPTH_RENDER_TEXTURE_WIDTH_BASE = 1024;
37597
37776
  const ROW_LENGTH_SPLAT = 3 * 4 + 3 * 4 + 4 + 4;
37598
37777
  const ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;
37599
37778
  const UPDATE_DEPTH_THRESHOLD = 5e-3;
37779
+ const POINT_BASE_RADIUS = 0.8;
37600
37780
  const FEATURE_BACKGROUND_EXISTS = "background-sphere-exists";
37601
37781
  const FEATURE_BITS = [FEATURE_BACKGROUND_EXISTS];
37602
37782
  const CHUNK_INDEX_BACKGROUND = 0;
@@ -37616,6 +37796,9 @@ const _getDepthRenderTextureWidth = (count) => {
37616
37796
  const height = Math.ceil(Math.ceil(count / 2) / width);
37617
37797
  return { width, height };
37618
37798
  };
37799
+ const dummyObject3D = new Object3D();
37800
+ const dummyVector3 = new Vector3();
37801
+ const dummyQuaternion = new Quaternion();
37619
37802
  class TavioMesh extends EventEmitter {
37620
37803
  perspectiveCamera;
37621
37804
  // カメラ
@@ -37730,6 +37913,8 @@ class TavioMesh extends EventEmitter {
37730
37913
  // wasmソート用ワーカークライアント
37731
37914
  isSorting;
37732
37915
  // ソート処理中かどうかのフラグ
37916
+ hasBillboard;
37917
+ // ビルボード処理するインスタンスを内包しているかどうか
37733
37918
  lastViewProjectionMatrix;
37734
37919
  // 直近のビュープロジェクション行列を保持
37735
37920
  depthRenderTarget;
@@ -37799,7 +37984,7 @@ class TavioMesh extends EventEmitter {
37799
37984
  * @param material - メッシュの生成に使うマテリアルは上の層から指定されたものを使う
37800
37985
  * @param pickingMaterial - メッシュの生成に使うマテリアルは上の層から指定されたものを使う
37801
37986
  */
37802
- constructor(index, camera, material, pinckingMaterial, viewerOption) {
37987
+ constructor(index, camera, material, pickingMaterial, viewerOption) {
37803
37988
  super();
37804
37989
  this.usingSharedArrayBuffer = viewerOption.usingSharedArrayBuffer ?? false;
37805
37990
  this.meshIndex = index;
@@ -37815,11 +38000,12 @@ class TavioMesh extends EventEmitter {
37815
38000
  this.initializedColorTexture = false;
37816
38001
  this.perspectiveCamera = camera;
37817
38002
  this.gaussianMaterial = material;
37818
- this.gaussianPickingMaterial = pinckingMaterial;
38003
+ this.gaussianPickingMaterial = pickingMaterial;
37819
38004
  this.maxDistance = 0;
37820
38005
  this.mainProperties = null;
37821
38006
  this.useWasmSort = false;
37822
38007
  this.isSorting = false;
38008
+ this.hasBillboard = false;
37823
38009
  this.lastViewProjectionMatrix = [];
37824
38010
  this.lastViewProjectionMatrix[2] = 0;
37825
38011
  this.lastViewProjectionMatrix[6] = 0;
@@ -37867,6 +38053,7 @@ class TavioMesh extends EventEmitter {
37867
38053
  * @param option - ロード・パース関連のオプション
37868
38054
  */
37869
38055
  async loadTavio(url, option) {
38056
+ this.setupFlags();
37870
38057
  this.setupTavioWorker();
37871
38058
  this.setUsingSphericalHarmonics(option?.useSphericalHarmonics ?? true);
37872
38059
  this.setUsingWasmSort(false);
@@ -37905,7 +38092,8 @@ class TavioMesh extends EventEmitter {
37905
38092
  translation: new Vector3(0, 0, 0),
37906
38093
  rotation: new Euler(0, 0, 0),
37907
38094
  scale: 1
37908
- }
38095
+ },
38096
+ billboard: false
37909
38097
  });
37910
38098
  const getPropertyInfo = async (start, data) => {
37911
38099
  const view = new DataView(data.buffer);
@@ -38435,6 +38623,7 @@ class TavioMesh extends EventEmitter {
38435
38623
  * @param option - ロード・パース関連のオプション
38436
38624
  */
38437
38625
  async loadPly(url, option) {
38626
+ this.setupFlags();
38438
38627
  this.setupTavioWorker();
38439
38628
  this.setUsingSphericalHarmonics(option?.useSphericalHarmonics ?? true);
38440
38629
  this.setUsingWasmSort(false);
@@ -38465,7 +38654,8 @@ class TavioMesh extends EventEmitter {
38465
38654
  translation: new Vector3(0, 0, 0),
38466
38655
  rotation: new Euler(0, 0, 0),
38467
38656
  scale: 1
38468
- }
38657
+ },
38658
+ billboard: false
38469
38659
  });
38470
38660
  const onFirstRead = (data) => {
38471
38661
  header = PlyDecoder.decodeHeader(data.buffer);
@@ -38648,6 +38838,7 @@ class TavioMesh extends EventEmitter {
38648
38838
  * @param url - 読み込む .splat ファイル
38649
38839
  */
38650
38840
  async loadSplat(url) {
38841
+ this.setupFlags();
38651
38842
  this.setupTavioWorker();
38652
38843
  this.setUsingSphericalHarmonics(false);
38653
38844
  this.setUsingWasmSort(false);
@@ -38678,7 +38869,8 @@ class TavioMesh extends EventEmitter {
38678
38869
  translation: new Vector3(0, 0, 0),
38679
38870
  rotation: new Euler(0, 0, 0),
38680
38871
  scale: 1
38681
- }
38872
+ },
38873
+ billboard: false
38682
38874
  });
38683
38875
  const loader = new StreamLoader();
38684
38876
  loader.on("getcontentbytelength", (byte) => {
@@ -38949,6 +39141,208 @@ class TavioMesh extends EventEmitter {
38949
39141
  await loader.load(url);
38950
39142
  });
38951
39143
  }
39144
+ /**
39145
+ * 画像形式のリソースをロードする
39146
+ * @param url - 読み込む画像ファイル
39147
+ */
39148
+ async loadImage(url) {
39149
+ this.setupFlags();
39150
+ this.setupTavioWorker();
39151
+ this.setUsingSphericalHarmonics(false);
39152
+ this.setUsingWasmSort(false);
39153
+ return new Promise(async (resolve, reject) => {
39154
+ let currentOffset = 0;
39155
+ let countOfPoints = 0;
39156
+ const index = this.sourceProperty.length;
39157
+ const isFirst = index === 0;
39158
+ if (isFirst !== true) {
39159
+ this.sourceProperty.forEach((prop) => {
39160
+ currentOffset += prop.vertexCount;
39161
+ });
39162
+ }
39163
+ this.sourceProperty.push({
39164
+ ready: false,
39165
+ index,
39166
+ type: "image",
39167
+ vertexCount: 0,
39168
+ vertexOffset: currentOffset,
39169
+ featureBits: null,
39170
+ containmentRadius: null,
39171
+ magicNumber: "",
39172
+ majorVersion: 0,
39173
+ minorVersion: 0,
39174
+ transform: {
39175
+ translation: new Vector3(0, 0, 0),
39176
+ rotation: new Euler(0, 0, 0),
39177
+ scale: 1
39178
+ },
39179
+ billboard: false
39180
+ });
39181
+ const response = await fetch(url);
39182
+ const blob2 = await response.blob();
39183
+ const byte = blob2.size;
39184
+ this.emit("getcontentbytelength", { byte });
39185
+ const img = new Image();
39186
+ img.addEventListener("load", () => {
39187
+ const splatSource = this.convertImageSource(img);
39188
+ countOfPoints = splatSource.count;
39189
+ if (countOfPoints === 0) {
39190
+ throw new Error("[TavioMesh]: Invalid resource");
39191
+ }
39192
+ this.gaussianCount = currentOffset + countOfPoints;
39193
+ this.setupGeometry(this.gaussianCount);
39194
+ this.sourceProperty[index].vertexCount = countOfPoints;
39195
+ const isEncodeEnabled = false;
39196
+ if (this.usingSharedArrayBuffer === true) {
39197
+ this.sharedData = this.allocateSharedData(
39198
+ index,
39199
+ currentOffset,
39200
+ 0,
39201
+ countOfPoints,
39202
+ isEncodeEnabled
39203
+ );
39204
+ this.gaussianData = this.sharedData.gaussianData;
39205
+ this.gaussianIndexData = this.sharedData.gaussianIndexData;
39206
+ this.gaussianOrderData = this.sharedData.gaussianOrderData;
39207
+ this.gaussianGeneralData = this.sharedData.gaussianGeneralData;
39208
+ this.sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
39209
+ this.currentSelectionCount = 0;
39210
+ this.worker.postMessage({
39211
+ buffer: this.gaussianData.buffer,
39212
+ indexBuffer: this.gaussianIndexData.buffer,
39213
+ orderBuffer: this.gaussianOrderData.buffer,
39214
+ shBuffer: this.sphericalHarmonicsData.buffer,
39215
+ generalBuffer: this.gaussianGeneralData.buffer,
39216
+ vertexCount: this.gaussianCount,
39217
+ usingSharedArrayBuffer: this.usingSharedArrayBuffer,
39218
+ offset: currentOffset
39219
+ });
39220
+ } else {
39221
+ const textureWidth = TEXTURE_WIDTH_BASE;
39222
+ const textureHeight = Math.ceil(this.gaussianCount / textureWidth);
39223
+ const gaussianDataSize = this.gaussianCount * ROW_LENGTH_TAVIO;
39224
+ const generalDataSize = textureWidth * textureHeight * 4;
39225
+ const shDataSize = this.gaussianCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4;
39226
+ this.gaussianData = null;
39227
+ this.sphericalHarmonicsData = null;
39228
+ if (currentOffset > 0) {
39229
+ const previousGeneralData = this.gaussianGeneralData;
39230
+ this.gaussianGeneralData = new Uint8Array(generalDataSize);
39231
+ this.gaussianGeneralData.set(previousGeneralData);
39232
+ } else {
39233
+ this.gaussianGeneralData = new Uint8Array(generalDataSize);
39234
+ }
39235
+ this.gaussianIndexData = null;
39236
+ const { width, height } = _getDepthRenderTextureWidth(this.gaussianCount);
39237
+ this.gaussianOrderData = new Uint8Array(width * height * 4);
39238
+ this.currentSelectionCount = 0;
39239
+ this.worker.postMessage({
39240
+ vertexCount: this.gaussianCount,
39241
+ usingSharedArrayBuffer: this.usingSharedArrayBuffer,
39242
+ offset: currentOffset,
39243
+ gaussianDataSize,
39244
+ generalDataSize,
39245
+ shDataSize
39246
+ });
39247
+ }
39248
+ this.setupTransformData(index, currentOffset, this.gaussianCount);
39249
+ this.emit("convert", { count: this.gaussianCount });
39250
+ this.setupPoints(splatSource.position32);
39251
+ this.setColorIntoPoints(splatSource.color8);
39252
+ if (isFirst === true) {
39253
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = splatSource.min.scale.x;
39254
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = splatSource.min.scale.y;
39255
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = splatSource.min.scale.z;
39256
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = splatSource.min.alpha;
39257
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = splatSource.max.scale.x;
39258
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = splatSource.max.scale.y;
39259
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = splatSource.max.scale.z;
39260
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = splatSource.max.alpha;
39261
+ this.worker.postMessage({
39262
+ updateTexture: true,
39263
+ buffer: splatSource.converted.buffer
39264
+ });
39265
+ } else {
39266
+ const preMinX = this.gaussianMaterial.uniforms.scaleAlphaMin.value.x;
39267
+ const preMinY = this.gaussianMaterial.uniforms.scaleAlphaMin.value.y;
39268
+ const preMinZ = this.gaussianMaterial.uniforms.scaleAlphaMin.value.z;
39269
+ const preMaxX = this.gaussianMaterial.uniforms.scaleAlphaMax.value.x;
39270
+ const preMaxY = this.gaussianMaterial.uniforms.scaleAlphaMax.value.y;
39271
+ const preMaxZ = this.gaussianMaterial.uniforms.scaleAlphaMax.value.z;
39272
+ const previousScale = {
39273
+ min: [
39274
+ preMinX,
39275
+ preMinY,
39276
+ preMinZ
39277
+ ],
39278
+ max: [
39279
+ preMaxX,
39280
+ preMaxY,
39281
+ preMaxZ
39282
+ ]
39283
+ };
39284
+ const currentScale = {
39285
+ min: [
39286
+ splatSource.min.scale.x,
39287
+ splatSource.min.scale.y,
39288
+ splatSource.min.scale.z
39289
+ ],
39290
+ max: [
39291
+ splatSource.max.scale.x,
39292
+ splatSource.max.scale.y,
39293
+ splatSource.max.scale.z
39294
+ ]
39295
+ };
39296
+ const curMinX = Math.min(splatSource.min.scale.x, preMinX);
39297
+ const curMinY = Math.min(splatSource.min.scale.y, preMinY);
39298
+ const curMinZ = Math.min(splatSource.min.scale.z, preMinZ);
39299
+ const curMaxX = Math.max(splatSource.max.scale.x, preMaxX);
39300
+ const curMaxY = Math.max(splatSource.max.scale.y, preMaxY);
39301
+ const curMaxZ = Math.max(splatSource.max.scale.z, preMaxZ);
39302
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = curMinX;
39303
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = curMinY;
39304
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = curMinZ;
39305
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = curMaxX;
39306
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = curMaxY;
39307
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = curMaxZ;
39308
+ const preMin = this.gaussianMaterial.uniforms.scaleAlphaMin.value.w;
39309
+ const preMax = this.gaussianMaterial.uniforms.scaleAlphaMax.value.w;
39310
+ const previousAlpha = {
39311
+ min: [preMin],
39312
+ max: [preMax]
39313
+ };
39314
+ const currentAlpha = {
39315
+ min: [splatSource.min.alpha],
39316
+ max: [splatSource.max.alpha]
39317
+ };
39318
+ const curMin = Math.min(splatSource.min.alpha, preMin);
39319
+ const curMax = Math.max(splatSource.max.alpha, preMax);
39320
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = curMin;
39321
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = curMax;
39322
+ this.worker.postMessage({
39323
+ updateTexture: true,
39324
+ buffer: splatSource.converted.buffer,
39325
+ scale: currentScale,
39326
+ // 既存のデータとの統合時のみ付与されるプロパティ
39327
+ alpha: currentAlpha,
39328
+ // 既存のデータとの統合時のみ付与されるプロパティ
39329
+ previousScale,
39330
+ // 既存のデータとの統合時のみ付与されるプロパティ
39331
+ previousAlpha
39332
+ // 既存のデータとの統合時のみ付与されるプロパティ
39333
+ });
39334
+ }
39335
+ this.emit("load", { length: byte });
39336
+ }, false);
39337
+ const listener = () => {
39338
+ this.sourceProperty[index].ready = true;
39339
+ resolve();
39340
+ };
39341
+ this.once("finallyupdate", listener);
39342
+ const objectURL = URL.createObjectURL(blob2);
39343
+ img.src = objectURL;
39344
+ });
39345
+ }
38952
39346
  /**
38953
39347
  * tavio 形式のリソースをロードする
38954
39348
  * @param url - 読み込む .tavio ファイル
@@ -38960,23 +39354,27 @@ class TavioMesh extends EventEmitter {
38960
39354
  * @param options.isEncodeEnabled - エンコードを有効にする. 有効にするとエンコード時に必要なデータを読み込む
38961
39355
  */
38962
39356
  async loadTavioWasm(url, options) {
39357
+ const decodeMode = options?.decodeMode ?? "sync";
39358
+ const useSphericalHarmonics = options?.useSphericalHarmonics ?? true;
39359
+ const maxDecodePoints = options?.maxDecodePoints ?? Number.POSITIVE_INFINITY;
38963
39360
  const threadCount = options?.decodeMode === "parallel" ? options.maxThreads ?? navigator.hardwareConcurrency : 1;
38964
39361
  const tavioWasmClient = await TavioWasmWorkerClient.create({
38965
39362
  useSharedArrayBuffer: this.usingSharedArrayBuffer,
38966
39363
  threadCount
38967
39364
  });
39365
+ this.setupFlags();
38968
39366
  this.setupTavioWorker();
38969
- this.setUsingSphericalHarmonics(options?.useSphericalHarmonics ?? true);
39367
+ this.setUsingSphericalHarmonics(useSphericalHarmonics);
38970
39368
  this.setUsingWasmSort(true);
38971
- this.gaussianMaterial.defines = {
38972
- // この定数が定義されている場合 sigmoid の計算をシェーダ内で行う
38973
- // ただし、そのためにはテクスチャ(position.w の位置)に変換前の生のアルファを含める必要がある
38974
- FORMAT_TAVIO: ""
38975
- };
38976
39369
  this.gaussianMaterial.needsUpdate = true;
38977
39370
  let contentLength = 0;
38978
39371
  let header = null;
38979
39372
  let shBuffer = null;
39373
+ const sourceIndex = this.sourceProperty.length;
39374
+ const sourceVertexOffset = this.sourceProperty.reduce(
39375
+ (acc, prop) => acc + prop.vertexCount,
39376
+ 0
39377
+ );
38980
39378
  tavioWasmClient.registerEventHandler((e) => {
38981
39379
  switch (e.type) {
38982
39380
  case "decode:fileSize":
@@ -38985,31 +39383,44 @@ class TavioMesh extends EventEmitter {
38985
39383
  break;
38986
39384
  case "decode:header":
38987
39385
  {
38988
- header = e.data;
39386
+ header = e.header;
38989
39387
  let totalPointCount;
38990
- if (options.maxDecodePoints) {
38991
- totalPointCount = Math.min(options.maxDecodePoints, e.data.totalPointCount);
38992
- } else {
38993
- totalPointCount = e.data.totalPointCount;
38994
- }
38995
- const chunkCount = e.data.chunkInfo.length;
38996
- const version = header.version.split(".");
38997
- this.majorVersionNumber = parseInt(version[0]);
38998
- this.minorVersionNumber = parseInt(version[1]);
38999
- this.featureBits = this._getFeatureBits(e.data.featureFlags);
39000
- this.containmentRadius.per50 = e.data.radius50percent;
39001
- this.containmentRadius.per70 = e.data.radius70percent;
39002
- this.containmentRadius.per90 = e.data.radius90percent;
39003
- this.gaussianCountInChunk = e.data.chunkInfo.map(
39388
+ totalPointCount = Math.min(maxDecodePoints, header.totalPointCount);
39389
+ const chunkCount = header.chunkInfo.length;
39390
+ this.majorVersionNumber = parseInt(header.version[0]);
39391
+ this.minorVersionNumber = parseInt(header.version[1]);
39392
+ this.featureBits = this._getFeatureBits(header.featureFlags);
39393
+ this.containmentRadius.per50 = header.radius50percent;
39394
+ this.containmentRadius.per70 = header.radius70percent;
39395
+ this.containmentRadius.per90 = header.radius90percent;
39396
+ this.gaussianCountInChunk = header.chunkInfo.map(
39004
39397
  (c) => c.pointCount
39005
39398
  );
39006
- this.setupGeometry(totalPointCount);
39007
- this.gaussianCount = totalPointCount;
39399
+ this.gaussianCount = sourceVertexOffset + totalPointCount;
39400
+ this.setupGeometry(this.gaussianCount);
39401
+ this.sourceProperty.push({
39402
+ ready: false,
39403
+ index: sourceIndex,
39404
+ type: "tavio",
39405
+ vertexCount: totalPointCount,
39406
+ vertexOffset: sourceVertexOffset,
39407
+ featureBits: this.featureBits,
39408
+ containmentRadius: this.containmentRadius,
39409
+ magicNumber: "TC",
39410
+ majorVersion: this.majorVersionNumber,
39411
+ minorVersion: this.minorVersionNumber,
39412
+ transform: {
39413
+ translation: new Vector3(0, 0, 0),
39414
+ rotation: new Euler(0, 0, 0),
39415
+ scale: 1
39416
+ },
39417
+ billboard: false
39418
+ });
39008
39419
  const textureWidth = TEXTURE_WIDTH_BASE;
39009
39420
  const textureHeight = Math.ceil(totalPointCount / textureWidth);
39010
- const gaussianDataSize = e.data.totalPointCount * ROW_LENGTH_TAVIO;
39421
+ const gaussianDataSize = header.totalPointCount * ROW_LENGTH_TAVIO;
39011
39422
  const generalDataSize = textureWidth * textureHeight * 4;
39012
- this.currentVertexCount = 0;
39423
+ this.currentVertexCount = sourceVertexOffset;
39013
39424
  this.currentSelectionCount = 0;
39014
39425
  if (this.usingSharedArrayBuffer) {
39015
39426
  this.sharedData = new SharedData(
@@ -39031,7 +39442,8 @@ class TavioMesh extends EventEmitter {
39031
39442
  shBuffer: this.sphericalHarmonicsData.buffer,
39032
39443
  generalBuffer: this.gaussianGeneralData.buffer,
39033
39444
  vertexCount: totalPointCount,
39034
- usingSharedArrayBuffer: this.usingSharedArrayBuffer
39445
+ usingSharedArrayBuffer: this.usingSharedArrayBuffer,
39446
+ offset: sourceVertexOffset
39035
39447
  });
39036
39448
  } else {
39037
39449
  const { width, height } = _getDepthRenderTextureWidth(totalPointCount);
@@ -39041,18 +39453,24 @@ class TavioMesh extends EventEmitter {
39041
39453
  this.worker.postMessage({
39042
39454
  vertexCount: totalPointCount,
39043
39455
  usingSharedArrayBuffer: this.usingSharedArrayBuffer,
39456
+ offset: sourceVertexOffset,
39044
39457
  gaussianDataSize,
39045
39458
  generalDataSize,
39046
39459
  shDataSize: totalPointCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4
39047
39460
  });
39048
39461
  }
39462
+ this.setupTransformData(
39463
+ sourceIndex,
39464
+ sourceVertexOffset,
39465
+ this.gaussianCount
39466
+ );
39049
39467
  }
39050
39468
  break;
39051
39469
  case "decode:point":
39052
- this.setupPoints(new Float32Array(e.data));
39470
+ this.setupPoints(e.data);
39053
39471
  break;
39054
39472
  case "decode:color":
39055
- this.setColorIntoPoints(new Uint8ClampedArray(e.data));
39473
+ this.setColorIntoPoints(e.data);
39056
39474
  break;
39057
39475
  case "decode:chunkMain":
39058
39476
  {
@@ -39060,12 +39478,11 @@ class TavioMesh extends EventEmitter {
39060
39478
  uniforms.scaleAlphaMin.value.x = e.scaleMinValues[0];
39061
39479
  uniforms.scaleAlphaMin.value.y = e.scaleMinValues[1];
39062
39480
  uniforms.scaleAlphaMin.value.z = e.scaleMinValues[2];
39063
- uniforms.scaleAlphaMin.value.w = e.alphaMinValues[0];
39481
+ uniforms.scaleAlphaMin.value.w = e.alphaMinValue;
39064
39482
  uniforms.scaleAlphaMax.value.x = e.scaleMaxValues[0];
39065
39483
  uniforms.scaleAlphaMax.value.y = e.scaleMaxValues[1];
39066
39484
  uniforms.scaleAlphaMax.value.z = e.scaleMaxValues[2];
39067
- uniforms.scaleAlphaMax.value.w = e.alphaMaxValues[0];
39068
- this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = e.alphaMaxValues[0];
39485
+ uniforms.scaleAlphaMax.value.w = e.alphaMaxValue;
39069
39486
  this.currentVertexCount += e.pointCount;
39070
39487
  this.emit("convert");
39071
39488
  if (shBuffer != null) {
@@ -39103,41 +39520,634 @@ class TavioMesh extends EventEmitter {
39103
39520
  }
39104
39521
  });
39105
39522
  const convertedUrl = new URL(url, location.origin).toString();
39523
+ const waitForFinally = new Promise((resolve) => {
39524
+ this.once("sort", () => {
39525
+ this.sourceProperty[sourceIndex].ready = true;
39526
+ if (!this.sorted) {
39527
+ this.sorted = true;
39528
+ this.emit("finallyupdate", this.gaussianCount);
39529
+ }
39530
+ resolve();
39531
+ });
39532
+ });
39106
39533
  await tavioWasmClient.api.decodeTavio(convertedUrl, {
39107
- decodeMode: options.decodeMode,
39108
- maxDecodePoints: options.maxDecodePoints,
39109
- useSphericalHarmonics: options.useSphericalHarmonics ?? true
39534
+ decodeMode,
39535
+ maxDecodePoints,
39536
+ useSphericalHarmonics
39110
39537
  });
39111
39538
  this.emit("load", { length: contentLength });
39112
39539
  tavioWasmClient.dispose();
39540
+ await waitForFinally;
39113
39541
  }
39114
39542
  /**
39115
- * ply 形式のリソースをロードする
39116
- * @param url - 読み込む .ply ファイル
39117
- * @param option - ロード・パース関連のオプション
39118
- * @param options.decodeMode - デコードモード. "sync", "concurrent", "parallel" を指定
39119
- * @param options.maxThreads - decodeMode が "parallel" のときに使用されるスレッド数の上限
39120
- * @param options.maxDecodePoints - 最大デコード点数. これを超える点は読み込まれない
39543
+ * 様々な形式のリソースをロードする
39544
+ * @param url - 読み込むファイル
39545
+ * @param format - ファイル形式
39546
+ * @param options - ロード・パース関連のオプション
39121
39547
  * @param options.useSphericalHarmonics - 球面調和関数を使用
39122
39548
  */
39123
- async loadPlyWasm(url, options) {
39124
- throw new Error("実装されていません");
39125
- }
39126
- /**
39127
- * tavio 形式のリソースをセーブする
39128
- * @param filename - 保存する .tavio ファイル名
39129
- * @param option - セーブ関連のオプション
39130
- * @param option.version - バージョン番号
39131
- * @param option.useSphericalHarmonics - 球面調和関数を使用する
39132
- * @param option.useGeneralData - 編集データを反映する
39133
- * @param option.featureFlags - tavio形式のフィーチャーフラグ
39134
- */
39135
- async saveTavioWasm(filename, options) {
39136
- throw new Error("実装されていません");
39137
- }
39138
- /**
39139
- * ==========================================================================
39140
- * getter / setter
39549
+ async loadMeshWasm(url, format, options) {
39550
+ const useSphericalHarmonics = options?.useSphericalHarmonics ?? true;
39551
+ const tavioWasmClient = await TavioWasmWorkerClient.create({
39552
+ useSharedArrayBuffer: this.usingSharedArrayBuffer
39553
+ });
39554
+ this.setupTavioWorker();
39555
+ this.setUsingSphericalHarmonics(useSphericalHarmonics);
39556
+ this.setUsingWasmSort(true);
39557
+ this.gaussianMaterial.needsUpdate = true;
39558
+ let contentLength = 0;
39559
+ const sourceIndex = this.sourceProperty.length;
39560
+ const sourceVertexOffset = this.sourceProperty.reduce((acc, prop) => {
39561
+ return acc + prop.vertexCount;
39562
+ }, 0);
39563
+ tavioWasmClient.registerEventHandler((e) => {
39564
+ switch (e.type) {
39565
+ case "decode:fileSize":
39566
+ contentLength = e.fileSize;
39567
+ this.emit("getcontentbytelength", { byte: contentLength });
39568
+ break;
39569
+ case "decode:header":
39570
+ {
39571
+ this.gaussianCount = sourceVertexOffset + e.totalPointCount;
39572
+ this.setupGeometry(this.gaussianCount);
39573
+ this.currentVertexCount = sourceVertexOffset;
39574
+ this.currentSelectionCount = 0;
39575
+ const sourceProperty = wasmBuildSourceProperty(
39576
+ e,
39577
+ sourceIndex,
39578
+ sourceVertexOffset
39579
+ );
39580
+ this.sourceProperty.push(sourceProperty);
39581
+ const generalDataSize = (() => {
39582
+ const textureWidth = TEXTURE_WIDTH_BASE;
39583
+ const textureHeight = Math.ceil(this.gaussianCount / textureWidth);
39584
+ return textureWidth * textureHeight * 4;
39585
+ })();
39586
+ const orderDataSize = (() => {
39587
+ const { width, height } = _getDepthRenderTextureWidth(
39588
+ this.gaussianCount
39589
+ );
39590
+ return width * height * 4;
39591
+ })();
39592
+ if (this.usingSharedArrayBuffer) {
39593
+ const sharedData = wasmBuildSharedData(
39594
+ e,
39595
+ SharedData.prototype,
39596
+ this.gaussianCount,
39597
+ generalDataSize,
39598
+ orderDataSize
39599
+ );
39600
+ this.sharedData = sharedData;
39601
+ this.gaussianData = this.sharedData.gaussianData;
39602
+ this.gaussianIndexData = this.sharedData.gaussianIndexData;
39603
+ this.gaussianOrderData = this.sharedData.gaussianOrderData;
39604
+ this.gaussianGeneralData = this.sharedData.gaussianGeneralData;
39605
+ this.sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
39606
+ this.worker.postMessage({
39607
+ buffer: sharedData.gaussianData.buffer,
39608
+ indexBuffer: sharedData.gaussianIndexData.buffer,
39609
+ orderBuffer: sharedData.gaussianOrderData.buffer,
39610
+ shBuffer: sharedData.sphericalHarmonicsData.buffer,
39611
+ generalBuffer: sharedData.gaussianGeneralData.buffer,
39612
+ vertexCount: this.gaussianCount,
39613
+ usingSharedArrayBuffer: true,
39614
+ offset: sourceVertexOffset
39615
+ });
39616
+ } else {
39617
+ this.gaussianIndexData = new Uint32Array(this.gaussianCount);
39618
+ this.gaussianOrderData = new Uint8Array(orderDataSize);
39619
+ this.gaussianGeneralData = new Uint8Array(generalDataSize);
39620
+ this.worker.postMessage({
39621
+ vertexCount: this.gaussianCount,
39622
+ usingSharedArrayBuffer: false,
39623
+ offset: sourceVertexOffset,
39624
+ gaussianDataSize: this.gaussianCount * ROW_LENGTH_TAVIO,
39625
+ generalDataSize,
39626
+ shDataSize: this.gaussianCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4
39627
+ });
39628
+ }
39629
+ this.setupTransformData(
39630
+ sourceIndex,
39631
+ sourceVertexOffset,
39632
+ this.gaussianCount
39633
+ );
39634
+ }
39635
+ break;
39636
+ case "decode:body":
39637
+ {
39638
+ this.setupPoints(e.point);
39639
+ this.setColorIntoPoints(e.color);
39640
+ this.currentVertexCount += e.pointCount;
39641
+ this.emit("convert");
39642
+ const uniforms = this.gaussianMaterial.uniforms;
39643
+ const { message, transfer } = wasmBuildWorkerUpdateMessage(
39644
+ e,
39645
+ uniforms,
39646
+ sourceIndex,
39647
+ this.usingSharedArrayBuffer
39648
+ );
39649
+ wasmUpdateUniforms(e, uniforms, sourceIndex);
39650
+ this.worker.postMessage(message, transfer);
39651
+ }
39652
+ break;
39653
+ }
39654
+ });
39655
+ const convertedUrl = new URL(url, location.origin).toString();
39656
+ const waitForFinally = new Promise((resolve) => {
39657
+ this.once("sort", () => {
39658
+ this.sourceProperty[sourceIndex].ready = true;
39659
+ if (!this.sorted) {
39660
+ this.sorted = true;
39661
+ this.emit("finallyupdate", this.gaussianCount);
39662
+ }
39663
+ resolve();
39664
+ });
39665
+ });
39666
+ const decodeOptions = {
39667
+ useSphericalHarmonics,
39668
+ useSharedArrayBuffer: this.usingSharedArrayBuffer,
39669
+ ...this.usingSharedArrayBuffer && this.sharedData && {
39670
+ sharedGaussianBuffer: this.sharedData.sharedGaussianData,
39671
+ sharedShBuffer: this.sharedData.sharedSphericalHarmonicsData,
39672
+ gaussianBufferOffset: sourceVertexOffset,
39673
+ shBufferOffset: sourceVertexOffset
39674
+ }
39675
+ };
39676
+ switch (format) {
39677
+ case "splat":
39678
+ await tavioWasmClient.api.decodeSplat(convertedUrl, decodeOptions);
39679
+ break;
39680
+ case "ply":
39681
+ await tavioWasmClient.api.decodePly(convertedUrl, decodeOptions);
39682
+ break;
39683
+ case "spz":
39684
+ await tavioWasmClient.api.decodeSpz(convertedUrl, decodeOptions);
39685
+ break;
39686
+ case "sog":
39687
+ await tavioWasmClient.api.decodeSog(convertedUrl, decodeOptions);
39688
+ break;
39689
+ default:
39690
+ throw new Error(`Unsupported format: ${format}`);
39691
+ }
39692
+ this.emit("load", { length: contentLength });
39693
+ tavioWasmClient.dispose();
39694
+ await waitForFinally;
39695
+ }
39696
+ /**
39697
+ * 様々な形式のリソースをセーブする
39698
+ * @param filename - 保存ファイル名
39699
+ */
39700
+ async saveTavioWasm(filename) {
39701
+ const tavioWasmClient = await TavioWasmWorkerClient.create({
39702
+ useSharedArrayBuffer: this.usingSharedArrayBuffer
39703
+ });
39704
+ let gaussianData;
39705
+ let sphericalHarmonicsData;
39706
+ if (this.usingSharedArrayBuffer) {
39707
+ gaussianData = this.sharedData.gaussianData;
39708
+ sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
39709
+ } else {
39710
+ ({ gaussianData, sphericalHarmonicsData } = await requestWorkerBuffer(this.worker));
39711
+ }
39712
+ const uniforms = this.gaussianMaterial.uniforms;
39713
+ const scaleMinValues = new Float32Array([
39714
+ uniforms.scaleAlphaMin.value.x,
39715
+ uniforms.scaleAlphaMin.value.y,
39716
+ uniforms.scaleAlphaMin.value.z
39717
+ ]);
39718
+ const scaleMaxValues = new Float32Array([
39719
+ uniforms.scaleAlphaMax.value.x,
39720
+ uniforms.scaleAlphaMax.value.y,
39721
+ uniforms.scaleAlphaMax.value.z
39722
+ ]);
39723
+ const alphaMin = uniforms.scaleAlphaMin.value.w;
39724
+ const alphaMax = uniforms.scaleAlphaMax.value.w;
39725
+ const bytes = await tavioWasmClient.api.encodeTavio(
39726
+ this.gaussianCount,
39727
+ gaussianData,
39728
+ sphericalHarmonicsData,
39729
+ scaleMinValues,
39730
+ scaleMaxValues,
39731
+ alphaMin,
39732
+ alphaMax
39733
+ );
39734
+ downloadAsFile(bytes, filename);
39735
+ tavioWasmClient.dispose();
39736
+ }
39737
+ /**
39738
+ * 様々な形式のリソースをセーブする
39739
+ * @param filename - 保存ファイル名
39740
+ * @param format - ファイル形式
39741
+ */
39742
+ async saveMeshWasm(filename, format) {
39743
+ const tavioWasmClient = await TavioWasmWorkerClient.create({
39744
+ useSharedArrayBuffer: this.usingSharedArrayBuffer
39745
+ });
39746
+ let gaussianData;
39747
+ let sphericalHarmonicsData;
39748
+ if (this.usingSharedArrayBuffer) {
39749
+ gaussianData = this.sharedData.gaussianData;
39750
+ sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
39751
+ } else {
39752
+ ({ gaussianData, sphericalHarmonicsData } = await requestWorkerBuffer(this.worker));
39753
+ }
39754
+ const uniforms = this.gaussianMaterial.uniforms;
39755
+ const scaleMinValues = new Float32Array([
39756
+ uniforms.scaleAlphaMin.value.x,
39757
+ uniforms.scaleAlphaMin.value.y,
39758
+ uniforms.scaleAlphaMin.value.z
39759
+ ]);
39760
+ const scaleMaxValues = new Float32Array([
39761
+ uniforms.scaleAlphaMax.value.x,
39762
+ uniforms.scaleAlphaMax.value.y,
39763
+ uniforms.scaleAlphaMax.value.z
39764
+ ]);
39765
+ const alphaMin = uniforms.scaleAlphaMin.value.w;
39766
+ const alphaMax = uniforms.scaleAlphaMax.value.w;
39767
+ let bytes;
39768
+ switch (format) {
39769
+ case "splat":
39770
+ bytes = await tavioWasmClient.api.encodeSplat(
39771
+ this.gaussianCount,
39772
+ gaussianData,
39773
+ scaleMinValues,
39774
+ scaleMaxValues,
39775
+ alphaMin,
39776
+ alphaMax
39777
+ );
39778
+ break;
39779
+ case "ply":
39780
+ bytes = await tavioWasmClient.api.encodePly(
39781
+ this.gaussianCount,
39782
+ gaussianData,
39783
+ sphericalHarmonicsData,
39784
+ scaleMinValues,
39785
+ scaleMaxValues,
39786
+ alphaMin,
39787
+ alphaMax
39788
+ );
39789
+ break;
39790
+ case "spz":
39791
+ bytes = await tavioWasmClient.api.encodeSpz(
39792
+ this.gaussianCount,
39793
+ gaussianData,
39794
+ sphericalHarmonicsData,
39795
+ scaleMinValues,
39796
+ scaleMaxValues,
39797
+ alphaMin,
39798
+ alphaMax
39799
+ );
39800
+ break;
39801
+ default:
39802
+ throw new Error(`Unsupported format: ${format}`);
39803
+ }
39804
+ downloadAsFile(bytes, filename);
39805
+ tavioWasmClient.dispose();
39806
+ }
39807
+ /**
39808
+ * canvas 要素からガウシアンを生成してシーンに追加する
39809
+ * @param canvas - 対象となる canvas 要素
39810
+ */
39811
+ async loadCanvas(canvas) {
39812
+ this.setupFlags();
39813
+ this.setupTavioWorker();
39814
+ this.setUsingSphericalHarmonics(false);
39815
+ this.setUsingWasmSort(false);
39816
+ return new Promise((resolve) => {
39817
+ const listener = () => {
39818
+ this.sourceProperty[index].ready = true;
39819
+ resolve();
39820
+ };
39821
+ this.once("finallyupdate", listener);
39822
+ let currentOffset = 0;
39823
+ let countOfPoints = 0;
39824
+ const index = this.sourceProperty.length;
39825
+ const isFirst = index === 0;
39826
+ if (isFirst !== true) {
39827
+ this.sourceProperty.forEach((prop) => {
39828
+ currentOffset += prop.vertexCount;
39829
+ });
39830
+ }
39831
+ this.sourceProperty.push({
39832
+ ready: false,
39833
+ index,
39834
+ type: "canvas",
39835
+ vertexCount: 0,
39836
+ vertexOffset: currentOffset,
39837
+ featureBits: null,
39838
+ containmentRadius: null,
39839
+ magicNumber: "",
39840
+ majorVersion: 0,
39841
+ minorVersion: 0,
39842
+ transform: {
39843
+ translation: new Vector3(0, 0, 0),
39844
+ rotation: new Euler(0, 0, 0),
39845
+ scale: 1
39846
+ },
39847
+ billboard: false
39848
+ });
39849
+ this.emit("getcontentbytelength", null);
39850
+ const splatSource = this.convertImageSource(canvas);
39851
+ countOfPoints = splatSource.count;
39852
+ if (countOfPoints === 0) {
39853
+ throw new Error("[TavioMesh]: Invalid resource");
39854
+ }
39855
+ this.gaussianCount = currentOffset + countOfPoints;
39856
+ this.setupGeometry(this.gaussianCount);
39857
+ this.sourceProperty[index].vertexCount = countOfPoints;
39858
+ const isEncodeEnabled = false;
39859
+ if (this.usingSharedArrayBuffer === true) {
39860
+ this.sharedData = this.allocateSharedData(
39861
+ index,
39862
+ currentOffset,
39863
+ 0,
39864
+ countOfPoints,
39865
+ isEncodeEnabled
39866
+ );
39867
+ this.gaussianData = this.sharedData.gaussianData;
39868
+ this.gaussianIndexData = this.sharedData.gaussianIndexData;
39869
+ this.gaussianOrderData = this.sharedData.gaussianOrderData;
39870
+ this.gaussianGeneralData = this.sharedData.gaussianGeneralData;
39871
+ this.sphericalHarmonicsData = this.sharedData.sphericalHarmonicsData;
39872
+ this.currentSelectionCount = 0;
39873
+ this.worker.postMessage({
39874
+ buffer: this.gaussianData.buffer,
39875
+ indexBuffer: this.gaussianIndexData.buffer,
39876
+ orderBuffer: this.gaussianOrderData.buffer,
39877
+ shBuffer: this.sphericalHarmonicsData.buffer,
39878
+ generalBuffer: this.gaussianGeneralData.buffer,
39879
+ vertexCount: this.gaussianCount,
39880
+ usingSharedArrayBuffer: this.usingSharedArrayBuffer,
39881
+ offset: currentOffset
39882
+ });
39883
+ } else {
39884
+ const textureWidth = TEXTURE_WIDTH_BASE;
39885
+ const textureHeight = Math.ceil(this.gaussianCount / textureWidth);
39886
+ const gaussianDataSize = this.gaussianCount * ROW_LENGTH_TAVIO;
39887
+ const generalDataSize = textureWidth * textureHeight * 4;
39888
+ const shDataSize = this.gaussianCount * SPHERICAL_HARMONICS_BASE_ELEMENT * 4;
39889
+ this.gaussianData = null;
39890
+ this.sphericalHarmonicsData = null;
39891
+ if (currentOffset > 0) {
39892
+ const previousGeneralData = this.gaussianGeneralData;
39893
+ this.gaussianGeneralData = new Uint8Array(generalDataSize);
39894
+ this.gaussianGeneralData.set(previousGeneralData);
39895
+ } else {
39896
+ this.gaussianGeneralData = new Uint8Array(generalDataSize);
39897
+ }
39898
+ this.gaussianIndexData = null;
39899
+ const { width, height } = _getDepthRenderTextureWidth(this.gaussianCount);
39900
+ this.gaussianOrderData = new Uint8Array(width * height * 4);
39901
+ this.currentSelectionCount = 0;
39902
+ this.worker.postMessage({
39903
+ vertexCount: this.gaussianCount,
39904
+ usingSharedArrayBuffer: this.usingSharedArrayBuffer,
39905
+ offset: currentOffset,
39906
+ gaussianDataSize,
39907
+ generalDataSize,
39908
+ shDataSize
39909
+ });
39910
+ }
39911
+ this.setupTransformData(index, currentOffset, this.gaussianCount);
39912
+ this.emit("convert", { count: this.gaussianCount });
39913
+ this.setupPoints(splatSource.position32);
39914
+ this.setColorIntoPoints(splatSource.color8);
39915
+ if (isFirst === true) {
39916
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = splatSource.min.scale.x;
39917
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = splatSource.min.scale.y;
39918
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = splatSource.min.scale.z;
39919
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = splatSource.min.alpha;
39920
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = splatSource.max.scale.x;
39921
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = splatSource.max.scale.y;
39922
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = splatSource.max.scale.z;
39923
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = splatSource.max.alpha;
39924
+ this.worker.postMessage({
39925
+ updateTexture: true,
39926
+ buffer: splatSource.converted.buffer
39927
+ });
39928
+ } else {
39929
+ const preMinX = this.gaussianMaterial.uniforms.scaleAlphaMin.value.x;
39930
+ const preMinY = this.gaussianMaterial.uniforms.scaleAlphaMin.value.y;
39931
+ const preMinZ = this.gaussianMaterial.uniforms.scaleAlphaMin.value.z;
39932
+ const preMaxX = this.gaussianMaterial.uniforms.scaleAlphaMax.value.x;
39933
+ const preMaxY = this.gaussianMaterial.uniforms.scaleAlphaMax.value.y;
39934
+ const preMaxZ = this.gaussianMaterial.uniforms.scaleAlphaMax.value.z;
39935
+ const previousScale = {
39936
+ min: [
39937
+ preMinX,
39938
+ preMinY,
39939
+ preMinZ
39940
+ ],
39941
+ max: [
39942
+ preMaxX,
39943
+ preMaxY,
39944
+ preMaxZ
39945
+ ]
39946
+ };
39947
+ const currentScale = {
39948
+ min: [
39949
+ splatSource.min.scale.x,
39950
+ splatSource.min.scale.y,
39951
+ splatSource.min.scale.z
39952
+ ],
39953
+ max: [
39954
+ splatSource.max.scale.x,
39955
+ splatSource.max.scale.y,
39956
+ splatSource.max.scale.z
39957
+ ]
39958
+ };
39959
+ const curMinX = Math.min(splatSource.min.scale.x, preMinX);
39960
+ const curMinY = Math.min(splatSource.min.scale.y, preMinY);
39961
+ const curMinZ = Math.min(splatSource.min.scale.z, preMinZ);
39962
+ const curMaxX = Math.max(splatSource.max.scale.x, preMaxX);
39963
+ const curMaxY = Math.max(splatSource.max.scale.y, preMaxY);
39964
+ const curMaxZ = Math.max(splatSource.max.scale.z, preMaxZ);
39965
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.x = curMinX;
39966
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.y = curMinY;
39967
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.z = curMinZ;
39968
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.x = curMaxX;
39969
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.y = curMaxY;
39970
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.z = curMaxZ;
39971
+ const preMin = this.gaussianMaterial.uniforms.scaleAlphaMin.value.w;
39972
+ const preMax = this.gaussianMaterial.uniforms.scaleAlphaMax.value.w;
39973
+ const previousAlpha = {
39974
+ min: [preMin],
39975
+ max: [preMax]
39976
+ };
39977
+ const currentAlpha = {
39978
+ min: [splatSource.min.alpha],
39979
+ max: [splatSource.max.alpha]
39980
+ };
39981
+ const curMin = Math.min(splatSource.min.alpha, preMin);
39982
+ const curMax = Math.max(splatSource.max.alpha, preMax);
39983
+ this.gaussianMaterial.uniforms.scaleAlphaMin.value.w = curMin;
39984
+ this.gaussianMaterial.uniforms.scaleAlphaMax.value.w = curMax;
39985
+ this.worker.postMessage({
39986
+ updateTexture: true,
39987
+ buffer: splatSource.converted.buffer,
39988
+ scale: currentScale,
39989
+ // 既存のデータとの統合時のみ付与されるプロパティ
39990
+ alpha: currentAlpha,
39991
+ // 既存のデータとの統合時のみ付与されるプロパティ
39992
+ previousScale,
39993
+ // 既存のデータとの統合時のみ付与されるプロパティ
39994
+ previousAlpha
39995
+ // 既存のデータとの統合時のみ付与されるプロパティ
39996
+ });
39997
+ }
39998
+ });
39999
+ }
40000
+ /**
40001
+ * 画像や canvas 要素をパースし変換する
40002
+ * @param imageSource - 対象となる画像や canvas
40003
+ */
40004
+ convertImageSource(imageSource) {
40005
+ const isCanvas = imageSource instanceof HTMLCanvasElement;
40006
+ const nWidth = isCanvas === true ? imageSource.width : imageSource.naturalWidth;
40007
+ const nHeight = isCanvas === true ? imageSource.height : imageSource.naturalHeight;
40008
+ const aspect2 = nWidth / nHeight;
40009
+ const cvs = document.createElement("canvas");
40010
+ cvs.width = nWidth;
40011
+ cvs.height = nHeight;
40012
+ const ctx = cvs.getContext("2d");
40013
+ ctx.imageSmoothingEnabled = true;
40014
+ ctx.imageSmoothingQuality = "high";
40015
+ ctx.drawImage(imageSource, 0, 0, nWidth, nHeight);
40016
+ const imageData = ctx.getImageData(0, 0, nWidth, nHeight);
40017
+ const data = imageData.data;
40018
+ let count = 0;
40019
+ for (let _i = 0, _j = data.length; _i < _j; _i += 4) {
40020
+ if (data[_i + 3] > 0) {
40021
+ ++count;
40022
+ }
40023
+ }
40024
+ const position32 = new Float32Array(count * 3);
40025
+ const color8 = new Uint8ClampedArray(count * 3);
40026
+ const converted = new Uint8Array(count * ROW_LENGTH_TAVIO);
40027
+ let alphaMin = Infinity;
40028
+ let alphaMax = -Infinity;
40029
+ const nx = [];
40030
+ const ny = [];
40031
+ const nr = [];
40032
+ const ng = [];
40033
+ const nb = [];
40034
+ const na = [];
40035
+ const ra = [];
40036
+ const EPS2 = 1e-4;
40037
+ for (let i = 0; i < nHeight; ++i) {
40038
+ for (let j = 0; j < nWidth; ++j) {
40039
+ const i4 = (i * nWidth + j) * 4;
40040
+ const a = data[i4 + 3];
40041
+ if (a === 0) {
40042
+ continue;
40043
+ }
40044
+ const x = j / (nWidth - 1) - 0.5;
40045
+ const y = i / (nHeight - 1) - 0.5;
40046
+ if (aspect2 >= 1) {
40047
+ nx.push(x);
40048
+ ny.push(y / aspect2);
40049
+ } else {
40050
+ nx.push(x * aspect2);
40051
+ ny.push(y);
40052
+ }
40053
+ const r = data[i4 + 0];
40054
+ const g = data[i4 + 1];
40055
+ const b = data[i4 + 2];
40056
+ nr.push(r);
40057
+ ng.push(g);
40058
+ nb.push(b);
40059
+ na.push(a);
40060
+ const A = Math.min(Math.max(a / 255, EPS2), 1 - EPS2);
40061
+ const raw = Math.log(A / (1 - A));
40062
+ alphaMin = Math.min(alphaMin, raw);
40063
+ alphaMax = Math.max(alphaMax, raw);
40064
+ ra.push(raw);
40065
+ }
40066
+ }
40067
+ const qt = convertQuaternion(1, 0, 0, 0);
40068
+ qt.u *= 255;
40069
+ qt.v *= 255;
40070
+ qt.w *= 255;
40071
+ const max = Math.max(nWidth, nHeight);
40072
+ const scaleX = Math.log(POINT_BASE_RADIUS / max);
40073
+ const scaleY = Math.log(POINT_BASE_RADIUS / max);
40074
+ const scaleZ = Math.log(EPS2);
40075
+ const alphaRange = alphaMax - alphaMin;
40076
+ for (let k = 0; k < count; ++k) {
40077
+ const ir = k * ROW_LENGTH_TAVIO;
40078
+ const viewPosition = new Float16Array(
40079
+ converted.buffer,
40080
+ ir,
40081
+ 3
40082
+ );
40083
+ const viewScale = new Uint8ClampedArray(
40084
+ converted.buffer,
40085
+ ir + 6,
40086
+ 3
40087
+ );
40088
+ const viewColor = new Uint8ClampedArray(
40089
+ converted.buffer,
40090
+ ir + 9,
40091
+ 4
40092
+ );
40093
+ const viewRotation = new Uint8ClampedArray(
40094
+ converted.buffer,
40095
+ ir + 13,
40096
+ 3
40097
+ );
40098
+ const viewRawAlpha = new Uint8ClampedArray(
40099
+ converted.buffer,
40100
+ ir + 16,
40101
+ 1
40102
+ );
40103
+ viewPosition[0] = nx[k];
40104
+ viewPosition[1] = ny[k];
40105
+ viewPosition[2] = 0;
40106
+ viewScale[0] = 0;
40107
+ viewScale[1] = 0;
40108
+ viewScale[2] = 0;
40109
+ viewColor[0] = nr[k];
40110
+ viewColor[1] = ng[k];
40111
+ viewColor[2] = nb[k];
40112
+ viewColor[3] = na[k];
40113
+ viewRotation[0] = qt.u;
40114
+ viewRotation[1] = qt.v;
40115
+ viewRotation[2] = qt.w;
40116
+ viewRawAlpha[0] = (ra[k] - alphaMin) / alphaRange * 255;
40117
+ const i3 = k * 3;
40118
+ position32[i3 + 0] = nx[k];
40119
+ position32[i3 + 1] = ny[k];
40120
+ position32[i3 + 2] = 0;
40121
+ color8[i3 + 0] = nr[k];
40122
+ color8[i3 + 1] = ng[k];
40123
+ color8[i3 + 2] = nb[k];
40124
+ }
40125
+ return {
40126
+ count,
40127
+ position32,
40128
+ color8,
40129
+ converted,
40130
+ min: {
40131
+ alpha: alphaMin,
40132
+ scale: {
40133
+ x: scaleX,
40134
+ y: scaleY,
40135
+ z: scaleZ
40136
+ }
40137
+ },
40138
+ max: {
40139
+ alpha: alphaMax,
40140
+ scale: {
40141
+ x: scaleX,
40142
+ y: scaleY,
40143
+ z: scaleZ
40144
+ }
40145
+ }
40146
+ };
40147
+ }
40148
+ /**
40149
+ * ==========================================================================
40150
+ * getter / setter
39141
40151
  * ==========================================================================
39142
40152
  */
39143
40153
  /**
@@ -39223,6 +40233,9 @@ class TavioMesh extends EventEmitter {
39223
40233
  */
39224
40234
  setUniforms(values) {
39225
40235
  Object.entries(values).forEach(([key, value]) => {
40236
+ if (this.gaussianMaterial.uniforms[key] == null) {
40237
+ return;
40238
+ }
39226
40239
  this.gaussianMaterial.uniforms[key].value = value;
39227
40240
  });
39228
40241
  }
@@ -39343,8 +40356,9 @@ class TavioMesh extends EventEmitter {
39343
40356
  * @param translation - 平行移動
39344
40357
  * @param rotation - 回転(オイラー角)
39345
40358
  * @param scale - 拡大縮小(XYZ で統一のスケール)
40359
+ * @param force - 同時にテクスチャの内容を強制的に書き換えるかどうか
39346
40360
  */
39347
- setTransform(index, translation, rotation, scale) {
40361
+ setTransform(index, translation, rotation, scale, isForce = true) {
39348
40362
  if (this.gaussianTransformData == null || this.sourceProperty[index] == null) {
39349
40363
  return;
39350
40364
  }
@@ -39352,7 +40366,6 @@ class TavioMesh extends EventEmitter {
39352
40366
  this.sourceProperty[index].transform.rotation.copy(rotation);
39353
40367
  this.sourceProperty[index].transform.scale = scale;
39354
40368
  const transformFloatView = new Float16Array(this.gaussianTransformData.buffer);
39355
- const width = this.transformTextureWidth;
39356
40369
  const q = new Quaternion().setFromEuler(rotation);
39357
40370
  const i8 = index * 8;
39358
40371
  transformFloatView[i8 + 0] = translation.x;
@@ -39363,22 +40376,9 @@ class TavioMesh extends EventEmitter {
39363
40376
  transformFloatView[i8 + 5] = q.y;
39364
40377
  transformFloatView[i8 + 6] = q.z;
39365
40378
  transformFloatView[i8 + 7] = q.w;
39366
- if (this.gaussianTransformDataTexture != null) {
39367
- this.gaussianTransformDataTexture.source.data.data = this.gaussianTransformData;
39368
- this.gaussianTransformDataTexture.needsUpdate = true;
39369
- } else {
39370
- this.gaussianTransformDataTexture = this.setupTransformDataTexture(
39371
- this.gaussianTransformData,
39372
- width,
39373
- width
39374
- );
40379
+ if (isForce === true) {
40380
+ this._updateTransformData();
39375
40381
  }
39376
- this.gaussianMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
39377
- this.gaussianMaterial.uniforms.transformTextureWidth.value = width;
39378
- this.gaussianMaterial.needsUpdate = true;
39379
- this.depthRenderMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
39380
- this.depthRenderMaterial.uniforms.transformTextureWidth.value = width;
39381
- this.depthRenderMaterial.needsUpdate = true;
39382
40382
  }
39383
40383
  /**
39384
40384
  * 指定されたインデックスの座標変換情報を返す
@@ -39397,13 +40397,80 @@ class TavioMesh extends EventEmitter {
39397
40397
  scale
39398
40398
  };
39399
40399
  }
40400
+ /**
40401
+ * インデックスを指定してビルボードの設定を行う
40402
+ * @param index - インデックス
40403
+ * @param flag - ビルボードとして扱うかどうか
40404
+ */
40405
+ setBillboard(index, flag) {
40406
+ if (this.sourceProperty[index] == null) {
40407
+ return null;
40408
+ }
40409
+ this.sourceProperty[index].billboard = flag;
40410
+ this.hasBillboard = this.sourceProperty.some((prop) => {
40411
+ return prop.billboard;
40412
+ });
40413
+ }
40414
+ /**
40415
+ * ビルボードのための transform 情報の更新を行う
40416
+ * @param camera - カメラのワールド空間上の位置
40417
+ */
40418
+ updateBillboard(camera) {
40419
+ if (this.hasBillboard !== true) {
40420
+ return;
40421
+ }
40422
+ dummyQuaternion.setFromAxisAngle(dummyVector3.set(1, 0, 0), Math.PI);
40423
+ this.sourceProperty.forEach((prop, index) => {
40424
+ if (prop.billboard === true) {
40425
+ dummyObject3D.quaternion.copy(camera.quaternion);
40426
+ dummyObject3D.quaternion.multiply(dummyQuaternion);
40427
+ dummyObject3D.rotation.setFromQuaternion(dummyObject3D.quaternion);
40428
+ this.setTransform(
40429
+ index,
40430
+ prop.transform.translation,
40431
+ dummyObject3D.rotation,
40432
+ prop.transform.scale,
40433
+ false
40434
+ // 更新は最後にまとめて行う(テクスチャを無駄に複数回更新させないため)
40435
+ );
40436
+ }
40437
+ });
40438
+ this._updateTransformData();
40439
+ }
40440
+ /**
40441
+ * インスタンスごとの transform 情報をテクスチャに適用し更新する
40442
+ * @private
40443
+ */
40444
+ _updateTransformData() {
40445
+ const width = this.transformTextureWidth;
40446
+ if (this.gaussianTransformDataTexture != null) {
40447
+ this.gaussianTransformDataTexture.source.data.data = this.gaussianTransformData;
40448
+ this.gaussianTransformDataTexture.needsUpdate = true;
40449
+ } else {
40450
+ this.gaussianTransformDataTexture = this.setupTransformDataTexture(
40451
+ this.gaussianTransformData,
40452
+ width,
40453
+ width
40454
+ );
40455
+ }
40456
+ this.gaussianMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
40457
+ this.gaussianMaterial.uniforms.transformTextureWidth.value = this.transformTextureWidth;
40458
+ this.gaussianMaterial.needsUpdate = true;
40459
+ this.depthRenderMaterial.uniforms.transformTexture.value = this.gaussianTransformDataTexture;
40460
+ this.depthRenderMaterial.uniforms.transformTextureWidth.value = this.transformTextureWidth;
40461
+ this.depthRenderMaterial.needsUpdate = true;
40462
+ }
39400
40463
  /**
39401
40464
  * 自身のプロパティの状態に応じて球面調和関数に関連する uniform 変数の更新を行う
39402
40465
  * @private
39403
40466
  */
39404
40467
  _updateUniformsForSphericalHarmonics() {
39405
- this.gaussianMaterial.uniforms.sphericalHarmonicsCalculation.value = this.usingSphericalHarmonics === true;
39406
- this.gaussianMaterial.uniforms.sphericalHarmonicsIntensity.value = this.usingSphericalHarmonics !== true ? 0 : 1;
40468
+ if (this.gaussianMaterial.uniforms.sphericalHarmonicsCalculation != null) {
40469
+ this.gaussianMaterial.uniforms.sphericalHarmonicsCalculation.value = this.usingSphericalHarmonics === true;
40470
+ }
40471
+ if (this.gaussianMaterial.uniforms.sphericalHarmonicsIntensity != null) {
40472
+ this.gaussianMaterial.uniforms.sphericalHarmonicsIntensity.value = this.usingSphericalHarmonics !== true ? 0 : 1;
40473
+ }
39407
40474
  }
39408
40475
  /**
39409
40476
  * tavio 形式の特性フラグを取得する
@@ -39437,15 +40504,6 @@ class TavioMesh extends EventEmitter {
39437
40504
  this.gaussianPickingMaterial.uniforms.focal.value = this.gaussianMaterial.uniforms.focal.value.clone();
39438
40505
  this.gaussianPickingMaterial.uniforms.inverseViewport.value = this.gaussianMaterial.uniforms.inverseViewport.value.clone();
39439
40506
  this.gaussianPickingMaterial.uniforms.gaussianScale.value = this.gaussianMaterial.uniforms.gaussianScale.value;
39440
- this.gaussianPickingMaterial.uniforms.effectMinimumScale.value = this.gaussianMaterial.uniforms.effectMinimumScale.value;
39441
- this.gaussianPickingMaterial.uniforms.effectDistance.value = this.gaussianMaterial.uniforms.effectDistance.value;
39442
- this.gaussianPickingMaterial.uniforms.effectDistanceMax.value = this.gaussianMaterial.uniforms.effectDistanceMax.value;
39443
- this.gaussianPickingMaterial.uniforms.effectDistanceRange.value = this.gaussianMaterial.uniforms.effectDistanceRange.value;
39444
- this.gaussianPickingMaterial.uniforms.effectDistanceColor.value = this.gaussianMaterial.uniforms.effectDistanceColor.value;
39445
- this.gaussianPickingMaterial.uniforms.effectDistanceColorNear.value = this.gaussianMaterial.uniforms.effectDistanceColorNear.value;
39446
- this.gaussianPickingMaterial.uniforms.effectSonar.value = this.gaussianMaterial.uniforms.effectSonar.value;
39447
- this.gaussianPickingMaterial.uniforms.effectSonarRange.value = this.gaussianMaterial.uniforms.effectSonarRange.value;
39448
- this.gaussianPickingMaterial.uniforms.worldOrigin.value = this.gaussianMaterial.uniforms.worldOrigin.value.clone();
39449
40507
  this.gaussianPickingMaterial.uniforms.scaleAlphaMin.value = this.gaussianMaterial.uniforms.scaleAlphaMin.value.clone();
39450
40508
  this.gaussianPickingMaterial.uniforms.scaleAlphaMax.value = this.gaussianMaterial.uniforms.scaleAlphaMax.value.clone();
39451
40509
  this.gaussianPickingMaterial.uniforms.transformTextureWidth.value = this.gaussianMaterial.uniforms.transformTextureWidth.value;
@@ -39616,6 +40674,17 @@ class TavioMesh extends EventEmitter {
39616
40674
  * setup
39617
40675
  * ==========================================================================
39618
40676
  */
40677
+ /**
40678
+ * データのロード前に各種フラグをセットアップする
40679
+ */
40680
+ setupFlags() {
40681
+ this.initialized = false;
40682
+ this.initializedPoints = false;
40683
+ this.initializedBackground = false;
40684
+ this.sorted = false;
40685
+ this.initializedTexture = false;
40686
+ this.initializedColorTexture = false;
40687
+ }
39619
40688
  /**
39620
40689
  * tavio 形式用の worker をセットアップする
39621
40690
  */
@@ -39670,10 +40739,12 @@ class TavioMesh extends EventEmitter {
39670
40739
  this.gaussianCompressedDataTexture1 = this.setupCompressedColorDataTexture(packedSH1, width, height);
39671
40740
  this.gaussianCompressedDataTexture2 = this.setupCompressedColorDataTexture(packedSH2, width, height);
39672
40741
  this.gaussianCompressedDataTexture3 = this.setupCompressedColorDataTexture(packedSH3, width, height);
39673
- uniforms.sphericalHarmonicsTexture0.value = this.gaussianCompressedDataTexture0;
39674
- uniforms.sphericalHarmonicsTexture1.value = this.gaussianCompressedDataTexture1;
39675
- uniforms.sphericalHarmonicsTexture2.value = this.gaussianCompressedDataTexture2;
39676
- uniforms.sphericalHarmonicsTexture3.value = this.gaussianCompressedDataTexture3;
40742
+ if (uniforms.sphericalHarmonicsTexture0 != null) {
40743
+ uniforms.sphericalHarmonicsTexture0.value = this.gaussianCompressedDataTexture0;
40744
+ uniforms.sphericalHarmonicsTexture1.value = this.gaussianCompressedDataTexture1;
40745
+ uniforms.sphericalHarmonicsTexture2.value = this.gaussianCompressedDataTexture2;
40746
+ uniforms.sphericalHarmonicsTexture3.value = this.gaussianCompressedDataTexture3;
40747
+ }
39677
40748
  this.initializedColorTexture = true;
39678
40749
  if (this._getInitialized() === true && this.listenerInitializedTexture != null) {
39679
40750
  this.listenerInitializedTexture();
@@ -39787,7 +40858,9 @@ class TavioMesh extends EventEmitter {
39787
40858
  this.maxDistance = this._getMaxDistance(position);
39788
40859
  this.containmentRadius.per100 = this.maxDistance;
39789
40860
  const uniforms = this.gaussianMaterial.uniforms;
39790
- uniforms.effectDistanceMax.value = this.maxDistance;
40861
+ if (uniforms.effectDistanceMax != null) {
40862
+ uniforms.effectDistanceMax.value = this.maxDistance;
40863
+ }
39791
40864
  const exists = this.gaussianPoints != null;
39792
40865
  let positionArray = null;
39793
40866
  let colorArray = null;
@@ -39802,12 +40875,15 @@ class TavioMesh extends EventEmitter {
39802
40875
  opacity: this.viewerOption.opacityPoints
39803
40876
  });
39804
40877
  const uniforms2 = this.gaussianMaterial.uniforms;
40878
+ const effectDistanceMax2 = uniforms2.effectDistanceMax?.value;
40879
+ const effectDistanceRange2 = uniforms2.effectDistanceRange?.value;
40880
+ const worldOrigin2 = uniforms2.worldOrigin?.value.clone() ?? new Vector3();
39805
40881
  this.gaussianPointUniforms = {
39806
40882
  effectDistance: { value: this.viewerOption.distanceEffectPoint },
39807
40883
  effectDistanceNear: { value: this.viewerOption.distanceEffectPointNear },
39808
- effectDistanceMax: { value: uniforms2.effectDistanceMax.value },
39809
- effectDistanceRange: { value: uniforms2.effectDistanceRange.value },
39810
- worldOrigin: { value: uniforms2.worldOrigin.value.clone() }
40884
+ effectDistanceMax: { value: effectDistanceMax2 },
40885
+ effectDistanceRange: { value: effectDistanceRange2 },
40886
+ worldOrigin: { value: worldOrigin2 }
39811
40887
  };
39812
40888
  this.gaussianPointMaterial.onBeforeCompile = (shader) => {
39813
40889
  shader.vertexShader = main$3;
@@ -39844,18 +40920,21 @@ class TavioMesh extends EventEmitter {
39844
40920
  transparent: true,
39845
40921
  opacity: this.viewerOption.opacityPoints
39846
40922
  });
40923
+ const effectDistanceMax = uniforms.effectDistanceMax?.value;
40924
+ const effectDistanceRange = uniforms.effectDistanceRange?.value;
40925
+ const worldOrigin = uniforms.worldOrigin?.value.clone() ?? new Vector3();
39847
40926
  this.gaussianPointUniforms = {
39848
40927
  effectDistance: { value: this.viewerOption.distanceEffectPoint },
39849
40928
  effectDistanceNear: { value: this.viewerOption.distanceEffectPointNear },
39850
- effectDistanceMax: { value: uniforms.effectDistanceMax.value },
39851
- effectDistanceRange: { value: uniforms.effectDistanceRange.value },
40929
+ effectDistanceMax: { value: effectDistanceMax },
40930
+ effectDistanceRange: { value: effectDistanceRange },
39852
40931
  effectDistanceColor: { value: this.viewerOption.distanceColorEffect },
39853
40932
  effectDistanceColorNear: {
39854
40933
  value: this.viewerOption.distanceColorEffectNear
39855
40934
  },
39856
40935
  effectSonar: { value: this.viewerOption.effectSonar },
39857
40936
  effectSonarRange: { value: this.viewerOption.effectSonarRange },
39858
- worldOrigin: { value: uniforms.worldOrigin.value.clone() },
40937
+ worldOrigin: { value: worldOrigin },
39859
40938
  temperature: { value: this.viewerOption.colorTemperature },
39860
40939
  tint: { value: this.viewerOption.colorTint },
39861
40940
  contrastIntensity: { value: this.viewerOption.colorContrast },
@@ -39913,8 +40992,8 @@ class TavioMesh extends EventEmitter {
39913
40992
  this.indexAttribute.setUsage(DynamicDrawUsage);
39914
40993
  this.indexAttribute.needsUpdate = true;
39915
40994
  this.gaussianGeometry = new InstancedBufferGeometry();
39916
- this.gaussianGeometry.setAttribute("localPosition", this.positionAttribute);
39917
- this.gaussianGeometry.setAttribute("indices", this.indexAttribute);
40995
+ this.gaussianGeometry.setAttribute("aLocalPosition", this.positionAttribute);
40996
+ this.gaussianGeometry.setAttribute("aIndices", this.indexAttribute);
39918
40997
  this.gaussianGeometry.setIndex(triangleIndex);
39919
40998
  this.gaussianMesh = new InstancedMeshEX(
39920
40999
  this.gaussianGeometry,
@@ -40106,8 +41185,26 @@ class TavioMesh extends EventEmitter {
40106
41185
  * @param collision - 設定する衝突判定、またはその配列
40107
41186
  */
40108
41187
  setCollision(collision) {
41188
+ const sources = this.sourceProperty.map((prop) => {
41189
+ return {
41190
+ translation: {
41191
+ x: prop.transform.translation.x,
41192
+ y: prop.transform.translation.y,
41193
+ z: prop.transform.translation.z
41194
+ },
41195
+ rotation: {
41196
+ x: prop.transform.rotation.x,
41197
+ y: prop.transform.rotation.y,
41198
+ z: prop.transform.rotation.z
41199
+ },
41200
+ scale: prop.transform.scale
41201
+ };
41202
+ });
40109
41203
  const collisions = Array.isArray(collision) === true ? collision : [collision];
40110
- this.worker.postMessage({ collision: collisions });
41204
+ this.worker.postMessage({
41205
+ source: sources,
41206
+ collision: collisions
41207
+ });
40111
41208
  }
40112
41209
  /**
40113
41210
  * 現在の衝突判定を解除する
@@ -40495,6 +41592,341 @@ class AnimationController extends EventEmitter {
40495
41592
  this.callbacks.start();
40496
41593
  }
40497
41594
  }
41595
+ const mainBegin = "void main() {\n";
41596
+ const mainEnd = "}\n";
41597
+ const precision$1 = "// #version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp usampler2D;\n";
41598
+ 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";
41599
+ 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";
41600
+ 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";
41601
+ 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";
41602
+ 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";
41603
+ const precision = "// #version 300 es\nprecision highp float;\n";
41604
+ const declaration$6 = "out vec4 fragColor;\n";
41605
+ const _function$2 = "";
41606
+ const mainIn$2 = " float finalAlpha = 1.0;\n vec3 finalColor = vec3(0.0);\n";
41607
+ const mainOut$1 = " fragColor = vec4(finalColor * finalAlpha, finalAlpha);\n";
41608
+ const CHUNK_TARGET = {
41609
+ ANY: 0,
41610
+ // すべてに反映する
41611
+ BASIC: 1,
41612
+ // 描画用シェーダ
41613
+ PICKING: 2
41614
+ // ピッキング用シェーダ
41615
+ };
41616
+ const SHADER_STAGE = {
41617
+ VERTEX_PRECISION: 0,
41618
+ // 精度修飾子
41619
+ VERTEX_DECLARATION: 1,
41620
+ // 変数宣言
41621
+ VERTEX_FUNCTION: 2,
41622
+ // 関数定義
41623
+ VERTEX_MAIN_BEGIN: 3,
41624
+ // main() の開始
41625
+ VERTEX_MAIN_TRANSFORM: 4,
41626
+ // main() 内の座標変換処理
41627
+ VERTEX_MAIN_SIGMA: 5,
41628
+ // main() 内のシグマ生成箇所
41629
+ VERTEX_MAIN_OUT: 6,
41630
+ // main() 内の変換結果の出力
41631
+ VERTEX_MAIN_END: 7,
41632
+ // main() の終了
41633
+ FRAGMENT_PRECISION: 8,
41634
+ // 精度修飾子
41635
+ FRAGMENT_DECLARATION: 9,
41636
+ // 変数宣言
41637
+ FRAGMENT_FUNCTION: 10,
41638
+ // 関数定義
41639
+ FRAGMENT_MAIN_BEGIN: 11,
41640
+ // main() の開始
41641
+ FRAGMENT_MAIN_IN: 12,
41642
+ // main() 内の開始
41643
+ FRAGMENT_MAIN_OUT: 13,
41644
+ // main() 内の終了
41645
+ FRAGMENT_MAIN_END: 14
41646
+ // main() の終了
41647
+ };
41648
+ const SHADER_STAGE_COUNT = 15;
41649
+ class MaterialGenerator {
41650
+ /**
41651
+ * shaderChunk/common に含まれる頂点シェーダのチャンクをセットした Map オブジェクトを生成する
41652
+ */
41653
+ static _createVertexMap() {
41654
+ const map = /* @__PURE__ */ new Map();
41655
+ map.set(SHADER_STAGE.VERTEX_PRECISION, precision$1);
41656
+ map.set(SHADER_STAGE.VERTEX_DECLARATION, declaration$7);
41657
+ map.set(SHADER_STAGE.VERTEX_FUNCTION, _function$3);
41658
+ map.set(SHADER_STAGE.VERTEX_MAIN_BEGIN, mainBegin);
41659
+ map.set(SHADER_STAGE.VERTEX_MAIN_TRANSFORM, mainTransform$1);
41660
+ map.set(SHADER_STAGE.VERTEX_MAIN_SIGMA, mainSigma$2);
41661
+ map.set(SHADER_STAGE.VERTEX_MAIN_OUT, mainOut$2);
41662
+ map.set(SHADER_STAGE.VERTEX_MAIN_END, mainEnd);
41663
+ return map;
41664
+ }
41665
+ /**
41666
+ * shaderChunk/common に含まれるフラグメントシェーダのチャンクをセットした Map オブジェクトを生成する
41667
+ */
41668
+ static _createFragmentMap() {
41669
+ const map = /* @__PURE__ */ new Map();
41670
+ map.set(SHADER_STAGE.FRAGMENT_PRECISION, precision);
41671
+ map.set(SHADER_STAGE.FRAGMENT_DECLARATION, declaration$6);
41672
+ map.set(SHADER_STAGE.FRAGMENT_FUNCTION, _function$2);
41673
+ map.set(SHADER_STAGE.FRAGMENT_MAIN_BEGIN, mainBegin);
41674
+ map.set(SHADER_STAGE.FRAGMENT_MAIN_IN, mainIn$2);
41675
+ map.set(SHADER_STAGE.FRAGMENT_MAIN_OUT, mainOut$1);
41676
+ map.set(SHADER_STAGE.FRAGMENT_MAIN_END, mainEnd);
41677
+ return map;
41678
+ }
41679
+ /**
41680
+ * シェーダチャンクに iMaterialOption.vertex / fragment に含まれるソースコードを結合する
41681
+ * @param option - シェーダチャンクを含むマテリアルオプション
41682
+ * @param vsMap - 頂点シェーダ用
41683
+ * @param fsMap - フラグメントシェーダ用
41684
+ * @return 各ステージに何回チャンクが結合されたかを表す配列
41685
+ */
41686
+ static _mergeShaderSource(option, vsMap, fsMap) {
41687
+ const chunkCount = new Array(SHADER_STAGE_COUNT).fill(0);
41688
+ if (option.vertex != null) {
41689
+ const vsArray = Array.isArray(option.vertex) === true ? option.vertex : [option.vertex];
41690
+ vsArray.forEach((opt) => {
41691
+ if (opt.source == null || opt.source === "") {
41692
+ return;
41693
+ }
41694
+ switch (opt.stage) {
41695
+ case SHADER_STAGE.VERTEX_PRECISION:
41696
+ case SHADER_STAGE.VERTEX_DECLARATION:
41697
+ case SHADER_STAGE.VERTEX_FUNCTION:
41698
+ case SHADER_STAGE.VERTEX_MAIN_BEGIN:
41699
+ case SHADER_STAGE.VERTEX_MAIN_TRANSFORM:
41700
+ case SHADER_STAGE.VERTEX_MAIN_SIGMA:
41701
+ case SHADER_STAGE.VERTEX_MAIN_OUT:
41702
+ case SHADER_STAGE.VERTEX_MAIN_END:
41703
+ const source = vsMap.get(opt.stage) + "\n" + opt.source + "\n";
41704
+ vsMap.set(opt.stage, source);
41705
+ ++chunkCount[opt.stage];
41706
+ break;
41707
+ default:
41708
+ throw new Error(`invalid SHADER_STAGE: ${opt.stage}`);
41709
+ }
41710
+ });
41711
+ }
41712
+ if (option.fragment != null) {
41713
+ const fsArray = Array.isArray(option.fragment) === true ? option.fragment : [option.fragment];
41714
+ fsArray.forEach((opt) => {
41715
+ if (opt.source == null || opt.source === "") {
41716
+ return;
41717
+ }
41718
+ switch (opt.stage) {
41719
+ case SHADER_STAGE.FRAGMENT_PRECISION:
41720
+ case SHADER_STAGE.FRAGMENT_DECLARATION:
41721
+ case SHADER_STAGE.FRAGMENT_FUNCTION:
41722
+ case SHADER_STAGE.FRAGMENT_MAIN_BEGIN:
41723
+ case SHADER_STAGE.FRAGMENT_MAIN_IN:
41724
+ case SHADER_STAGE.FRAGMENT_MAIN_OUT:
41725
+ case SHADER_STAGE.FRAGMENT_MAIN_END:
41726
+ const source = fsMap.get(opt.stage) + "\n" + opt.source + "\n";
41727
+ fsMap.set(opt.stage, source);
41728
+ ++chunkCount[opt.stage];
41729
+ break;
41730
+ default:
41731
+ throw new Error(`invalid SHADER_STAGE: ${opt.stage}`);
41732
+ }
41733
+ });
41734
+ }
41735
+ return chunkCount;
41736
+ }
41737
+ /**
41738
+ * uniform 変数用の雛形を生成する(src/shderChunk/common 以下で定義される最低限のもの)
41739
+ */
41740
+ static _createUniforms() {
41741
+ return {
41742
+ splatTexture: { value: null },
41743
+ generalTexture: { value: null },
41744
+ transformTexture: { value: null },
41745
+ projection: { value: new Matrix4() },
41746
+ view: { value: new Matrix4() },
41747
+ focal: { value: new Vector2() },
41748
+ inverseViewport: { value: new Vector2() },
41749
+ gaussianScale: { value: 1 },
41750
+ additionAlpha: { value: 0 },
41751
+ multiplicationAlpha: { value: 1 },
41752
+ blur: { value: 0.3 },
41753
+ sharpness: { value: 0.3 },
41754
+ scaleAlphaMin: { value: new Vector4(0, 0, 0, 0) },
41755
+ scaleAlphaMax: { value: new Vector4(1, 1, 1, 1) },
41756
+ transformTextureWidth: { value: 2 }
41757
+ };
41758
+ }
41759
+ /**
41760
+ * Map オブジェクトに含まれるソースコードを結合する
41761
+ * @param map - 処理の対象となる Map オブジェクト
41762
+ * @param isDebug - デバッグ用にコンソールにソースコードを出力するかどうか
41763
+ */
41764
+ static _createShaderSource(map, chunkCount, isDebug = false) {
41765
+ let source = "";
41766
+ if (isDebug === true) {
41767
+ map.forEach((v, k) => {
41768
+ let key = "";
41769
+ switch (k) {
41770
+ case SHADER_STAGE.VERTEX_PRECISION:
41771
+ key = "VERTEX_PRECISION";
41772
+ break;
41773
+ case SHADER_STAGE.VERTEX_DECLARATION:
41774
+ key = "VERTEX_DECLARATION";
41775
+ break;
41776
+ case SHADER_STAGE.VERTEX_FUNCTION:
41777
+ key = "VERTEX_FUNCTION";
41778
+ break;
41779
+ case SHADER_STAGE.VERTEX_MAIN_BEGIN:
41780
+ key = "VERTEX_MAIN_BEGIN";
41781
+ break;
41782
+ case SHADER_STAGE.VERTEX_MAIN_TRANSFORM:
41783
+ key = "VERTEX_MAIN_TRANSFORM";
41784
+ break;
41785
+ case SHADER_STAGE.VERTEX_MAIN_SIGMA:
41786
+ key = "VERTEX_MAIN_SIGMA";
41787
+ break;
41788
+ case SHADER_STAGE.VERTEX_MAIN_OUT:
41789
+ key = "VERTEX_MAIN_OUT";
41790
+ break;
41791
+ case SHADER_STAGE.VERTEX_MAIN_END:
41792
+ key = "VERTEX_MAIN_END";
41793
+ break;
41794
+ case SHADER_STAGE.FRAGMENT_PRECISION:
41795
+ key = "FRAGMENT_PRECISION";
41796
+ break;
41797
+ case SHADER_STAGE.FRAGMENT_DECLARATION:
41798
+ key = "FRAGMENT_DECLARATION";
41799
+ break;
41800
+ case SHADER_STAGE.FRAGMENT_FUNCTION:
41801
+ key = "FRAGMENT_FUNCTION";
41802
+ break;
41803
+ case SHADER_STAGE.FRAGMENT_MAIN_BEGIN:
41804
+ key = "FRAGMENT_MAIN_BEGIN";
41805
+ break;
41806
+ case SHADER_STAGE.FRAGMENT_MAIN_IN:
41807
+ key = "FRAGMENT_MAIN_IN";
41808
+ break;
41809
+ case SHADER_STAGE.FRAGMENT_MAIN_OUT:
41810
+ key = "FRAGMENT_MAIN_OUT";
41811
+ break;
41812
+ case SHADER_STAGE.FRAGMENT_MAIN_END:
41813
+ key = "FRAGMENT_MAIN_END";
41814
+ break;
41815
+ default:
41816
+ key = "UNKNOWN";
41817
+ }
41818
+ source += `
41819
+ /* ============================== ${key} : [${chunkCount[k]}] ============================== */
41820
+ ${v}`;
41821
+ });
41822
+ } else {
41823
+ map.forEach((v) => source += v);
41824
+ }
41825
+ return source;
41826
+ }
41827
+ /**
41828
+ * マテリアルを生成する
41829
+ * @param option - シェーダチャンクなどの情報を含むマテリアルオプション
41830
+ * @param isDebug - デバッグ用にコンソールにソースコードを出力するかどうか
41831
+ */
41832
+ static generate(option, isDebug = false) {
41833
+ const vsBasicMap = MaterialGenerator._createVertexMap();
41834
+ const fsBasicMap = MaterialGenerator._createFragmentMap();
41835
+ const vsPickingMap = MaterialGenerator._createVertexMap();
41836
+ const fsPickingMap = MaterialGenerator._createFragmentMap();
41837
+ const basicUniforms = MaterialGenerator._createUniforms();
41838
+ const pickingUniforms = MaterialGenerator._createUniforms();
41839
+ const optionArray = Array.isArray(option) === true ? option : [option];
41840
+ const bcc = new Array(optionArray.length);
41841
+ const pcc = new Array(optionArray.length);
41842
+ optionArray.forEach((opt, index) => {
41843
+ if (opt == null) {
41844
+ return;
41845
+ }
41846
+ const isTargetAny = opt.target === CHUNK_TARGET.ANY;
41847
+ const isTargetBasic = checkBit(opt.target, 0);
41848
+ const isTargetPicking = checkBit(opt.target, 1);
41849
+ if (isTargetAny === true || isTargetBasic === true) {
41850
+ bcc[index] = MaterialGenerator._mergeShaderSource(opt, vsBasicMap, fsBasicMap);
41851
+ if (opt.uniforms != null) {
41852
+ Object.assign(basicUniforms, opt.uniforms);
41853
+ }
41854
+ }
41855
+ if (isTargetAny === true || isTargetPicking === true) {
41856
+ pcc[index] = MaterialGenerator._mergeShaderSource(opt, vsPickingMap, fsPickingMap);
41857
+ if (opt.uniforms != null) {
41858
+ Object.assign(pickingUniforms, opt.uniforms);
41859
+ }
41860
+ }
41861
+ });
41862
+ const basicChunkCount = new Array(SHADER_STAGE_COUNT).fill(0);
41863
+ const pickingChunkCount = new Array(SHADER_STAGE_COUNT).fill(0);
41864
+ bcc.forEach((cc) => {
41865
+ cc.forEach((v, i) => {
41866
+ basicChunkCount[i] += v;
41867
+ });
41868
+ });
41869
+ pcc.forEach((cc) => {
41870
+ cc.forEach((v, i) => {
41871
+ pickingChunkCount[i] += v;
41872
+ });
41873
+ });
41874
+ const basicVertexShaderSource = MaterialGenerator._createShaderSource(vsBasicMap, basicChunkCount, isDebug);
41875
+ const basicFragmentShaderSource = MaterialGenerator._createShaderSource(fsBasicMap, basicChunkCount, isDebug);
41876
+ const basic = new RawShaderMaterial({
41877
+ uniforms: basicUniforms,
41878
+ vertexShader: basicVertexShaderSource,
41879
+ fragmentShader: basicFragmentShaderSource,
41880
+ depthTest: true,
41881
+ depthWrite: false,
41882
+ blending: CustomBlending,
41883
+ blendSrc: OneFactor,
41884
+ blendDst: OneMinusSrcAlphaFactor,
41885
+ blendSrcAlpha: OneFactor,
41886
+ blendDstAlpha: OneMinusSrcAlphaFactor,
41887
+ blendEquation: AddEquation,
41888
+ blendEquationAlpha: AddEquation,
41889
+ glslVersion: GLSL3,
41890
+ side: DoubleSide
41891
+ });
41892
+ const pickingVertexShaderSource = MaterialGenerator._createShaderSource(vsPickingMap, pickingChunkCount, isDebug);
41893
+ const pickingFragmentShaderSource = MaterialGenerator._createShaderSource(fsPickingMap, pickingChunkCount, isDebug);
41894
+ const picking = new RawShaderMaterial({
41895
+ uniforms: pickingUniforms,
41896
+ vertexShader: pickingVertexShaderSource,
41897
+ fragmentShader: pickingFragmentShaderSource,
41898
+ depthTest: true,
41899
+ depthWrite: false,
41900
+ glslVersion: GLSL3,
41901
+ side: DoubleSide
41902
+ });
41903
+ if (isDebug === true) {
41904
+ console.log("[ basic-vertex ]");
41905
+ console.log(basicVertexShaderSource);
41906
+ console.log("[ basic-fragment ]");
41907
+ console.log(basicFragmentShaderSource);
41908
+ console.log("[ picking-vertex ]");
41909
+ console.log(pickingVertexShaderSource);
41910
+ console.log("[ picking-fragment ]");
41911
+ console.log(pickingFragmentShaderSource);
41912
+ }
41913
+ return { basic, picking };
41914
+ }
41915
+ }
41916
+ 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";
41917
+ 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";
41918
+ 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";
41919
+ 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";
41920
+ 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";
41921
+ 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";
41922
+ 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";
41923
+ 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";
41924
+ 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";
41925
+ 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";
41926
+ const declaration$1 = "out vec4 vColor;\nflat out uint vGeneralA;\n";
41927
+ const mainTransform = " vColor = vec4(transformedCenter, 0.0);\n vGeneralA = general.a;\n";
41928
+ const declaration = "in vec4 vColor;\nflat in uint vGeneralA;\n";
41929
+ 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";
40498
41930
  const TavioErrorCode = {
40499
41931
  /** Float16Array 未対応環境 */
40500
41932
  FLOAT16_NOT_SUPPORTED: "E001"
@@ -40665,6 +42097,11 @@ class Core extends EventEmitter {
40665
42097
  CONTROLS_TYPE_PATH,
40666
42098
  CONTROLS_TYPE_FLIGHT
40667
42099
  ];
42100
+ /**
42101
+ * シェーダチャンク関連(定義は MaterialGenerator.ts 内)
42102
+ */
42103
+ static CHUNK_TARGET = CHUNK_TARGET;
42104
+ static SHADER_STAGE = SHADER_STAGE;
40668
42105
  /**
40669
42106
  * @constructor
40670
42107
  * @param viewerOption - ビューア実装の初期化オプション
@@ -40795,179 +42232,25 @@ class Core extends EventEmitter {
40795
42232
  "hsv-S": this.viewerOption.colorHSV.y,
40796
42233
  "hsv-V": this.viewerOption.colorHSV.z,
40797
42234
  "rgb-R": this.viewerOption.colorRGB.x,
40798
- "rgb-G": this.viewerOption.colorRGB.y,
40799
- "rgb-B": this.viewerOption.colorRGB.z,
40800
- blur: this.viewerOption.colorBlur,
40801
- sharpness: this.viewerOption.colorSharpness
40802
- };
40803
- }
40804
- /**
40805
- * 各種初期化処理を行う
40806
- * @param canvas - WebGL コンテキストを取得する対象となる canvas 要素
40807
- */
40808
- init(canvas) {
40809
- this.canvas = canvas;
40810
- this.renderer = new WebGLRenderer({
40811
- canvas,
40812
- antialias: false,
40813
- preserveDrawingBuffer: true
40814
- });
40815
- this.renderer.setClearColor(new Color(0, 0, 0), 0);
40816
- this.scene = new Scene();
40817
- this.scene.backgroundRotation.x = Math.PI * 0.5;
40818
- this.scene.backgroundIntensity = this.viewerOption.backgroundOpacity;
40819
- this.pickingScene = new Scene();
40820
- this.pmremGenerator = new PMREMGenerator(this.renderer);
40821
- this.gaussianGroup = new Group();
40822
- this.meshGroup = new Group();
40823
- this.meshGroup.rotation.z = Math.PI;
40824
- this.interfaceGroup = new Group();
40825
- this.scene.add(this.gaussianGroup);
40826
- this.scene.add(this.meshGroup);
40827
- this.scene.add(this.interfaceGroup);
40828
- this.perspectiveCamera = new PerspectiveCamera(
40829
- PERSPECTIVE_FOV,
40830
- this.canvas.width / this.canvas.height,
40831
- PERSPECTIVE_NEAR,
40832
- PERSPECTIVE_FAR
40833
- );
40834
- this.perspectiveCamera.up.set(0, -1, 0);
40835
- this.perspectiveCamera.position.set(0, 0, PERSPECTIVE_POSITION_Z);
40836
- this.perspectiveCamera.lookAt(new Vector3(0, 0, 0));
40837
- this.gaussianMaterial = new RawShaderMaterial({
40838
- uniforms: {
40839
- projection: { value: new Matrix4() },
40840
- view: { value: new Matrix4() },
40841
- eyePosition: { value: new Vector3() },
40842
- focal: { value: new Vector2() },
40843
- inverseViewport: { value: new Vector2() },
40844
- splatTexture: { value: null },
40845
- // splat state value
40846
- generalTexture: { value: null },
40847
- // general parameters
40848
- transformTexture: { value: null },
40849
- // transform parameters
40850
- sphericalHarmonicsTexture0: { value: null },
40851
- // sh color (shN) compressed value: (00 to 03)
40852
- sphericalHarmonicsTexture1: { value: null },
40853
- // sh color (shN) compressed value: (04 to 07)
40854
- sphericalHarmonicsTexture2: { value: null },
40855
- // sh color (shN) compressed value: (08 to 11)
40856
- sphericalHarmonicsTexture3: { value: null },
40857
- // sh color (shN) compressed value: (12 to 15) and scale
40858
- sphericalHarmonicsIntensity: { value: 0 },
40859
- // range of 0.0 to 1.0
40860
- sphericalHarmonicsCalculation: { value: false },
40861
- // is calculation on shader
40862
- gaussianScale: { value: this.viewerOption.gaussianScale },
40863
- // ガウシアンの大きさの基本係数
40864
- effectMinimumScale: { value: this.viewerOption.minimumScale },
40865
- // 距離に応じた大きさの最小サイズ
40866
- effectDistance: { value: this.viewerOption.distanceEffectBase },
40867
- // 距離に応じた大きさの係数(0.0 to 1.0)
40868
- effectDistanceMax: { value: 0 },
40869
- // 正規化するための最大距離
40870
- effectDistanceRange: { value: this.viewerOption.distanceEffectRange },
40871
- // 正規化済みの値の範囲係数(0.0 < n <= 1.0)
40872
- effectDistanceColor: { value: this.viewerOption.distanceColorEffect },
40873
- // 色エフェクト(可視部分の外側)
40874
- effectDistanceColorNear: {
40875
- value: this.viewerOption.distanceColorEffectNear
40876
- },
40877
- // 色エフェクト(可視部分の内側)
40878
- effectSonar: { value: this.viewerOption.effectSonar },
40879
- // ソナーエフェクト(外側の円の半径)
40880
- effectSonarRange: {
40881
- value: this.viewerOption.effectSonarRange
40882
- },
40883
- // ソナーエフェクトの範囲
40884
- worldOrigin: {
40885
- value: new Vector3(
40886
- this.viewerOption.worldOrigin.x,
40887
- this.viewerOption.worldOrigin.y,
40888
- this.viewerOption.worldOrigin.z
40889
- )
40890
- },
40891
- additionAlpha: { value: this.viewerOption.opacityAdditive },
40892
- multiplicationAlpha: { value: this.viewerOption.opacityMultiplier },
40893
- temperature: { value: this.viewerOption.colorTemperature },
40894
- tint: { value: this.viewerOption.colorTint },
40895
- contrastIntensity: { value: this.viewerOption.colorContrast },
40896
- hsv: {
40897
- value: new Vector3(
40898
- this.viewerOption.colorHSV.x,
40899
- this.viewerOption.colorHSV.y,
40900
- this.viewerOption.colorHSV.z
40901
- )
40902
- },
40903
- rgb: {
40904
- value: new Vector3(
40905
- this.viewerOption.colorRGB.x,
40906
- this.viewerOption.colorRGB.y,
40907
- this.viewerOption.colorRGB.z
40908
- )
40909
- },
40910
- scaleAlphaMin: { value: new Vector4(0, 0, 0, 0) },
40911
- // シェーダ内で scale と raw-alpha を復元するための値
40912
- scaleAlphaMax: { value: new Vector4(1, 1, 1, 1) },
40913
- // シェーダ内で scale と raw-alpha を復元するための値
40914
- blur: { value: this.viewerOption.colorBlur },
40915
- // ガウシアン内部の色のぼかし係数
40916
- sharpness: { value: this.viewerOption.colorSharpness },
40917
- // ガウシアン内部の色の範囲を広げることで結果鮮明に見える状態にする係数
40918
- transformTextureWidth: { value: 2 }
40919
- // transformTexture の幅
40920
- },
40921
- vertexShader: main$7,
40922
- fragmentShader: main$6,
40923
- depthTest: true,
40924
- depthWrite: false,
40925
- blending: CustomBlending,
40926
- blendSrc: OneFactor,
40927
- blendDst: OneMinusSrcAlphaFactor,
40928
- blendSrcAlpha: OneFactor,
40929
- blendDstAlpha: OneMinusSrcAlphaFactor,
40930
- blendEquation: AddEquation,
40931
- blendEquationAlpha: AddEquation,
40932
- glslVersion: GLSL3,
40933
- side: DoubleSide
40934
- });
40935
- this.gaussianPickingMaterial = new RawShaderMaterial({
40936
- uniforms: {
40937
- splatTexture: { value: null },
40938
- generalTexture: { value: null },
40939
- transformTexture: { value: null },
40940
- projection: { value: new Matrix4() },
40941
- view: { value: new Matrix4() },
40942
- focal: { value: new Vector2() },
40943
- inverseViewport: { value: new Vector2() },
40944
- gaussianScale: { value: 1 },
40945
- effectMinimumScale: { value: this.viewerOption.minimumScale },
40946
- effectDistance: { value: this.viewerOption.distanceEffectBase },
40947
- effectDistanceMax: { value: 0 },
40948
- effectDistanceRange: { value: this.viewerOption.distanceEffectRange },
40949
- effectDistanceColor: { value: this.viewerOption.distanceColorEffect },
40950
- effectDistanceColorNear: { value: this.viewerOption.distanceColorEffectNear },
40951
- effectSonar: { value: this.viewerOption.effectSonar },
40952
- effectSonarRange: { value: this.viewerOption.effectSonarRange },
40953
- worldOrigin: {
40954
- value: new Vector3(
40955
- this.viewerOption.worldOrigin.x,
40956
- this.viewerOption.worldOrigin.y,
40957
- this.viewerOption.worldOrigin.z
40958
- )
40959
- },
40960
- scaleAlphaMin: { value: new Vector4(0, 0, 0, 0) },
40961
- scaleAlphaMax: { value: new Vector4(1, 1, 1, 1) },
40962
- transformTextureWidth: { value: 2 }
40963
- },
40964
- vertexShader: main$5,
40965
- fragmentShader: main$4,
40966
- depthTest: true,
40967
- depthWrite: false,
40968
- glslVersion: GLSL3,
40969
- side: DoubleSide
42235
+ "rgb-G": this.viewerOption.colorRGB.y,
42236
+ "rgb-B": this.viewerOption.colorRGB.z,
42237
+ blur: this.viewerOption.colorBlur,
42238
+ sharpness: this.viewerOption.colorSharpness
42239
+ };
42240
+ }
42241
+ /**
42242
+ * 各種初期化処理を行う
42243
+ * @param canvas - WebGL コンテキストを取得する対象となる canvas 要素
42244
+ * @param materialOption - シェーダチャンクなどの情報を含むマテリアルオプション
42245
+ */
42246
+ init(canvas, materialOption) {
42247
+ this.canvas = canvas;
42248
+ this.renderer = new WebGLRenderer({
42249
+ canvas,
42250
+ antialias: false,
42251
+ preserveDrawingBuffer: true
40970
42252
  });
42253
+ this.renderer.setClearColor(new Color(0, 0, 0), 0);
40971
42254
  this.pickingRenderTarget = new WebGLRenderTarget(
40972
42255
  this.canvas.width,
40973
42256
  this.canvas.height,
@@ -40977,12 +42260,202 @@ class Core extends EventEmitter {
40977
42260
  magFilter: NearestFilter
40978
42261
  }
40979
42262
  );
40980
- this.meshMap = /* @__PURE__ */ new Map();
42263
+ this.scene = new Scene();
42264
+ this.scene.backgroundRotation.x = Math.PI * 0.5;
42265
+ this.scene.backgroundIntensity = this.viewerOption.backgroundOpacity;
42266
+ this.pickingScene = new Scene();
42267
+ this.pmremGenerator = new PMREMGenerator(this.renderer);
42268
+ this.gaussianGroup = new Group();
42269
+ this.meshGroup = new Group();
42270
+ this.meshGroup.rotation.z = Math.PI;
42271
+ this.interfaceGroup = new Group();
42272
+ this.scene.add(this.gaussianGroup);
42273
+ this.scene.add(this.meshGroup);
42274
+ this.scene.add(this.interfaceGroup);
42275
+ this.perspectiveCamera = new PerspectiveCamera(
42276
+ PERSPECTIVE_FOV,
42277
+ this.canvas.width / this.canvas.height,
42278
+ PERSPECTIVE_NEAR,
42279
+ PERSPECTIVE_FAR
42280
+ );
42281
+ this.perspectiveCamera.up.set(0, -1, 0);
42282
+ this.perspectiveCamera.position.set(0, 0, PERSPECTIVE_POSITION_Z);
42283
+ this.perspectiveCamera.lookAt(new Vector3(0, 0, 0));
40981
42284
  this.cameraPathManager = new CameraPathManager();
42285
+ this.meshMap = /* @__PURE__ */ new Map();
42286
+ this.setupMaterial(materialOption);
40982
42287
  this.setupControls();
40983
42288
  this.setupSelector();
40984
42289
  this.setupEvent();
40985
42290
  }
42291
+ /**
42292
+ * マテリアルをセットアップする
42293
+ * @param option - シェーダチャンクなどの情報を含むマテリアルオプション
42294
+ */
42295
+ setupMaterial(option) {
42296
+ const materialOption = [
42297
+ {
42298
+ // 交流成分を有効化したうえで RGB を出力し、範囲選択の見た目を変化させる
42299
+ target: CHUNK_TARGET.BASIC,
42300
+ uniforms: {
42301
+ sphericalHarmonicsTexture0: { value: null },
42302
+ sphericalHarmonicsTexture1: { value: null },
42303
+ sphericalHarmonicsTexture2: { value: null },
42304
+ sphericalHarmonicsTexture3: { value: null },
42305
+ sphericalHarmonicsIntensity: { value: 1 },
42306
+ eyePosition: { value: new Vector3(0, 0, 0) }
42307
+ },
42308
+ vertex: [
42309
+ {
42310
+ stage: SHADER_STAGE.VERTEX_DECLARATION,
42311
+ source: declaration$5
42312
+ },
42313
+ {
42314
+ stage: SHADER_STAGE.VERTEX_FUNCTION,
42315
+ source: _function$1
42316
+ },
42317
+ {
42318
+ stage: SHADER_STAGE.VERTEX_MAIN_SIGMA,
42319
+ source: mainSigma$1
42320
+ }
42321
+ ],
42322
+ fragment: [
42323
+ {
42324
+ stage: SHADER_STAGE.FRAGMENT_DECLARATION,
42325
+ source: declaration$4
42326
+ },
42327
+ {
42328
+ stage: SHADER_STAGE.FRAGMENT_MAIN_IN,
42329
+ source: mainIn$1
42330
+ }
42331
+ ]
42332
+ },
42333
+ {
42334
+ // 各種エフェクトやカラーグレーディングに対応させる
42335
+ target: CHUNK_TARGET.BASIC,
42336
+ uniforms: {
42337
+ effectMinimumScale: {
42338
+ value: this.viewerOption.minimumScale
42339
+ // 距離に応じた大きさの最小サイズ
42340
+ },
42341
+ effectDistance: {
42342
+ value: this.viewerOption.distanceEffectBase
42343
+ // 距離に応じた大きさの係数(0.0 to 1.0)
42344
+ },
42345
+ effectDistanceMax: {
42346
+ value: 0
42347
+ // 正規化するための最大距離
42348
+ },
42349
+ effectDistanceRange: {
42350
+ value: this.viewerOption.distanceEffectRange
42351
+ // 正規化済みの値の範囲係数(0.0 < n <= 1.0)
42352
+ },
42353
+ effectDistanceColor: {
42354
+ value: this.viewerOption.distanceColorEffect
42355
+ // 色エフェクト(可視部分の外側)
42356
+ },
42357
+ effectDistanceColorNear: {
42358
+ value: this.viewerOption.distanceColorEffectNear
42359
+ // 色エフェクト(可視部分の内側)
42360
+ },
42361
+ effectSonar: {
42362
+ value: this.viewerOption.effectSonar
42363
+ // ソナーエフェクト(外側の円の半径)
42364
+ },
42365
+ effectSonarRange: {
42366
+ value: this.viewerOption.effectSonarRange
42367
+ // ソナーエフェクトの範囲
42368
+ },
42369
+ worldOrigin: {
42370
+ value: new Vector3(
42371
+ this.viewerOption.worldOrigin.x,
42372
+ this.viewerOption.worldOrigin.y,
42373
+ this.viewerOption.worldOrigin.z
42374
+ )
42375
+ },
42376
+ temperature: { value: this.viewerOption.colorTemperature },
42377
+ tint: { value: this.viewerOption.colorTint },
42378
+ contrastIntensity: { value: this.viewerOption.colorContrast },
42379
+ hsv: {
42380
+ value: new Vector3(
42381
+ this.viewerOption.colorHSV.x,
42382
+ this.viewerOption.colorHSV.y,
42383
+ this.viewerOption.colorHSV.z
42384
+ )
42385
+ },
42386
+ rgb: {
42387
+ value: new Vector3(
42388
+ this.viewerOption.colorRGB.x,
42389
+ this.viewerOption.colorRGB.y,
42390
+ this.viewerOption.colorRGB.z
42391
+ )
42392
+ }
42393
+ },
42394
+ vertex: [
42395
+ {
42396
+ stage: SHADER_STAGE.VERTEX_DECLARATION,
42397
+ source: declaration$3
42398
+ },
42399
+ {
42400
+ stage: SHADER_STAGE.VERTEX_MAIN_SIGMA,
42401
+ source: mainSigma
42402
+ }
42403
+ ],
42404
+ fragment: [
42405
+ {
42406
+ stage: SHADER_STAGE.FRAGMENT_DECLARATION,
42407
+ source: declaration$2
42408
+ },
42409
+ {
42410
+ stage: SHADER_STAGE.FRAGMENT_FUNCTION,
42411
+ source: _function
42412
+ },
42413
+ {
42414
+ stage: SHADER_STAGE.FRAGMENT_MAIN_IN,
42415
+ source: mainIn
42416
+ }
42417
+ ]
42418
+ },
42419
+ {
42420
+ // ワールド座標をレンダリングするピッキング用シェーダ
42421
+ target: CHUNK_TARGET.PICKING,
42422
+ vertex: [
42423
+ {
42424
+ stage: SHADER_STAGE.VERTEX_DECLARATION,
42425
+ source: declaration$1
42426
+ },
42427
+ {
42428
+ stage: SHADER_STAGE.VERTEX_MAIN_TRANSFORM,
42429
+ source: mainTransform
42430
+ }
42431
+ ],
42432
+ fragment: [
42433
+ {
42434
+ stage: SHADER_STAGE.FRAGMENT_DECLARATION,
42435
+ source: declaration
42436
+ },
42437
+ {
42438
+ stage: SHADER_STAGE.FRAGMENT_MAIN_OUT,
42439
+ source: mainOut
42440
+ }
42441
+ ]
42442
+ }
42443
+ ];
42444
+ if (option != null && option.materialOption != null) {
42445
+ const mat = option.materialOption;
42446
+ const opt = Array.isArray(mat) === true ? mat : [mat];
42447
+ opt.forEach((ep) => {
42448
+ materialOption.push(ep);
42449
+ });
42450
+ }
42451
+ const isDebug = option?.isDebug === true;
42452
+ const {
42453
+ basic,
42454
+ picking
42455
+ } = MaterialGenerator.generate(materialOption, isDebug);
42456
+ this.gaussianMaterial = basic;
42457
+ this.gaussianPickingMaterial = picking;
42458
+ }
40986
42459
  /**
40987
42460
  * カメラコントロール・カメラコライダーをセットアップする
40988
42461
  */
@@ -41265,69 +42738,70 @@ class Core extends EventEmitter {
41265
42738
  colorFolder.addBinding(this.parameters, "sharpness", { min: 0, max: 1 }).on("change", (v) => {
41266
42739
  this.setColorSharpness(v.value);
41267
42740
  });
42741
+ const transformTargetIndex = 0;
41268
42742
  const transformFolder = pane.addFolder({ title: "transform" });
41269
42743
  transformFolder.addBinding(this.parameters, "position-x", {
41270
42744
  min: -2,
41271
42745
  max: 2
41272
42746
  }).on("change", (v) => {
41273
42747
  const key = this.meshMap.keys().next().value;
41274
- const prev = this.meshMap.get(key).getTransform(0);
42748
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41275
42749
  prev.translation.x = v.value;
41276
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42750
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41277
42751
  });
41278
42752
  transformFolder.addBinding(this.parameters, "position-y", {
41279
42753
  min: -2,
41280
42754
  max: 2
41281
42755
  }).on("change", (v) => {
41282
42756
  const key = this.meshMap.keys().next().value;
41283
- const prev = this.meshMap.get(key).getTransform(0);
42757
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41284
42758
  prev.translation.y = v.value;
41285
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42759
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41286
42760
  });
41287
42761
  transformFolder.addBinding(this.parameters, "position-z", {
41288
42762
  min: -2,
41289
42763
  max: 2
41290
42764
  }).on("change", (v) => {
41291
42765
  const key = this.meshMap.keys().next().value;
41292
- const prev = this.meshMap.get(key).getTransform(0);
42766
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41293
42767
  prev.translation.z = v.value;
41294
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42768
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41295
42769
  });
41296
42770
  transformFolder.addBinding(this.parameters, "rotation-x", {
41297
42771
  min: -Math.PI,
41298
42772
  max: Math.PI
41299
42773
  }).on("change", (v) => {
41300
42774
  const key = this.meshMap.keys().next().value;
41301
- const prev = this.meshMap.get(key).getTransform(0);
42775
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41302
42776
  prev.rotation.x = v.value;
41303
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42777
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41304
42778
  });
41305
42779
  transformFolder.addBinding(this.parameters, "rotation-y", {
41306
42780
  min: -Math.PI,
41307
42781
  max: Math.PI
41308
42782
  }).on("change", (v) => {
41309
42783
  const key = this.meshMap.keys().next().value;
41310
- const prev = this.meshMap.get(key).getTransform(0);
42784
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41311
42785
  prev.rotation.y = v.value;
41312
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42786
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41313
42787
  });
41314
42788
  transformFolder.addBinding(this.parameters, "rotation-z", {
41315
42789
  min: -Math.PI,
41316
42790
  max: Math.PI
41317
42791
  }).on("change", (v) => {
41318
42792
  const key = this.meshMap.keys().next().value;
41319
- const prev = this.meshMap.get(key).getTransform(0);
42793
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41320
42794
  prev.rotation.z = v.value;
41321
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42795
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41322
42796
  });
41323
42797
  transformFolder.addBinding(this.parameters, "scale", {
41324
42798
  min: 0,
41325
42799
  max: 2
41326
42800
  }).on("change", (v) => {
41327
42801
  const key = this.meshMap.keys().next().value;
41328
- const prev = this.meshMap.get(key).getTransform(0);
42802
+ const prev = this.meshMap.get(key).getTransform(transformTargetIndex);
41329
42803
  prev.scale = v.value;
41330
- this.setTransform(key, 0, prev.translation, prev.rotation, prev.scale);
42804
+ this.setTransform(key, transformTargetIndex, prev.translation, prev.rotation, prev.scale);
41331
42805
  });
41332
42806
  }
41333
42807
  /**
@@ -41367,6 +42841,10 @@ class Core extends EventEmitter {
41367
42841
  this.perspectiveCamera.updateProjectionMatrix();
41368
42842
  this._updateViewportUniforms();
41369
42843
  }
42844
+ setTimeout(() => {
42845
+ const force = true;
42846
+ this._renderDepthRenderTarget(force);
42847
+ });
41370
42848
  });
41371
42849
  tavioMesh.on("updatecollision", () => {
41372
42850
  this.start();
@@ -41437,7 +42915,7 @@ class Core extends EventEmitter {
41437
42915
  /**
41438
42916
  * 既存の TavioMesh のインスタンスにデータを統合する
41439
42917
  * @param name - このメッシュの固有名
41440
- * @param url - 読み込む .tavio ファイル
42918
+ * @param url - 読み込む .ply ファイル
41441
42919
  * @param option - ロード・パース関連のオプション
41442
42920
  */
41443
42921
  async concatPly(name, url, option) {
@@ -41462,8 +42940,7 @@ class Core extends EventEmitter {
41462
42940
  /**
41463
42941
  * 既存の TavioMesh のインスタンスにデータを統合する
41464
42942
  * @param name - このメッシュの固有名
41465
- * @param url - 読み込む .tavio ファイル
41466
- * @param option - ロード・パース関連のオプション
42943
+ * @param url - 読み込む .splat ファイル
41467
42944
  */
41468
42945
  async concatSplat(name, url) {
41469
42946
  const tavioMesh = this.meshMap.get(name);
@@ -41474,6 +42951,54 @@ class Core extends EventEmitter {
41474
42951
  await tavioMesh.loadSplat(url);
41475
42952
  await this._afterLoadMesh(name);
41476
42953
  }
42954
+ /**
42955
+ * TavioMesh のインスタンスを生成し画像形式のリソースをロード、シーンに追加する
42956
+ * @param name - このメッシュの固有名
42957
+ * @param url - 読み込む画像ファイル
42958
+ */
42959
+ async loadImage(name, url) {
42960
+ const tavioMesh = this._beforeLoadMesh(name);
42961
+ await tavioMesh.loadImage(url);
42962
+ await this._afterLoadMesh(name);
42963
+ }
42964
+ /**
42965
+ * 既存の TavioMesh のインスタンスにデータを統合する
42966
+ * @param name - このメッシュの固有名
42967
+ * @param url - 読み込む画像ファイル
42968
+ */
42969
+ async concatImage(name, url) {
42970
+ const tavioMesh = this.meshMap.get(name);
42971
+ if (tavioMesh == null) {
42972
+ return;
42973
+ }
42974
+ this.removeTavioMesh(name);
42975
+ await tavioMesh.loadImage(url);
42976
+ await this._afterLoadMesh(name);
42977
+ }
42978
+ /**
42979
+ * canvas 要素から TavioMesh のインスタンスを生成し、シーンに追加する
42980
+ * @param name - このメッシュの固有名
42981
+ * @param canvas - 処理の対象となる canvas 要素
42982
+ */
42983
+ async loadCanvas(name, canvas) {
42984
+ const tavioMesh = this._beforeLoadMesh(name);
42985
+ await tavioMesh.loadCanvas(canvas);
42986
+ await this._afterLoadMesh(name);
42987
+ }
42988
+ /**
42989
+ * 既存の TavioMesh のインスタンスにデータを統合する
42990
+ * @param name - このメッシュの固有名
42991
+ * @param canvas - 処理の対象となる canvas 要素
42992
+ */
42993
+ async concatCanvas(name, canvas) {
42994
+ const tavioMesh = this.meshMap.get(name);
42995
+ if (tavioMesh == null) {
42996
+ return;
42997
+ }
42998
+ this.removeTavioMesh(name);
42999
+ await tavioMesh.loadCanvas(canvas);
43000
+ await this._afterLoadMesh(name);
43001
+ }
41477
43002
  /**
41478
43003
  * tavio 形式のリソースをロードする
41479
43004
  * @param name - このメッシュの固有名
@@ -41489,19 +43014,76 @@ class Core extends EventEmitter {
41489
43014
  * @param name - このメッシュの固有名
41490
43015
  * @see {@link TavioMesh.prototype.loadPlyWasm}
41491
43016
  */
41492
- async loadPlyWasm(name, ...args) {
43017
+ async loadPlyWasm(name, url, options) {
43018
+ const tavioMesh = this._beforeLoadMesh(name);
43019
+ await tavioMesh.loadMeshWasm(url, "ply", options);
43020
+ await this._afterLoadMesh(name);
43021
+ }
43022
+ /**
43023
+ * splat 形式のリソースをロードする
43024
+ * @param name - このメッシュの固有名
43025
+ * @see {@link TavioMesh.prototype.loadSplatWasm}
43026
+ */
43027
+ async loadSplatWasm(name, url, options) {
43028
+ const tavioMesh = this._beforeLoadMesh(name);
43029
+ await tavioMesh.loadMeshWasm(url, "splat", options);
43030
+ await this._afterLoadMesh(name);
43031
+ }
43032
+ /**
43033
+ * spz 形式のリソースをロードする
43034
+ * @param name - このメッシュの固有名
43035
+ * @see {@link TavioMesh.prototype.loadSpzWasm}
43036
+ */
43037
+ async loadSpzWasm(name, url, options) {
43038
+ const tavioMesh = this._beforeLoadMesh(name);
43039
+ await tavioMesh.loadMeshWasm(url, "spz", options);
43040
+ await this._afterLoadMesh(name);
43041
+ }
43042
+ /**
43043
+ * sog 形式のリソースをロードする
43044
+ * @param name - このメッシュの固有名
43045
+ * @see {@link TavioMesh.prototype.loadSogWasm}
43046
+ */
43047
+ async loadSogWasm(name, url, options) {
41493
43048
  const tavioMesh = this._beforeLoadMesh(name);
41494
- await tavioMesh.loadPlyWasm(...args);
43049
+ await tavioMesh.loadMeshWasm(url, "sog", options);
41495
43050
  await this._afterLoadMesh(name);
41496
43051
  }
41497
43052
  /**
41498
- * tavio 形式のリソースをセーブする
43053
+ * tavio 形式のリソースを保存する
43054
+ * @param name - このメッシュの固有名
43055
+ * @param fileName - 保存ファイル名
43056
+ */
43057
+ async saveTavioWasm(name, fileName) {
43058
+ const tavioMesh = this.meshMap.get(name);
43059
+ await tavioMesh.saveTavioWasm(fileName);
43060
+ }
43061
+ /**
43062
+ * splat 形式のリソースを保存する
43063
+ * @param name - このメッシュの固有名
43064
+ * @param fileName - 保存ファイル名
43065
+ */
43066
+ async saveSplatWasm(name, fileName) {
43067
+ const tavioMesh = this.meshMap.get(name);
43068
+ await tavioMesh.saveMeshWasm(fileName, "splat");
43069
+ }
43070
+ /**
43071
+ * ply 形式のリソースを保存する
43072
+ * @param name - このメッシュの固有名
43073
+ * @param fileName - 保存ファイル名
43074
+ */
43075
+ async savePlyWasm(name, fileName) {
43076
+ const tavioMesh = this.meshMap.get(name);
43077
+ await tavioMesh.saveMeshWasm(fileName, "ply");
43078
+ }
43079
+ /**
43080
+ * spz 形式のリソースを保存する
41499
43081
  * @param name - このメッシュの固有名
41500
- * @see {@link TavioMesh.prototype.saveTavioWasm}
43082
+ * @param fileName - 保存ファイル名
41501
43083
  */
41502
- async saveTavioWasm(name, ...args) {
43084
+ async saveSpzWasm(name, fileName) {
41503
43085
  const tavioMesh = this.meshMap.get(name);
41504
- await tavioMesh.saveTavioWasm(...args);
43086
+ await tavioMesh.saveMeshWasm(fileName, "spz");
41505
43087
  }
41506
43088
  /**
41507
43089
  * 名前を指定してロード済み TavioMesh をシーンに追加する
@@ -41611,7 +43193,7 @@ class Core extends EventEmitter {
41611
43193
  }
41612
43194
  /**
41613
43195
  * 名前を指定した TavioMesh に含まれるインスタンスを、インデックスで指定して動かす
41614
- * ※ここでいうインデックスとは load/concat した順番を意味する整数値
43196
+ * ※ここでいうインデックスとは load/concat した順番を意味する整数値(concat していない場合常に 0)
41615
43197
  * @param name - 対象の名前
41616
43198
  * @param index - インデックス
41617
43199
  * @param translation - 平行移動
@@ -41623,28 +43205,19 @@ class Core extends EventEmitter {
41623
43205
  if (tavioMesh == null) {
41624
43206
  return;
41625
43207
  }
43208
+ const t = new Vector3(translation.x, translation.y, translation.z);
43209
+ const r = new Euler(rotation.x, rotation.y, rotation.z);
41626
43210
  tavioMesh.setTransform(
41627
43211
  index,
41628
- translation,
41629
- rotation,
43212
+ t,
43213
+ r,
41630
43214
  scale
41631
43215
  );
41632
43216
  tavioMesh.once("sort", () => {
41633
43217
  this.start();
41634
43218
  });
41635
- const cameraPosition = this.perspectiveCamera.position.clone();
41636
- const vMatrix = this.perspectiveCamera.matrixWorldInverse;
41637
- const pMatrix = this.perspectiveCamera.projectionMatrix;
41638
- const vpMatrix = pMatrix.clone().multiply(vMatrix);
41639
- const vpElements = vpMatrix.elements;
41640
- const cpElements = cameraPosition.toArray();
41641
43219
  const force = true;
41642
- tavioMesh.setCameraParameterForDepthRenderTarget(
41643
- vpElements,
41644
- cpElements,
41645
- this.renderer,
41646
- force
41647
- );
43220
+ this._renderDepthRenderTarget(force);
41648
43221
  }
41649
43222
  /**
41650
43223
  * 名前を指定した TavioMesh に含まれるインスタンスの、指定されたインデックスの座標変換情報を返す
@@ -41659,6 +43232,20 @@ class Core extends EventEmitter {
41659
43232
  }
41660
43233
  return tavioMesh.getTransform(index);
41661
43234
  }
43235
+ /**
43236
+ * 名前を指定した TavioMesh に含まれるインスタンスをビルボードとして扱うかどうかを設定する
43237
+ * ※ここでいうインデックスとは load/concat した順番を意味する整数値
43238
+ * @param name - 対象の名前
43239
+ * @param index - インデックス
43240
+ * @param flag - ビルボードとして扱うかどうか
43241
+ */
43242
+ setBillboard(name, index, flag) {
43243
+ const tavioMesh = this.meshMap.get(name);
43244
+ if (tavioMesh == null) {
43245
+ return;
43246
+ }
43247
+ tavioMesh.setBillboard(index, flag);
43248
+ }
41662
43249
  /**
41663
43250
  * ==========================================================================
41664
43251
  * general
@@ -41790,6 +43377,7 @@ class Core extends EventEmitter {
41790
43377
  eyePosition: cameraPosition
41791
43378
  };
41792
43379
  this.meshMap.forEach((mesh) => {
43380
+ mesh.updateBillboard(this.perspectiveCamera);
41793
43381
  mesh.setUniforms(uniforms);
41794
43382
  mesh.setCameraParameterForDepthRenderTarget(
41795
43383
  vpElements,
@@ -42057,46 +43645,81 @@ class Core extends EventEmitter {
42057
43645
  mesh.setUniforms(uniforms);
42058
43646
  });
42059
43647
  }
43648
+ /**
43649
+ * 座標を焼き込むレンダリング処理を実行しソートを実行させる
43650
+ * @param isForce - 強制的に実行するかどうか
43651
+ */
43652
+ _renderDepthRenderTarget(isForce = false) {
43653
+ const cameraPosition = this.perspectiveCamera.position.clone();
43654
+ const vMatrix = this.perspectiveCamera.matrixWorldInverse;
43655
+ const pMatrix = this.perspectiveCamera.projectionMatrix;
43656
+ const vpMatrix = pMatrix.clone().multiply(vMatrix);
43657
+ const vpElements = vpMatrix.elements;
43658
+ const cpElements = cameraPosition.toArray();
43659
+ this.meshMap.forEach((tavioMesh) => {
43660
+ tavioMesh.setCameraParameterForDepthRenderTarget(
43661
+ vpElements,
43662
+ cpElements,
43663
+ this.renderer,
43664
+ isForce
43665
+ );
43666
+ });
43667
+ }
42060
43668
  /**
42061
43669
  * ==========================================================================
42062
43670
  * camera
42063
43671
  * ==========================================================================
42064
43672
  */
42065
43673
  /**
42066
- * カメラの現在の座標と注視点、視野角を取得する
43674
+ * カメラの現在の座標と視線方向、視野角を取得する
42067
43675
  */
42068
43676
  getCameraParameter() {
42069
43677
  const position = this.perspectiveCamera.getWorldPosition(new Vector3());
42070
43678
  const eye = position.clone().add(this.perspectiveCamera.getWorldDirection(new Vector3()));
43679
+ const orbitControls = this.controlsMap.get(
43680
+ CONTROLS_TYPE_ORBIT
43681
+ );
43682
+ const target = orbitControls.getTarget();
42071
43683
  const fov2 = this.perspectiveCamera.fov;
42072
- return { position: position.toArray(), eye: eye.toArray(), fov: fov2 };
43684
+ return {
43685
+ position: position.toArray(),
43686
+ eye: eye.toArray(),
43687
+ target: target.toArray(),
43688
+ fov: fov2
43689
+ };
42073
43690
  }
42074
43691
  /**
42075
- * カメラの現在の座標と注視点、視野角を取得する
43692
+ * カメラの現在の座標と注視点、視野角を設定する
43693
+ * ※このメソッドは設定時、その値が即座に反映される
42076
43694
  * @param position - 設定する座標
42077
- * @param eye - 設定する注視点
43695
+ * @param target - 設定する注視点
42078
43696
  * @param fov - 設定する視野角
42079
43697
  */
42080
- setCameraParameter(position, eye, fov2) {
43698
+ setCameraParameter(position, target, fov2) {
42081
43699
  if (this.currentControlsType === CONTROLS_TYPE_PATH) {
42082
43700
  return;
42083
43701
  }
42084
- const p = new Vector3(position.x, position.y, position.z);
42085
- const e = new Vector3(eye.x, eye.y, eye.z);
42086
- const f = fov2 ?? this.perspectiveCamera.fov;
42087
- this.perspectiveCamera.position.copy(p);
42088
- this.perspectiveCamera.lookAt(e);
42089
- const force = true;
42090
- this.setTransferPosition(p, force);
42091
- this.setTransferFov(f, force);
42092
43702
  const orbitControls = this.controlsMap.get(
42093
43703
  CONTROLS_TYPE_ORBIT
42094
43704
  );
42095
- orbitControls.setTarget(e);
42096
- orbitControls.syncCameraParameter();
42097
43705
  const flightControls = this.controlsMap.get(
42098
43706
  CONTROLS_TYPE_FLIGHT
42099
43707
  );
43708
+ if (position != null) {
43709
+ const p = new Vector3(position.x, position.y, position.z);
43710
+ this.setTransferPosition(p);
43711
+ this.perspectiveCamera.position.copy(p);
43712
+ }
43713
+ if (target != null) {
43714
+ const t = new Vector3(target.x, target.y, target.z);
43715
+ orbitControls.setTarget(t);
43716
+ this.perspectiveCamera.lookAt(t);
43717
+ }
43718
+ if (fov2 != null) {
43719
+ const force = true;
43720
+ this.setTransferFov(fov2, force);
43721
+ }
43722
+ orbitControls.syncCameraParameter();
42100
43723
  flightControls.syncCameraParameter();
42101
43724
  this.start();
42102
43725
  }
@@ -42211,43 +43834,6 @@ class Core extends EventEmitter {
42211
43834
  * orbit controls
42212
43835
  * ==========================================================================
42213
43836
  */
42214
- /**
42215
- * オービットコントロールの注視点の座標を取得する
42216
- * @returns 注視点の座標
42217
- */
42218
- getOrbitTarget() {
42219
- const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
42220
- const target = controls.getTarget();
42221
- return {
42222
- x: target.x,
42223
- y: target.y,
42224
- z: target.z
42225
- };
42226
- }
42227
- /**
42228
- * オービットコントロールの注視点と座標を設定する
42229
- * @param position - カメラの座標
42230
- * @param target - 注視点の座標
42231
- * setTransferPositionのみ呼び出した場合、見た目が変わらなかったため本関数を作成。
42232
- */
42233
- setOrbitPositionAndTarget(position, target) {
42234
- const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
42235
- this.perspectiveCamera.position.set(position.x, position.y, position.z);
42236
- controls.setTarget(new Vector3(target.x, target.y, target.z));
42237
- controls.syncCameraParameter();
42238
- this.transferControls.syncCameraParameter();
42239
- this.start();
42240
- }
42241
- /**
42242
- * オービットコントロールの注視点を設定する
42243
- * @param target - 注視点の座標
42244
- */
42245
- setOrbitTarget(target) {
42246
- const controls = this.controlsMap.get(CONTROLS_TYPE_ORBIT);
42247
- controls.setTarget(new Vector3(target.x, target.y, target.z));
42248
- controls.syncCameraParameter();
42249
- this.start();
42250
- }
42251
43837
  /**
42252
43838
  * オービットコントロールのズーム使用可否を設定する
42253
43839
  * @param enable - 使用可否を意味する真偽値
@@ -42694,6 +44280,14 @@ class Core extends EventEmitter {
42694
44280
  p.z += position.z;
42695
44281
  this.transferControls.setPosition(p, isForce);
42696
44282
  }
44283
+ /**
44284
+ * TransferControls に fov を設定する
44285
+ * @param fov - 設定する fov
44286
+ * @param isForce - トランジションせず即座に強制上書きするかどうか
44287
+ */
44288
+ setTransferFov(fov2, isForce) {
44289
+ this.transferControls.setFov(fov2, isForce);
44290
+ }
42697
44291
  /**
42698
44292
  * TransferControls に、現在の位置と向きに応じて移動するよう設定する
42699
44293
  * @param offset - 移動する量
@@ -42731,14 +44325,6 @@ class Core extends EventEmitter {
42731
44325
  moveTransferToBottom(scale, isForce) {
42732
44326
  this.transferControls.moveToBottom(scale, isForce);
42733
44327
  }
42734
- /**
42735
- * TransferControls に fov を設定する
42736
- * @param fov - 設定する fov
42737
- * @param isForce - トランジションせず即座に強制上書きするかどうか
42738
- */
42739
- setTransferFov(fov2, isForce) {
42740
- this.transferControls.setFov(fov2, isForce);
42741
- }
42742
44328
  /**
42743
44329
  * ==========================================================================
42744
44330
  * camera collider
@@ -42785,6 +44371,21 @@ class Core extends EventEmitter {
42785
44371
  });
42786
44372
  });
42787
44373
  }
44374
+ /**
44375
+ * MaterialGenerator で独自に拡張した uniform 変数を更新する
44376
+ * @param customUniforms - 設定・更新する uniform 変数
44377
+ */
44378
+ setCustomUniforms(customUniforms) {
44379
+ const uniforms = {};
44380
+ Object.entries(customUniforms).forEach(([k, v]) => {
44381
+ const _v = v;
44382
+ uniforms[k] = _v.value;
44383
+ });
44384
+ this.meshMap.forEach((mesh) => {
44385
+ mesh.setUniforms(uniforms);
44386
+ });
44387
+ this.start();
44388
+ }
42788
44389
  /**
42789
44390
  * ガウシアンの大きさの基本係数を設定する
42790
44391
  * @param value - 設定する係数(0.0 to 1.0)