@doki-land/live2d 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/l2d.umd.js CHANGED
@@ -40,18 +40,18 @@
40
40
  `,L,N),N},Qr.prototype.updateParam=function(l){try{for(var w=!1,$=0;$<this.motions.length;$++){var L=this.motions[$];if(L==null){this.motions.splice($,1),$--;continue}var O=L._$w0;if(O==null){this.motions=this.motions.splice($,1),$--;continue}O.updateParam(l,L),w=!0,L.isFinished()&&(this._$eb&&h._$Ji(`MotionQueueManager[size:%2d]->updateParam() / _$T0 _$w0 (m%d)
41
41
  `,this.motions.length-1,L._$sr),this.motions.splice($,1),$--)}return w}catch(N){return h._$li(N),!0}},Qr.prototype.isFinished=function(l){if(arguments.length>=1){for(var w=0;w<this.motions.length;w++){var $=this.motions[w];if($!=null&&$._$sr==l&&!$.isFinished())return!1}return!0}else{for(var w=0;w<this.motions.length;w++){var $=this.motions[w];if($==null){this.motions.splice(w,1),w--;continue}var L=$._$w0;if(L==null){this.motions.splice(w,1),w--;continue}if(!$.isFinished())return!1}return!0}},Qr.prototype.stopAllMotions=function(){for(var l=0;l<this.motions.length;l++){var w=this.motions[l];if(w==null){this.motions.splice(l,1),l--;continue}var $=w._$w0;if($==null){this.motions.splice(l,1),l--;continue}this.motions.splice(l,1),l--}},Qr.prototype._$Zr=function(l){this._$eb=l},Qr.prototype._$e=function(){console.log(`-- _$R --
42
42
  `);for(var l=0;l<this.motions.length;l++){var w=this.motions[l],$=w._$w0;console.log(`MotionQueueEnt[%d] :: %s
43
- `,this.motions.length,$.toString())}};function Tt(){this._$w0=null,this._$AT=!0,this._$9L=!1,this._$z2=-1,this._$bs=-1,this._$Do=-1,this._$sr=null,this._$sr=Tt._$Gs++}Tt._$Gs=0,Tt.prototype.isFinished=function(){return this._$9L},Tt.prototype._$qS=function(l){var w=pt.getUserTimeMSec(),$=w+l;(this._$Do<0||$<this._$Do)&&(this._$Do=$)},Tt.prototype._$Bs=function(){return this._$sr};function $t(){this.m=new Array(1,0,0,0,1,0,0,0,1)}$t.prototype.setContext=function(l){var w=this.m;l.transform(w[0],w[1],w[3],w[4],w[6],w[7])},$t.prototype.toString=function(){for(var l="LDTransform { ",w=0;w<9;w++)l+=this.m[w].toFixed(2)+" ,";return l+=" }",l},$t.prototype.identity=function(){var l=this.m;l[0]=l[4]=l[8]=1,l[1]=l[2]=l[3]=l[5]=l[6]=l[7]=0},$t.prototype._$PS=function(l,w,$){$==null&&($=new Array(0,0));var L=this.m;return $[0]=L[0]*l+L[3]*w+L[6],$[1]=L[1]*l+L[4]*w+L[7],$},$t.prototype._$P2=function(l){l||(l=new $t);var w=this.m,$=w[0],L=w[1],O=w[2],N=w[3],e=w[4],H=w[5],W=w[6],rt=w[7],I=w[8],ct=$*e*I+L*H*W+O*N*rt-$*H*rt-O*e*W-L*N*I;if(ct==0)return null;var j=1/ct;return l.m[0]=j*(e*I-rt*H),l.m[1]=j*(rt*O-L*I),l.m[2]=j*(L*H-e*O),l.m[3]=j*(W*H-N*I),l.m[4]=j*($*I-W*O),l.m[5]=j*(N*O-$*H),l.m[6]=j*(N*rt-W*e),l.m[7]=j*(W*L-$*rt),l.m[8]=j*($*e-N*L),l},$t.prototype.transform=function(l,w,$){$==null&&($=new Array(0,0));var L=this.m;return $[0]=L[0]*l+L[3]*w+L[6],$[1]=L[1]*l+L[4]*w+L[7],$},$t.prototype.translate=function(l,w){var $=this.m;$[6]=$[0]*l+$[3]*w+$[6],$[7]=$[1]*l+$[4]*w+$[7],$[8]=$[2]*l+$[5]*w+$[8]},$t.prototype.scale=function(l,w){var $=this.m;$[0]*=l,$[1]*=l,$[2]*=l,$[3]*=w,$[4]*=w,$[5]*=w},$t.prototype.shear=function(l,w){var $=this.m,L=$[0]+$[3]*w,O=$[1]+$[4]*w,N=$[2]+$[5]*w;$[3]=$[0]*l+$[3],$[4]=$[1]*l+$[4],$[5]=$[2]*l+$[5],$[0]=L,$[1]=O,$[2]=N},$t.prototype.rotate=function(l){var w=this.m,$=Math.cos(l),L=Math.sin(l),O=w[0]*$+w[3]*L,N=w[1]*$+w[4]*L,e=w[2]*$+w[5]*L;w[3]=-w[0]*L+w[3]*$,w[4]=-w[1]*L+w[4]*$,w[5]=-w[2]*L+w[5]*$,w[0]=O,w[1]=N,w[2]=e},$t.prototype.concatenate=function(l){var w=this.m,$=l.m,L=w[0]*$[0]+w[3]*$[1]+w[6]*$[2],O=w[1]*$[0]+w[4]*$[1]+w[7]*$[2],N=w[2]*$[0]+w[5]*$[1]+w[8]*$[2],e=w[0]*$[3]+w[3]*$[4]+w[6]*$[5],H=w[1]*$[3]+w[4]*$[4]+w[7]*$[5],W=w[2]*$[3]+w[5]*$[4]+w[8]*$[5],rt=w[0]*$[6]+w[3]*$[7]+w[6]*$[8],I=w[1]*$[6]+w[4]*$[7]+w[7]*$[8],ct=w[2]*$[6]+w[5]*$[7]+w[8]*$[8];m[0]=L,m[1]=O,m[2]=N,m[3]=e,m[4]=H,m[5]=W,m[6]=rt,m[7]=I,m[8]=ct};function at(l){zt||vr.prototype.constructor.call(this,l)}at.prototype=new vr,at._$eT=null,at._$tP=new Object,at._$2o=function(){return at._$eT==null&&(at._$eT=at.getID("DST_BASE")),at._$eT},at._$27=function(){at._$tP.clear(),at._$eT=null},at.getID=function(l){var w=at._$tP[l];return w==null&&(w=new at(l),at._$tP[l]=w),w},at.prototype._$3s=function(){return new at};function lt(l){zt||(wt.prototype.constructor.call(this),this.textures=new Array,this.transform=null,this.gl=null,this.glno=l,this.firstDraw=!0,this.anisotropyExt=null,this.maxAnisotropy=0,this._$As=32,this._$Gr=!1,this._$NT=null,this._$vS=null,this._$no=null,this.vertShader=null,this.fragShader=null,this.vertShaderOff=null,this.fragShaderOff=null)}lt.prototype=new wt,lt._$9r=function(l){var w=new Float32Array(l);return w},lt._$vb=function(l){var w=new Int16Array(l);return w},lt._$cr=function(l,w){return l==null||l._$yL()<w.length?(l=lt._$9r(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},lt._$mb=function(l,w){return l==null||l._$yL()<w.length?(l=lt._$vb(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},lt._$Hs=function(){return this._$Gr},lt._$as=function(l){this._$Gr=l},lt.prototype.getGL=function(){return this.gl},lt.prototype.setGL=function(l){this.gl=l},lt.prototype.setTransform=function(l){this.transform=l},lt.prototype._$ZT=function(){var l=this.gl;this.firstDraw&&(this.initShader(),this.firstDraw=!1,this.anisotropyExt=l.getExtension("EXT_texture_filter_anisotropic")||l.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||l.getExtension("MOZ_EXT_texture_filter_anisotropic"),this.anisotropyExt&&(this.maxAnisotropy=l.getParameter(this.anisotropyExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),l.disable(l.SCISSOR_TEST),l.disable(l.STENCIL_TEST),l.disable(l.DEPTH_TEST),l.frontFace(l.CW),l.enable(l.BLEND),l.colorMask(1,1,1,1),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)},lt.prototype._$Uo=function(l,w,$,L,O,N,e,H){if(!(N<.01&&this.clipBufPre_clipContextMask==null)){N>.9&&Pt.EXPAND_W;var W=this.gl;if(this.gl==null)throw new Error("gl is null");var rt=!1,I=1,ct=1,j=1,v=this._$C0*I*N,St=this._$tT*ct*N,yt=this._$WL*j*N,Mt=this._$lT*N;if(this.clipBufPre_clipContextMask!=null){W.frontFace(W.CCW),W.useProgram(this.shaderProgram),this._$vS=Wt(W,this._$vS,L),this._$no=Ae(W,this._$no,$),W.enableVertexAttribArray(this.a_position_Loc),W.vertexAttribPointer(this.a_position_Loc,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc,1),W.enableVertexAttribArray(this.a_texCoord_Loc),W.vertexAttribPointer(this.a_texCoord_Loc,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_matrix_Loc,!1,this.getClipBufPre_clipContextMask().matrixForMask);var Ft=this.getClipBufPre_clipContextMask().layoutChannelNo,Nt=this.getChannelFlagAsColor(Ft);W.uniform4f(this.u_channelFlag,Nt.r,Nt.g,Nt.b,Nt.a);var Lt=this.getClipBufPre_clipContextMask().layoutBounds;W.uniform4f(this.u_baseColor_Loc,Lt.x*2-1,Lt.y*2-1,Lt._$EL()*2-1,Lt._$5T()*2-1),W.uniform1i(this.u_maskFlag_Loc,!0)}else if(rt=this.getClipBufPre_clipContextDraw()!=null,rt){W.useProgram(this.shaderProgramOff),this._$vS=Wt(W,this._$vS,L),this._$no=Ae(W,this._$no,$),W.enableVertexAttribArray(this.a_position_Loc_Off),W.vertexAttribPointer(this.a_position_Loc_Off,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc_Off,1),W.enableVertexAttribArray(this.a_texCoord_Loc_Off),W.vertexAttribPointer(this.a_texCoord_Loc_Off,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_clipMatrix_Loc_Off,!1,this.getClipBufPre_clipContextDraw().matrixForDraw),W.uniformMatrix4fv(this.u_matrix_Loc_Off,!1,this.matrix4x4),W.activeTexture(W.TEXTURE2),W.bindTexture(W.TEXTURE_2D,Pt.fTexture[this.glno]),W.uniform1i(this.s_texture1_Loc_Off,2);var Ft=this.getClipBufPre_clipContextDraw().layoutChannelNo,Nt=this.getChannelFlagAsColor(Ft);W.uniform4f(this.u_channelFlag_Loc_Off,Nt.r,Nt.g,Nt.b,Nt.a),W.uniform4f(this.u_baseColor_Loc_Off,v,St,yt,Mt)}else W.useProgram(this.shaderProgram),this._$vS=Wt(W,this._$vS,L),this._$no=Ae(W,this._$no,$),W.enableVertexAttribArray(this.a_position_Loc),W.vertexAttribPointer(this.a_position_Loc,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc,1),W.enableVertexAttribArray(this.a_texCoord_Loc),W.vertexAttribPointer(this.a_texCoord_Loc,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_matrix_Loc,!1,this.matrix4x4),W.uniform4f(this.u_baseColor_Loc,v,St,yt,Mt),W.uniform1i(this.u_maskFlag_Loc,!1);this.culling?this.gl.enable(W.CULL_FACE):this.gl.disable(W.CULL_FACE),this.gl.enable(W.BLEND);var re,Zt,K,Vt;if(this.clipBufPre_clipContextMask!=null)re=W.ONE,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ONE,Vt=W.ONE_MINUS_SRC_ALPHA;else switch(e){case Xe._$ms:re=W.ONE,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ONE,Vt=W.ONE_MINUS_SRC_ALPHA;break;case Xe._$ns:re=W.ONE,Zt=W.ONE,K=W.ZERO,Vt=W.ONE;break;case Xe._$_s:re=W.DST_COLOR,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ZERO,Vt=W.ONE;break}W.blendEquationSeparate(W.FUNC_ADD,W.FUNC_ADD),W.blendFuncSeparate(re,Zt,K,Vt),this.anisotropyExt&&W.texParameteri(W.TEXTURE_2D,this.anisotropyExt.TEXTURE_MAX_ANISOTROPY_EXT,this.maxAnisotropy);var jt=$.length;W.drawElements(W.TRIANGLES,jt,W.UNSIGNED_SHORT,0),W.bindTexture(W.TEXTURE_2D,null)}};function Wt(l,w,$){return w==null&&(w=l.createBuffer()),l.bindBuffer(l.ARRAY_BUFFER,w),l.bufferData(l.ARRAY_BUFFER,$,l.DYNAMIC_DRAW),w}function Ae(l,w,$){return w==null&&(w=l.createBuffer()),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,w),l.bufferData(l.ELEMENT_ARRAY_BUFFER,$,l.DYNAMIC_DRAW),w}lt.prototype._$Rs=function(){throw new Error("_$Rs")},lt.prototype._$Ds=function(l){throw new Error("_$Ds")},lt.prototype._$K2=function(){for(var l=0;l<this.textures.length;l++){var w=this.textures[l];w!=0&&(this.gl._$K2(1,this.textures,l),this.textures[l]=null)}},lt.prototype.setTexture=function(l,w){this.textures[l]=w},lt.prototype.initShader=function(){var l=this.gl;this.loadShaders2(),this.a_position_Loc=l.getAttribLocation(this.shaderProgram,"a_position"),this.a_texCoord_Loc=l.getAttribLocation(this.shaderProgram,"a_texCoord"),this.u_matrix_Loc=l.getUniformLocation(this.shaderProgram,"u_mvpMatrix"),this.s_texture0_Loc=l.getUniformLocation(this.shaderProgram,"s_texture0"),this.u_channelFlag=l.getUniformLocation(this.shaderProgram,"u_channelFlag"),this.u_baseColor_Loc=l.getUniformLocation(this.shaderProgram,"u_baseColor"),this.u_maskFlag_Loc=l.getUniformLocation(this.shaderProgram,"u_maskFlag"),this.a_position_Loc_Off=l.getAttribLocation(this.shaderProgramOff,"a_position"),this.a_texCoord_Loc_Off=l.getAttribLocation(this.shaderProgramOff,"a_texCoord"),this.u_matrix_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_mvpMatrix"),this.u_clipMatrix_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_ClipMatrix"),this.s_texture0_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"s_texture0"),this.s_texture1_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"s_texture1"),this.u_channelFlag_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_channelFlag"),this.u_baseColor_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_baseColor")},lt.prototype.disposeShader=function(){var l=this.gl;this.shaderProgram&&(l.deleteProgram(this.shaderProgram),this.shaderProgram=null),this.shaderProgramOff&&(l.deleteProgram(this.shaderProgramOff),this.shaderProgramOff=null)},lt.prototype.compileShader=function(l,w){var $=this.gl,N,L=w,O=$.createShader(l);if(O==null)return h._$Ji("_$L0 to create shader"),null;$.shaderSource(O,L),$.compileShader(O);var N=$.getShaderParameter(O,$.COMPILE_STATUS);if(!N){var e=$.getShaderInfoLog(O);return h._$Ji("_$L0 to compile shader : "+e),$.deleteShader(O),null}return O},lt.prototype.loadShaders2=function(){var l=this.gl;if(this.shaderProgram=l.createProgram(),!this.shaderProgram||(this.shaderProgramOff=l.createProgram(),!this.shaderProgramOff))return!1;var w="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform mat4 u_mvpMatrix;void main(){ gl_Position = u_mvpMatrix * a_position; v_ClipPos = u_mvpMatrix * a_position; v_texCoord = a_texCoord;}",$="precision mediump float;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform sampler2D s_texture0;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform bool u_maskFlag;void main(){ vec4 smpColor; if(u_maskFlag){ float isInside = step(u_baseColor.x, v_ClipPos.x/v_ClipPos.w) * step(u_baseColor.y, v_ClipPos.y/v_ClipPos.w) * step(v_ClipPos.x/v_ClipPos.w, u_baseColor.z) * step(v_ClipPos.y/v_ClipPos.w, u_baseColor.w); smpColor = u_channelFlag * texture2D(s_texture0 , v_texCoord).a * isInside; }else{ smpColor = texture2D(s_texture0 , v_texCoord) * u_baseColor; } gl_FragColor = smpColor;}",L="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform mat4 u_mvpMatrix;uniform mat4 u_ClipMatrix;void main(){ gl_Position = u_mvpMatrix * a_position; v_ClipPos = u_ClipMatrix * a_position; v_texCoord = a_texCoord ;}",O="precision mediump float ;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor ;void main(){ vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor; vec4 clipMask = texture2D(s_texture1, v_ClipPos.xy / v_ClipPos.w) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}";if(this.vertShader=this.compileShader(l.VERTEX_SHADER,w),!this.vertShader)return h._$Ji("Vertex shader compile _$li!"),!1;if(this.vertShaderOff=this.compileShader(l.VERTEX_SHADER,L),!this.vertShaderOff)return h._$Ji("OffVertex shader compile _$li!"),!1;if(this.fragShader=this.compileShader(l.FRAGMENT_SHADER,$),!this.fragShader)return h._$Ji("Fragment shader compile _$li!"),!1;if(this.fragShaderOff=this.compileShader(l.FRAGMENT_SHADER,O),!this.fragShaderOff)return h._$Ji("OffFragment shader compile _$li!"),!1;l.attachShader(this.shaderProgram,this.vertShader),l.attachShader(this.shaderProgram,this.fragShader),l.attachShader(this.shaderProgramOff,this.vertShaderOff),l.attachShader(this.shaderProgramOff,this.fragShaderOff),l.linkProgram(this.shaderProgram),l.linkProgram(this.shaderProgramOff);var N=l.getProgramParameter(this.shaderProgram,l.LINK_STATUS);if(!N){var e=l.getProgramInfoLog(this.shaderProgram);return h._$Ji("_$L0 to link program: "+e),this.vertShader&&(l.deleteShader(this.vertShader),this.vertShader=0),this.fragShader&&(l.deleteShader(this.fragShader),this.fragShader=0),this.shaderProgram&&(l.deleteProgram(this.shaderProgram),this.shaderProgram=0),this.vertShaderOff&&(l.deleteShader(this.vertShaderOff),this.vertShaderOff=0),this.fragShaderOff&&(l.deleteShader(this.fragShaderOff),this.fragShaderOff=0),this.shaderProgramOff&&(l.deleteProgram(this.shaderProgramOff),this.shaderProgramOff=0),!1}return!0},lt.prototype.createFramebuffer=function(){var l=this.gl,w=Pt.clippingMaskBufferSize,$=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,$);var L=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,L),l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,w,w),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.RENDERBUFFER,L);var O=l.createTexture();return l.bindTexture(l.TEXTURE_2D,O),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,w,w,0,l.RGBA,l.UNSIGNED_BYTE,null),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,O,0),l.bindTexture(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),l.bindFramebuffer(l.FRAMEBUFFER,null),Pt.fTexture[this.glno]=O,{framebuffer:$,renderbuffer:L,texture:Pt.fTexture[this.glno]}};function de(l){zt||(this._$P=new Int8Array(8),this._$R0=new DataView(this._$P.buffer),this._$3i=new Int8Array(1e3),this._$hL=0,this._$v0=0,this._$S2=0,this._$Ko=new Array,this._$T=l,this._$F=0)}de.prototype._$fP=function(){var l=this._$ST(),w,$,L;if((l&128)==0)return l&255;if(((w=this._$ST())&128)==0)return(l&127)<<7|w&127;if((($=this._$ST())&128)==0)return(l&127)<<14|(w&127)<<7|$&255;if(((L=this._$ST())&128)==0)return(l&127)<<21|(w&127)<<14|($&127)<<7|L&255;throw new Hr("_$L _$0P _")},de.prototype.getFormatVersion=function(){return this._$S2},de.prototype._$gr=function(l){this._$S2=l},de.prototype._$3L=function(){return this._$fP()},de.prototype._$mP=function(){return this._$zT(),this._$F+=8,this._$T.getFloat64(this._$F-8)},de.prototype._$_T=function(){return this._$zT(),this._$F+=4,this._$T.getFloat32(this._$F-4)},de.prototype._$6L=function(){return this._$zT(),this._$F+=4,this._$T.getInt32(this._$F-4)},de.prototype._$ST=function(){return this._$zT(),this._$T.getInt8(this._$F++)},de.prototype._$9T=function(){return this._$zT(),this._$F+=2,this._$T.getInt16(this._$F-2)},de.prototype._$2T=function(){throw this._$zT(),this._$F+=8,new Hr("_$L _$q read long")},de.prototype._$po=function(){return this._$zT(),this._$T.getInt8(this._$F++)!=0};var Yt=!0;de.prototype._$bT=function(){this._$zT();var l=this._$3L(),w=null;if(Yt)try{var $=new ArrayBuffer(l*2);w=new Uint16Array($);for(var L=0;L<l;++L)w[L]=this._$T.getUint8(this._$F++);return String.fromCharCode.apply(null,w)}catch{Yt=!1}try{var O=new Array;if(w==null)for(var L=0;L<l;++L)O[L]=this._$T.getUint8(this._$F++);else for(var L=0;L<l;++L)O[L]=w[L];return String.fromCharCode.apply(null,O)}catch(N){console.log("read utf8 / _$rT _$L0 !! : "+N)}},de.prototype._$cS=function(){this._$zT();for(var l=this._$3L(),w=new Int32Array(l),$=0;$<l;$++)w[$]=this._$T.getInt32(this._$F),this._$F+=4;return w},de.prototype._$Tb=function(){this._$zT();for(var l=this._$3L(),w=new Float32Array(l),$=0;$<l;$++)w[$]=this._$T.getFloat32(this._$F),this._$F+=4;return w},de.prototype._$5b=function(){this._$zT();for(var l=this._$3L(),w=new Float64Array(l),$=0;$<l;$++)w[$]=this._$T.getFloat64(this._$F),this._$F+=8;return w},de.prototype._$nP=function(){return this._$Jb(-1)},de.prototype._$Jb=function(l){if(this._$zT(),l<0&&(l=this._$3L()),l==ht._$7P){var w=this._$6L();if(0<=w&&w<this._$Ko.length)return this._$Ko[w];throw new Hr("_$sL _$4i @_$m0")}else{var $=this._$4b(l);return this._$Ko.push($),$}},de.prototype._$4b=function(l){if(l==0)return null;if(l==50){var w=this._$bT(),$=nt.getID(w);return $}else if(l==51){var w=this._$bT(),$=at.getID(w);return $}else if(l==134){var w=this._$bT(),$=T.getID(w);return $}else if(l==60){var w=this._$bT(),$=x.getID(w);return $}if(l>=48){var L=ht._$9o(l);return L!=null?(L._$F0(this),L):null}switch(l){case 1:return this._$bT();case 10:return this._$6L(),new n;case 11:return new Q(this._$mP(),this._$mP(),this._$mP(),this._$mP());case 12:return new Q(this._$_T(),this._$_T(),this._$_T(),this._$_T());case 13:return new et(this._$mP(),this._$mP());case 14:return new et(this._$_T(),this._$_T());case 15:for(var O=this._$3L(),$=new Array(O),N=0;N<O;N++)$[N]=this._$nP();return $;case 17:var $=new Y(this._$mP(),this._$mP(),this._$mP(),this._$mP(),this._$mP(),this._$mP());return $;case 21:return new A(this._$6L(),this._$6L(),this._$6L(),this._$6L());case 22:return new Rs(this._$6L(),this._$6L());case 23:throw new Error("_$L _$ro ");case 16:case 25:return this._$cS();case 26:return this._$5b();case 27:return this._$Tb();case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 18:case 19:case 20:case 24:case 28:throw new Hr("_$6 _$q : _$nP() of 2-9 ,18,19,20,24,28 : "+l);default:throw new Hr("_$6 _$q : _$nP() NO _$i : "+l)}},de.prototype._$8L=function(){return this._$hL==0?this._$v0=this._$ST():this._$hL==8&&(this._$v0=this._$ST(),this._$hL=0),(this._$v0>>7-this._$hL++&1)==1},de.prototype._$zT=function(){this._$hL!=0&&(this._$hL=0)};function ze(){}ze._$2S=Math.PI/180,ze._$bS=Math.PI/180,ze._$wS=180/Math.PI,ze._$NS=180/Math.PI,ze.PI_F=Math.PI,ze._$kT=[0,.012368,.024734,.037097,.049454,.061803,.074143,.086471,.098786,.111087,.12337,.135634,.147877,.160098,.172295,.184465,.196606,.208718,.220798,.232844,.244854,.256827,.268761,.280654,.292503,.304308,.316066,.327776,.339436,.351044,.362598,.374097,.385538,.396921,.408243,.419502,.430697,.441826,.452888,.463881,.474802,.485651,.496425,.507124,.517745,.528287,.538748,.549126,.559421,.56963,.579752,.589785,.599728,.609579,.619337,.629,.638567,.648036,.657406,.666676,.675843,.684908,.693867,.70272,.711466,.720103,.72863,.737045,.745348,.753536,.76161,.769566,.777405,.785125,.792725,.800204,.807561,.814793,.821901,.828884,.835739,.842467,.849066,.855535,.861873,.868079,.874153,.880093,.885898,.891567,.897101,.902497,.907754,.912873,.917853,.922692,.92739,.931946,.936359,.940629,.944755,.948737,.952574,.956265,.959809,.963207,.966457,.96956,.972514,.97532,.977976,.980482,.982839,.985045,.987101,.989006,.990759,.992361,.993811,.995109,.996254,.997248,.998088,.998776,.999312,.999694,.999924,1],ze._$92=function(l,w){var $=Math.atan2(l[1],l[0]),L=Math.atan2(w[1],w[0]);return ze._$tS($,L)},ze._$tS=function(l,w){for(var $=l-w;$<-Math.PI;)$+=2*Math.PI;for(;$>Math.PI;)$-=2*Math.PI;return $},ze._$9=function(l){return Math.sin(l)},ze.fcos=function(l){return Math.cos(l)};function Ye(l){zt||(this._$e0=null,this._$IP=null,this._$Us=null,this._$7s=null,this._$IS=[!1],this._$VS=null,this._$AT=!0,this.baseOpacity=1,this.clipBufPre_clipContext=null,this._$e0=l)}Ye.prototype._$u2=function(){return this._$IS[0]},Ye.prototype._$yo=function(){return this._$AT&&!this._$IS[0]},Ye.prototype._$GT=function(){return this._$e0};function Qt(){}Qt._$W2=0,Qt.SYSTEM_INFO=null,Qt.USER_AGENT=navigator.userAgent,Qt.isIPhone=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone},Qt.isIOS=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone||Qt.SYSTEM_INFO._isIPad},Qt.isAndroid=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isAndroid},Qt.getOSVersion=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO.version},Qt.getOS=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone||Qt.SYSTEM_INFO._isIPad?"iOS":Qt.SYSTEM_INFO._isAndroid?"Android":"_$Q0 OS"},Qt.setup=function(){var l=Qt.USER_AGENT;function w(O,N){for(var e=O.substring(N).split(/[ _,;\.]/),H=0,W=0;W<=2&&!isNaN(e[W]);W++){var rt=parseInt(e[W]);if(rt<0||rt>999){h._$li("err : "+rt+" @UtHtml5.setup()"),H=0;break}H+=rt*Math.pow(1e3,2-W)}return H}var $,L=Qt.SYSTEM_INFO={userAgent:l};if(($=l.indexOf("iPhone OS "))>=0)L.os="iPhone",L._isIPhone=!0,L.version=w(l,$+10);else if(($=l.indexOf("iPad"))>=0){if($=l.indexOf("CPU OS"),$<0){h._$li(" err : "+l+" @UtHtml5.setup()");return}L.os="iPad",L._isIPad=!0,L.version=w(l,$+7)}else($=l.indexOf("Android"))>=0?(L.os="Android",L._isAndroid=!0,L.version=w(l,$+8)):(L.os="-",L.version=-1)},window.UtSystem=pt,window.UtDebug=h,window.LDTransform=$t,window.LDGL=sr,window.Live2D=Pt,window.Live2DModelWebGL=hr,window.Live2DModelJS=Kt,window.Live2DMotion=Xt,window.MotionQueueManager=Qr,window.PhysicsHair=D,window.AMotion=o,window.PartsDataID=T,window.DrawDataID=nt,window.BaseDataID=at,window.ParamID=x,Pt.init();var zt=!1})();var Ds;(function(s){var t,r=function(){function C(){}return C.getVersion=function(){return T.ccall("csmGetVersion","number",[],[])},C.getLatestMocVersion=function(){return T.ccall("csmGetLatestMocVersion","number",[],[])},C.getMocVersion=function(x,M){return T.ccall("csmGetMocVersion","number",["number","number"],[x,M])},C.getLogFunction=function(){return T.ccall("csmGetLogFunction","number",[],[])},C.getSizeofModel=function(x){return T.ccall("csmGetSizeofModel","number",["number"],[x])},C.reviveMocInPlace=function(x,M){return T.ccall("csmReviveMocInPlace","number",["number","number"],[x,M])},C.initializeModelInPlace=function(x,M,D){return T.ccall("csmInitializeModelInPlace","number",["number","number","number"],[x,M,D])},C.hasMocConsistency=function(x,M){return T.ccall("csmHasMocConsistency","number",["number","number"],[x,M])},C.getParameterCount=function(x){return T.ccall("csmGetParameterCount","number",["number"],[x])},C.getParameterIds=function(x){return T.ccall("csmGetParameterIds","number",["number"],[x])},C.getParameterMinimumValues=function(x){return T.ccall("csmGetParameterMinimumValues","number",["number"],[x])},C.getParameterTypes=function(x){return T.ccall("csmGetParameterTypes","number",["number"],[x])},C.getParameterMaximumValues=function(x){return T.ccall("csmGetParameterMaximumValues","number",["number"],[x])},C.getParameterDefaultValues=function(x){return T.ccall("csmGetParameterDefaultValues","number",["number"],[x])},C.getParameterValues=function(x){return T.ccall("csmGetParameterValues","number",["number"],[x])},C.getParameterKeyCounts=function(x){return T.ccall("csmGetParameterKeyCounts","number",["number"],[x])},C.getParameterKeyValues=function(x){return T.ccall("csmGetParameterKeyValues","number",["number"],[x])},C.getPartCount=function(x){return T.ccall("csmGetPartCount","number",["number"],[x])},C.getPartIds=function(x){return T.ccall("csmGetPartIds","number",["number"],[x])},C.getPartOpacities=function(x){return T.ccall("csmGetPartOpacities","number",["number"],[x])},C.getPartParentPartIndices=function(x){return T.ccall("csmGetPartParentPartIndices","number",["number"],[x])},C.getDrawableCount=function(x){return T.ccall("csmGetDrawableCount","number",["number"],[x])},C.getDrawableIds=function(x){return T.ccall("csmGetDrawableIds","number",["number"],[x])},C.getDrawableConstantFlags=function(x){return T.ccall("csmGetDrawableConstantFlags","number",["number"],[x])},C.getDrawableDynamicFlags=function(x){return T.ccall("csmGetDrawableDynamicFlags","number",["number"],[x])},C.getDrawableTextureIndices=function(x){return T.ccall("csmGetDrawableTextureIndices","number",["number"],[x])},C.getDrawableDrawOrders=function(x){return T.ccall("csmGetDrawableDrawOrders","number",["number"],[x])},C.getDrawableRenderOrders=function(x){return T.ccall("csmGetDrawableRenderOrders","number",["number"],[x])},C.getDrawableOpacities=function(x){return T.ccall("csmGetDrawableOpacities","number",["number"],[x])},C.getDrawableMaskCounts=function(x){return T.ccall("csmGetDrawableMaskCounts","number",["number"],[x])},C.getDrawableMasks=function(x){return T.ccall("csmGetDrawableMasks","number",["number"],[x])},C.getDrawableVertexCounts=function(x){return T.ccall("csmGetDrawableVertexCounts","number",["number"],[x])},C.getDrawableVertexPositions=function(x){return T.ccall("csmGetDrawableVertexPositions","number",["number"],[x])},C.getDrawableVertexUvs=function(x){return T.ccall("csmGetDrawableVertexUvs","number",["number"],[x])},C.getDrawableIndexCounts=function(x){return T.ccall("csmGetDrawableIndexCounts","number",["number"],[x])},C.getDrawableIndices=function(x){return T.ccall("csmGetDrawableIndices","number",["number"],[x])},C.getDrawableMultiplyColors=function(x){return T.ccall("csmGetDrawableMultiplyColors","number",["number"],[x])},C.getDrawableScreenColors=function(x){return T.ccall("csmGetDrawableScreenColors","number",["number"],[x])},C.getDrawableParentPartIndices=function(x){return T.ccall("csmGetDrawableParentPartIndices","number",["number"],[x])},C.mallocMoc=function(x){return T.ccall("csmMallocMoc","number",["number"],[x])},C.mallocModelAndInitialize=function(x){return T.ccall("csmMallocModelAndInitialize","number",["number"],[x])},C.malloc=function(x){return T.ccall("csmMalloc","number",["number"],[x])},C.setLogFunction=function(x){T.ccall("csmSetLogFunction",null,["number"],[x])},C.updateModel=function(x){T.ccall("csmUpdateModel",null,["number"],[x])},C.readCanvasInfo=function(x,M,D,k){T.ccall("csmReadCanvasInfo",null,["number","number","number","number"],[x,M,D,k])},C.resetDrawableDynamicFlags=function(x){T.ccall("csmResetDrawableDynamicFlags",null,["number"],[x])},C.free=function(x){T.ccall("csmFree",null,["number"],[x])},C.initializeAmountOfMemory=function(x){T.ccall("csmInitializeAmountOfMemory",null,["number"],[x])},C}(),f=(s.AlignofMoc=64,s.AlignofModel=16,s.MocVersion_Unknown=0,s.MocVersion_30=1,s.MocVersion_33=2,s.MocVersion_40=3,s.MocVersion_42=4,s.MocVersion_50=5,s.ParameterType_Normal=0,s.ParameterType_BlendShape=1,function(){function C(){}return C.csmGetVersion=function(){return r.getVersion()},C.csmGetLatestMocVersion=function(){return r.getLatestMocVersion()},C.csmGetMocVersion=function(x,M){return r.getMocVersion(x._ptr,M.byteLength)},C}()),f=(s.Version=f,function(){function C(){}return C.csmSetLogFunction=function(x){C.logFunction=x,x=T.addFunction(C.wrapLogFunction,"vi"),r.setLogFunction(x)},C.csmGetLogFunction=function(){return C.logFunction},C.wrapLogFunction=function(x){x=T.UTF8ToString(x),C.logFunction(x)},C}()),f=(s.Logging=f,function(){function C(x){var M=r.mallocMoc(x.byteLength);M&&(new Uint8Array(T.HEAPU8.buffer,M,x.byteLength).set(new Uint8Array(x)),this._ptr=r.reviveMocInPlace(M,x.byteLength),this._ptr||r.free(M))}return C.prototype.hasMocConsistency=function(x){var M=r.mallocMoc(x.byteLength);if(M)return new Uint8Array(T.HEAPU8.buffer,M,x.byteLength).set(new Uint8Array(x)),x=r.hasMocConsistency(M,x.byteLength),r.free(M),x},C.fromArrayBuffer=function(x){return x&&(x=new C(x))._ptr?x:null},C.prototype._release=function(){r.free(this._ptr),this._ptr=0},C}()),f=(s.Moc=f,function(){function C(x){this._ptr=r.mallocModelAndInitialize(x._ptr),this._ptr&&(this.parameters=new n(this._ptr),this.parts=new o(this._ptr),this.drawables=new h(this._ptr),this.canvasinfo=new i(this._ptr))}return C.fromMoc=function(x){return x=new C(x),x._ptr?x:null},C.prototype.update=function(){r.updateModel(this._ptr)},C.prototype.release=function(){r.free(this._ptr),this._ptr=0},C}()),i=(s.Model=f,function(C){var x,M,D,k,U,G,X;C&&(D=(x=new Float32Array(2)).length*x.BYTES_PER_ELEMENT,M=r.malloc(D),(M=new Uint8Array(T.HEAPU8.buffer,M,D)).set(new Uint8Array(x.buffer)),U=(D=new Float32Array(2)).length*D.BYTES_PER_ELEMENT,k=r.malloc(U),(k=new Uint8Array(T.HEAPU8.buffer,k,U)).set(new Uint8Array(D.buffer)),G=(U=new Float32Array(1)).length*U.BYTES_PER_ELEMENT,X=r.malloc(G),(X=new Uint8Array(T.HEAPU8.buffer,X,G)).set(new Uint8Array(U.buffer)),r.readCanvasInfo(C,M.byteOffset,k.byteOffset,X.byteOffset),x=new Float32Array(M.buffer,M.byteOffset,M.length),D=new Float32Array(k.buffer,k.byteOffset,k.length),U=new Float32Array(X.buffer,X.byteOffset,X.length),this.CanvasWidth=x[0],this.CanvasHeight=x[1],this.CanvasOriginX=D[0],this.CanvasOriginY=D[1],this.PixelsPerUnit=U[0],r.free(M.byteOffset),r.free(k.byteOffset),r.free(X.byteOffset))}),n=(s.CanvasInfo=i,function(C){this.count=r.getParameterCount(C),x=r.getParameterCount(C),this.ids=new Array(x);for(var x,M,D=new Uint32Array(T.HEAPU32.buffer,r.getParameterIds(C),x),k=0;k<D.length;k++)this.ids[k]=T.UTF8ToString(D[k]);x=r.getParameterCount(C),this.minimumValues=new Float32Array(T.HEAPF32.buffer,r.getParameterMinimumValues(C),x),x=r.getParameterCount(C),this.types=new Int32Array(T.HEAP32.buffer,r.getParameterTypes(C),x),x=r.getParameterCount(C),this.maximumValues=new Float32Array(T.HEAPF32.buffer,r.getParameterMaximumValues(C),x),x=r.getParameterCount(C),this.defaultValues=new Float32Array(T.HEAPF32.buffer,r.getParameterDefaultValues(C),x),x=r.getParameterCount(C),this.values=new Float32Array(T.HEAPF32.buffer,r.getParameterValues(C),x),x=r.getParameterCount(C),this.keyCounts=new Int32Array(T.HEAP32.buffer,r.getParameterKeyCounts(C),x),x=r.getParameterCount(C),M=new Int32Array(T.HEAP32.buffer,r.getParameterKeyCounts(C),x),this.keyValues=new Array(x);for(var U=new Uint32Array(T.HEAPU32.buffer,r.getParameterKeyValues(C),x),k=0;k<U.length;k++)this.keyValues[k]=new Float32Array(T.HEAPF32.buffer,U[k],M[k])}),o=(s.Parameters=n,function(C){this.count=r.getPartCount(C),x=r.getPartCount(C),this.ids=new Array(x);for(var x,M=new Uint32Array(T.HEAPU32.buffer,r.getPartIds(C),x),D=0;D<M.length;D++)this.ids[D]=T.UTF8ToString(M[D]);x=r.getPartCount(C),this.opacities=new Float32Array(T.HEAPF32.buffer,r.getPartOpacities(C),x),x=r.getPartCount(C),this.parentIndices=new Int32Array(T.HEAP32.buffer,r.getPartParentPartIndices(C),x)}),h=(s.Parts=o,function(){function C(x){this._modelPtr=x;for(var M,D=null,k=(this.count=r.getDrawableCount(x),M=r.getDrawableCount(x),this.ids=new Array(M),new Uint32Array(T.HEAPU32.buffer,r.getDrawableIds(x),M)),U=0;U<k.length;U++)this.ids[U]=T.UTF8ToString(k[U]);M=r.getDrawableCount(x),this.constantFlags=new Uint8Array(T.HEAPU8.buffer,r.getDrawableConstantFlags(x),M),M=r.getDrawableCount(x),this.dynamicFlags=new Uint8Array(T.HEAPU8.buffer,r.getDrawableDynamicFlags(x),M),M=r.getDrawableCount(x),this.textureIndices=new Int32Array(T.HEAP32.buffer,r.getDrawableTextureIndices(x),M),M=r.getDrawableCount(x),this.drawOrders=new Int32Array(T.HEAP32.buffer,r.getDrawableDrawOrders(x),M),M=r.getDrawableCount(x),this.renderOrders=new Int32Array(T.HEAP32.buffer,r.getDrawableRenderOrders(x),M),M=r.getDrawableCount(x),this.opacities=new Float32Array(T.HEAPF32.buffer,r.getDrawableOpacities(x),M),M=r.getDrawableCount(x),this.maskCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableMaskCounts(x),M),M=r.getDrawableCount(x),this.vertexCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),M),M=r.getDrawableCount(x),this.indexCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableIndexCounts(x),M),M=r.getDrawableCount(x),this.multiplyColors=new Float32Array(T.HEAPF32.buffer,r.getDrawableMultiplyColors(x),4*M),M=r.getDrawableCount(x),this.screenColors=new Float32Array(T.HEAPF32.buffer,r.getDrawableScreenColors(x),4*M),M=r.getDrawableCount(x),this.parentPartIndices=new Int32Array(T.HEAP32.buffer,r.getDrawableParentPartIndices(x),M),M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableMaskCounts(x),M),this.masks=new Array(M);for(var G=new Uint32Array(T.HEAPU32.buffer,r.getDrawableMasks(x),M),U=0;U<G.length;U++)this.masks[U]=new Int32Array(T.HEAP32.buffer,G[U],D[U]);M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),M),this.vertexPositions=new Array(M);for(var X=new Uint32Array(T.HEAPU32.buffer,r.getDrawableVertexPositions(x),M),U=0;U<X.length;U++)this.vertexPositions[U]=new Float32Array(T.HEAPF32.buffer,X[U],2*D[U]);M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),M),this.vertexUvs=new Array(M);for(var J=new Uint32Array(T.HEAPU32.buffer,r.getDrawableVertexUvs(x),M),U=0;U<J.length;U++)this.vertexUvs[U]=new Float32Array(T.HEAPF32.buffer,J[U],2*D[U]);M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableIndexCounts(x),M),this.indices=new Array(M);for(var Z=new Uint32Array(T.HEAPU32.buffer,r.getDrawableIndices(x),M),U=0;U<Z.length;U++)this.indices[U]=new Uint16Array(T.HEAPU16.buffer,Z[U],D[U])}return C.prototype.resetDynamicFlags=function(){r.resetDrawableDynamicFlags(this._modelPtr)},C}()),f=(s.Drawables=h,function(){function C(){}return C.hasBlendAdditiveBit=function(x){return(1&x)==1},C.hasBlendMultiplicativeBit=function(x){return(2&x)==2},C.hasIsDoubleSidedBit=function(x){return(4&x)==4},C.hasIsInvertedMaskBit=function(x){return(8&x)==8},C.hasIsVisibleBit=function(x){return(1&x)==1},C.hasVisibilityDidChangeBit=function(x){return(2&x)==2},C.hasOpacityDidChangeBit=function(x){return(4&x)==4},C.hasDrawOrderDidChangeBit=function(x){return(8&x)==8},C.hasRenderOrderDidChangeBit=function(x){return(16&x)==16},C.hasVertexPositionsDidChangeBit=function(x){return(32&x)==32},C.hasBlendColorDidChangeBit=function(x){return(64&x)==64},C}()),f=(s.Utils=f,function(){function C(){}return C.initializeAmountOfMemory=function(x){16777216<x&&r.initializeAmountOfMemory(x)},C}()),A=(s.Memory=f,t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,function(C){C=C||{};var x,M,D={};for(M in x=x||(C!==void 0?C:{}))x.hasOwnProperty(M)&&(D[M]=x[M]);var k,U,G,X,it=!1,J=typeof window=="object",Z=typeof importScripts=="function",it=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!J&&!Z,Q=!J&&!it&&!Z,Ar="",_t=(it?(Ar=__dirname+"/",G=function(Tt,$t){var at=Wr(Tt);return at||(k=k||require("fs"),Tt=(U=U||require("path")).normalize(Tt),at=k.readFileSync(Tt)),$t?at:at.toString()},X=function(Tt){return Ct((Tt=(Tt=G(Tt,!0)).buffer?Tt:new Uint8Array(Tt)).buffer),Tt},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(Tt){throw Tt}),process.on("unhandledRejection",Jt),x.inspect=function(){return"[Emscripten Module object]"}):Q?(typeof read<"u"&&(G=function(Tt){var $t=Wr(Tt);return $t?Fi($t):read(Tt)}),X=function(Tt){var $t;if(!($t=Wr(Tt))){if(typeof readbuffer=="function")return new Uint8Array(readbuffer(Tt));Ct(typeof($t=read(Tt,"binary"))=="object")}return $t},typeof print<"u"&&((console=typeof console>"u"?{}:console).log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)):(J||Z)&&(Z?Ar=self.location.href:document.currentScript&&(Ar=document.currentScript.src),Ar=(Ar=t||Ar).indexOf("blob:")!==0?Ar.substr(0,Ar.lastIndexOf("/")+1):"",G=function(Tt){try{var $t=new XMLHttpRequest;return $t.open("GET",Tt,!1),$t.send(null),$t.responseText}catch(at){if(Tt=Wr(Tt))return Fi(Tt);throw at}},Z)&&(X=function(Tt){try{var $t=new XMLHttpRequest;return $t.open("GET",Tt,!1),$t.responseType="arraybuffer",$t.send(null),new Uint8Array($t.response)}catch(at){if(Tt=Wr(Tt))return Tt;throw at}}),x.print||console.log.bind(console)),et=x.printErr||console.warn.bind(console);for(M in D)D.hasOwnProperty(M)&&(x[M]=D[M]);function ft(){return{exports:function(Tt,$t,at){var lt=new ArrayBuffer(8),Wt=new Int32Array(lt),Ae=new Float32Array(lt),de=new Float64Array(lt);function Yt(a,p){Wt[a]=p}function ze(){return de[0]}function Ye(a){de[0]=a}function Qt(a){Ae[0]=a}function zt(){return Ae[0]}lt=$t.buffer;var jt,l,w,$,L,O,N,e,H,W,rt,I,ct,j,v,St,yt,Mt,Ft,Nt,Lt,re,Zt,K,Vt,jt=new Uint8Array(lt);return(lt=function(a,p){var P,_;if(typeof Buffer>"u")for(P=atob(p),_=0;_<P.length;_++)jt[a+_]=P.charCodeAt(_);else for(P=Buffer.from(p,"base64"),_=0;_<P.length;_++)jt[a+_]=P[_]})(1024,"QW4gZXJyb3Igb2NjdXJyZWQgaW4gdGhlIGludGVycG9sYXRpb24gZm9yIGJsZW5kIHNoYXBlcy4gQ29tYmluYXRpb25Db3VudCBpcyAlZC4ACgBbQ1NNXSBbRV1XYXJwRGVmb3JtZXI6OlRyYW5zZm9ybVRhcmdldCgpIGVycm9yLiBbJWRdIHAwMT0oJS40ZiAsICUuNGYpCgBbQ1NNXSBbRV1Jbml0aWFsaXplRGVmb3JtZXJzKCk6IFVua25vd24gRGVmb3JtZXIgVHlwZS4KAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBUaGlzIG1vYzMgc2l6ZSBpcyBpbnZhbGlkLgoAW0NTTV0gW0VdJXM6ICVzCgBbQ1NNXSBbV11Sb3RhdGlvbkRlZm9ybWVyOiBOb3QgZm91bmQgdHJhbnNmb3JtZWQgRGlyZWN0aW9uLgoAW0NTTV0gW0VdVXBkYXRlRGVmb3JtZXJIaWVyYXJjaHkoKTogVW5rbm93biBEZWZvcm1lciBUeXBlLgoAJXMKACAgAE1PQzMAImFkZHJlc3MiIGlzIG51bGwuACUwMlggAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBGaWxlVHlwZSBpcyBpbnZhbGlkLgoAImFkZHJlc3MiIGFsaWdubWVudCBpcyBpbnZhbGlkLgBbQ1NNXSBbRV1jc21IYXNNb2NDb25zaXN0ZW5jeTogVGhpcyBtb2MzIHZlciBpcyBpbnZhbGlkIFt2ZXI6JWRdLgoAInNpemUiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBUaGUgQ29yZSB1bnN1cHBvcnQgbGF0ZXIgdGhhbiBtb2MzIHZlcjpbJWRdLiBUaGlzIG1vYzMgdmVyIGlzIFslZF0uCgAibW9kZWwiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBIZWFkZXIgc2VjdGlvbiBpcyBpbnZhbGlkLgoAIm91dFNpemVJblBpeGVscyIgaXMgbnVsbC4AW0NTTV0gW0VdY3NtSGFzTW9jQ29uc2lzdGVuY3k6IERhdGEgc2VjdGlvbiBpcyBpbnZhbGlkLgoAIm91dE9yaWdpbkluUGl4ZWxzIiBpcyBudWxsLgBbQ1NNXSBbRV1jc21SZXZpdmVNb2NJblBsYWNlIGlzIGZhaWxlZC4gQ29ycnVwdGVkICBtb2MzIGZpbGUuCgAib3V0UGl4ZWxzUGVyVW5pdCIgaXMgbnVsbC4AW0NTTV0gW0VdY3NtUmV2aXZlTW9jSW5QbGFjZSBpcyBmYWlsZWQuIFRoZSBDb3JlIHVuc3VwcG9ydCBsYXRlciB0aGFuIG1vYzMgdmVyOlslZF0uIFRoaXMgbW9jMyB2ZXIgaXMgWyVkXS4KACJtb2MiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUdldE1vY1ZlcnNpb24gaXMgZmFpbGVkLiBDb3JydXB0ZWQgbW9jMyBmaWxlLgoAInNpemUiIGlzIGludmFsaWQATGl2ZTJEIEN1YmlzbSBTREsgQ29yZSBWZXJzaW9uICVkLiVkLiVkAGNzbUdldE1vY1ZlcnNpb24AY3NtSGFzTW9jQ29uc2lzdGVuY3kAY3NtUmV2aXZlTW9jSW5QbGFjZQBjc21SZWFkQ2FudmFzSW5mbwBjc21HZXRTaXplb2ZNb2RlbABjc21Jbml0aWFsaXplTW9kZWxJblBsYWNlAGNzbVVwZGF0ZU1vZGVsAGNzbUdldFBhcmFtZXRlckNvdW50AGNzbUdldFBhcmFtZXRlcklkcwBjc21HZXRQYXJhbWV0ZXJUeXBlcwBjc21HZXRQYXJhbWV0ZXJNaW5pbXVtVmFsdWVzAGNzbUdldFBhcmFtZXRlck1heGltdW1WYWx1ZXMAY3NtR2V0UGFyYW1ldGVyRGVmYXVsdFZhbHVlcwBjc21HZXRQYXJhbWV0ZXJWYWx1ZXMAY3NtR2V0UGFydENvdW50AGNzbUdldFBhcnRJZHMAY3NtR2V0UGFydE9wYWNpdGllcwBjc21HZXRQYXJ0UGFyZW50UGFydEluZGljZXMAY3NtR2V0RHJhd2FibGVDb3VudABjc21HZXREcmF3YWJsZUlkcwBjc21HZXREcmF3YWJsZUNvbnN0YW50RmxhZ3MAY3NtR2V0RHJhd2FibGVEeW5hbWljRmxhZ3MAY3NtR2V0RHJhd2FibGVUZXh0dXJlSW5kaWNlcwBjc21HZXREcmF3YWJsZURyYXdPcmRlcnMAY3NtR2V0RHJhd2FibGVSZW5kZXJPcmRlcnMAY3NtR2V0RHJhd2FibGVPcGFjaXRpZXMAY3NtR2V0RHJhd2FibGVNYXNrQ291bnRzAGNzbUdldERyYXdhYmxlTWFza3MAY3NtR2V0RHJhd2FibGVWZXJ0ZXhDb3VudHMAY3NtR2V0RHJhd2FibGVWZXJ0ZXhQb3NpdGlvbnMAY3NtR2V0RHJhd2FibGVWZXJ0ZXhVdnMAY3NtR2V0RHJhd2FibGVJbmRleENvdW50cwBjc21HZXREcmF3YWJsZUluZGljZXMAY3NtR2V0RHJhd2FibGVNdWx0aXBseUNvbG9ycwBjc21HZXREcmF3YWJsZVNjcmVlbkNvbG9ycwBjc21HZXREcmF3YWJsZVBhcmVudFBhcnRJbmRpY2VzAGNzbVJlc2V0RHJhd2FibGVEeW5hbWljRmxhZ3MAY3NtR2V0UGFyYW1ldGVyS2V5Q291bnRzAGNzbUdldFBhcmFtZXRlcktleVZhbHVlcw=="),lt(3228,"Cg=="),lt(3267,"//////8="),lt(3336,"LSsgICAwWDB4AChudWxsKQ=="),lt(3360,"EQAKABEREQAAAAAFAAAAAAAACQAAAAAL"),lt(3392,"EQAPChEREQMKBwABEwkLCwAACQYLAAALAAYRAAAAERER"),lt(3441,"Cw=="),lt(3450,"EQAKChEREQAKAAACAAkLAAAACQALAAAL"),lt(3499,"DA=="),lt(3511,"DAAAAAAMAAAAAAkMAAAAAAAMAAAM"),lt(3557,"Dg=="),lt(3569,"DQAAAAQNAAAAAAkOAAAAAAAOAAAO"),lt(3615,"EA=="),lt(3627,"DwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhIS"),lt(3682,"EgAAABISEgAAAAAAAAk="),lt(3731,"Cw=="),lt(3743,"CgAAAAAKAAAAAAkLAAAAAAALAAAL"),lt(3789,"DA=="),lt(3801,"DAAAAAAMAAAAAAkMAAAAAAAMAAAMAAAwMTIzNDU2Nzg5QUJDREVGLTBYKzBYIDBYLTB4KzB4IDB4AGluZgBJTkYAbmFuAE5BTgAuAAAAAKgaAAAAAAAAAwAAAAQAAAAEAAAABgAAAIP5ogBETm4A/CkVANFXJwDdNPUAYtvAADyZlQBBkEMAY1H+ALveqwC3YcUAOm4kANJNQgBJBuAACeouAByS0QDrHf4AKbEcAOg+pwD1NYIARLsuAJzphAC0JnAAQX5fANaROQBTgzkAnPQ5AItfhAAo+b0A+B87AN7/lwAPmAUAES/vAApaiwBtH20Az342AAnLJwBGT7cAnmY/AC3qXwC6J3UA5evHAD178QD3OQcAklKKAPtr6gAfsV8ACF2NADADVgB7/EYA8KtrACC8zwA29JoA46kdAF5hkQAIG+YAhZllAKAUXwCNQGgAgNj/ACdzTQAGBjEAylYVAMmocwB74mAAa4zAABnERwDNZ8MACejcAFmDKgCLdsQAphyWAESv3QAZV9EApT4FAAUH/wAzfj8AwjLoAJhP3gC7fTIAJj3DAB5r7wCf+F4ANR86AH/yygDxhx0AfJAhAGokfADVbvoAMC13ABU7QwC1FMYAwxmdAK3EwgAsTUEADABdAIZ9RgDjcS0Am8aaADNiAAC00nwAtKeXADdV1QDXPvYAoxAYAE12/ABknSoAcNerAGN8+AB6sFcAFxXnAMBJVgA71tkAp4Q4ACQjywDWincAWlQjAAAfuQDxChsAGc7fAJ8x/wBmHmoAmVdhAKz7RwB+f9gAImW3ADLoiQDmv2AA78TNAGw2CQBdP9QAFt7XAFg73gDem5IA0iIoACiG6ADiWE0AxsoyAAjjFgDgfcsAF8BQAPMdpwAY4FsALhM0AIMSYgCDSAEA9Y5bAK2wfwAe6fIASEpDABBn0wCq3dgArl9CAGphzgAKKKQA05m0AAam8gBcd38Ao8KDAGE8iACKc3gAr4xaAG/XvQAtpmMA9L/LAI2B7wAmwWcAVcpFAMrZNgAoqNIAwmGNABLJdwAEJhQAEkabAMRZxADIxUQATbKRAAAX8wDUQ60AKUnlAP3VEAAAvvwAHpTMAHDO7gATPvUA7PGAALPnwwDH+CgAkwWUAMFxPgAuCbMAC0XzAIgSnACrIHsALrWfAEeSwgB7Mi8ADFVtAHKnkABr5x8AMcuWAHkWSgBBeeIA9N+JAOiUlwDi5oQAmTGXAIjtawBfXzYAu/0OAEiatABnpGwAcXJCAI1dMgCfFbgAvOUJAI0xJQD3dDkAMAUcAA0MAQBLCGgALO5YAEeqkAB05wIAvdYkAPd9pgBuSHIAnxbvAI6UpgC0kfYA0VNRAM8K8gAgmDMA9Ut+ALJjaADdPl8AQF0DAIWJfwBVUikAN2TAAG3YEAAySDIAW0x1AE5x1ABFVG4ACwnBACr1aQAUZtUAJwedAF0EUAC0O9sA6nbFAIf5FwBJa30AHSe6AJZpKQDGzKwArRRUAJDiagCI2YkALHJQAASkvgB3B5QA8zBwAAD8JwDqcagAZsJJAGTgPQCX3YMAoz+XAEOU/QANhowAMUHeAJI5nQDdcIwAF7fnAAjfOwAVNysAXICgAFqAkwAQEZIAD+jYAGyArwDb/0sAOJAPAFkYdgBipRUAYcu7AMeJuQAQQL0A0vIEAEl1JwDrtvYA2yK7AAoUqgCJJi8AZIN2AAk7MwAOlBoAUTqqAB2jwgCv7a4AXCYSAG3CTQAtepwAwFaXAAM/gwAJ8PYAK0CMAG0xmQA5tAcADCAVANjDWwD1ksQAxq1LAE7KpQCnN80A5qk2AKuSlADdQmgAGWPeAHaM7wBoi1IA/Ns3AK6hqwDfFTEAAK6hAAz72gBkTWYA7QW3ACllMABXVr8AR/86AGr5uQB1vvMAKJPfAKuAMABmjPYABMsVAPoiBgDZ5B0APbOkAFcbjwA2zQkATkLpABO+pAAzI7UA8KoaAE9lqADSwaUACz8PAFt4zQAj+XYAe4sEAIkXcgDGplMAb27iAO/rAACbSlgAxNq3AKpmugB2z88A0QIdALHxLQCMmcEAw613AIZI2gD3XaAAxoD0AKzwLwDd7JoAP1y8ANDebQCQxx8AKtu2AKMlOgAAr5oArVOTALZXBAApLbQAS4B+ANoHpwB2qg4Ae1mhABYSKgDcty0A+uX9AInb/gCJvv0A5HZsAAap/AA+gHAAhW4VAP2H/wAoPgcAYWczACoYhgBNveoAs+evAI9tbgCVZzkAMb9bAITXSAAw3xYAxy1DACVhNQDJcM4AMMu4AL9s/QCkAKIABWzkAFrdoAAhb0cAYhLSALlchABwYUkAa1bgAJlSAQBQVTcAHtW3ADPxxAATbl8AXTDkAIUuqQAdssMAoTI2AAi3pADqsdQAFvchAI9p5AAn/3cADAOAAI1ALQBPzaAAIKWZALOi0wAvXQoAtPlCABHaywB9vtAAm9vBAKsXvQDKooEACGpcAC5VFwAnAFUAfxTwAOEHhgAUC2QAlkGNAIe+3gDa/SoAayW2AHuJNAAF8/4Aub+eAGhqTwBKKqgAT8RaAC34vADXWpgA9MeVAA1NjQAgOqYApFdfABQ/sQCAOJUAzCABAHHdhgDJ3rYAv2D1AE1lEQABB2sAjLCsALLA0ABRVUgAHvsOAJVywwCjBjsAwEA1AAbcewDgRcwATin6ANbKyADo80EAfGTeAJtk2ADZvjEApJfDAHdY1ABp48UA8NoTALo6PABGGEYAVXVfANK99QBuksYArC5dAA5E7QAcPkIAYcSHACn96QDn1vMAInzKAG+RNQAI4MUA/9eNAG5q4gCw/cYAkwjBAHxddABrrbIAzW6dAD5yewDGEWoA98+pAClz3wC1yboAtwBRAOKyDQB0uiQA5X1gAHTYigANFSwAgRgMAH5mlAABKRYAn3p2AP39vgBWRe8A2X42AOzZEwCLurkAxJf8ADGoJwDxbsMAlMU2ANioVgC0qLUAz8wOABKJLQBvVzQALFaJAJnO4wDWILkAa16qAD4qnAARX8wA/QtKAOH0+wCOO20A4oYsAOnUhAD8tKkA7+7RAC41yQAvOWEAOCFEABvZyACB/AoA+0pqAC8c2ABTtIQATpmMAFQizAAqVdwAwMbWAAsZlgAacLgAaZVkACZaYAA/Uu4AfxEPAPS1EQD8y/UANLwtADS87gDoXcwA3V5gAGeOmwCSM+8AyRe4AGFYmwDhV7wAUYPGANg+EADdcUgALRzdAK8YoQAhLEYAWfPXANl6mACeVMAAT4b6AFYG/ADlea4AiSI2ADitIgBnk9wAVeiqAIImOADK55sAUQ2kAJkzsQCp1w4AaQVIAGWy8AB/iKcAiEyXAPnRNgAhkrMAe4JKAJjPIQBAn9wA3EdVAOF0OgBn60IA/p3fAF7UXwB7Z6QAuqx6AFX2ogAriCMAQbpVAFluCAAhKoYAOUeDAInj5gDlntQASftAAP9W6QAcD8oAxVmKAJT6KwDTwcUAD8XPANtargBHxYYAhUNiACGGOwAseZQAEGGHACpMewCALBoAQ78SAIgmkAB4PIkAqMTkAOXbewDEOsIAJvTqAPdnigANkr8AZaMrAD2TsQC9fAsApFHcACfdYwBp4d0AmpQZAKgplQBozigACe20AESfIABOmMoAcIJjAH58IwAPuTIAp/WOABRW5wAh8QgAtZ0qAG9+TQClGVEAtfmrAILf1gCW3WEAFjYCAMQ6nwCDoqEAcu1tADmNegCCuKkAazJcAEYnWwAANO0A0gB3APz0VQABWU0A4HGA"),lt(6675,"QPsh+T8AAAAALUR0PgAAAICYRvg8AAAAYFHMeDsAAACAgxvwOQAAAEAgJXo4AAAAgCKC4zYAAAAAHfNpNThj7T7aD0k/Xph7P9oPyT9pN6wxaCEiM7QPFDNoIaIz2w9JP9sPSb/kyxZA5MsWwAAAAAAAAACA2w9JQNsPScAAAIA/AADAPwAAAADcz9E1AAAAAADAFT8="),lt(6824,"BQ=="),lt(6836,"DQ=="),lt(6860,"DgAAAA8AAABYHAAAAAQ="),lt(6884,"AQ=="),lt(6899,"Cv////8="),lt(7156,"gCA="),l={Int8Array,Int16Array,Int32Array,Uint8Array,Uint16Array,Uint32Array,Float32Array,Float64Array,NaN:NaN,Infinity:1/0,Math},w=$t.buffer,$=(lt=Tt).memory,L=at,O=new l.Int8Array(w),N=new l.Int16Array(w),e=new l.Int32Array(w),H=new l.Uint8Array(w),W=new l.Uint16Array(w),rt=new l.Uint32Array(w),I=new l.Float32Array(w),ct=new l.Float64Array(w),j=l.Math.imul,v=l.Math.fround,St=l.Math.abs,yt=l.Math.clz32,Mt=l.Math.min,l.Math.max,Ft=l.Math.floor,l.Math.ceil,l.Math.sqrt,lt.abort,l.NaN,Nt=l.Infinity,Lt=lt.a,re=lt.b,Zt=lt.c,K=5251744,Vt=0,L[1]=function(a,p,P,_,c){a|=0,p|=0,P|=0,_|=0,c|=0;var E,u,d,g,y,b,S,R,F,B,V,z,q,tt,ut,mt,Bt,Ht,ce,we,Ue,He,pe,tr,Ot=0,fe=v(0),Te=v(0),ke=0,Ne=v(0),er=v(0),ar=v(0),wr=v(0),Tr=v(0),Er=v(0),Cr=v(0),Sr=v(0),Rr=v(0),Or=v(0),Nr=v(0),Jr=v(0),ti=v(0),xi=v(0),bi=v(0),Oi=v(0),Ni=v(0),es=v(0),rs=v(0),d2=(v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),0);if(K=tr=K-32|0,1<=(0|c))for(E=e[16+(e[a+308>>2]+(p<<5)|0)>>2],Ot=e[a+60>>2]+j(E,24)|0,p=(u=e[Ot+8>>2])+-1|0,z=(y=e[Ot+4>>2])+-1|0,q=F=(E=e[e[a+152>>2]+(E<<2)>>2])+(u<<3)|0,tt=B=E+((R=j(y,d=u+1|0))<<3)|0,ut=V=E+(u+R<<3)|0,pe=e[Ot+12>>2],b=v(0|y),S=v(0|u),a=0;ar=I[4+(Ot=(g=a<<3)+P|0)>>2],Te=v(ar*b),wr=I[Ot>>2],fe=v(wr*S),Ot=ar>=v(1),Te=!(ar<v(0)^1)||Ot|wr>=v(1)|wr<v(0)?(d2||(Rr=I[4+ut>>2],mt=I[E+4>>2],Tr=v(Rr-mt),Bt=I[4+q>>2],Ht=I[4+tt>>2],Er=v(Bt-Ht),Or=v(v(Tr-Er)*v(.5)),ce=I[V>>2],we=I[E>>2],Cr=v(ce-we),Ue=I[F>>2],He=I[B>>2],Sr=v(Ue-He),Nr=v(v(Cr-Sr)*v(.5)),Er=v(v(Er+Tr)*v(.5)),Sr=v(v(Sr+Cr)*v(.5)),d2=1,Tr=v(v(v(v(v(mt+Bt)+Ht)+Rr)*v(.25))-v(Tr*v(.5))),Cr=v(v(v(v(v(we+Ue)+He)+ce)*v(.25))-v(Cr*v(.5)))),ar<v(3)^1|wr>v(-2)^1|(wr<v(3)^1|ar>v(-2)^1)?(I[_+g>>2]=v(ar*Nr)+v(v(wr*Sr)+Cr),fe=v(ar*Or),v(v(wr*Er)+Tr)):(wr<=v(0)?ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ne=v(v(wr+v(2))*v(.5)),fe=v(Or+Or),es=v(Tr-fe),Te=v(Nr+Nr),rs=v(Cr-Te),Oi=v(Tr-v(Er+Er)),Jr=v(Oi-fe),Ni=v(Cr-v(Sr+Sr)),ti=v(Ni-Te),xi=I[E+4>>2],bi=I[E>>2]):Ot?(fe=v(Or*v(3)),Te=v(Tr-v(Er+Er)),Oi=v(fe+Te),Jr=v(Nr*v(3)),ti=v(Cr-v(Sr+Sr)),Ni=v(Jr+ti),er=v(v(ar+v(-1))*v(.5)),Ne=v(v(wr+v(2))*v(.5)),xi=v(fe+Tr),bi=v(Jr+Cr),Jr=v(Or+Te),ti=v(Nr+ti),es=I[4+tt>>2],rs=I[B>>2]):(fe=v(Tr-v(Er+Er)),Ot=z,ke=v(St(Te))<v(2147483648)?~~Te:-2147483648,er=v(0|(Ot=(0|ke)==(0|y)?Ot:ke)),Ne=v(er/b),Jr=v(v(Ne*Or)+fe),Rr=v(Ne*Nr),Ne=v(Cr-v(Sr+Sr)),ti=v(Rr+Ne),ar=v(v(0|(ke=Ot+1|0))/b),Oi=v(v(ar*Or)+fe),Ni=v(v(ar*Nr)+Ne),Ne=v(v(wr+v(2))*v(.5)),er=v(Te-er),Ot=E+(j(Ot,d)<<3)|0,es=I[Ot+4>>2],rs=I[Ot>>2],Ot=E+(j(ke,d)<<3)|0,xi=I[Ot+4>>2],bi=I[Ot>>2]):wr>=v(1)?ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ne=v(v(wr+v(-1))*v(.5)),fe=v(Or+Or),Jr=v(v(Er+Tr)-fe),Te=v(Nr+Nr),ti=v(v(Sr+Cr)-Te),xi=v(v(Er*v(3))+Tr),es=v(xi-fe),bi=v(v(Sr*v(3))+Cr),rs=v(bi-Te),Oi=I[4+q>>2],Ni=I[F>>2]):Ot?(fe=v(Or*v(3)),Oi=v(fe+v(Er+Tr)),Te=v(Nr*v(3)),Ni=v(Te+v(Sr+Cr)),Rr=fe,fe=v(v(Er*v(3))+Tr),xi=v(Rr+fe),Rr=Te,Te=v(v(Sr*v(3))+Cr),bi=v(Rr+Te),er=v(v(ar+v(-1))*v(.5)),Ne=v(v(wr+v(-1))*v(.5)),es=v(Or+fe),rs=v(Nr+Te),Jr=I[4+ut>>2],ti=I[V>>2]):(fe=v(v(Er*v(3))+Tr),Ot=z,ke=v(St(Te))<v(2147483648)?~~Te:-2147483648,er=v(0|(Ot=(0|ke)==(0|y)?Ot:ke)),Ne=v(er/b),es=v(v(Ne*Or)+fe),Rr=v(Ne*Nr),Ne=v(v(Sr*v(3))+Cr),rs=v(Rr+Ne),ar=v(v(0|(ke=Ot+1|0))/b),xi=v(v(ar*Or)+fe),bi=v(v(ar*Nr)+Ne),Ne=v(v(wr+v(-1))*v(.5)),er=v(Te-er),Ot=E+(j(Ot,d)+u<<3)|0,Jr=I[Ot+4>>2],ti=I[Ot>>2],Ot=E+(j(ke,d)+u<<3)|0,Oi=I[Ot+4>>2],Ni=I[Ot>>2]):ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ot=p,ke=v(St(Te=fe))<v(2147483648)?~~fe:-2147483648,fe=v(0|(Ot=(0|ke)==(0|u)?Ot:ke)),Ne=v(Te-fe),fe=v(fe/S),Te=v(Or+Or),Jr=v(v(v(fe*Er)+Tr)-Te),Rr=v(v(fe*Sr)+Cr),fe=v(Nr+Nr),ti=v(Rr-fe),ar=v(v(0|(ke=Ot+1|0))/S),es=v(v(v(ar*Er)+Tr)-Te),rs=v(v(v(ar*Sr)+Cr)-fe),Oi=I[4+(Ot=E+(Ot<<3)|0)>>2],Ni=I[Ot>>2],xi=I[4+(Ot=E+(ke<<3)|0)>>2],bi=I[Ot>>2]):Ot?(Rr=Te=v(Or*v(3)),Ot=p,ke=v(St(fe))<v(2147483648)?~~fe:-2147483648,Ne=v(0|(Ot=(0|ke)==(0|u)?Ot:ke)),er=v(Ne/S),Oi=v(Rr+v(v(er*Er)+Tr)),wr=v(Nr*v(3)),Ni=v(wr+v(v(er*Sr)+Cr)),Rr=Te,Te=v(v(0|(ke=Ot+1|0))/S),xi=v(Rr+v(v(Te*Er)+Tr)),bi=v(wr+v(v(Te*Sr)+Cr)),er=v(v(ar+v(-1))*v(.5)),Ne=v(fe-Ne),Jr=I[4+(Ot=E+(Ot+R<<3)|0)>>2],ti=I[Ot>>2],es=I[4+(Ot=E+(ke+R<<3)|0)>>2],rs=I[Ot>>2]):(ct[16+tr>>3]=ar,e[tr>>2]=a,ct[8+tr>>3]=wr,Ut(4,1107,tr)),v(Ne+er)<=v(1)?(I[_+g>>2]=v(ti+v(v(rs-ti)*Ne))+v(v(Ni-ti)*er),fe=v(Jr+v(v(es-Jr)*Ne)),v(v(Oi-Jr)*er)):(fe=v(v(1)-Ne),Te=v(v(1)-er),I[_+g>>2]=v(bi+v(v(Ni-bi)*fe))+v(v(rs-bi)*Te),fe=v(xi+v(v(Oi-xi)*fe)),v(v(es-xi)*Te)))):(Ot=v(St(Rr=Te))<v(2147483648)?~~Te:-2147483648,er=v(Rr-v(0|Ot)),ke=v(St(Te=fe))<v(2147483648)?~~fe:-2147483648,Ne=v(Te-v(0|ke)),Ot=ke+j(Ot,d)|0,pe?(fe=v(v(1)-er),Te=v(v(1)-Ne),ke=E+(Ot<<3)|0,Ot=E+(Ot+d<<3)|0,I[_+g>>2]=v(v(v(fe*v(Te*I[ke>>2]))+v(fe*v(Ne*I[ke+8>>2])))+v(er*v(Te*I[Ot>>2])))+v(er*v(Ne*I[Ot+8>>2])),fe=v(v(v(fe*v(Te*I[ke+4>>2]))+v(fe*v(Ne*I[ke+12>>2])))+v(er*v(Te*I[Ot+4>>2]))),v(er*v(Ne*I[Ot+12>>2]))):v(Ne+er)<=v(1)?(fe=v(v(v(1)-Ne)-er),ke=E+(Ot<<3)|0,Ot=E+(Ot+d<<3)|0,I[_+g>>2]=v(v(fe*I[ke>>2])+v(Ne*I[ke+8>>2]))+v(er*I[Ot>>2]),fe=v(v(fe*I[ke+4>>2])+v(Ne*I[ke+12>>2])),v(er*I[Ot+4>>2])):(fe=v(v(Ne+v(-1))+er),ke=E+(Ot+d<<3)|0,Te=v(v(1)-Ne),ar=v(v(1)-er),Ot=E+(Ot<<3)|0,I[_+g>>2]=v(v(fe*I[ke+8>>2])+v(Te*I[ke>>2]))+v(ar*I[Ot+8>>2]),fe=v(v(fe*I[ke+12>>2])+v(Te*I[ke+4>>2])),v(ar*I[Ot+12>>2]))),I[4+(_+g|0)>>2]=fe+Te,(0|c)!=(0|(a=a+1|0)););K=32+tr|0},L[2]=function(a,p){a|=0,p|=0;var b=0,P=0,_=0,y=0,S=0,c=v(0),E=0,u=0,d=(v(0),0),g=0,y=e[a+320>>2],b=e[a+316>>2],S=e[a+308>>2];(0|(P=e[8+(_=S+(p<<5)|0)>>2]))==-1?(e[(g=b)+(b=p<<2)>>2]=e[e[a+148>>2]+(e[_+16>>2]<<2)>>2],e[b+y>>2]=1065353216):(E=e[_+16>>2],u=e[e[a+152>>2]+(E<<2)>>2],L[e[24+(S+(P<<5)|0)>>2]](a,P,u,u,e[16+(e[a+60>>2]+j(E,24)|0)>>2]),c=I[e[a+148>>2]+(e[_+16>>2]<<2)>>2],_=e[_+8>>2]<<2,I[(P=p<<2)+b>>2]=c*I[_+b>>2],e[P+y>>2]=e[_+y>>2]),4<=H[e[a>>2]+4|0]&&(y=p<<2,b=e[a+308>>2]+(p<<5)|0,P=e[b+16>>2]<<2,_=e[a+328>>2],p=e[a+324>>2],(0|(S=e[b+8>>2]))==-1?(S=e[a+156>>2],e[(b=y<<2)+p>>2]=e[S+(P<<=2)>>2],e[(E=4|b)+p>>2]=e[(u=4|P)+S>>2],e[(d=8|b)+p>>2]=e[S+(g=8|P)>>2],e[p+((y|=3)<<2)>>2]=1065353216,a=e[a+160>>2],e[b+_>>2]=e[a+P>>2],e[_+E>>2]=e[a+u>>2],e[_+d>>2]=e[a+g>>2]):(P=(u=P<<2)+e[a+156>>2]|0,I[(b=(E=y<<2)+p|0)>>2]=I[P>>2]*I[(S=(d=S<<4)+p|0)>>2],I[b+4>>2]=I[P+4>>2]*I[S+4>>2],I[b+8>>2]=I[P+8>>2]*I[S+8>>2],e[p+((y|=3)<<2)>>2]=1065353216,a=u+e[a+160>>2]|0,g=I[a>>2],c=I[(b=_+d|0)>>2],I[(p=_+E|0)>>2]=v(g+c)-v(g*c),g=I[a+4>>2],c=I[b+4>>2],I[p+4>>2]=v(g+c)-v(g*c),g=I[a+8>>2],c=I[b+8>>2],I[p+8>>2]=v(g+c)-v(g*c)),e[_+(y<<2)>>2]=1065353216)},L[3]=function(a,p,P,_,c){a|=0,p|=0,P|=0,_|=0,c|=0;var E,u,d,g,y,b=0,b=(v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),(p=e[16+(e[a+308>>2]+(p<<5)|0)>>2])<<2),S=function(V){var z,q,tt,ut,mt=v(0);K=tt=K-16|0,Qt(V);r:if((z=2147483647&(ut=Wt[0]))>>>0<=1061752794)mt=v(1),z>>>0<964689920||(mt=ve(+V));else if(z>>>0<=1081824209)q=+V,mt=1075235812<=z>>>0?v(-ve(((0|ut)<0?3.141592653589793:-3.141592653589793)+q)):me((0|ut)<=-1?1.5707963267948966+q:1.5707963267948966-q);else if(z>>>0<=1088565717)mt=1085271520<=z>>>0?ve(+V+((0|ut)<0?6.283185307179586:-6.283185307179586)):me((0|ut)<=-1?-4.71238898038469-+V:+V-4.71238898038469);else if(mt=v(V-V),!(2139095040<=z>>>0))if((z=3&Qe(V,8+tt|0))>>>0<=2){switch(z-1|0){default:mt=ve(ct[8+tt>>3]);break r;case 0:mt=me(-ct[8+tt>>3]);break r;case 1:}mt=v(-ve(ct[8+tt>>3]))}else mt=me(ct[8+tt>>3]);return K=16+tt|0,mt}(B=v(v(v(I[4+(e[a+168>>2]+j(p,12)|0)>>2]+I[b+e[a+284>>2]>>2])*v(3.1415927410125732))/v(180))),R=I[b+e[a+272>>2]>>2],F=e[b+e[a+292>>2]>>2],B=function(V){var z,q,tt,ut=0;K=q=K-16|0,Qt(V);r:if((z=2147483647&(tt=Wt[0]))>>>0<=1061752794)z>>>0<964689920||(V=me(+V));else if(z>>>0<=1081824209)ut=+V,V=z>>>0<=1075235811?(0|tt)<=-1?v(-ve(ut+1.5707963267948966)):ve(ut+-1.5707963267948966):me(-(((0|tt)<0?3.141592653589793:-3.141592653589793)+ut));else if(z>>>0<=1088565717)ut=+V,V=z>>>0<=1085271519?(0|tt)<=-1?ve(ut+4.71238898038469):v(-ve(ut+-4.71238898038469)):me(((0|tt)<0?6.283185307179586:-6.283185307179586)+ut);else if(2139095040<=z>>>0)V=v(V-V);else if((z=3&Qe(V,8+q|0))>>>0<=2){switch(z-1|0){default:V=me(ct[8+q>>3]);break r;case 0:V=ve(ct[8+q>>3]);break r;case 1:}V=me(-ct[8+q>>3])}else V=v(-ve(ct[8+q>>3]));return K=16+q|0,V}(B);if((p=0)<(0|c))for(S=v(R*S),u=v(F?-1:1),g=v(S*u),E=e[b+e[a+288>>2]>>2]?v(-1):v(1),y=v(v(R*B)*E),S=v(S*E),R=v(v(R*v(-B))*u),B=I[b+e[a+280>>2]>>2],u=I[b+e[a+276>>2]>>2];b=(a=p<<3)+_|0,E=I[(a=a+P|0)>>2],d=I[a+4>>2],I[b+4>>2]=B+v(v(y*E)+v(g*d)),I[b>>2]=u+v(v(S*E)+v(R*d)),(0|c)!=(0|(p=p+1|0)););},L[4]=function(a,p){a|=0,p|=0;var P,_,c,E,u,d,g=0,y=0,b=0,S=v(0),R=0,F=0,B=v(0),V=0,z=0,q=0;if(v(0),v(0),v(0),v(0),K=d=K+-64|0,V=e[a+320>>2],z=e[a+316>>2],y=e[a+308>>2],(0|(R=e[8+(b=y+(p<<5)|0)>>2]))==-1)g=e[b+16>>2]<<2,e[(y=p<<2)+z>>2]=e[g+e[a+268>>2]>>2],e[y+V>>2]=e[g+e[a+272>>2]>>2];else{g=e[b+16>>2]<<2,q=e[g+e[a+276>>2]>>2],e[24+d>>2]=q,g=e[g+e[a+280>>2]>>2],e[28+d>>2]=g,e[16+d>>2]=0,_=e[12+(F=y+(R<<5)|0)>>2]==1?v(-10):v(-.10000000149011612),I[20+d>>2]=_,e[60+d>>2]=g,e[56+d>>2]=q,L[e[F+24>>2]](a,R,56+d|0,48+d|0,1),S=v(1),y=9;r:{for(;;){if(g=y,B=v(S*v(0)),I[32+d>>2]=B+I[56+d>>2],P=v(_*S),I[36+d>>2]=P+I[60+d>>2],L[e[F+24>>2]](a,R,32+d|0,40+d|0,1),c=v(I[44+d>>2]-I[52+d>>2]),I[44+d>>2]=c,E=v(I[40+d>>2]-I[48+d>>2]),I[40+d>>2]=E,c!=v(0)||E!=v(0)){y=e[44+d>>2],e[8+d>>2]=e[40+d>>2],e[12+d>>2]=y;break r}if(I[32+d>>2]=I[56+d>>2]-B,I[36+d>>2]=I[60+d>>2]-P,L[e[F+24>>2]](a,R,32+d|0,40+d|0,1),B=v(I[40+d>>2]-I[48+d>>2]),I[40+d>>2]=B,P=v(I[44+d>>2]-I[52+d>>2]),(I[44+d>>2]=P)!=v(0)||B!=v(0)){I[12+d>>2]=-P,I[8+d>>2]=-B;break r}if(y=g+-1|0,S=v(S*v(.10000000149011612)),!g)break}Ut(3,1311,0)}S=function(tt,ut){var mt=v(0);if((mt=v(Bi(I[4+tt>>2],I[tt>>2])-Bi(I[4+ut>>2],I[ut>>2])))<v(-3.1415927410125732))for(;(mt=v(mt+v(6.2831854820251465)))<v(-3.1415927410125732););if(mt>v(3.1415927410125732))for(;(mt=v(mt+v(-6.2831854820251465)))>v(3.1415927410125732););return mt}(16+d|0,8+d|0),L[e[F+24>>2]](a,e[b+8>>2],24+d|0,24+d|0,1),y=e[b+16>>2]<<2,e[y+e[a+276>>2]>>2]=e[24+d>>2],e[y+e[a+280>>2]>>2]=e[28+d>>2],g=y+e[a+284>>2]|0,I[g>>2]=I[g>>2]+v(v(S*v(-180))/v(3.1415927410125732)),b=e[b+8>>2]<<2,I[(g=p<<2)+z>>2]=I[y+e[a+268>>2]>>2]*I[b+z>>2],y=y+e[a+272>>2]|0,S=v(I[y>>2]*I[b+V>>2]),I[g+V>>2]=S,I[y>>2]=S}4<=H[e[a>>2]+4|0]&&(g=p<<2,b=e[a+308>>2]+(p<<5)|0,R=e[b+16>>2]<<2,y=e[a+328>>2],p=e[a+324>>2],(0|(F=e[b+8>>2]))==-1?(F=e[a+296>>2],e[(b=g<<2)+p>>2]=e[F+(R<<=2)>>2],e[(V=4|b)+p>>2]=e[(z=4|R)+F>>2],e[(q=8|b)+p>>2]=e[F+(u=8|R)>>2],e[p+((g|=3)<<2)>>2]=1065353216,a=e[a+300>>2],e[y+b>>2]=e[a+R>>2],e[y+V>>2]=e[a+z>>2],e[y+q>>2]=e[a+u>>2]):(R=(z=R<<2)+e[a+296>>2]|0,I[(b=(V=g<<2)+p|0)>>2]=I[R>>2]*I[(F=(q=F<<4)+p|0)>>2],I[b+4>>2]=I[R+4>>2]*I[F+4>>2],I[b+8>>2]=I[R+8>>2]*I[F+8>>2],e[p+((g|=3)<<2)>>2]=1065353216,a=z+e[a+300>>2]|0,S=I[a>>2],B=I[(b=y+q|0)>>2],I[(p=y+V|0)>>2]=v(S+B)-v(S*B),S=I[a+4>>2],B=I[b+4>>2],I[p+4>>2]=v(S+B)-v(S*B),S=I[a+8>>2],B=I[b+8>>2],I[p+8>>2]=v(S+B)-v(S*B)),e[y+(g<<2)>>2]=1065353216),K=64+d|0},L[5]=function(a,p){return a|=0,p|=0,v(0),v(0),0|((a=I[a>>2])<(p=I[p>>2])?-1:p<a)},L[6]=function(a,p,P,_){a|=0,p|=0,P|=0,_|=0;var c=0,E=0,u=v(0),d=0,g=0,y=0,b=0,S=0;if(1<=(0|(d=e[a+8>>2])))for(y=e[a+12>>2],g=e[a+20>>2];I[(E=c<<2)+y>>2]=I[p+E>>2]*I[E+g>>2],(0|(c=c+1|0))<(0|d););if(!((0|(d=e[a>>2]))<1))if(y=e[a+4>>2],_)for(E=p=0;;){if(e[_>>2]){if((0|(c=e[(g=p<<2)+e[a+16>>2]>>2]))<1)u=v(0);else for(b=c+E|0,S=e[a+12>>2],u=v(0),c=E;u=v(u+I[S+(c<<2)>>2]),(0|(c=c+1|0))<(0|b););I[P+g>>2]=u}if(_=_+4|0,E=e[y+(p<<2)>>2]+E|0,!((0|(p=p+1|0))<(0|d)))break}else for(g=e[a+16>>2],p=_=0;;){if((0|(c=e[(E=_<<2)+g>>2]))<=0)u=v(0);else for(b=p+c|0,S=e[a+12>>2],u=v(0),c=p;u=v(u+I[S+(c<<2)>>2]),(0|(c=c+1|0))<(0|b););if(I[P+E>>2]=u,p=e[E+y>>2]+p|0,!((0|(_=_+1|0))<(0|d)))break}},L[7]=function(a,p,P,_){a|=0,p|=0,P|=0,_|=0;var c=0,E=v(0),u=0,d=0,g=0,y=0,b=0;if(1<=(0|(y=e[a+8>>2])))for(d=e[a+12>>2],g=e[a+20>>2];I[(u=c<<2)+d>>2]=I[p+u>>2]*I[u+g>>2],(0|(c=c+1|0))<(0|y););if(!((0|(c=e[a>>2]))<1))if(y=e[a+4>>2],_)for(u=p=0;;){if(e[_>>2]){if((0|(c=e[(d=p<<2)+e[a+16>>2]>>2]))<1)E=v(0);else for(g=c+u|0,b=e[a+12>>2],E=v(0),c=u;E=v(E+I[b+(c<<2)>>2]),(0|(c=c+1|0))<(0|g););c=P+d|0,E=v(E+v(.0010000000474974513)),d=v(St(E))<v(2147483648)?~~E:-2147483648,e[c>>2]=d,c=e[a>>2]}if(_=_+4|0,u=e[y+(p<<2)>>2]+u|0,!((0|(p=p+1|0))<(0|c)))break}else for(d=e[a+16>>2],p=_=0;;){if((0|(c=e[(u=_<<2)+d>>2]))<=0)E=v(0);else for(g=p+c|0,b=e[a+12>>2],E=v(0),c=p;E=v(E+I[b+(c<<2)>>2]),(0|(c=c+1|0))<(0|g););if(c=P+u|0,E=v(E+v(.0010000000474974513)),g=v(St(E))<v(2147483648)?~~E:-2147483648,e[c>>2]=g,p=e[u+y>>2]+p|0,!((0|(_=_+1|0))<e[a>>2]))break}},L[8]=function(a,p,P,_,c,E){a|=0,p|=0,P|=0,_|=0,c|=0,E|=0;var u,d,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=v(0),ut=0,mt=e[a>>2];if(!((0|mt)<1))if(u=c<<2,d=e[a+4>>2],E)for(;;){if(e[E>>2]&&(b=e[(g=S<<2)+e[a+16>>2]>>2],B=e[P+g>>2],y=e[_+g>>2],(g=(0|(V=j(y,c)))<1)||Ce(B,0,j(y,u)),!(g|(0|b)<1)))for(z=b+F|0,q=e[a+20>>2],g=F;;){for(tt=I[(y=g<<2)+q>>2],ut=e[p+y>>2],R=0;I[(y=(b=R<<2)+B|0)>>2]=I[y>>2]+v(tt*I[b+ut>>2]),(0|V)!=(0|(R=R+1|0)););if(!((0|(g=g+1|0))<(0|z)))break}if(E=E+4|0,F=e[(S<<2)+d>>2]+F|0,!((0|(S=S+1|0))<(0|mt)))break}else for(E=0;;){if(b=e[(S=E<<2)+e[a+16>>2]>>2],B=e[P+S>>2],y=e[_+S>>2],(g=(0|(V=j(y,c)))<1)||Ce(B,0,j(y,u)),!(g|(0|b)<=0))for(z=b+F|0,q=e[a+20>>2],g=F;;){for(tt=I[(y=g<<2)+q>>2],ut=e[p+y>>2],R=0;I[(y=(b=R<<2)+B|0)>>2]=I[y>>2]+v(tt*I[b+ut>>2]),(0|V)!=(0|(R=R+1|0)););if(!((0|(g=g+1|0))<(0|z)))break}if(F=e[S+d>>2]+F|0,!((0|(E=E+1|0))<(0|mt)))break}},L[9]=function(a){var p,P,_,c=0,E=0,u=0,d=0;if(!(e[(a|=0)+648>>2]||(0|(c=e[a+332>>2]))<1))for(P=(E=e[a+336>>2])+j(c,20)|0,c=e[a+424>>2],d=e[a+444>>2];;){if(e[c>>2]&&!((0|(u=e[E+16>>2]))<(a=1)))for(u<<=1,_=e[d>>2];I[(p=(a<<2)+_|0)>>2]=-I[p>>2],(0|(a=a+2|0))<(0|u););if(d=d+4|0,c=c+4|0,!((E=E+20|0)>>>0<P>>>0))break}},L[10]=function(a,p,P){var _;return ge(_=e[20+(a|=0)>>2],p|=0,p=(P|=0)>>>0<(p=e[a+16>>2]-_|0)>>>0?P:p),e[a+20>>2]=p+e[a+20>>2],0|P},L[11]=function(a,p,P,_,c,E){a|=0,p=+p,P|=0,_|=0,c|=0,E|=0;var u,d,g,y,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,we=0;if(e[44+(K=g=K-560|0)>>2]=0,Ye(+p),b=0|Wt[1],d=4294967295<Wt[0]>>>0?0:1,y=(0|b)<-1||(0|b)<=-1&&d?(Ye(p=-p),b=0|Wt[1],Wt[0],ce=1,3840):2048&c?(ce=1,3843):(ce=1&c)?3846:3841,(2146435072&b)==2146435072)We(a,32,P,V=ce+3|0,-65537&c),Fe(a,y,ce),_=E>>>5&1,Fe(a,p!=p?_?3867:3871:_?3859:3863,3);else if(p=function Ue(He,pe){var tr,Ot,fe=0;if(Ye(+He),fe=0|Wt[1],tr=0|Wt[0],(0|(fe=(Ot=fe)>>>20&2047))!=2047){if(!fe)return fe=pe,pe=He==0?0:(He=Ue(18446744073709552e3*He,pe),e[pe>>2]+-64|0),e[fe>>2]=pe,He;e[pe>>2]=fe+-1022,Yt(0,0|tr),Yt(1,-2146435073&Ot|1071644672),He=+ze()}return He}(p,44+g|0),(p+=p)!=0&&(e[44+g>>2]=e[44+g>>2]+-1),u=16+g|0,(0|(d=32|E))==97){if(mt=(ut=32&E)?9+y|0:y,!(11<_>>>0)&&(b=12-_|0)){for(Bt=8;Bt*=16,b=b+-1|0;);p=H[0|mt]==45?-(Bt+(-p-Bt)):p+Bt-Bt}for((0|u)==(0|(b=ye((R=(b=e[44+g>>2])>>31)^b+R,0,u)))&&(O[15+g|0]=48,b=15+g|0),B=2|ce,R=e[44+g>>2],O[0|(tt=b+-2|0)]=E+15,O[b+-1|0]=(0|R)<0?45:43,b=8&c,S=16+g|0;E=S,q=ut,R=St(p)<2147483648?~~p:-2147483648,O[0|S]=q|H[R+3824|0],((S=E+1|0)-(16+g|0)|0)!=1|((p=16*(p-(0|R)))==0?!(b|0<(0|_)):0)||(O[E+1|0]=46,S=E+2|0),p!=0;);We(a,32,P,V=(E=!_|(0|_)<=((S-g|0)-18|0)?((u-(16+g|0)|0)-tt|0)+S|0:2+((_+u|0)-tt|0)|0)+B|0,c),Fe(a,mt,B),We(a,48,P,V,65536^c),Fe(a,16+g|0,_=S-(16+g|0)|0),We(a,48,E-((b=_)+(_=u-tt|0)|0)|0,0,0),Fe(a,tt,_)}else{for(b=(0|_)<0,p==0?F=e[44+g>>2]:(F=e[44+g>>2]+-28|0,e[44+g>>2]=F,p*=268435456),z=b?6:_,R=ut=(0|F)<0?48+g|0:336+g|0;R=(_=R)+4|0,(p=1e9*(p-((e[_>>2]=b=p<4294967296&0<=p?~~p>>>0:0)>>>0)))!=0;);if((0|F)<1)b=R,S=ut;else for(S=ut;;){if(tt=(0|F)<29?F:29,!((b=R+-4|0)>>>0<S>>>0)){for(_=tt,q=0;we=q,q=e[(mt=b)>>2],B=31&_,B=32<=(63&_)>>>(V=0)?(F=q<<B,0):(F=(1<<B)-1&q>>>32-B,q<<B),V=F+V|0,V=(q=we+B|0)>>>0<B>>>0?V+1|0:V,we=mt,mt=So(q=Po(B=q,V,1e9),Vt,1e9),e[we>>2]=B-mt,S>>>0<=(b=b+-4|0)>>>0;);(_=q)&&(e[(S=S+-4|0)>>2]=_)}for(;S>>>0<(b=R)>>>0&&!e[(R=b+-4|0)>>2];);if(F=e[44+g>>2]-tt|0,R=b,!(0<(0|(e[44+g>>2]=F))))break}if((0|F)<=-1)for(Ht=1+((z+25|0)/9|0)|0,tt=(0|d)==102;;){if(q=(0|F)<-9?9:0-F|0,b>>>0<=S>>>0)S=e[S>>2]?S:S+4|0;else{for(mt=1e9>>>q,B=-1<<q^-1,F=0,R=S;_=e[R>>2],e[R>>2]=(_>>>q)+F,F=j(mt,_&B),(R=R+4|0)>>>0<b>>>0;);S=e[S>>2]?S:S+4|0,F&&(e[b>>2]=F,b=b+4|0)}if(F=q+e[44+g>>2]|0,b=(0|Ht)<b-(_=tt?ut:S)>>2?_+(Ht<<2)|0:b,!((0|(e[44+g>>2]=F))<0))break}if(!(b>>>(R=0)<=S>>>0||(R=j(ut-S>>2,9),(_=e[S>>2])>>>0<(F=10))))for(;R=R+1|0,(F=j(F,10))>>>0<=_>>>0;);if((0|(_=(z-((0|d)==102?0:R)|0)-((0|d)==103&(0|z)!=0)|0))<(j(b-ut>>2,9)+-9|0)){if(V=(ut+((_=(0|(B=_+9216|0))/9|0)<<2)|0)-4092|0,F=10,(0|(_=1+(B-j(_,9)|0)|0))<=8)for(;F=j(F,10),(0|(_=_+1|0))!=9;);if(Ht=V+4|0,((tt=(mt=e[V>>2])-j(F,B=(mt>>>0)/(F>>>0)|0)|0)||(0|Ht)!=(0|b))&&(Bt=tt>>>0<(_=F>>>1)>>>0?.5:(0|b)==(0|Ht)&&(0|_)==(0|tt)?1:1.5,p=1&B?9007199254740994:9007199254740992,!ce|H[0|y]!=45||(Bt=-Bt,p=-p),e[V>>2]=_=mt-tt|0,p+Bt!=p)){if(1e9<=(e[V>>2]=_=_+F|0)>>>0)for(;(V=V+-4|(e[V>>2]=0))>>>0<S>>>0&&(e[(S=S+-4|0)>>2]=0),_=e[V>>2]+1|0,999999999<(e[V>>2]=_)>>>0;);if(R=j(ut-S>>2,9),!((_=e[S>>2])>>>0<(F=10)))for(;R=R+1|0,(F=j(F,10))>>>0<=_>>>0;);}b=(_=V+4|0)>>>0<b>>>0?_:b}r:{for(;;){if((tt=b)>>>(mt=0)<=S>>>0)break r;if(e[(b=tt+-4|0)>>2])break}mt=1}if((0|d)!=103)B=8&c;else if(z=((_=(0|R)<(0|(b=z||1))&-5<(0|R))?-1^R:-1)+b|0,E=(_?-1:-2)+E|0,!(B=8&c)){if(b=9,mt&&(B=e[tt+-4>>2])&&!((B>>>(b=0))%(_=10)))for(;b=b+1|0,!((B>>>0)%((_=j(_,10))>>>0)););_=j(tt-ut>>2,9)+-9|0,z=(32|E)==102?((B=0)|z)<(0|(_=0<(0|(_=_-b|0))?_:0))?z:_:((B=0)|z)<(0|(_=0<(0|(_=(_+R|0)-b|0))?_:0))?z:_}if(V=(0|(F=z|B))!=0,_=a,we=P,b=0<(0|R)?R:0,(0|(q=32|E))!=102){if((u-(b=ye((b=R>>31)+R^b,0,u))|0)<=1)for(;O[0|(b=b+-1|0)]=48,(u-b|0)<2;);O[0|(Ht=b+-2|0)]=E,O[b+-1|0]=(0|R)<0?45:43,b=u-Ht|0}if(We(_,32,we,V=1+(b+(V+(z+ce|0)|0)|0)|0,c),Fe(a,y,ce),We(a,48,P,V,65536^c),(0|q)==102){for(_=16+g|8,R=16+g|9,S=E=ut>>>0<S>>>0?ut:S;;){if(b=ye(e[S>>2],0,R),(0|E)!=(0|S)){if(!(b>>>0<=16+g>>>0))for(;O[0|(b=b+-1|0)]=48,16+g>>>0<b>>>0;);}else(0|b)==(0|R)&&(O[24+g|0]=48,b=_);if(Fe(a,b,R-b|0),!((S=S+4|0)>>>0<=ut>>>0))break}F&&Fe(a,3875,1);r:if(!((0|z)<1|tt>>>0<=S>>>0))for(;;){if(16+g>>>0<(b=ye(e[S>>2],0,R))>>>0)for(;O[0|(b=b+-1|0)]=48,16+g>>>0<b>>>0;);if(Fe(a,b,(0|z)<9?z:9),z=z+-9|0,tt>>>0<=(S=S+4|0)>>>0)break r;if(!(0<(0|z)))break}We(a,48,z+9|0,9,0)}else{r:if(!((0|z)<0))for(E=mt?tt:S+4|0,_=16+g|8,ut=16+g|9,R=S;;){if((0|ut)==(0|(b=ye(e[R>>2],0,ut)))&&(O[24+g|0]=48,b=_),(0|S)!=(0|R)){if(!(b>>>0<=16+g>>>0))for(;O[0|(b=b+-1|0)]=48,16+g>>>0<b>>>0;);}else Fe(a,b,1),b=b+1|0,(0|z)<1&&!B||Fe(a,3875,1);if(Fe(a,q=b,(0|(b=ut-b|0))<(0|z)?b:z),z=z-b|0,E>>>0<=(R=R+4|0)>>>0)break r;if(!(-1<(0|z)))break}We(a,48,z+18|0,18,0),Fe(a,Ht,u-Ht|0)}}return We(a,32,P,V,8192^c),K=560+g|0,0|((0|V)<(0|P)?P:V)},L[12]=function(a,p){a|=0;var P=p|=0;p=e[p>>2]+15&-16,e[P>>2]=p+16,P=a,a=function(_,c,E,u){var d,g,y=0,b=0,S=0,R=0;return K=g=K-32|0,y=(R=y=2147483647&u)-1006698496|0,b=y=(d=b=S=E)>>>0<0?y+1|0:y,y=R-1140785152|0,(0|(y=S>>>0<0?y+1|0:y))==(0|b)&d>>>0<S>>>0|b>>>0<y>>>0?(y=u<<4|E>>>28,E=E<<4|c>>>28,(0|(S=c&=268435455))==134217728&1<=_>>>0|134217728<c>>>0?(y=y+1073741824|0,(_=E+1|0)>>>0<1&&(y=y+1|0),b=_):(y=y-(((b=E)>>>0<0)+-1073741824|0)|0,_|134217728^S||((_=b+(1&b)|0)>>>0<b>>>0&&(y=y+1|0),b=_))):(!S&(0|R)==2147418112?!(_|c):(0|R)==2147418112&S>>>0<0|R>>>0<2147418112)?(y=2146435072,((b=0)|R)==1140785151&4294967295<S>>>0|1140785151<R>>>0||(S=R>>>16)>>>(y=0)<15249||(function(F,B,V,z,q,tt){var ut,mt,Bt=0,Ht=0;64&tt?(B=31&(V=tt-64|0),B=32<=(63&V)>>>0?(V=0,q>>>B):(V=q>>>B,((1<<B)-1&q)<<32-B|z>>>B),q=z=0):tt&&(Ht=q,Bt=31&(mt=64-tt|0),mt=32<=(63&mt)>>>0?(Ht=z<<Bt,0):(Ht=(1<<Bt)-1&z>>>32-Bt|Ht<<Bt,z<<Bt),ut=B,B=31&(Bt=tt),B=32<=(63&Bt)>>>0?(Bt=0,V>>>B):(Bt=V>>>B,((1<<B)-1&V)<<32-B|ut>>>B),B|=mt,V=Bt|Ht,Bt=z,z=31&tt,z=32<=(63&tt)>>>0?(Ht=0,q>>>z):(Ht=q>>>z,((1<<z)-1&q)<<32-z|Bt>>>z),q=Ht),e[F>>2]=B,e[4+F>>2]=V,e[8+F>>2]=z,e[12+F>>2]=q}(g,_,c,E,y=65535&u|65536,15361-S|0),function(F,B,V,z,q,tt){var ut,mt,Bt=0;64&tt?(z=B,B=31&(q=tt+-64|0),32<=(63&q)>>>0?(q=z<<B,z=0):(q=(1<<B)-1&z>>>32-B|V<<B,z<<=B),V=B=0):tt&&(mt=z,z=31&(ut=tt),mt=32<=(63&tt)>>>0?(Bt=mt<<z,0):(Bt=(1<<z)-1&mt>>>32-z|q<<z,mt<<z),z=V,q=31&(tt=64-tt|0),32<=(63&tt)>>>0?(tt=0,z>>>=q):(tt=z>>>q,z=((1<<q)-1&z)<<32-q|B>>>q),z|=mt,q=tt|Bt,tt=B,B=31&ut,B=32<=(63&ut)>>>0?(Bt=tt<<B,0):(Bt=(1<<B)-1&tt>>>32-B|V<<B,tt<<B),V=Bt),e[F>>2]=B,e[4+F>>2]=V,e[8+F>>2]=z,e[12+F>>2]=q}(16+g|0,_,c,E,y,S+-15233|0),E=e[4+g>>2],_=e[8+g>>2],y=e[12+g>>2]<<4|_>>>28,b=_<<4|E>>>28,(0|(E=_=268435455&E))==134217728&1<=(c=e[g>>2]|((e[16+g>>2]|e[24+g>>2])!=0|(e[20+g>>2]|e[28+g>>2])!=0))>>>0|134217728<_>>>0?((_=b+1|0)>>>0<1&&(y=y+1|0),b=_):c|134217728^E||((_=b+(1&b)|0)>>>0<b>>>0&&(y=y+1|0),b=_))):(b=E<<4|c>>>28,y=524287&(y=u<<4|E>>>28)|2146959360),K=32+g|0,Yt(0,0|b),Yt(1,-2147483648&u|y),+ze()}(e[p>>2],e[p+4>>2],e[p+8>>2],e[p+12>>2]),ct[P>>3]=a},L[13]=function(a){return 0},L[14]=function(a,p,P){p|=0,P|=0;var _,c,E=0,u=0,d=0,g=0;for(K=c=K-32|0,E=e[28+(a|=0)>>2],e[16+c>>2]=E,d=e[a+20>>2],e[28+c>>2]=P,e[24+c>>2]=p,d=(e[20+c>>2]=p=d-E|0)+P|0,g=2,p=16+c|0;;){r:{if((u=(E=0)|Zt(e[a+60>>2],0|p,0|g,12+c|0))&&(e[2086]=u,E=-1),(0|(E=E?e[12+c>>2]=-1:e[12+c>>2]))==(0|d))p=e[a+44>>2],e[a+28>>2]=p,e[a+20>>2]=p,e[a+16>>2]=p+e[a+48>>2],a=P;else{if(-1<(0|E))break r;e[a+28>>2]=0,e[a+16>>2]=0,e[a+20>>2]=0,e[a>>2]=32|e[a>>2],((a=0)|g)!=2&&(a=P-e[p+4>>2]|0)}return K=32+c|0,0|a}u=e[p+4>>2],e[(p=(_=u>>>0<E>>>0)?p+8|0:p)>>2]=(u=E-(_?u:0)|0)+e[p>>2],e[p+4>>2]=e[p+4>>2]-u,d=d-E|0,g=g-_|0}},L[15]=function(a,p,P,_){return Vt=0},{d:function(){},e:function(){return e[1805]},f:function(){return 83886080},g:function(){return 5},h:function(a,p){return p|=0,K=p=K-16|0,a=(a|=0)?ur(a)?(Ut(4,2150,0),0):H[a+4|0]:(e[p+4>>2]=1444,e[p>>2]=2267,Ut(4,1294,p),0),K=p+16|0,0|a},i:function(a,p){var P;return p|=0,K=P=K-48|0,a=(a|=0)?(a+63&-64)!=(0|a)?(e[36+P>>2]=1522,e[32+P>>2]=2284,Ut(4,1294,32+P|0),0):(p+63&-64)==(0|p)&&p?function(_,c){var E,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,we=0,Ue=0,He=0;K=b=(E=d=K)-704&-64;r:if(c>>>0<=1343)Ut(4,1235,0);else if(ur(_))Ut(4,1469,0);else if(d=H[0|(Ue=_+4|0)]){if(!(6<=d>>>0)){(Bt=(0|!H[_+5|0])==1)||(Ee(Ue,1),vt(_- -64|0,4,160)),Ce(b- -64|0,0,640),ir(_,b- -64|0),d=_+c|0,c=e[b+64>>2];t:{e:{i:{if(5<=(mt=H[_+4|0])>>>0){if(c>>>0<_>>>0|d>>>0<c>>>0||(y=c+256|0)>>>0<_>>>0)break e;if(y>>>0<=d>>>0)break i;break e}if(c>>>0<_>>>0|d>>>0<c>>>0||(y=c+128|0)>>>0<_>>>0|d>>>0<y>>>0)break e}if(!((g=e[b+68>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<y>>>0||(g=g- -64|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(V=e[c>>2]))<0||(y=e[b+72>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(u=y)+(y=V<<2)|0)>>>0<_>>>0|d>>>0<g>>>0||(R=e[b+76>>2])>>>0<_>>>0|d>>>0<R>>>0|R>>>0<g>>>0||(u=(V<<6)+R|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+80>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+84>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+88>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+92>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+96>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+100>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+4>>2]))<0||(y=e[b+104>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(S=(g=y)+(y=u<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(g=e[b+108>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<S>>>0||(u=g+(u<<6)|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+112>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+116>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+120>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+124>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+128>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+132>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+136>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+8>>2]))<0||(y=e[b+140>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(z=u<<2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+144>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+148>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+156>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+160>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+164>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+12>>2]))<0||(y=e[b+172>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(q=u<<2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+176>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+q|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+180>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+q|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+188>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=y+q|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(g=e[c+16>>2]))<0||(y=e[b+192>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(S=(u=y)+(y=g<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+196>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+200>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+204>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+208>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+(g<<6)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+212>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+216>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+220>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+228>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+232>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+236>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+240>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+244>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+248>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(u=u+g|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+252>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+256>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+260>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+264>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+268>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+272>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(S=e[c+20>>2]))<0||(g=e[b+276>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(tt=(u=g)+(g=S<<2)|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+280>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(S=u+(S<<6)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+284>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+288>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+292>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+296>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+300>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+308>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+312>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[c+24>>2]))<0||(u=e[b+336>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+(tt<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[c+28>>2]))<0||(u=e[b+340>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=(ce=tt<<2)+u|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+344>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+ce|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[c+32>>2]))<0||(u=e[b+356>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(tt=(S=tt<<2)+u|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+360>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+364>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+368>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+372>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+376>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+380>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(0|(F=e[c+36>>2]))<0||(u=e[b+392>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(F=(tt=F<<2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+396>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+tt|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+400>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+tt|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+40>>2]))<0||(u=e[b+412>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+44>>2]))<0||(u=e[b+424>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+48>>2]))<0||(u=e[b+428>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=(B<<=2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+432>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+B|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+52>>2]))<0||(u=e[b+416>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=(B<<=2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+420>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+B|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+56>>2]))<0||(u=e[b+552>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+60>>2]))<0||(u=e[b+556>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+64>>2]))<0||(u=e[b+560>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<1)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+68>>2]))<0||(u=e[b+564>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+72>>2]))<0||(u=e[b+568>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(B=(F=u)+(u=B<<2)|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+572>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+576>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+580>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+584>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+76>>2]))<0||(u=e[b+588>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(B=(F=B<<2)+u|0)>>>0<_>>>0|d>>>0<B>>>0||(u=e[b+592>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(u=e[b+596>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<B>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+80>>2]))<0||(u=e[b+600>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(ut=(F=u)+(u=B<<2)|0)>>>0<_>>>0|d>>>0<ut>>>0||(F=e[b+604>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<ut>>>0||(B=F+(B<<6)|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+608>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+612>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+616>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+620>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+624>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+628>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+632>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+84>>2]))<0||(u=e[b+636>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+640>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<1)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+88>>2]))<0||(u=e[b+644>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(u=u+(B<<2)|0)>>>0<_>>>0|d>>>0<u>>>0)){if(!(mt>>>0<2)&&((F=e[b+168>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<u>>>0||(u=F+z|0)>>>0<_>>>0|d>>>0<u>>>0||!(mt>>>0<4)&&((F=e[b+324>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<u>>>0||(F=g+F|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+328>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+g|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+332>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+g|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+152>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(z=u+z|0)>>>0<_>>>0|d>>>0<z>>>0||(u=e[b+184>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<z>>>0||(z=u+q|0)>>>0<_>>>0|d>>>0<z>>>0||(u=e[b+224>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<z>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(z=e[c+92>>2]))<0||(y=e[b+648>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(z=(u=z<<2)+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+652>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(z=u+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+656>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(z=e[c+96>>2]))<0||(y=e[b+660>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(z=(u=z<<2)+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+664>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(z=u+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+668>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+304>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+316>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+320>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+100>>2]))<0||(y=e[b+436>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+440>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+444>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+104>>2]))<0||(y=e[b+448>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=y)+(y=u<<2)|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+452>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+456>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+460>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+464>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+108>>2]))<0||(y=e[b+480>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+484>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+488>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+112>>2]))<0||(y=e[b+504>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+508>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+512>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+116>>2]))<0||(y=e[b+528>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+(u<<2)|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+120>>2]))<0||(y=e[b+532>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+536>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+540>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+124>>2]))<0||(y=e[b+544>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(u<<=2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+548>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0)))break e;if(mt>>>0<5||!((y=e[b+348>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=y+ce|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+352>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+ce|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+384>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+S|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+388>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+S|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+404>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+tt|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+408>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+tt|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+128>>2]))<0||(y=e[b+468>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+472>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+476>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+132>>2]))<0||(y=e[b+492>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+496>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+500>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+136>>2]))<0||(y=e[b+516>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+520>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+524>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(y=g+y|0)>>>0<_>>>0)&&y>>>0<=d>>>0)break t}}Ut(4,1760,0),Ee(Ue,1),vt(_- -64|0,4,160);break r}Bt||(Ji(_),O[_+5|0]=0,c=e[b+64>>2],V=e[c>>2],R=e[b+76>>2],mt=H[_+4|0]);t:{if((_=0)<(0|V)){for(;;){if(63<he((_<<6)+R|0)>>>0)break t;if((0|V)==(0|(_=_+1|0)))break}if(u=c+48|0,(d=0)<(0|(_=e[c>>2]))){for(y=e[c+48>>2],g=e[b+80>>2];;){if((0|(R=e[g+(d<<2)>>2]))<0|(0|y)<=(0|R))break t;if((0|_)==(0|(d=d+1|0)))break}for(tt=c+24|0,y=e[c+24>>2],S=e[b+88>>2],V=e[b+84>>2],d=0;;){if((g=e[(R=d<<2)+S>>2])&&((0|g)<0|(0|y)<(0|g)||(0|(R=e[R+V>>2]))<0|(0|y)<=(0|R)||(g=g+R|0)>>>31|(0|y)<(0|g)))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+92>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+96>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+100>>2];;){if((0|(g=e[y+(d<<2)>>2]))<-1|(0|_)<=(0|g))break t;if((0|_)==(0|(d=d+1|0)))break}}else tt=c+24|0}else tt=c+24|0,u=c+48|0;if((_=0)<(0|(d=e[c+4>>2]))){for(y=e[b+108>>2];;){if(63<he(y+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(S=(y=e[c+48>>2])+-1|0,!(((d=0)|(_=e[c+4>>2]))<=0)){for(g=e[b+112>>2];;){if((0|(R=e[g+(d<<2)>>2]))<0|(0|y)<=(0|R))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+116>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+120>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(y=e[c>>2],d=0,g=e[b+124>>2];;){if((0|(R=e[g+(d<<2)>>2]))<-1|(0|y)<=(0|R))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+128>>2];;){if((0|(g=e[y+(d<<2)>>2]))<-1|(0|_)<=(0|g))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+132>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(g=c+8|0,R=c+12|0,V=e[b+136>>2],d=0;;){if(1<(q=e[(z=d<<2)+y>>2])>>>0||(0|(z=e[V+z>>2]))<0|(0|z)>=e[(q-1|0?g:R)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}}}else S=e[u>>2]+-1|0;if((_=0)<(0|(d=e[c+8>>2]))){for(y=e[b+140>>2];;){if((0|(g=e[y+(_<<2)>>2]))<0|(0|S)<(0|g))break t;if((0|d)==(0|(_=_+1|0)))break}for(ce=c+28|0,y=e[c+28>>2],V=e[b+148>>2],z=e[b+144>>2],_=0;;){if((g=e[(R=_<<2)+V>>2])&&((0|g)<0|(0|y)<(0|g)||(0|(R=e[R+z>>2]))<0|(0|y)<=(0|R)||(g=g+R|0)>>>31|(0|y)<(0|g)))break t;if((0|d)==(0|(_=_+1|0)))break}for(_=0,g=e[b+156>>2],R=e[b+164>>2],V=e[b+160>>2];;){if((0|(z=e[(y=_<<2)+V>>2]))<1||(0|(q=e[y+R>>2]))<1||(0|(y=e[g+y>>2]))<1|(0|y)!=(0|j(q+1|0,z+1|0)))break t;if((0|d)==(0|(_=_+1|0)))break}}else ce=c+28|0;if((_=0)<(0|(g=e[c+12>>2]))){for(d=e[b+172>>2];;){if((0|(y=e[d+(_<<2)>>2]))<0|(0|S)<(0|y))break t;if((0|g)==(0|(_=_+1|0)))break}for(F=c+32|0,d=e[c+32>>2],S=e[b+180>>2],V=e[b+176>>2],_=0;;){if((y=e[(R=_<<2)+S>>2])&&((0|y)<0|(0|d)<(0|y)||(0|(R=e[R+V>>2]))<0|(0|d)<=(0|R)||(y=y+R|0)>>>31|(0|d)<(0|y)))break t;if((0|g)==(0|(_=_+1|0)))break}}else F=c+32|0;y=c+16|0;e:{i:{if(!(((_=0)|(d=e[c+16>>2]))<=0)){for(g=e[b+208>>2];;){if(63<he(g+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(!(((d=0)|(_=e[y>>2]))<=0)){for(g=e[u>>2],R=e[b+212>>2];;){if((0|(S=e[R+(d<<2)>>2]))<0|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(Ue=c+36|0,g=e[c+36>>2],V=e[b+220>>2],z=e[b+216>>2],d=0;;){if((R=e[(S=d<<2)+V>>2])&&((0|R)<0|(0|g)<(0|R)||(0|(S=e[S+z>>2]))<0|(0|g)<=(0|S)||(R=R+S|0)>>>31|(0|g)<(0|R)))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[b+228>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[b+232>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[c>>2],d=0,R=e[b+236>>2];;){if((0|(S=e[R+(d<<2)>>2]))<-1|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[c+4>>2],d=0,R=e[b+240>>2];;){if((0|(S=e[R+(d<<2)>>2]))<-1|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[b+244>>2],d=0;;){if(e[g+(d<<2)>>2]<0)break t;if((0|_)==(0|(d=d+1|0)))break}break i}}R=c+68|0,Ue=c+36|0;break e}for(g=e[b+252>>2],d=0;;){if(e[g+(d<<2)>>2]<0)break t;if((0|_)==(0|(d=d+1|0)))break}for(R=e[c+60>>2],d=0,S=e[b+256>>2];;){if((V=e[(V=d<<2)+S>>2]+(e[g+V>>2]<<1)|0)>>>31|(0|R)<(0|V))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[c+64>>2],V=e[b+264>>2],z=e[b+260>>2],d=0;;){if((R=e[(S=d<<2)+V>>2])&&((0|R)<0|(0|g)<(0|R)||(0|(S=e[S+z>>2]))<0|(0|g)<=(0|S)||(R=R+S|0)>>>31|(0|g)<(0|R)))break t;if((0|_)==(0|(d=d+1|0)))break}for(R=c+68|0,g=e[c+68>>2],z=e[b+272>>2],q=e[b+268>>2],d=0;;){if((S=e[(V=d<<2)+z>>2])&&((0|S)<0|(0|g)<(0|S)||(0|(V=e[V+q>>2]))<0|(0|g)<=(0|V)||(S=S+V|0)>>>31|(0|g)<(0|S)))break t;if((0|_)==(0|(d=d+1|0)))break}}e:{i:{if(!(((_=0)|(d=e[c+20>>2]))<=0)){for(g=e[b+280>>2];;){if(63<he(g+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(!(((_=0)|(d=e[c+20>>2]))<=0)){for(g=e[b+296>>2];;){if(1<rt[g+(_<<2)>>2])break t;if((0|d)==(0|(_=_+1|0)))break}for(g=e[b+300>>2],_=0;;){if(e[g+(_<<2)>>2]<0)break t;if((0|d)==(0|(_=_+1|0)))break}break i}}_=e[c+52>>2];break e}for(_=e[c+52>>2],z=e[b+312>>2],q=e[b+308>>2],S=0;;){if((g=e[(V=S<<2)+z>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(V=e[V+q>>2]))<0|(0|_)<=(0|V)||(g=g+V|0)>>>31|(0|_)<(0|g)))break t;if((0|d)==(0|(S=S+1|0)))break}}if(g=e[c+40>>2],(d=0)<(0|(S=e[c+8>>2])))for(V=e[b+344>>2],z=e[b+156>>2];;){if((q=e[(q=d<<2)+V>>2]+(e[z+q>>2]<<1)|0)>>>31|(0|g)<(0|q))break t;if((0|S)==(0|(d=d+1|0)))break}if((d=0)<(0|(S=e[F>>2]))){for(V=e[b+376>>2];;){if(1<rt[V+(d<<2)>>2])break t;if((0|S)==(0|(d=d+1|0)))break}for(d=0,V=e[b+380>>2];;){if(1<rt[V+(d<<2)>>2])break t;if((0|S)==(0|(d=d+1|0)))break}}if((d=0)<(0|(S=e[y>>2])))for(V=e[b+400>>2],z=e[b+252>>2];;){if((q=e[(q=d<<2)+V>>2]+(e[z+q>>2]<<1)|0)>>>31|(0|g)<(0|q))break t;if((0|S)==(0|(d=d+1|0)))break}if((d=0)<(0|(g=e[c+44>>2])))for(V=e[b+424>>2];;){if((0|(z=e[V+(d<<2)>>2]))<0|(0|_)<=(0|z))break t;if((0|g)==(0|(d=d+1|0)))break}if(1<=(0|(z=e[u>>2])))for(d=0,q=e[b+432>>2],B=e[b+428>>2];;){if((u=e[(V=d<<2)+q>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(V=e[B+V>>2]))<0|(0|g)<=(0|V)||(u=u+V|0)>>>31|(0|g)<(0|u)))break t;if((0|z)==(0|(d=d+1|0)))break}if(1<=(0|_))for(g=e[c+56>>2],d=0,z=e[b+420>>2],q=e[b+416>>2];;){if((u=e[(V=d<<2)+z>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(V=e[V+q>>2]))<0|(0|g)<=(0|V)||(u=u+V|0)>>>31|(0|g)<(0|u)))break t;if((0|(d=d+1|0))==(0|_))break}if((_=0)<(0|(d=e[R>>2])))for(g=e[b+564>>2];;){if((0|(R=e[g+(_<<2)>>2]))<-1|(0|S)<=(0|R))break t;if((0|d)==(0|(_=_+1|0)))break}if(_=e[c+76>>2],1<=(0|(R=e[c+72>>2])))for(d=0,S=e[b+572>>2],V=e[b+568>>2];;){if((g=e[(u=d<<2)+S>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+V>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|R)==(0|(d=d+1|0)))break}if((d=0)<(0|_)){for(g=e[b+588>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(u=e[b+592>>2],d=0;;){if(1<(V=e[(S=d<<2)+g>>2])>>>0||(0|(S=e[u+S>>2]))<0|(0|S)>=e[(V-1|0?y:c)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[b+596>>2];;){if((0|(u=e[g+(d<<2)>>2]))<-1|(0|R)<=(0|u))break t;if((0|_)==(0|(d=d+1|0)))break}}e:{if(!(((_=0)|(S=e[c+80>>2]))<=0)){for(d=e[b+604>>2];;){if(63<he(d+(_<<6)|0)>>>0)break t;if((0|S)==(0|(_=_+1|0)))break}if(!(((_=0)|(S=e[c+80>>2]))<=0)){for(d=e[c+48>>2],g=e[b+608>>2];;){if((0|(R=e[g+(_<<2)>>2]))<0|(0|d)<=(0|R))break t;if((0|S)==(0|(_=_+1|0)))break}for(z=e[c+88>>2],R=e[b+616>>2],u=e[b+612>>2],_=0;;){if((d=e[(g=_<<2)+R>>2])&&((0|d)<0|(0|z)<(0|d)||(0|(g=e[u+g>>2]))<0|(0|z)<=(0|g)||(d=d+g|0)>>>31|(0|z)<(0|d)))break t;if((0|S)==(0|(_=_+1|0)))break}for(y=e[y>>2],R=e[b+620>>2],_=0;;){if((0|(d=e[R+(_<<2)>>2]))<0|(0|y)<=(0|d))break t;if((0|S)==(0|(_=_+1|0)))break}for(u=e[b+624>>2],_=0;;){if((0|(d=e[u+(_<<2)>>2]))<0|(0|y)<=(0|d))break t;if((0|S)==(0|(_=_+1|0)))break}for(d=e[c+84>>2],V=e[b+632>>2],q=e[b+628>>2],_=0;;){if((g=e[(B=_<<2)+V>>2])&&((0|g)<0|(0|d)<(0|g)||(0|(B=e[B+q>>2]))<0|(0|d)<=(0|B)||(g=g+B|0)>>>31|(0|d)<(0|g)))break t;if((0|S)==(0|(_=_+1|0)))break}for(ut=e[b+640>>2],d=e[b+252>>2],g=0;;){if(0<(0|(Bt=e[(_=g<<2)+V>>2])))for(B=ut+(e[_+q>>2]<<1)|0,He=e[d+(e[_+u>>2]<<2)>>2],Ht=e[d+(e[_+R>>2]<<2)>>2],_=0;;){if((0|He)<=W[B+(2|(we=_<<1))>>1]|(0|Ht)<=W[B+we>>1])break t;if(!((0|(_=_+2|0))<(0|Bt)))break}if((0|S)==(0|(g=g+1|0)))break}break e}}y=e[c+16>>2],z=e[c+88>>2]}if(!((255&mt)>>>0<2)){if((_=0)<(0|(V=e[c+8>>2])))for(d=e[b+168>>2];;){if(1<rt[d+(_<<2)>>2])break t;if((0|V)==(0|(_=_+1|0)))break}if(!((255&mt)>>>0<4)){if(R=e[c+56>>2],1<=(0|(q=e[c+20>>2])))for(u=e[b+332>>2],B=e[b+328>>2],_=0;;){if((d=e[(g=_<<2)+u>>2])&&((0|d)<0|(0|R)<(0|d)||(0|(g=e[g+B>>2]))<0|(0|R)<=(0|g)||(d=d+g|0)>>>31|(0|R)<(0|d)))break t;if((0|q)==(0|(_=_+1|0)))break}if((0|(_=e[c+92>>2]))!=e[c+96>>2])break t;if(1<=(0|V))for(B=e[b+152>>2],d=0,ut=e[b+148>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+B>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|V)==(0|(d=d+1|0)))break}if(1<=(0|(He=e[c+12>>2])))for(B=e[b+184>>2],d=0,ut=e[b+180>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+B>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|He)==(0|(d=d+1|0)))break}if(1<=(0|y))for(B=e[b+224>>2],d=0,ut=e[b+220>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+B>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|y)==(0|(d=d+1|0)))break}if((d=0)<(0|q)){for(g=e[b+304>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|q)==(0|(d=d+1|0)))break}for(g=e[c+100>>2],ut=e[b+320>>2],Bt=e[b+316>>2],d=0;;){if((u=e[(B=d<<2)+ut>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(B=e[B+Bt>>2]))<0|(0|g)<=(0|B)||(u=u+B|0)>>>31|(0|g)<(0|u)))break t;if((0|q)==(0|(d=d+1|0)))break}}else g=e[c+100>>2];if(1<=(0|g)){for(B=e[b+440>>2],d=0,Bt=e[b+436>>2];;){if((u=e[(ut=d<<2)+B>>2])&&((0|u)<0|(0|R)<(0|u)||(0|(ut=e[ut+Bt>>2]))<0|(0|R)<=(0|ut)||(u=u+ut|0)>>>31|(0|R)<(0|u)))break t;if((0|g)==(0|(d=d+1|0)))break}for(R=e[b+444>>2],d=0;;){if((0|(ut=e[(u=d<<2)+R>>2]))<0|(0|ut)>=e[u+B>>2])break t;if((0|g)==(0|(d=d+1|0)))break}}if((R=0)<(0|(d=e[c+104>>2]))){for(u=e[b+448>>2];;){if((0|(B=e[u+(R<<2)>>2]))<0|(0|g)<=(0|B))break t;if((0|d)==(0|(R=R+1|0)))break}for(u=e[c+116>>2],ut=e[b+464>>2],Bt=e[b+460>>2],g=0;;){if((R=e[(B=g<<2)+ut>>2])&&((0|R)<0|(0|u)<(0|R)||(0|(B=e[B+Bt>>2]))<0|(0|u)<=(0|B)||(R=R+B|0)>>>31|(0|u)<(0|R)))break t;if((0|d)==(0|(g=g+1|0)))break}}else u=e[c+116>>2];if((g=0)<(0|(B=e[c+108>>2]))){for(R=e[b+480>>2];;){if((0|(ut=e[R+(g<<2)>>2]))<0|(0|V)<=(0|ut))break t;if((0|B)==(0|(g=g+1|0)))break}for(ut=e[b+488>>2],Ht=e[b+484>>2],g=0;;){if((R=e[(V=g<<2)+ut>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(V=e[V+Ht>>2]))<0|(0|d)<=(0|V)||(R=R+V|0)>>>31|(0|d)<(0|R)))break t;if((0|B)==(0|(g=g+1|0)))break}for(ut=e[ce>>2],g=e[b+456>>2],V=e[b+452>>2],R=0;;){if(we=e[Ht+(R<<2)>>2]<<2,(Bt=e[we+g>>2])&&((0|Bt)<0|(0|ut)<(0|Bt)||(0|(we=e[V+we>>2]))<0|(0|ut)<=(0|we)||(0|(Bt=Bt+we|0))<0|(0|ut)<(0|Bt)))break t;if((0|B)==(0|(R=R+1|0)))break}}else g=e[b+456>>2],V=e[b+452>>2];if((R=0)<(0|(B=e[c+112>>2]))){for(ut=e[b+504>>2];;){if((0|(Bt=e[ut+(R<<2)>>2]))<0|(0|y)<=(0|Bt))break t;if((0|B)==(0|(R=R+1|0)))break}for(Ht=e[b+512>>2],Bt=e[b+508>>2],y=0;;){if((R=e[(ut=y<<2)+Ht>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(ut=e[ut+Bt>>2]))<0|(0|d)<=(0|ut)||(R=R+ut|0)>>>31|(0|d)<(0|R)))break t;if((0|B)==(0|(y=y+1|0)))break}for(R=e[Ue>>2],y=0;;){if(Ht=e[Bt+(y<<2)>>2]<<2,(ut=e[Ht+g>>2])&&((0|ut)<0|(0|R)<(0|ut)||(0|(Ht=e[V+Ht>>2]))<0|(0|R)<=(0|Ht)||(0|(ut=ut+Ht|0))<0|(0|R)<(0|ut)))break t;if((0|B)==(0|(y=y+1|0)))break}}if(R=e[c+120>>2],(y=0)<(0|u))for(B=e[b+528>>2];;){if((0|(ut=e[B+(y<<2)>>2]))<0|(0|R)<=(0|ut))break t;if((0|(y=y+1|0))==(0|u))break}if((y=0)<(0|R)){for(u=e[b+532>>2];;){if((0|(B=e[u+(y<<2)>>2]))<-1|(0|q)<=(0|B))break t;if((0|R)==(0|(y=y+1|0)))break}for(u=e[c+124>>2],ut=e[b+540>>2],Bt=e[b+536>>2],y=0;;){if((q=e[(B=y<<2)+ut>>2])&&((0|q)<0|(0|u)<(0|q)||(0|(B=e[B+Bt>>2]))<0|(0|u)<=(0|B)||(q=B+q|0)>>>31|(0|u)<(0|q)))break t;if((0|R)==(0|(y=y+1|0)))break}}if(!((255&mt)>>>0<5)){if((y=0)<(0|(mt=e[ce>>2]))){for(R=e[b+348>>2];;){if((0|(u=e[R+(y<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|mt)==(0|(y=y+1|0)))break}for(R=e[b+352>>2],y=0;;){if((0|(u=e[R+(y<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|mt)==(0|(y=y+1|0)))break}}if((mt=0)<(0|(y=e[F>>2]))){for(R=e[b+384>>2];;){if((0|(u=e[R+(mt<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|y)==(0|(mt=mt+1|0)))break}for(R=e[b+388>>2],mt=0;;){if((0|(u=e[R+(mt<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|y)==(0|(mt=mt+1|0)))break}}if((mt=0)<(0|(R=e[Ue>>2]))){for(u=e[b+404>>2];;){if((0|(q=e[u+(mt<<2)>>2]))<0|(0|_)<(0|q))break t;if((0|R)==(0|(mt=mt+1|0)))break}for(u=e[b+408>>2],mt=0;;){if((0|(q=e[u+(mt<<2)>>2]))<0|(0|_)<(0|q))break t;if((0|R)==(0|(mt=mt+1|0)))break}}if((_=0)<(0|(mt=e[c+128>>2]))){for(R=e[c>>2],u=e[b+468>>2];;){if((0|(q=e[u+(_<<2)>>2]))<0|(0|R)<=(0|q))break t;if((0|mt)==(0|(_=_+1|0)))break}for(ce=e[b+476>>2],q=e[b+472>>2],_=0;;){if((R=e[(u=_<<2)+ce>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(u=e[u+q>>2]))<0|(0|d)<=(0|u)||(R=u+R|0)>>>31|(0|d)<(0|R)))break t;if((0|mt)==(0|(_=_+1|0)))break}for(R=e[tt>>2],_=0;;){if(tt=e[q+(_<<2)>>2]<<2,(u=e[tt+g>>2])&&((0|u)<0|(0|R)<(0|u)||(0|(tt=e[V+tt>>2]))<0|(0|R)<=(0|tt)||(0|(u=u+tt|0))<0|(0|R)<(0|u)))break t;if((0|mt)==(0|(_=_+1|0)))break}}if((_=0)<(0|(mt=e[c+132>>2]))){for(R=e[b+492>>2];;){if((0|(u=e[R+(_<<2)>>2]))<0|(0|He)<=(0|u))break t;if((0|mt)==(0|(_=_+1|0)))break}for(tt=e[b+500>>2],u=e[b+496>>2],_=0;;){if((R=e[(q=_<<2)+tt>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(q=e[u+q>>2]))<0|(0|d)<=(0|q)||(R=R+q|0)>>>31|(0|d)<(0|R)))break t;if((0|mt)==(0|(_=_+1|0)))break}for(_=0;;){if(q=e[u+(_<<2)>>2]<<2,(R=e[q+g>>2])&&((0|R)<0|(0|y)<(0|R)||(0|(q=e[V+q>>2]))<0|(0|y)<=(0|q)||(0|(R=R+q|0))<0|(0|y)<(0|R)))break t;if((0|mt)==(0|(_=_+1|0)))break}}if(!(((_=0)|(c=e[c+136>>2]))<=0)){for(y=e[b+516>>2];;){if((0|(mt=e[y+(_<<2)>>2]))<0|(0|S)<=(0|mt))break t;if((0|c)==(0|(_=_+1|0)))break}for(R=e[b+524>>2],y=e[b+520>>2],_=0;;){if((b=e[(mt=_<<2)+R>>2])&&((0|b)<0|(0|d)<(0|b)||(0|(mt=e[y+mt>>2]))<0|(0|d)<=(0|mt)||(b=b+mt|0)>>>31|(0|d)<(0|b)))break t;if((0|c)==(0|(_=_+1|0)))break}for(_=0;;){if(b=e[y+(_<<2)>>2]<<2,(d=e[b+g>>2])&&((0|d)<0|(0|z)<(0|d)||(0|(b=e[b+V>>2]))<0|(0|z)<=(0|b)||(0|(d=d+b|0))<0|(0|z)<(0|d)))break t;if((0|c)==(0|(_=_+1|0)))break}}}}}return K=E,1}return Ut(4,1846,0),K=E,0}e[b+52>>2]=d,e[b+48>>2]=5,Ut(4,1640,b+48|0)}else e[b+32>>2]=d,Ut(4,1554,b+32|0);return K=E,0}(a,p):(e[20+P>>2]=1621,e[16+P>>2]=2284,Ut(4,1294,16+P|0),0):(e[4+P>>2]=1444,e[P>>2]=2284,Ut(4,1294,P),0),K=48+P|0,0|a},j:function(a){e[1805]=a|=0},k:function(a,p){var P;return p|=0,K=P=K-48|0,a=(a|=0)?(a+63&-64)!=(0|a)?(e[36+P>>2]=1522,e[32+P>>2]=2305,Ut(4,1294,32+P|0),0):(p+63&-64)==(0|p)&&p?function(_){var c,E,u,d,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0;e[24+(K=c=K-32|0)>>2]=0,e[16+c>>2]=5,e[20+c>>2]=0,Ao(16+(K=d=K-272|0)|0,2227,e[12+d>>2]=16+c|0),function(z){var q;e[(K=q=K-16|0)>>2]=z,function(tt,ut){var mt;e[12+(K=mt=K-16|0)>>2]=ut,bo(tt,1432,ut,0,0),K=16+mt|0}(e[970],q),K=16+q|0}(16+d|0),K=272+d|0;r:{if(ur(_))Ut(4,1932,0);else{if(!(6<=(b=H[_+4|0])>>>0)){if((0|!H[_+5|0])!=1?(Ee(_+4|0,1),vt(_- -64|0,4,160),ir(_,_+704|(O[_+5|0]=0)),Ji(_)):ir(_,_+704|0),H[7224]||(e[1807]=6,O[7224]=1,e[1808]=7,e[1809]=8,e[1810]=9),y=e[_+704>>2],1<=(0|(b=e[y+16>>2]))){for(V=(S=e[_+912>>2])+(b<<2)|0,R=e[_+908>>2];;){B=e[_+1204>>2]+(e[R>>2]<<2)|0;t:if(!(((y=0)|(g=(b=e[S>>2])+-1|0))<1))e:for(;;){for(;;){if(e[(F=B+(y<<2)|0)>>2]<=-1){if(function(z,q,tt){var ut=0,mt=0;i:if((0|z)!=(0|q)){if(!(z>>>0<q+tt>>>0&&q>>>0<(mt=z+tt|0)>>>0))return ge(z,q,tt);if(ut=3&(z^q),z>>>0<q>>>0){if(!ut){if(3&z)for(;;){if(!tt)break i;if(O[0|z]=H[0|q],q=q+1|0,tt=tt+-1|0,!(3&(z=z+1|0)))break}if(!(tt>>>0<=3)){for(ut=tt;e[z>>2]=e[q>>2],q=q+4|0,z=z+4|0,3<(ut=ut+-4|0)>>>0;);tt&=3}}if(tt)for(;O[0|z]=H[0|q],z=z+1|0,q=q+1|0,tt=tt+-1|0;);}else{if(!ut){if(3&mt)for(;;){if(!tt)break i;if(O[0|(ut=(tt=tt+-1|0)+z|0)]=H[q+tt|0],!(3&ut))break}if(!(tt>>>0<=3))for(;e[(tt=tt+-4|0)+z>>2]=e[q+tt>>2],3<tt>>>0;);}if(tt)for(;O[(tt=tt+-1|0)+z|0]=H[q+tt|0],tt;);}}}(F,F+4|0,(-1^y)+b<<2),(0|y)<(0|(g=(b=g)+-1|0)))continue e;break t}if(!((0|(y=y+1|0))<(0|g)))break}break}if(y=S,0<(0|b)&&(b=e[B+(g<<2)>>2]<0?g:b),e[y>>2]=b,R=R+4|0,!((S=S+4|0)>>>0<V>>>0))break}y=e[_+704>>2]}if(1<=e[y>>2])for(g=0;e[e[_+712>>2]+(g<<2)>>2]=e[_+716>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y>>2];);if(1<=e[y+4>>2])for(g=0;e[e[_+744>>2]+(g<<2)>>2]=e[_+748>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+4>>2];);if(1<=e[y+16>>2])for(g=0;e[(b=g<<2)+e[_+832>>2]>>2]=e[_+848>>2]+(g<<6),e[b+e[_+836>>2]>>2]=e[_+1196>>2]+(e[b+e[_+896>>2]>>2]<<2),e[b+e[_+840>>2]>>2]=e[_+1200>>2]+(e[b+e[_+900>>2]>>2]<<1),e[b+e[_+844>>2]>>2]=e[_+1204>>2]+(e[b+e[_+908>>2]>>2]<<2),y=e[_+704>>2],(0|(g=g+1|0))<e[y+16>>2];);if(1<=e[y+20>>2])for(g=0;e[e[_+916>>2]+(g<<2)>>2]=e[_+920>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+20>>2];);if(1<=e[y+80>>2])for(g=0;e[e[_+1240>>2]+(g<<2)>>2]=e[_+1244>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+80>>2];);if(1&O[e[_+708>>2]+20|0]||(0|(S=e[y+16>>2]))<1)break r;for(g=e[_+904>>2],B=e[_+900>>2],F=e[_+1200>>2],R=0;;){if(0<(0|(V=e[(b=R<<2)+g>>2]+-1|0)))for(E=F+(e[b+B>>2]<<1)|0,y=0;u=W[(b=E+(y<<1)|0)>>1],N[b>>1]=W[b+4>>1],N[b+4>>1]=u,(0|(y=y+3|0))<(0|V););if((0|S)==(0|(R=R+1|0)))break}for(b=e[_+892>>2],R=e[_+896>>2],B=e[_+1196>>2],g=0;;){if(1<=(0|(F=e[(y=g<<2)+b>>2])))for(F=(y=B+(e[y+R>>2]<<2)|0)+(F<<3)|0,y=y+4|0;I[y>>2]=v(1)-I[y>>2],(y=y+8|0)>>>0<F>>>0;);if((0|S)==(0|(g=g+1|0)))break}break r}e[4+c>>2]=b,e[c>>2]=5,Ut(4,2023,c)}_=0}return K=32+c|0,_}(a):(e[20+P>>2]=1621,e[16+P>>2]=2305,Ut(4,1294,16+P|0),0):(e[4+P>>2]=1444,e[P>>2]=2305,Ut(4,1294,P),0),K=48+P|0,0|a},l:function(a,p,P,_){var c;p|=0,P|=0,_|=0,K=c=K+-64|0,(a|=0)?p?P?_?(a=e[e[a>>2]+708>>2],e[p>>2]=e[a+12>>2],e[p+4>>2]=e[a+16>>2],e[P>>2]=e[a+4>>2],e[P+4>>2]=e[a+8>>2],e[_>>2]=e[a>>2]):(e[52+c>>2]=1995,e[48+c>>2]=2325,Ut(4,1294,48+c|0)):(e[36+c>>2]=1903,e[32+c>>2]=2325,Ut(4,1294,32+c|0)):(e[20+c>>2]=1819,e[16+c>>2]=2325,Ut(4,1294,16+c|0)):(e[4+c>>2]=1740,e[c>>2]=2325,Ut(4,1294,c)),K=64+c|0},m:cr,n:jr,o:function(a){var p;K=p=K-16|0,(a|=0)?hi(a):(e[4+p>>2]=1740,e[p>>2]=2387,Ut(4,1294,p)),K=16+p|0},p:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+540>>2]:(e[4+p>>2]=1740,e[p>>2]=2402,Ut(4,1294,p),-1),K=16+p|0,0|a},q:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+916>>2]:(e[4+p>>2]=1740,e[p>>2]=2423,Ut(4,1294,p),0),K=16+p|0,0|a},r:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+548>>2]:(e[4+p>>2]=1740,e[p>>2]=2442,Ut(4,1294,p),0),K=16+p|0,0|a},s:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+928>>2]:(e[4+p>>2]=1740,e[p>>2]=2463,Ut(4,1294,p),0),K=16+p|0,0|a},t:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+924>>2]:(e[4+p>>2]=1740,e[p>>2]=2492,Ut(4,1294,p),0),K=16+p|0,0|a},u:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+932>>2]:(e[4+p>>2]=1740,e[p>>2]=2521,Ut(4,1294,p),0),K=16+p|0,0|a},v:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+552>>2]:(e[4+p>>2]=1740,e[p>>2]=2550,Ut(4,1294,p),0),K=16+p|0,0|a},w:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+4>>2]:(e[4+p>>2]=1740,e[p>>2]=2572,Ut(4,1294,p),-1),K=16+p|0,0|a},x:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+712>>2]:(e[4+p>>2]=1740,e[p>>2]=2588,Ut(4,1294,p),0),K=16+p|0,0|a},y:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+52>>2]:(e[4+p>>2]=1740,e[p>>2]=2602,Ut(4,1294,p),0),K=16+p|0,0|a},z:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+740>>2]:(e[4+p>>2]=1740,e[p>>2]=2622,Ut(4,1294,p),0),K=16+p|0,0|a},A:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+332>>2]:(e[4+p>>2]=1740,e[p>>2]=2650,Ut(4,1294,p),-1),K=16+p|0,0|a},B:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+832>>2]:(e[4+p>>2]=1740,e[p>>2]=2670,Ut(4,1294,p),0),K=16+p|0,0|a},C:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+888>>2]:(e[4+p>>2]=1740,e[p>>2]=2688,Ut(4,1294,p),0),K=16+p|0,0|a},D:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+432>>2]:(e[4+p>>2]=1740,e[p>>2]=2716,Ut(4,1294,p),0),K=16+p|0,0|a},E:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+884>>2]:(e[4+p>>2]=1740,e[p>>2]=2743,Ut(4,1294,p),0),K=16+p|0,0|a},F:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+440>>2]:(e[4+p>>2]=1740,e[p>>2]=2772,Ut(4,1294,p),0),K=16+p|0,0|a},G:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+436>>2]:(e[4+p>>2]=1740,e[p>>2]=2797,Ut(4,1294,p),0),K=16+p|0,0|a},H:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+448>>2]:(e[4+p>>2]=1740,e[p>>2]=2824,Ut(4,1294,p),0),K=16+p|0,0|a},I:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+912>>2]:(e[4+p>>2]=1740,e[p>>2]=2848,Ut(4,1294,p),0),K=16+p|0,0|a},J:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+844>>2]:(e[4+p>>2]=1740,e[p>>2]=2873,Ut(4,1294,p),0),K=16+p|0,0|a},K:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+892>>2]:(e[4+p>>2]=1740,e[p>>2]=2893,Ut(4,1294,p),0),K=16+p|0,0|a},L:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+444>>2]:(e[4+p>>2]=1740,e[p>>2]=2920,Ut(4,1294,p),0),K=16+p|0,0|a},M:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+836>>2]:(e[4+p>>2]=1740,e[p>>2]=2950,Ut(4,1294,p),0),K=16+p|0,0|a},N:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+904>>2]:(e[4+p>>2]=1740,e[p>>2]=2974,Ut(4,1294,p),0),K=16+p|0,0|a},O:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+840>>2]:(e[4+p>>2]=1740,e[p>>2]=3e3,Ut(4,1294,p),0),K=16+p|0,0|a},P:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+452>>2]:(e[4+p>>2]=1740,e[p>>2]=3022,Ut(4,1294,p),0),K=16+p|0,0|a},Q:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+456>>2]:(e[4+p>>2]=1740,e[p>>2]=3051,Ut(4,1294,p),0),K=16+p|0,0|a},R:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+876>>2]:(e[4+p>>2]=1740,e[p>>2]=3078,Ut(4,1294,p),0),K=16+p|0,0|a},S:function(a){var p;K=p=K-16|0,(a|=0)?e[a+428>>2]=1:(e[4+p>>2]=1740,e[p>>2]=3110,Ut(4,1294,p)),K=16+p|0},T:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+640>>2]:(e[4+p>>2]=1740,e[p>>2]=3139,Ut(4,1294,p),0),K=16+p|0,0|a},U:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+636>>2]:(e[4+p>>2]=1740,e[p>>2]=3164,Ut(4,1294,p),0),K=16+p|0,0|a},V:function(a){var p;return qe(12+(K=p=K-16|0)|0,64,a|=0),K=16+p|0,e[12+p>>2]},W:function(a){var p,P,_=0;return K=P=K-16|0,!(a|=0)||qe(12+P|0,16,p=cr(a))||(_=jr(a,e[12+P>>2],p))||(gr(e[12+P>>2]),_=0),K=16+P|0,0|_},X:function(a){return 0|Je(a|=0)},Y:function(a){gr(a|=0)},Z:function(a){var p;qe(12+(K=p=K-16|0)|0,64,a|=0),gr(e[12+p>>2]),K=16+p|0},_:function(){return 0|K},$:function(a){return 0|(K=K-(0|a)&-16)},aa:function(a){K=0|a},ba:function(a){return 0|(a=0|(a|=0),(P=0|$o())<(a=P+(a|=0)|0)&&a<65536&&(a=new ArrayBuffer(j(a,65536)),(p=new l.Int8Array(a)).set(O),O=p,O=new l.Int8Array(a),N=new l.Int16Array(a),e=new l.Int32Array(a),H=new l.Uint8Array(a),W=new l.Uint16Array(a),rt=new l.Uint32Array(a),I=new l.Float32Array(a),ct=new l.Float64Array(a),w=a,$.buffer=a),P);var p,P},ca:function(a,p){L[a|=0](p|=0)}};function vt(a,p,P){var _,c,E=0;if(P)for(;;){if(P=P+-1|0,a>>>0<(E=(_=a+p|0)-1|0)>>>0)for(;c=H[0|a],O[0|a]=H[0|E],O[0|E]=c,(a=a+1|0)>>>0<(E=E+-1|0)>>>0;);if(a=_,!P)break}}function Ut(a,p,P){var _;K=_=K-272|0,rt[1804]>a>>>0||(a=e[1805])&&(Ao(16+_|0,p,e[12+_>>2]=P),L[a](16+_|0)),K=272+_|0}function Fe(a,p,P){32&H[0|a]||function(_,c,E){var u=0,d=0,g=0;r:{if(!(u=e[E+16>>2])){if(function(y){var b;return b=H[y+74|0],O[y+74|0]=b+-1|b,8&(b=e[y>>2])?(e[y>>2]=32|b,1):(e[y+4>>2]=0,e[y+8>>2]=0,b=e[y+44>>2],e[y+28>>2]=b,e[y+20>>2]=b,e[y+16>>2]=b+e[y+48>>2],0)}(E))break r;u=e[E+16>>2]}if(u-(g=e[E+20>>2])>>>0<c>>>0)return L[e[E+36>>2]](E,_,c);t:if(!(O[E+75|0]<0)){for(u=c;;){if(!(d=u))break t;if(H[(u=d+-1|0)+_|0]==10)break}if(L[e[E+36>>2]](E,_,d)>>>0<d>>>0)break r;c=c-d|0,_=_+d|0,g=e[E+20>>2]}ge(g,_,c),e[E+20>>2]=e[E+20>>2]+c}}(p,P,a)}function We(a,p,P,_,c){var E,u,d;if(K=d=K-256|0,!(73728&c|(0|P)<=(0|_))){if(Ce(d,p,(E=(c=P-_|0)>>>0<256)?c:256),p=a,u=d,!E){for(P=P-_|0;Fe(a,d,256),255<(c=c+-256|0)>>>0;);c=255&P}Fe(p,u,c)}K=256+d|0}function ge(a,p,P){var _,c=0;if(8192<=P>>>0)Lt(0|a,0|p,0|P);else{if(_=a+P|0,3&(a^p))if(_>>>0<4)P=a;else if((c=_-4|0)>>>0<a>>>0)P=a;else for(P=a;O[0|P]=H[0|p],O[P+1|0]=H[p+1|0],O[P+2|0]=H[p+2|0],O[P+3|0]=H[p+3|0],p=p+4|0,(P=P+4|0)>>>0<=c>>>0;);else{r:if((0|P)<1)P=a;else if(3&a)for(P=a;;){if(O[0|P]=H[0|p],p=p+1|0,_>>>0<=(P=P+1|0)>>>0)break r;if(!(3&P))break}else P=a;if(!((a=-4&_)>>>0<64||(c=a+-64|0)>>>0<P>>>0))for(;e[P>>2]=e[p>>2],e[P+4>>2]=e[p+4>>2],e[P+8>>2]=e[p+8>>2],e[P+12>>2]=e[p+12>>2],e[P+16>>2]=e[p+16>>2],e[P+20>>2]=e[p+20>>2],e[P+24>>2]=e[p+24>>2],e[P+28>>2]=e[p+28>>2],e[P+32>>2]=e[p+32>>2],e[P+36>>2]=e[p+36>>2],e[P+40>>2]=e[p+40>>2],e[P+44>>2]=e[p+44>>2],e[P+48>>2]=e[p+48>>2],e[P+52>>2]=e[p+52>>2],e[P+56>>2]=e[p+56>>2],e[P+60>>2]=e[p+60>>2],p=p- -64|0,(P=P- -64|0)>>>0<=c>>>0;);if(!(a>>>0<=P>>>0))for(;e[P>>2]=e[p>>2],p=p+4|0,(P=P+4|0)>>>0<a>>>0;);}if(P>>>0<_>>>0)for(;O[0|P]=H[0|p],p=p+1|0,(0|_)!=(0|(P=P+1|0)););}}function me(a){var p,P;return v((p=a*a)*p*(P=p*a)*(2718311493989822e-21*p-.00019839334836096632)+(P*(.008333329385889463*p-.16666666641626524)+a))}function ve(a){var p;return v(-.499999997251031*(a*=a)+1+.04166662332373906*(p=a*a)+a*p*(2439044879627741e-20*a-.001388676377460993))}function Ce(a,p,P){var _,c,E,u;if(P&&(O[(_=a+P|0)-1|0]=p,O[0|a]=p,!(P>>>0<3||(O[_-2|0]=p,O[a+1|0]=p,O[_-3|0]=p,O[a+2|0]=p,P>>>0<7)||(O[_-4|0]=p,O[a+3|0]=p,P>>>0<9)||(c=(_=0-a&3)+a|0,p=j(255&p,16843009),e[c>>2]=p,e[(_=(P=P-_&-4)+c|0)-4>>2]=p,P>>>0<9)||(e[8+c>>2]=p,e[4+c>>2]=p,e[_-8>>2]=p,e[_-12>>2]=p,P>>>0<25)||(e[24+c>>2]=p,e[20+c>>2]=p,e[16+c>>2]=p,e[12+c>>2]=p,e[_-16>>2]=p,e[_-20>>2]=p,e[_-24>>2]=p,e[_-28>>2]=p,(P=P-(u=4&c|24)|0)>>>0<32))))for(E=_=p,p=c+u|0;e[p+24>>2]=E,e[p+28>>2]=_,e[p+16>>2]=E,e[p+20>>2]=_,e[p+8>>2]=E,e[p+12>>2]=_,e[p>>2]=E,e[p+4>>2]=_,p=p+32|0,31<(P=P+-32|0)>>>0;);return a}function Ee(a,p){var P;if(a>>>0<(p=(a+p|0)-1|0)>>>0)for(;P=H[0|a],O[0|a]=H[0|p],O[0|p]=P,(a=a+1|0)>>>0<(p=p+-1|0)>>>0;);}function Me(a){var p,P=$o();return(a=(p=e[2216])+a|0)>>>0<=P<<16>>>0||re(0|a)?(e[2216]=a,p):(e[2086]=48,-1)}function te(a,p,P,_,c,E,u){var d,g,y,b,S,R,F,B,V,z,q=0,tt=v(0),ut=v(0),mt=v(0);if(v(0),v(0),v(0),v(0),K=z=K-16|0,1<=(0|a))for(R=j(a,12)+p|0;;){if(1<=(0|(g=e[p+4>>2])))for(F=(a=e[p+8>>2])+j(g,48)|0,g=(d=e[p>>2]<<4)+u|0,y=(8|d)+u|0,d=(4|d)+u|0;(q=e[a+8>>2])&&((B=q+-1|0)>>>0<=1?(V=(e[a+4>>2]<<2)+P|0,q=e[V+(e[a+12>>2]<<2)>>2]<<2,tt=I[q+E>>2],S=I[c+q>>2],ut=I[_+q>>2],B-1?(mt=ut,ut=I[a+20>>2],I[g>>2]=I[g>>2]+v(I[a+44>>2]*v(mt*ut)),I[d>>2]=I[d>>2]+v(v(S*ut)*I[a+44>>2]),I[y>>2]=I[y>>2]+v(v(tt*ut)*I[a+44>>2])):(q=e[(e[a+16>>2]<<2)+V>>2]<<2,B=I[q+E>>2],V=I[c+q>>2],mt=ut,ut=I[a+20>>2],b=I[a+24>>2],I[g>>2]=I[g>>2]+v(I[a+44>>2]*v(v(mt*ut)+v(I[_+q>>2]*b))),I[d>>2]=I[d>>2]+v(v(v(S*ut)+v(V*b))*I[a+44>>2]),I[y>>2]=I[y>>2]+v(v(v(tt*ut)+v(B*b))*I[a+44>>2]))):(e[z>>2]=q,Ut(4,1024,z))),(a=a+48|0)>>>0<F>>>0;);if(a=(e[p>>2]<<4)+u|0,tt=I[a>>2],I[a>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),tt=I[a+4>>2],I[a+4>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),tt=I[a+8>>2],I[a+8>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),!((p=p+12|0)>>>0<R>>>0))break}K=16+z|0}function ye(a,p,P){var _,c,E=0;if((0|p)==1&a>>>0<0|p>>>0<1)E=a;else for(;_=So(E=Po(a,p,10),c=Vt,10),O[0|(P=P+-1|0)]=a-_|48,_=(0|p)==9&4294967295<a>>>0|9<p>>>0,a=E,p=c,_;);if(E)for(;O[0|(P=P+-1|0)]=E-j(a=(E>>>0)/10|0,10)|48,p=9<E>>>0,E=a,p;);return P}function ie(a){return a+-48>>>0<10}function he(a){var p;return(p=wo(a,64))?p-a|0:64}function Be(a,p){var P=0;return 1024<=(0|p)?(a*=898846567431158e293,p=(0|(P=p+-1023|0))<1024?P:(a*=898846567431158e293,((0|p)<3069?p:3069)+-2046|0)):-1023<(0|p)||(a*=22250738585072014e-324,p=-1023<(0|(P=p+1022|0))?P:(a*=22250738585072014e-324,(-3066<(0|p)?p:-3066)+2044|0)),Yt(0,0),Yt(1,p+1023<<20),a*+ze()}function lr(a,p){var P=0,_=a,c=p>>>0<=31?(P=e[a+4>>2],e[a>>2]):(P=e[a>>2],e[a+4>>2]=P,p=p+-32|(e[a>>2]=0),0);e[_>>2]=c<<p,e[a+4>>2]=P<<p|c>>>32-p}function je(a,p,P,_,c){var E,u=0,d=0,g=0;K=E=K-240|0,u=e[p>>2],e[232+E>>2]=u,p=e[p+4>>2],e[E>>2]=a,d=1;r:{t:{e:{if(((e[236+E>>2]=p)||(0|u)!=1)&&(u=a-e[(P<<2)+c>>2]|0,!((0|L[5](u,a))<1))){for(g=!_;;){i:{if(p=u,!(!g|(0|P)<2)&&(_=e[((P<<2)+c|0)-8>>2],-1<(0|L[5](u=a+-4|0,p))||-1<(0|L[5](u-_|0,p))))break i;if(e[(d<<2)+E>>2]=p,d=d+1|0,Le(232+E|0,a=Co(232+E|0)),P=a+P|0,!e[236+E>>2]&&e[232+E>>2]==1)break t;if(g=1,u=(a=p)-e[(P<<2)+c>>2]|(_=0),0<(0|L[5](u,e[E>>2])))continue;break e}break}p=a;break t}p=a}if(_)break r}Eo(E,d),Br(p,P,c)}K=240+E|0}function Le(a,p){var P=0,_=a,c=p>>>0<=31?(P=e[a>>2],e[a+4>>2]):(P=e[a+4>>2],e[a+4>>2]=0,e[a>>2]=P,p=p+-32|0,0);e[_+4>>2]=c>>>p,e[a>>2]=c<<32-p|P>>>p}function ir(a,p){var P=H[a+4|0];e[p>>2]=e[a+64>>2]+a,e[p+4>>2]=e[a+68>>2]+a,e[p+8>>2]=e[a+72>>2]+a,e[p+12>>2]=e[a+76>>2]+a,e[p+16>>2]=e[a+80>>2]+a,e[p+20>>2]=e[a+84>>2]+a,e[p+24>>2]=e[a+88>>2]+a,e[p+28>>2]=e[a+92>>2]+a,e[p+32>>2]=e[a+96>>2]+a,e[p+36>>2]=e[a+100>>2]+a,e[p+40>>2]=e[a+104>>2]+a,e[p+44>>2]=e[a+108>>2]+a,e[p+48>>2]=e[a+112>>2]+a,e[p+52>>2]=e[a+116>>2]+a,e[p+56>>2]=e[a+120>>2]+a,e[p+60>>2]=e[a+124>>2]+a,e[p- -64>>2]=e[a+128>>2]+a,e[p+68>>2]=e[a+132>>2]+a,e[p+72>>2]=e[a+136>>2]+a,e[p+76>>2]=e[a+140>>2]+a,e[p+80>>2]=e[a+144>>2]+a,e[p+84>>2]=e[a+148>>2]+a,e[p+92>>2]=e[a+152>>2]+a,e[p+96>>2]=e[a+156>>2]+a,e[p+100>>2]=e[a+160>>2]+a,e[p+108>>2]=e[a+164>>2]+a,e[p+112>>2]=e[a+168>>2]+a,e[p+116>>2]=e[a+172>>2]+a,e[p+124>>2]=e[a+176>>2]+a,e[p+128>>2]=e[a+180>>2]+a,e[p+132>>2]=e[a+184>>2]+a,e[p+136>>2]=e[a+188>>2]+a,e[p+140>>2]=e[a+192>>2]+a,e[p+144>>2]=e[a+196>>2]+a,e[p+148>>2]=e[a+200>>2]+a,e[p+152>>2]=e[a+204>>2]+a,e[p+156>>2]=e[a+208>>2]+a,e[p+164>>2]=e[a+212>>2]+a,e[p+168>>2]=e[a+216>>2]+a,e[p+172>>2]=e[a+220>>2]+a,e[p+176>>2]=e[a+224>>2]+a,e[p+180>>2]=e[a+228>>2]+a,e[p+184>>2]=e[a+232>>2]+a,e[p+188>>2]=e[a+236>>2]+a,e[p+192>>2]=e[a+240>>2]+a,e[p+196>>2]=e[a+244>>2]+a,e[p+200>>2]=e[a+248>>2]+a,e[p+204>>2]=e[a+252>>2]+a,e[p+208>>2]=e[a+256>>2]+a,e[p+212>>2]=e[a+260>>2]+a,e[p+216>>2]=e[a+264>>2]+a,e[p+220>>2]=e[a+268>>2]+a,e[p+224>>2]=e[a+272>>2]+a,e[p+228>>2]=e[a+276>>2]+a,e[p+232>>2]=e[a+280>>2]+a,e[p+236>>2]=e[a+284>>2]+a,e[p+244>>2]=e[a+288>>2]+a,e[p+248>>2]=e[a+292>>2]+a,e[p+272>>2]=e[a+296>>2]+a,e[p+276>>2]=e[a+300>>2]+a,e[p+280>>2]=e[a+304>>2]+a,e[p+292>>2]=e[a+308>>2]+a,e[p+296>>2]=e[a+312>>2]+a,e[p+300>>2]=e[a+316>>2]+a,e[p+304>>2]=e[a+320>>2]+a,e[p+308>>2]=e[a+324>>2]+a,e[p+312>>2]=e[a+328>>2]+a,e[p+316>>2]=e[a+332>>2]+a,e[p+328>>2]=e[a+336>>2]+a,e[p+332>>2]=e[a+340>>2]+a,e[p+336>>2]=e[a+344>>2]+a,e[p+348>>2]=e[a+348>>2]+a,e[p+360>>2]=e[a+352>>2]+a,e[p+364>>2]=e[a+356>>2]+a,e[p+368>>2]=e[a+360>>2]+a,e[p+352>>2]=e[a+364>>2]+a,e[p+356>>2]=e[a+368>>2]+a,e[p+488>>2]=e[a+372>>2]+a,e[p+492>>2]=e[a+376>>2]+a,e[p+496>>2]=e[a+380>>2]+a,e[p+500>>2]=e[a+384>>2]+a,e[p+504>>2]=e[a+388>>2]+a,e[p+508>>2]=e[a+392>>2]+a,e[p+512>>2]=e[a+396>>2]+a,e[p+516>>2]=e[a+400>>2]+a,e[p+520>>2]=e[a+404>>2]+a,e[p+524>>2]=e[a+408>>2]+a,e[p+528>>2]=e[a+412>>2]+a,e[p+532>>2]=e[a+416>>2]+a,e[p+536>>2]=e[a+420>>2]+a,e[p+540>>2]=e[a+424>>2]+a,e[p+544>>2]=e[a+428>>2]+a,e[p+548>>2]=e[a+432>>2]+a,e[p+552>>2]=e[a+436>>2]+a,e[p+556>>2]=e[a+440>>2]+a,e[p+560>>2]=e[a+444>>2]+a,e[p+564>>2]=e[a+448>>2]+a,e[p+568>>2]=e[a+452>>2]+a,e[p+572>>2]=e[a+456>>2]+a,e[p+576>>2]=e[a+460>>2]+a,e[p+580>>2]=e[a+464>>2]+a,P>>>0<2||(e[p+104>>2]=e[a+468>>2]+a,P>>>0<4)||(e[p+260>>2]=e[a+472>>2]+a,e[p+264>>2]=e[a+476>>2]+a,e[p+268>>2]=e[a+480>>2]+a,e[p+88>>2]=e[a+484>>2]+a,e[p+120>>2]=e[a+488>>2]+a,e[p+160>>2]=e[a+492>>2]+a,e[p+584>>2]=e[a+496>>2]+a,e[p+588>>2]=e[a+500>>2]+a,e[p+592>>2]=e[a+504>>2]+a,e[p+596>>2]=e[a+508>>2]+a,e[p+600>>2]=e[a+512>>2]+a,e[p+604>>2]=e[a+516>>2]+a,e[p+240>>2]=e[a+520>>2]+a,e[p+252>>2]=e[a+524>>2]+a,e[p+256>>2]=e[a+528>>2]+a,e[p+372>>2]=e[a+532>>2]+a,e[p+376>>2]=e[a+536>>2]+a,e[p+380>>2]=e[a+540>>2]+a,e[p+384>>2]=e[a+544>>2]+a,e[p+388>>2]=e[a+548>>2]+a,e[p+392>>2]=e[a+552>>2]+a,e[p+396>>2]=e[a+556>>2]+a,e[p+400>>2]=e[a+560>>2]+a,e[p+416>>2]=e[a+564>>2]+a,e[p+420>>2]=e[a+568>>2]+a,e[p+424>>2]=e[a+572>>2]+a,e[p+440>>2]=e[a+576>>2]+a,e[p+444>>2]=e[a+580>>2]+a,e[p+448>>2]=e[a+584>>2]+a,e[p+464>>2]=e[a+588>>2]+a,e[p+468>>2]=e[a+592>>2]+a,e[p+472>>2]=e[a+596>>2]+a,e[p+476>>2]=e[a+600>>2]+a,e[p+480>>2]=e[a+604>>2]+a,e[p+484>>2]=e[a+608>>2]+a,(0|P)!=4&&(e[p+284>>2]=e[a+612>>2]+a,e[p+288>>2]=e[a+616>>2]+a,e[p+320>>2]=e[a+620>>2]+a,e[p+324>>2]=e[a+624>>2]+a,e[p+340>>2]=e[a+628>>2]+a,e[p+344>>2]=e[a+632>>2]+a,e[p+404>>2]=e[a+636>>2]+a,e[p+408>>2]=e[a+640>>2]+a,e[p+412>>2]=e[a+644>>2]+a,e[p+428>>2]=e[a+648>>2]+a,e[p+432>>2]=e[a+652>>2]+a,e[p+436>>2]=e[a+656>>2]+a,e[p+452>>2]=e[a+660>>2]+a,e[p+456>>2]=e[a+664>>2]+a,e[p+460>>2]=e[a+668>>2]+a))}function qe(a,p,P){var _=0;r:{if((0|p)==8)p=Je(P);else{if(_=28,3&p|(0|function(c){for(var E=0,u=0;u=E,c;)c&=c-1,E=E+1|0;return u}(p>>>2))!=1||(_=48,-64-p>>>0<P>>>0))break r;p=function(c,E){var u,d,g=0,y=0,b=0;if((y=c>>>0>(g=16)?c:16)+-1&y)for(;g=(c=g)<<1,c>>>0<y>>>0;);else c=y;return-64-c>>>0<=E>>>0?(e[2086]=48,0):(g=Je(12+((y=E>>>0<11?16:E+11&-8)+c|0)|0))?(E=g+-8|0,g&c+-1?(b=(-8&(d=e[(u=g+-4|0)>>2]))-(g=(c=15<(g=((c+g|0)-1&0-c)-8|0)-E>>>0?g:c+g|0)-E|0)|0,3&d?(e[c+4>>2]=b|1&e[c+4>>2]|2,e[4+(b=c+b|0)>>2]=1|e[4+b>>2],e[u>>2]=g|1&e[u>>2]|2,e[c+4>>2]=1|e[c+4>>2],ts(E,g)):(E=e[E>>2],e[c+4>>2]=b,e[c>>2]=E+g)):c=E,3&(E=e[c+4>>2])&&((g=-8&E)>>>0<=y+16>>>0||(e[c+4>>2]=y|1&E|2,e[(E=c+y|0)+4>>2]=3|(y=g-y|0),e[4+(g=c+g|0)>>2]=1|e[g+4>>2],ts(E,y))),c+8|0):0}(16<p>>>0?p:16,P)}if(!p)return 1;e[a>>2]=p,_=0}return _}function gr(a){var p,P=0,_=0,c=0,E=0,u=0,d=0,g=0;r:if(a){p=(c=a+-8|0)+(a=-8&(_=e[a+-4>>2]))|0;t:if(!(1&_)){if(!(3&_)||(c=c-(_=e[c>>2])|0)>>>0<rt[2091])break r;if(a=a+_|0,e[2092]!=(0|c))if(_>>>0<=255)E=e[c+8>>2],_>>>=3,(0|(P=e[c+12>>2]))==(0|E)?(g=e[2087]&kr(_),e[2087]=g):(e[E+12>>2]=P,e[P+8>>2]=E);else{if(d=e[c+24>>2],(0|c)!=(0|(_=e[c+12>>2])))P=e[c+8>>2],e[P+12>>2]=_,e[_+8>>2]=P;else if(P=(P=e[(E=c+20|0)>>2])||e[(E=c+16|0)>>2]){for(;u=E,(P=e[(E=(_=P)+20|0)>>2])||(E=_+16|0,P=e[_+16>>2]););e[u>>2]=0}else _=0;if(d){E=e[c+28>>2];e:{if(e[(P=8652+(E<<2)|0)>>2]==(0|c)){if(e[P>>2]=_)break e;g=e[2088]&kr(E),e[2088]=g;break t}if(!(e[d+(e[d+16>>2]==(0|c)?16:20)>>2]=_))break t}e[_+24>>2]=d,(P=e[c+16>>2])&&(e[_+16>>2]=P,e[P+24>>2]=_),(P=e[c+20>>2])&&(e[_+20>>2]=P,e[P+24>>2]=_)}}else if((3&(_=e[4+p>>2]))==3)return e[2089]=a,e[4+p>>2]=-2&_,e[c+4>>2]=1|a,e[a+c>>2]=a}if(!(p>>>0<=c>>>0)&&1&(_=e[4+p>>2])){t:{if(!(2&_)){if(e[2093]==(0|p)){if(e[2093]=c,a=e[2090]+a|0,e[2090]=a,e[c+4>>2]=1|a,e[2092]!=(0|c))break r;return e[2089]=0,e[2092]=0}if(e[2092]==(0|p))return e[2092]=c,a=e[2089]+a|0,e[2089]=a,e[c+4>>2]=1|a,e[a+c>>2]=a;a=(-8&_)+a|0;e:if(_>>>0<=255)_>>>=3,(0|(P=e[8+p>>2]))==(0|(E=e[12+p>>2]))?(g=e[2087]&kr(_),e[2087]=g):(e[P+12>>2]=E,e[E+8>>2]=P);else{if(d=e[24+p>>2],(0|p)!=(0|(_=e[12+p>>2])))P=e[8+p>>2],e[P+12>>2]=_,e[_+8>>2]=P;else if(P=(P=e[(E=20+p|0)>>2])||e[(E=16+p|0)>>2]){for(;u=E,(P=e[(E=(_=P)+20|0)>>2])||(E=_+16|0,P=e[_+16>>2]););e[u>>2]=0}else _=0;if(d){E=e[28+p>>2];i:{if(e[(P=8652+(E<<2)|0)>>2]==(0|p)){if(e[P>>2]=_)break i;g=e[2088]&kr(E),e[2088]=g;break e}if(!(e[d+(e[d+16>>2]==(0|p)?16:20)>>2]=_))break e}e[_+24>>2]=d,(P=e[16+p>>2])&&(e[_+16>>2]=P,e[P+24>>2]=_),(P=e[20+p>>2])&&(e[_+20>>2]=P,e[P+24>>2]=_)}}if(e[c+4>>2]=1|a,e[a+c>>2]=a,e[2092]!=(0|c))break t;return e[2089]=a}e[4+p>>2]=-2&_,e[c+4>>2]=1|a,e[a+c>>2]=a}if(a>>>0<=255)return _=8388+((a>>>=3)<<3)|0,a=(P=e[2087])&(a=1<<a)?e[_+8>>2]:(e[2087]=a|P,_),e[_+8>>2]=c,e[a+12>>2]=c,e[c+12>>2]=_,e[c+8>>2]=a;e[c+16>>2]=0,P=e[c+20>>2]=0,(E=a>>>8)&&(P=31,16777215<a>>>0||(P=E,P=28+((P=((P=(P<<=E=E+1048320>>>16&8)<<(d=P+520192>>>16&4))<<(u=P+245760>>>16&2)>>>15)-(u|E|d)|0)<<1|a>>>P+21&1)|0)),u=8652+((e[(_=c)+28>>2]=P)<<2)|0;t:if((E=e[2088])&(_=1<<P)){E=a<<((0|P)==31?0:25-(P>>>1)|0),_=e[u>>2];e:{for(;;){if((-8&e[(P=_)+4>>2])==(0|a))break e;if(_=E>>>29,E<<=1,!(_=e[16+(u=P+(4&_)|0)>>2]))break}e[u+16>>2]=c,e[c+12>>2]=c,e[c+24>>2]=P,e[c+8>>2]=c;break t}a=e[P+8>>2],e[a+12>>2]=c,e[P+8>>2]=c,e[c+24>>2]=0,e[c+12>>2]=P,e[c+8>>2]=a}else e[2088]=_|E,e[u>>2]=c,e[c+12>>2]=c,e[c+24>>2]=u,e[c+8>>2]=c;if(a=e[2095]+-1|0,!(e[2095]=a)){for(c=8804;c=(a=e[c>>2])+8|0,a;);e[2095]=-1}}}}function Je(a){var p,P=0,_=0,c=0,E=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0;K=p=K-16|0;r:{t:{e:{i:{s:{o:{n:{c:{f:{l:{a:{if(a>>>0<=244){if(3&(P=(u=e[2087])>>>(a=(d=a>>>0<11?16:a+11&-8)>>>3))){a=(P=e[8396+(E=(_=a+(1&(-1^P))|0)<<3)>>2])+8|0,(0|(c=e[P+8>>2]))==(0|(E=E+8388|0))?(R=kr(_)&u,e[2087]=R):(e[c+12>>2]=E,e[E+8>>2]=c),e[P+4>>2]=3|(_<<=3),e[4+(P=P+_|0)>>2]=1|e[P+4>>2];break r}if(d>>>0<=(y=e[2089])>>>0)break a;if(P){_=P=(a=(0-(a=(0-(_=2<<a)|_)&P<<a)&a)-1|0)>>>12&16,P=e[8396+(c=(_=((_=(_|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)|0)<<3)>>2],(0|(a=e[P+8>>2]))==(0|(c=c+8388|0))?(u=kr(_)&u,e[2087]=u):(e[a+12>>2]=c,e[c+8>>2]=a),a=P+8|0,e[P+4>>2]=3|d,e[4+(g=P+d|0)>>2]=1|(E=(_<<=3)-d|0),e[P+_>>2]=E,y&&(P=8388+((_=y>>>3)<<3)|0,c=e[2092],_=(_=1<<_)&u?e[P+8>>2]:(e[2087]=_|u,P),e[P+8>>2]=c,e[_+12>>2]=c,e[c+12>>2]=P,e[c+8>>2]=_),e[2092]=g,e[2089]=E;break r}if(!(S=e[2088]))break a;for(_=P=(a=(S&0-S)-1|0)>>>12&16,P=e[8652+(((_=(_|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)<<2)>>2],c=(-8&e[P+4>>2])-d|0,_=P;a=(a=e[_+16>>2])||e[_+20>>2];)c=(_=(E=(-8&e[a+4>>2])-d|0)>>>0<c>>>0)?E:c,P=_?a:P,_=a;if(b=e[P+24>>2],(0|(E=e[P+12>>2]))!=(0|P)){a=e[P+8>>2],e[a+12>>2]=E,e[E+8>>2]=a;break t}if(!(a=e[(_=P+20|0)>>2])){if(!(a=e[P+16>>2]))break l;_=P+16|0}for(;g=_,(a=e[(_=(E=a)+20|0)>>2])||(_=E+16|0,a=e[E+16>>2]););e[g>>2]=0;break t}if(d=-1,!(4294967231<a>>>0)&&(d=-8&(P=a+11|0),y=e[2088])){_=0-d|0,u=0,(P>>>=8)&&(u=31,16777215<d>>>0||(u=28+((a=((u=(P<<=c=P+1048320>>>16&8)<<(a=P+520192>>>16&4))<<(P=u+245760>>>16&2)>>>15)-(P|a|c)|0)<<1|d>>>a+21&1)|0));d:{p:{if(c=e[8652+(u<<2)>>2])for(P=d<<((0|u)==31?0:25-(u>>>1)|0),a=0;;){if(!(_>>>0<=(g=(-8&e[c+4>>2])-d|0)>>>0||(E=c,_=g))){_=0,a=c;break p}if(g=e[c+20>>2],c=e[16+((P>>>29&4)+c|0)>>2],a=g&&(0|g)!=(0|c)?g:a,P<<=(0|c)!=0,!c)break}else a=0;if(!(a|E)){if(!(a=(0-(a=2<<u)|a)&y))break a;c=P=(a=(a&0-a)-1|0)>>>12&16,a=e[8652+(((c=(c|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)<<2)>>2]}if(!a)break d}for(;_=(P=(c=(-8&e[a+4>>2])-d|0)>>>0<_>>>0)?c:_,E=P?a:E,a=(P=e[a+16>>2])||e[a+20>>2];);}if(!(!E|_>>>0>=e[2089]-d>>>0)){if(g=e[E+24>>2],(0|E)!=(0|(P=e[E+12>>2]))){a=e[E+8>>2],e[a+12>>2]=P,e[P+8>>2]=a;break e}if(!(a=e[(c=E+20|0)>>2])){if(!(a=e[E+16>>2]))break f;c=E+16|0}for(;u=c,(a=e[(c=(P=a)+20|0)>>2])||(c=P+16|0,a=e[P+16>>2]););e[u>>2]=0;break e}}}if(d>>>0<=(P=e[2089])>>>0){a=e[2092],16<=(_=P-d|0)>>>0?(e[2089]=_,e[2092]=c=a+d|0,e[c+4>>2]=1|_,e[a+P>>2]=_,e[a+4>>2]=3|d):(e[2092]=0,e[2089]=0,e[a+4>>2]=3|P,e[4+(P=a+P|0)>>2]=1|e[P+4>>2]),a=a+8|0;break r}if(d>>>0<(c=e[2090])>>>0){e[2090]=P=c-d|0,a=e[2093],e[2093]=_=a+d|0,e[_+4>>2]=1|P,e[a+4>>2]=3|d,a=a+8|0;break r}if((_=(u=(_=E=d+47|(a=0))+(P=e[2205]?e[2207]:(e[2208]=-1,e[2209]=-1,e[2206]=4096,e[2207]=4096,e[2205]=12+p&-16^1431655768,e[2210]=0,e[2198]=0,4096))|0)&(g=0-P|0))>>>0<=d>>>0||(P=e[2197])&&(b=(y=e[2195])+_|0)>>>0<=y>>>0|P>>>0<b>>>0)break r;if(4&H[8792])break o;a:{d:{if(P=e[2093])for(a=8796;;){if((y=e[a>>2])+e[a+4>>2]>>>0>P>>>0&&y>>>0<=P>>>0)break d;if(!(a=e[a+8>>2]))break}if((0|(P=Me(0)))==-1||(u=_,(u=(c=(a=e[2206])+-1|0)&P?(_-P|0)+(P+c&0-a)|0:u)>>>0<=d>>>0|2147483646<u>>>0)||(a=e[2197])&&(g=(c=e[2195])+u|0)>>>0<=c>>>0|a>>>0<g>>>0)break n;if((0|P)!=(0|(a=Me(u))))break a;break s}if(2147483646<(u=g&u-c)>>>0)break n;if((0|(P=Me(u)))==(e[a>>2]+e[a+4>>2]|0))break c;a=P}if(!(d+48>>>0<=u>>>0|2147483646<u>>>0|(0|(P=a))==-1)){if(2147483646<(a=(a=e[2207])+(E-u|0)&0-a)>>>0)break s;if((0|Me(a))!=-1){u=a+u|0;break s}Me(0-u|0);break n}if((0|P)!=-1)break s;break n}E=0;break t}P=0;break e}if((0|P)!=-1)break s}e[2198]=4|e[2198]}if(2147483646<_>>>0||(P=Me(_),(a=Me(0))>>>0<=P>>>0|(0|P)==-1|(0|a)==-1)||(u=a-P|0)>>>0<=d+40>>>0)break i}a=e[2195]+u|0,(e[2195]=a)>>>0>rt[2196]&&(e[2196]=a);s:{o:{n:{if(_=e[2093]){for(a=8796;;){if(((c=e[a>>2])+(E=e[a+4>>2])|0)==(0|P))break n;if(!(a=e[a+8>>2]))break}break o}for((a=e[2091])>>>0<=P>>>0&&a||(e[2091]=P),a=0,e[2200]=u,e[2199]=P,e[2095]=-1,e[2096]=e[2205],e[2202]=0;e[8396+(_=a<<3)>>2]=c=_+8388|0,e[_+8400>>2]=c,(0|(a=a+1|0))!=32;);e[2090]=c=(a=u+-40|0)-(_=P+8&7?-8-P&7:0)|0,e[2093]=_=P+_|0,e[_+4>>2]=1|c,e[4+(a+P|0)>>2]=40,e[2094]=e[2209];break s}if(!(8&H[a+12|0]|P>>>0<=_>>>0|_>>>0<c>>>0)){e[a+4>>2]=E+u,e[2093]=P=(a=_+8&7?-8-_&7:0)+_|0,c=e[2090]+u|0,e[2090]=a=c-a|0,e[P+4>>2]=1|a,e[4+(_+c|0)>>2]=40,e[2094]=e[2209];break s}}P>>>0<(E=e[2091])>>>0&&(e[2091]=P,E=0),c=P+u|0,a=8796;o:{n:{c:{f:{l:{a:{for(;(0|c)!=e[a>>2];)if(!(a=e[a+8>>2]))break a;if(!(8&H[a+12|0]))break l}for(a=8796;;){if((c=e[a>>2])>>>0<=_>>>0&&_>>>0<(E=c+e[a+4>>2]|0)>>>0)break f;a=e[a+8>>2]}}if(e[a>>2]=P,e[a+4>>2]=e[a+4>>2]+u,e[4+(b=(P+8&7?-8-P&7:0)+P|0)>>2]=3|d,a=((P=c+(c+8&7?-8-c&7:0)|0)-b|0)-d|0,g=d+b|0,(0|P)==(0|_)){e[2093]=g,a=e[2090]+a|0,e[2090]=a,e[g+4>>2]=1|a;break n}if(e[2092]==(0|P)){e[2092]=g,a=e[2089]+a|0,e[2089]=a,e[g+4>>2]=1|a,e[a+g>>2]=a;break n}if((3&(_=e[P+4>>2]))==1){S=-8&_;l:if(_>>>0<=255)E=_>>>3,_=e[P+8>>2],(0|(c=e[P+12>>2]))==(0|_)?(R=e[2087]&kr(E),e[2087]=R):(e[_+12>>2]=c,e[c+8>>2]=_);else{if(y=e[P+24>>2],(0|(u=e[P+12>>2]))!=(0|P))_=e[P+8>>2],e[_+12>>2]=u,e[u+8>>2]=_;else if(d=(d=e[(c=P+20|0)>>2])||e[(c=P+16|0)>>2]){for(;_=c,(d=e[(c=(u=d)+20|0)>>2])||(c=u+16|0,d=e[u+16>>2]););e[_>>2]=0}else u=0;if(y){_=e[P+28>>2];a:{if(e[(c=8652+(_<<2)|0)>>2]==(0|P)){if(e[c>>2]=u)break a;R=e[2088]&kr(_),e[2088]=R;break l}if(!(e[y+(e[y+16>>2]==(0|P)?16:20)>>2]=u))break l}e[u+24>>2]=y,(_=e[P+16>>2])&&(e[u+16>>2]=_,e[_+24>>2]=u),(_=e[P+20>>2])&&(e[u+20>>2]=_,e[_+24>>2]=u)}}P=P+S|0,a=a+S|0}if(e[P+4>>2]=-2&e[P+4>>2],e[g+4>>2]=1|a,(e[a+g>>2]=a)>>>0<=255){a=8388+((P=a>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|_,a),e[a+8>>2]=g,e[P+12>>2]=g,e[g+12>>2]=a,e[g+8>>2]=P;break n}if(P=0,(c=a>>>8)&&(P=31,16777215<a>>>0||(P=28+((P=((d=(c<<=E=c+1048320>>>16&8)<<(P=c+520192>>>16&4))<<(c=d+245760>>>16&2)>>>15)-(c|P|E)|0)<<1|a>>>P+21&1)|0)),e[(_=g)+28>>2]=P,e[g+16>>2]=0,_=8652+(P<<2)|(e[g+20>>2]=0),(c=e[2088])&(E=1<<P)){for(c=a<<((0|P)==31?0:25-(P>>>1)|0),P=e[_>>2];;){if((-8&e[(_=P)+4>>2])==(0|a))break c;if(P=c>>>29,c<<=1,!(P=e[16+(E=(4&P)+_|0)>>2]))break}e[E+16>>2]=g}else e[2088]=c|E,e[_>>2]=g;e[g+24>>2]=_,e[g+12>>2]=g,e[g+8>>2]=g;break n}for(e[2090]=g=(a=u+-40|0)-(c=P+8&7?-8-P&7:0)|0,e[2093]=c=P+c|0,e[c+4>>2]=1|g,e[4+(a+P|0)>>2]=40,e[2094]=e[2209],e[(c=(a=(E+(E+-39&7?39-E&7:0)|0)-47|0)>>>0<_+16>>>0?_:a)+4>>2]=27,a=e[2202],e[c+16>>2]=e[2201],e[c+20>>2]=a,a=e[2200],e[c+8>>2]=e[2199],e[c+12>>2]=a,e[2201]=c+8,e[2200]=u,e[2199]=P,a=c+24|(e[2202]=0);e[a+4>>2]=7,P=a+8|0,a=a+4|0,P>>>0<E>>>0;);if((0|_)==(0|c))break s;if(e[c+4>>2]=-2&e[c+4>>2],e[_+4>>2]=1|(E=c-_|0),(e[c>>2]=E)>>>0<=255){a=8388+((P=E>>>3)<<3)|0,P=(c=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|c,a),e[a+8>>2]=_,e[P+12>>2]=_,e[_+12>>2]=a,e[_+8>>2]=P;break s}if(e[_+16>>2]=0,a=e[_+20>>2]=0,(c=E>>>8)&&(a=31,16777215<E>>>0||(a=28+((a=((g=(c<<=u=c+1048320>>>16&8)<<(a=c+520192>>>16&4))<<(c=g+245760>>>16&2)>>>15)-(c|a|u)|0)<<1|E>>>a+21&1)|0)),P=8652+((e[(P=_)+28>>2]=a)<<2)|0,(c=e[2088])&(u=1<<a)){for(a=E<<((0|a)==31?0:25-(a>>>1)|0),P=e[P>>2];;){if((0|E)==(-8&e[(c=P)+4>>2]))break o;if(P=a>>>29,a<<=1,!(P=e[16+(u=c+(4&P)|0)>>2]))break}e[u+16>>2]=_,e[_+24>>2]=c}else e[2088]=c|u,e[P>>2]=_,e[_+24>>2]=P;e[_+12>>2]=_,e[_+8>>2]=_;break s}a=e[_+8>>2],e[a+12>>2]=g,e[_+8>>2]=g,e[g+24>>2]=0,e[g+12>>2]=_,e[g+8>>2]=a}a=b+8|0;break r}a=e[c+8>>2],e[a+12>>2]=_,e[c+8>>2]=_,e[_+24>>2]=0,e[_+12>>2]=c,e[_+8>>2]=a}if(!((a=e[2090])>>>0<=d>>>0)){e[2090]=P=a-d|0,a=e[2093],e[2093]=_=a+d|0,e[_+4>>2]=1|P,e[a+4>>2]=3|d,a=a+8|0;break r}}e[2086]=48,a=0;break r}e:if(g){a=e[E+28>>2];i:{if(e[(c=8652+(a<<2)|0)>>2]==(0|E)){if(e[c>>2]=P)break i;y=kr(a)&y,e[2088]=y;break e}if(!(e[g+(e[g+16>>2]==(0|E)?16:20)>>2]=P))break e}e[P+24>>2]=g,(a=e[E+16>>2])&&(e[P+16>>2]=a,e[a+24>>2]=P),(a=e[E+20>>2])&&(e[P+20>>2]=a,e[a+24>>2]=P)}e:if(_>>>0<=15)e[E+4>>2]=3|(a=_+d|0),e[4+(a=a+E|0)>>2]=1|e[a+4>>2];else if(e[E+4>>2]=3|d,e[4+(c=E+d|0)>>2]=1|_,(e[_+c>>2]=_)>>>0<=255)a=8388+((P=_>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|_,a),e[a+8>>2]=c,e[P+12>>2]=c,e[c+12>>2]=a,e[c+8>>2]=P;else{a=0,(d=_>>>8)&&(a=31,16777215<_>>>0||(a=28+((a=((g=(d<<=u=d+1048320>>>16&8)<<(a=d+520192>>>16&4))<<(d=g+245760>>>16&2)>>>15)-(d|a|u)|0)<<1|_>>>a+21&1)|0)),e[(P=c)+28>>2]=a,e[c+16>>2]=0,P=8652+(a<<2)|(e[c+20>>2]=0);i:{if((d=1<<a)&y){for(a=_<<((0|a)==31?0:25-(a>>>1)|0),d=e[P>>2];;){if((-8&e[(P=d)+4>>2])==(0|_))break i;if(d=a>>>29,a<<=1,!(d=e[16+(u=(4&d)+P|0)>>2]))break}e[u+16>>2]=c}else e[2088]=d|y,e[P>>2]=c;e[c+24>>2]=P,e[c+12>>2]=c,e[c+8>>2]=c;break e}a=e[P+8>>2],e[a+12>>2]=c,e[P+8>>2]=c,e[c+24>>2]=0,e[c+12>>2]=P,e[c+8>>2]=a}a=E+8|0;break r}t:if(b){a=e[P+28>>2];e:{if(e[(_=8652+(a<<2)|0)>>2]==(0|P)){if(e[_>>2]=E)break e;R=kr(a)&S,e[2088]=R;break t}if(!(e[b+(e[b+16>>2]==(0|P)?16:20)>>2]=E))break t}e[E+24>>2]=b,(a=e[P+16>>2])&&(e[E+16>>2]=a,e[a+24>>2]=E),(a=e[P+20>>2])&&(e[E+20>>2]=a,e[a+24>>2]=E)}c>>>0<=15?(e[P+4>>2]=3|(a=c+d|0),e[4+(a=a+P|0)>>2]=1|e[a+4>>2]):(e[P+4>>2]=3|d,e[4+(d=P+d|0)>>2]=1|c,e[c+d>>2]=c,y&&(a=8388+((_=y>>>3)<<3)|0,E=e[2092],_=(_=1<<_)&u?e[a+8>>2]:(e[2087]=_|u,a),e[a+8>>2]=E,e[_+12>>2]=E,e[E+12>>2]=a,e[E+8>>2]=_),e[2092]=d,e[2089]=c),a=P+8|0}return K=16+p|0,a}function mr(a,p,P,_,c,E,u){var d,g,y,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0;e[76+(K=y=K-80|0)>>2]=p,g=55+y|0,d=56+y|0,p=0;r:{t:{e:for(;;){(0|tt)<0||(tt=(2147483647-tt|0)<(0|p)?(e[2086]=61,-1):p+tt|0);i:{s:{o:{n:{c:{f:{l:{a:{d:{p:{m:{y:{_:{if(F=e[76+y>>2],R=H[0|(p=F)]){for(;;){v:{x:{h:if(b=255&R){if((0|b)!=37)break x;for(R=p;;){if(H[p+1|0]!=37)break h;if(e[76+y>>2]=b=p+2|0,R=R+1|0,S=H[p+2|0],p=b,(0|S)!=37)break}}else R=p;if(p=R-F|0,a&&Fe(a,F,p),p)continue e;ut=-1,B=!ie(O[e[76+(b=y)>>2]+(R=1)|0]),p=e[76+y>>2],B|H[p+2|0]!=36||(ut=O[p+1|0]+-48|0,mt=1,R=3),e[b+76>>2]=p=R+p|0;h:if(31<(S=(z=O[(R=0)|p])+-32|0)>>>0)b=p;else if(b=p,75913&(S=1<<S))for(;;){if(e[76+y>>2]=b=p+1|0,R|=S,31<(S=(z=O[p+1|0])+-32|0)>>>0)break h;if(p=b,!(75913&(S=1<<S)))break}if((0|z)==42){if(B=y,ie(O[b+1|0])&&(p=e[76+y>>2],H[p+2|0]==36))e[((O[p+1|0]<<2)+c|0)-192>>2]=10,q=e[((O[p+1|0]<<3)+_|0)-384>>2],mt=1,p=p+3|0;else{if(mt)break t;q=mt=0,a&&(p=e[P>>2],e[P>>2]=p+4,q=e[p>>2]),p=e[76+y>>2]+1|0}e[B+76>>2]=p,-1<(0|q)||(q=0-q|0,R|=8192)}else{if((0|(q=xo(76+y|0)))<0)break t;p=e[76+y>>2]}if(S=-1,H[0|p]==46)if(H[p+1|0]==42)if(ie(O[p+2|0])&&(p=e[76+y>>2],H[p+3|0]==36))e[((O[p+2|0]<<2)+c|0)-192>>2]=10,S=e[((O[p+2|0]<<3)+_|0)-384>>2],e[76+y>>2]=p=p+4|0;else{if(mt)break t;S=a?(p=e[P>>2],e[P>>2]=p+4,e[p>>2]):0,p=e[76+y>>2]+2|0,e[76+y>>2]=p}else e[76+y>>2]=p+1,S=xo(76+y|0),p=e[76+y>>2];for(b=0;;){if(Bt=b,V=-1,57<O[0|p]+-65>>>0)break r;if(e[76+y>>2]=z=p+1|0,b=O[0|p],p=z,!((b=H[3295+(b+j(Bt,58)|0)|0])+-1>>>0<8))break}if(!b)break r;h:{u:{g:{if((0|b)==19){if((0|ut)<=-1)break g;break r}if((0|ut)<0)break u;e[(ut<<2)+c>>2]=b,b=e[4+(p=(ut<<3)+_|0)>>2],e[64+y>>2]=e[p>>2],e[68+y>>2]=b}if(p=0,a)break h;continue e}if(!a)break i;ki(64+y|0,b,P,u),z=e[76+y>>2]}if(B=-65537&R,R=8192&R?B:R,ut=3336,b=d,p=O[z+-1|(V=0)],(z=(p=Bt&&(15&p)==3?-33&p:p)+-88|0)>>>0<=32)break v;h:{u:{g:{b:{if(6<(B=p+-65|0)>>>0){if((0|p)!=83)break s;if(!S)break b;b=e[64+y>>2];break u}switch(B-1|0){case 1:break g;case 0:case 2:break s;default:break _}}We(a,32,q,p=0,R);break h}e[12+y>>2]=0,e[8+y>>2]=e[64+y>>2],e[64+y>>2]=8+y,S=-1,b=8+y|0}p=0;u:{for(;;){if(!(F=e[b>>2]))break u;if((B=(0|(F=vo(4+y|0,F)))<0)|S-p>>>0<F>>>0)break;if(b=b+4|0,!((p=p+F|0)>>>0<S>>>0))break u}if(V=-1,B)break r}if(We(a,32,q,p,R),p)for(S=0,b=e[64+y>>2];;){if(!(F=e[b>>2])||(0|p)<(0|(S=(F=vo(4+y|0,F))+S|0)))break h;if(Fe(a,4+y|0,F),b=b+4|0,!(S>>>0<p>>>0))break}else p=0}We(a,32,q,p,8192^R),p=(0|p)<(0|q)?q:p;continue e}e[76+y>>2]=b=p+1|0,R=H[p+1|0],p=b;continue}break}switch(z-1|0){case 28:break c;case 21:break f;case 23:break a;case 22:break d;case 11:case 16:break p;case 10:break m;case 26:break y;case 8:case 12:case 13:case 14:break _;case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 9:case 15:case 17:case 18:case 19:case 20:case 24:case 25:case 27:case 29:case 30:break s;default:break l}}if(V=tt,a)break r;if(!mt)break i;for(p=1;;){if(a=e[(p<<2)+c>>2]){if(ki((p<<3)+_|0,a,P,u),(0|(p=p+(V=1)|0))!=10)continue;break r}break}if(V=1,9<p>>>0||(V=-1,e[(p<<2)+c>>2]))break r;for(;!e[((p=p+1|0)<<2)+c>>2]&&(0|p)!=10;);V=p>>>0<10?-1:1;break r}p=0|L[E](a,ct[64+y>>3],q,S,R,p);continue}b=(p=wo(F=(p=e[64+y>>2])||3346,S))||S+F|0,R=B,S=p?p-F|0:S;break s}O[55+y|0]=e[64+y>>2],S=1,F=g,R=B;break s}if(p=B=e[68+y>>2],F=e[64+y>>2],(0|p)<-1||(0|p)<=-1&&!(4294967295<F>>>0)){p=0-(p+(0<F>>>0)|0)|0,e[64+y>>2]=F=0-F|0,e[68+y>>2]=p,V=1,ut=3336;break n}if(2048&R){V=1,ut=3337;break n}ut=(V=1&R)?3338:3336;break n}if(F=function(Ht,ce,we){if(Ht|ce)for(;O[0|(we=we+-1|0)]=7&Ht|48,(Ht=(7&ce)<<29|Ht>>>3)|(ce>>>=3););return we}(e[64+y>>2],e[68+y>>2],d),!(8&R))break o;S=(0|(p=d-F|0))<(0|S)?S:p+1|0;break o}S=8<S>>>0?S:8,R|=8,p=120}if(F=function(Ht,ce,we,Ue){if(Ht|ce)for(;O[0|(we=we+-1|0)]=H[3824+(15&Ht)|0]|Ue,(Ht=(15&ce)<<28|Ht>>>4)|(ce>>>=4););return we}(e[64+y>>2],e[68+y>>2],d,32&p),!(8&R)|!(e[64+y>>2]|e[68+y>>2]))break o;ut=3336+(p>>>4)|0,V=2;break o}if(7<(b=255&Bt)>>>(p=0))continue;switch(b-1|0){default:case 0:e[e[64+y>>2]>>2]=tt;continue;case 1:b=e[64+y>>2],e[b>>2]=tt,e[b+4>>2]=tt>>31;continue;case 2:N[e[64+y>>2]>>1]=tt;continue;case 3:O[e[64+y>>2]]=tt;continue;case 5:e[e[64+y>>2]>>2]=tt;continue;case 4:continue;case 6:}b=e[64+y>>2],e[b>>2]=tt,e[b+4>>2]=tt>>31;continue}F=e[64+y>>2],p=e[68+y>>2],ut=3336}F=ye(F,p,d)}R=-1<(0|S)?-65537&R:R,S=!!((B=p=e[68+y>>2])|(z=e[64+y>>2]))|S?(0|(p=!(B|z)+(d-F|0)|0))<(0|S)?S:p:(F=d,0)}We(a,32,p=(0|q)<(0|(b=(S=(0|S)<(0|(B=b-F|0))?B:S)+V|0))?b:q,b,R),Fe(a,ut,V),We(a,48,p,b,65536^R),We(a,48,S,B,0),Fe(a,F,B),We(a,32,p,b,8192^R);continue}break}V=0;break r}V=-1}return K=80+y|0,V}function ur(a){var p,P=0,E=0,c=0,_=0,c=4,E=1439;r:if(P=H[0|a]){for(;!((0|(p=H[0|E]))!=(0|P)||!(c=c+-1|0)|!p);)if(E=E+1|0,P=H[a+1|0],a=a+1|0,!P)break r;_=P}return(255&_)-H[0|E]|0}function Br(a,p,P){var _,c,E=0,u=0,d=0;e[(K=c=K-240|0)>>2]=a,u=1;r:if(!((0|p)<2))for(E=a;;){if(E=(_=E+-4|0)-e[((d=p+-2|0)<<2)+P>>2]|0,0<=(0|L[5](a,E))&&-1<(0|L[5](a,_))||(a=(u<<2)+c|0,0<=(0|L[5](E,_))?(e[a>>2]=E,d=p+-1|0):E=e[a>>2]=_,u=u+1|0,(0|d)<2))break r;a=e[c>>2],p=d}Eo(c,u),K=240+c|0}function hi(a){var p,P,_=0;if(v(0),function(c){var E,u;e[c+428>>2]&&(u=e[c+332>>2],ge(e[c+460>>2],e[c+436>>2],E=u<<2),ge(e[c+464>>2],e[c+440>>2],E),ge(e[c+468>>2],e[c+448>>2],E),H[e[c>>2]+4|0]<4||(ge(e[c+472>>2],e[c+452>>2],E=u<<4),ge(e[c+476>>2],e[c+456>>2],E)))}(a),function(c){var E,u,d,g=0,y=v(0),b=v(0),S=0,R=v(0);if(v(0),v(0),1<=(0|(S=e[c>>2])))for(d=(g=e[c+4>>2])+j(S,52)|0,c=e[c+12>>2];y=I[c>>2],I[g+44>>2]!=(y=(E=e[g+16>>2])?(b=y,y=I[g+4>>2],R=I[g+12>>2],b=v(v(b-y)/R),u=v(Ft(b)),S=v(St(u))<v(2147483648)?~~u:-2147483648,v(y+v(R*v(b-v(0|S))))):(R=I[g+4>>2],b=I[g+8>>2],y<R?R:b<y?b:y))?(I[g+44>>2]=y,e[g+48>>2]=1):e[g+48>>2]=0,E||(I[c>>2]=y),c=c+4|0,(g=g+52|0)>>>0<d>>>0;);}(a+540|0),function(c){var E,u,d,g,y,b,S=0,R=0,F=v(0),B=0,V=v(0),z=(v(0),v(0),0),q=v(0),tt=0,ut=0,mt=0;if(v(0),1<=(0|(B=e[c+540>>2])))for(y=(z=e[c+544>>2])+j(B,52)|0,b=e[c+644>>2];;){r:if(!(e[z>>2]||(0|(B=e[z+32>>2]))<1))if(d=(c=e[z+28>>2])+j(B,28)|0,g=I[z+24>>2],u=I[z+20>>2],E=I[z+44>>2],b)for(;;){q=v(ut=0);t:{e:{i:{if((0|(R=e[c>>2]))<1)S=B=0;else if(tt=e[c+4>>2],V=I[tt>>2],F=v(V-u),(0|R)==1)B=E<v(u+V)^1|F<E^1,S=0;else{if(E<F){B=1,S=0;break e}if(B=0,E<v(u+V))S=0;else{if(S=1,F=I[tt+4>>2],!(E<v(u+F)))for(;;){if((0|R)==(0|(S=S+1|0)))break i;if(V=F,F=I[tt+(S<<2)>>2],E<v(u+F))break}v(F-u)<E||(S=S+-1|0,(F=v(F-V))<g)||(q=v(v(E-V)/F))}}if(B)break e;if(tt=R=1,e[c+16>>2])break t;break e}S=R+-1|0,B=1}tt=(R=(V=I[c+12>>2])!=q)&(q==v(0)|V==v(0))|e[c+8>>2]!=(0|S),ut=B}if(e[c+20>>2]=tt,e[c+24>>2]=R,I[c+12>>2]=q,e[c+16>>2]=ut,e[c+8>>2]=S,!((c=c+28|0)>>>0<d>>>0))break}else{if(!e[z+48>>2]){for(;;)if(e[c+20>>2]=0,!((c=c+28|(e[c+24>>2]=0))>>>0<d>>>0))break r}for(;;){q=v(ut=0);t:{e:{i:{s:if(!(((R=0)|(S=e[(tt=c)>>2]))<1)){if(B=e[c+4>>2],V=I[B>>2],F=v(V-u),(0|S)!=1){if(!(E<F)){if(R=0,E<v(u+V))break s;R=1;o:if(F=I[B+4>>2],!(E<v(u+F))){for(S=S+-1|0;V=F,(0|S)!=(0|R);)if(F=I[B+((R=R+1|0)<<2)>>2],E<v(u+F))break o;B=1;break e}if(B=0,v(F-u)<E){S=R;break i}if(S=R+-1|0,(F=v(F-V))<g)break i;q=v(v(E-V)/F);break i}B=1,S=0;break e}R=E<v(u+V)^1|F<E^1}B=R,S=0}if(!B&&(mt=R=1,e[c+16>>2]))break t}ut=B,mt=(R=(V=I[c+12>>2])!=q)&(q==v(0)|V==v(0))|e[c+8>>2]!=(0|S)}if(e[tt+20>>2]=mt,e[c+24>>2]=R,I[c+12>>2]=q,e[c+16>>2]=ut,e[c+8>>2]=S,!((c=c+28|0)>>>0<d>>>0))break}}if(!((z=z+52|0)>>>0<y>>>0))break}}(a),function(c){var E,u,d,g,y,b=0,S=v(0),R=0,F=0,B=v(0),V=0,z=v(0);if(v(0),!(H[e[c>>2]+4|0]<4||(0|(b=e[c+540>>2]))<1))for(g=(V=e[c+544>>2])+j(b,52)|0,y=e[c+644>>2];;){r:if(e[V>>2]==1&&!((0|(b=e[V+40>>2]))<1))if(u=(c=e[V+36>>2])+j(b,28)|0,E=I[V+44>>2],y)for(;;){z=v(b=0);t:if(!((0|(F=e[c>>2]))<2||(R=e[c+4>>2],E<=(S=I[R>>2])))){b=1;e:if(!(E<(B=I[R+4>>2]))){for(;S=B,(0|F)!=(0|(b=b+1|0));)if(E<(B=I[R+(b<<2)>>2]))break e;b=F+-1|0;break t}z=v(v(E-S)/v(B-S)),b=b+-1|0}if(S=I[c+16>>2],I[c+16>>2]=z,F=e[c+12>>2],e[c+12>>2]=b,e[c+24>>2]=R=S!=z,e[c+20>>2]=R&(z==v(0)|S==v(0))|(0|b)!=(0|F),!((c=c+28|0)>>>0<u>>>0))break}else{if(!e[V+48>>2]){for(;;)if(e[c+20>>2]=0,!((c=c+28|(e[c+24>>2]=0))>>>0<u>>>0))break r}for(;;){z=v(F=0);t:if(!((0|(d=e[c>>2]))<2||(R=e[c+4>>2],E<=(S=I[R>>2])))){if(b=1,!(E<(B=I[R+4>>2])))for(F=d+-1|0;;){if(S=B,(0|b)==(0|F))break t;if(E<(B=I[R+((b=b+1|0)<<2)>>2]))break}z=v(v(E-S)/v(B-S)),F=b+-1|0}if(S=I[c+16>>2],I[c+16>>2]=z,b=e[c+12>>2],e[c+12>>2]=F,e[c+24>>2]=R=S!=z,e[c+20>>2]=R&(z==v(0)|S==v(0))|(0|b)!=(0|F),!((c=c+28|0)>>>0<u>>>0))break}}if(!((V=V+52|0)>>>0<g>>>0))break}}(a),function(c){var E,u,d,g,y,b,S,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=v(0),mt=0,Bt=0,Ht=0,ce=0,we=0;if(1<=(0|(F=e[c+564>>2])))for(b=(z=e[c+568>>2])+j(F,36)|0,g=e[c+644>>2];;){r:{if(!(q=((B=V=F=0)|(u=e[z+4>>2]))<1))for(mt=e[z>>2],c=ce=0;;){if(R=e[mt+(c<<2)>>2],e[R+16>>2]){R=1,we=0;break r}if(B=B||e[R+24>>2],F=F||e[R+20>>2],V=(I[R+12>>2]!=v(0))+V|0,(0|u)==(0|(c=c+1|0)))break}if(R=0,(ce=g?1:B)|(we=g?1:F)&&(e[z+12>>2]=mt=1<<V,(0|V)!=31)){for(F=e[z+20>>2],y=e[z>>2],B=(c=e[z+16>>2])+(tt=mt<<2)|0,B=Ce(c,0,4+((-1^c)+((c=c+4|0)>>>0<B>>>0?B:c)|0)&-4),tt=F+tt|0,c=F;e[c>>2]=1065353216,(c=c+4|0)>>>0<tt>>>0;);if(!q){if(q=0,tt=R=1,V)for(;;){if(V=e[(q<<2)+y>>2],Bt=e[V+8>>2],Ht=j(Bt,R),(ut=I[V+12>>2])!=v(c=0)){for(e[B>>2]=Ht+e[B>>2],I[F>>2]=v(v(1)-ut)*I[F>>2],Bt=j(Bt+(c=1)|0,R);ut=I[V+12>>2],S=e[(d=(E=c<<2)+B|0)>>2],e[d>>2]=S+((d=c&tt)?Bt:Ht),I[(E=F+E|0)>>2]=(d?ut:v(v(1)-ut))*I[E>>2],(0|mt)!=(0|(c=c+1|0)););tt<<=1}else for(;e[(Bt=B+(c<<2)|0)>>2]=Ht+e[Bt>>2],(0|mt)!=(0|(c=c+1|0)););if(R=j(e[V>>2],R),(0|u)==(0|(q=q+1|0)))break}else for(;;){if(V=e[(q<<2)+y>>2],tt=j(e[V+8>>2],R),(ut=I[V+12>>2])!=v(c=0))e[B>>2]=tt+e[B>>2],I[F>>2]=v(v(1)-ut)*I[F>>2];else for(;e[(Ht=B+(c<<2)|0)>>2]=tt+e[Ht>>2],(0|mt)!=(0|(c=c+1|0)););if(R=j(e[V>>2],R),(0|u)==(0|(q=q+1|0)))break}R=0}}}if(e[z+32>>2]=R,e[z+24>>2]=we,e[z+28>>2]=ce,!((z=z+36|0)>>>0<b>>>0))break}}(a),function(c){var E,u,d,g,y=v(0),b=0,S=0,R=0,F=0,B=0,V=v(0),z=v(0),q=v(0),tt=0,ut=0,mt=0;if(!(H[e[c>>2]+4|0]<4||(0|(b=e[c+588>>2]))<1))for(g=(R=e[c+592>>2])+j(b,48)|0,E=e[c+644>>2];;){if(c=e[R>>2],(ut=E?1:e[c+20>>2])|(mt=E?1:e[c+24>>2])){r:{t:{B=R,F=e[c+8>>2],b=e[c+12>>2],y=I[c+16>>2],c=(0|F)!=(0|b);e:{if(y!=v(0)){if(c=b+1|0,(0|b)==(0|F)){e[R+8>>2]=ut=1,y=v(v(1)-y),mt=1;break e}c=(0|c)==(0|F)?1:2}if(e[B+8>>2]=c,!mt)break t;c=b}I[R+24>>2]=y,I[R+20>>2]=v(1)-y;break r}mt=0,c=b}ut?(e[R+12>>2]=c,e[R+16>>2]=c+1):ut=0}else ut=mt=0;r:if((0|(u=e[R+36>>2]))<1)q=v(1);else{if(d=e[R+40>>2],c=0,q=v(1),!E)for(;;){t:{e:{if(b=e[(c<<2)+d>>2],S=e[b>>2]){if(!e[S+48>>2]){y=I[b+16>>2];break t}if((0|(F=e[b+12>>2]))<1){y=v(1),I[b+16>>2]=1;break t}if(tt=e[b+8>>2],(0|F)!=1&&(V=I[S+44>>2],B=e[b+4>>2],!(V<=(z=I[B>>2]))))break e;y=I[tt>>2],I[b+16>>2]=y;break t}e[b+16>>2]=1065353216,y=v(1);break t}S=1;e:if(!(V<(y=I[B+4>>2]))){for(;z=y,(0|F)!=(0|(S=S+1|0));)if(V<(y=I[B+(S<<2)>>2]))break e;y=I[(tt+(F<<2)|0)-4>>2],I[b+16>>2]=y;break t}B=b,y=v(v(V-z)/v(y-z)),y=v(v(y*I[(b=tt+(S<<2)|0)>>2])+v(I[b+-4>>2]*v(v(1)-y))),I[B+16>>2]=y}if(q=q<y?q:y,(0|u)==(0|(c=c+1|0)))break r}for(;;){b=e[(c<<2)+d>>2],S=e[b>>2],y=v(1);t:if(S&&(tt=e[b+12>>2],y=v(1),!((0|tt)<1))&&(F=e[b+8>>2],y=I[F>>2],(0|tt)!=1)){e:{if(V=I[S+44>>2],B=e[b+4>>2],V<=(z=I[B>>2])){y=I[F>>2];break t}if(S=1,!(V<(y=I[B+4>>2]))){for(;z=y,(0|tt)!=(0|(S=S+1|0));)if(V<(y=I[B+(S<<2)>>2]))break e;y=I[(F+(tt<<2)|0)-4>>2];break t}}y=v(v(V-z)/v(y-z)),y=v(v(y*I[(S=F+(S<<2)|0)>>2])+v(I[S+-4>>2]*v(v(1)-y)))}if(q=q<(I[b+16>>2]=y)?q:y,(0|u)==(0|(c=c+1|0)))break}}if(e[R+32>>2]=mt,e[R+28>>2]=ut,I[R+44>>2]=q,!((R=R+48|0)>>>0<g>>>0))break}}(a),1<=(0|(p=e[a+4>>2])))for(p=(_=e[a+52>>2])+(p<<2)|0;P=I[_>>2],I[_>>2]=P<v(0)?v(0):v(Mt(P,v(1))),(_=_+4|0)>>>0<p>>>0;);(function(c){var E,u,d,g=0,y=0;if(1<=(0|(y=e[c+4>>2])))for(d=(g=e[c+8>>2])+j(y,12)|0,c=E=e[c+40>>2];y=0,e[g+8>>2]&&(u=e[g+4>>2],!e[(u<<2)+E>>2]&&(0|u)!=-1||(y=!e[e[g>>2]+32>>2])),e[c>>2]=y,c=c+4|0,(g=g+12|0)>>>0<d>>>0;);})(a),function(c){var E,u,d,g,y,b,S,R=0,F=0,B=0,V=0,z=0;if(1<=(0|(u=e[c+4>>2])))for(g=e[c+8>>2],d=e[c>>2],y=e[d+724>>2];;){if(E=e[j(V,12)+g>>2],(e[E+28>>2]||e[E+24>>2])&&(e[(R=V<<2)+e[c+28>>2]>>2]=e[E+12>>2],e[E+24>>2])&&!((0|(B=e[E+12>>2]))<1))for(B=(F=e[E+16>>2])+(B<<2)|0,b=e[R+y>>2],R=e[c+36>>2]+(z<<2)|0,S=e[d+976>>2];e[R>>2]=e[(e[F>>2]+b<<2)+S>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(e[E+28>>2]&&!((0|(R=e[E+12>>2]))<1))for(B=(F=e[E+20>>2])+(R<<2)|0,R=e[c+32>>2]+(z<<2)|0;e[R>>2]=e[F>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(z=e[E+8>>2]+z|0,(0|u)==(0|(V=V+1|0)))break}}(a),L[e[1808]](a+12|0,e[a+36>>2],e[a+44>>2],e[a+40>>2]),function(c){var E,u,d,g,y,b,S=0,R=0,F=0;if(1<=(0|(F=e[c+304>>2])))for(d=(S=e[c+308>>2])+(F<<5)|0,g=e[c+264>>2],y=e[c+144>>2],b=e[c+40>>2],F=u=e[c+312>>2];E=F,R=0,c=R=!e[S+28>>2]||(0|(c=e[S+4>>2]))!=-1&&(R=0,!e[(c<<2)+b>>2])||(0|(c=e[S+8>>2]))!=-1&&(R=0,!e[(c<<2)+u>>2])?R:!e[e[S>>2]+32>>2],e[E>>2]=c,(E=e[S+12>>2])>>>0<=1?E-1?e[(e[S+16>>2]<<2)+y>>2]=c:e[(e[S+16>>2]<<2)+g>>2]=c:Ut(4,1372,0),F=F+4|0,(S=S+32|0)>>>0<d>>>0;);}(a),function(c){var E,u,d,g,y,b,S,R,F,B=0,V=0,z=0,q=0,pe=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,we=0,Ue=0,He=0,pe=e[c>>2];if(1<=(0|(mt=e[c+56>>2]))){for(Bt=e[c+60>>2],Ht=e[pe+1052>>2],ce=e[pe+784>>2];;){if(B=e[Bt+j(tt,24)>>2],(e[B+28>>2]||e[B+24>>2])&&(e[(V=tt<<2)+e[c+80>>2]>>2]=e[B+12>>2],e[B+24>>2])&&!((0|(q=e[B+12>>2]))<1))for(we=(z=e[B+16>>2])+(q<<2)|0,Ue=e[V+ce>>2],V=(q=ut<<2)+e[c+92>>2]|0,q=q+e[c+88>>2]|0;He=Ue+e[z>>2]<<2,e[V>>2]=Ht+(e[He+e[pe+984>>2]>>2]<<2),e[q>>2]=e[He+e[pe+980>>2]>>2],q=q+4|0,V=V+4|0,(z=z+4|0)>>>0<we>>>0;);if(e[B+28>>2]&&!((0|(V=e[B+12>>2]))<1))for(q=(z=e[B+20>>2])+(V<<2)|0,V=e[c+84>>2]+(ut<<2)|0;e[V>>2]=e[z>>2],V=V+4|0,(z=z+4|0)>>>0<q>>>0;);if(ut=e[B+8>>2]+ut|0,(0|mt)==(0|(tt=tt+1|0)))break}pe=e[c>>2]}if(!(H[pe+4|0]<4||(0|(Ue=e[c+56>>2]))<1))for(He=e[pe+792>>2],E=e[c+60>>2],z=ut=0;;){if(tt=e[j(z,24)+E>>2],e[tt+24>>2]&&!((0|(B=e[tt+12>>2]))<1))for(u=(V=e[tt+16>>2])+(B<<2)|0,d=e[He+(z<<2)>>2],q=(B=ut<<2)+e[c+96>>2]|0,mt=B+e[c+100>>2]|0,Bt=B+e[c+104>>2]|0,Ht=B+e[c+108>>2]|0,ce=B+e[c+112>>2]|0,we=B+e[c+116>>2]|0,g=e[pe+1308>>2],y=e[pe+1304>>2],b=e[pe+1300>>2],S=e[pe+1296>>2],R=e[pe+1292>>2],F=e[pe+1288>>2];B=e[V>>2]+d<<2,e[q>>2]=e[B+F>>2],e[mt>>2]=e[B+R>>2],e[Bt>>2]=e[B+S>>2],e[Ht>>2]=e[B+b>>2],e[ce>>2]=e[B+y>>2],e[we>>2]=e[B+g>>2],we=we+4|0,ce=ce+4|0,Ht=Ht+4|0,Bt=Bt+4|0,mt=mt+4|0,q=q+4|0,(V=V+4|0)>>>0<u>>>0;);if(ut=e[tt+8>>2]+ut|0,(0|Ue)==(0|(z=z+1|0)))break}}(a),function(c){var E=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,we=0,Ue=0,He=e[c+168>>2],pe=e[c>>2];if(1<=(0|(q=e[c+164>>2])))for(ut=e[pe+816>>2];;){if(d=e[j(S,12)+He>>2],(e[d+28>>2]||e[d+24>>2])&&(e[(R=S<<2)+e[c+188>>2]>>2]=e[d+12>>2],e[d+24>>2])){if(u=e[d+16>>2],tt=e[R+ut>>2],1<=(0|(E=e[d+12>>2])))for(mt=u+(E<<2)|0,g=(E=b<<2)+e[c+200>>2]|0,F=E+e[c+204>>2]|0,B=E+e[c+208>>2]|0,V=E+e[c+212>>2]|0,z=E+e[c+196>>2]|0,Bt=e[pe+996>>2],Ht=e[pe+1012>>2],ce=e[pe+1008>>2],we=e[pe+1004>>2],Ue=e[pe+1e3>>2],E=u;y=tt+e[E>>2]<<2,e[g>>2]=e[y+Ue>>2],e[F>>2]=e[y+we>>2],e[B>>2]=e[y+ce>>2],e[V>>2]=e[y+Ht>>2],e[z>>2]=e[y+Bt>>2],z=z+4|0,V=V+4|0,B=B+4|0,F=F+4|0,g=g+4|0,(E=E+4|0)>>>0<mt>>>0;);E=tt+e[u>>2]<<2,e[R+e[c+288>>2]>>2]=e[E+e[pe+1016>>2]>>2],e[R+e[c+292>>2]>>2]=e[E+e[pe+1020>>2]>>2]}if(e[d+28>>2]&&!((0|(u=e[d+12>>2]))<1))for(u=(E=e[d+20>>2])+(u<<2)|0,g=e[c+192>>2]+(b<<2)|0;e[g>>2]=e[E>>2],g=g+4|0,(E=E+4|0)>>>0<u>>>0;);if(b=e[d+8>>2]+b|0,(0|q)==(0|(S=S+1|0)))break}if(!(H[pe+4|0]<4||(0|(R=e[c+164>>2]))<1))for(tt=e[pe+824>>2],b=d=0;;){if(y=e[j(b,12)+He>>2],e[y+24>>2]&&!((0|(E=e[y+12>>2]))<1))for(q=(g=e[y+16>>2])+(E<<2)|0,ut=e[tt+(b<<2)>>2],F=(u=d<<2)+e[c+216>>2]|0,B=u+e[c+220>>2]|0,V=u+e[c+224>>2]|0,z=u+e[c+228>>2]|0,E=u+e[c+232>>2]|0,S=u+e[c+236>>2]|0,mt=e[pe+1308>>2],Bt=e[pe+1304>>2],Ht=e[pe+1300>>2],ce=e[pe+1296>>2],we=e[pe+1292>>2],Ue=e[pe+1288>>2];u=ut+e[g>>2]<<2,e[F>>2]=e[u+Ue>>2],e[B>>2]=e[u+we>>2],e[V>>2]=e[u+ce>>2],e[z>>2]=e[u+Ht>>2],e[E>>2]=e[u+Bt>>2],e[S>>2]=e[u+mt>>2],S=S+4|0,E=E+4|0,z=z+4|0,V=V+4|0,B=B+4|0,F=F+4|0,(g=g+4|0)>>>0<q>>>0;);if(d=e[y+8>>2]+d|0,(0|R)==(0|(b=b+1|0)))break}}(a),function(c){var E,F=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=c- -64|0;if(L[e[1807]](F,e[c+88>>2],e[c+148>>2],e[c+144>>2]),L[e[1809]](F,e[c+92>>2],e[c+152>>2],e[e[c>>2]+796>>2],2,e[c+144>>2]),!(H[e[c>>2]+4|0]<4||(L[e[1807]](F,e[c+96>>2],e[c+120>>2],e[c+144>>2]),L[e[1807]](F,e[c+100>>2],e[c+124>>2],e[c+144>>2]),L[e[1807]](F,e[c+104>>2],e[c+128>>2],e[c+144>>2]),L[e[1807]](F,e[c+108>>2],e[c+132>>2],e[c+144>>2]),L[e[1807]](F,e[c+112>>2],e[c+136>>2],e[c+144>>2]),L[e[1807]](F,e[c+116>>2],e[c+140>>2],e[c+144>>2]),(0|(b=e[c+56>>2]))<1))){for(S=e[c+128>>2],R=e[c+124>>2],E=e[c+120>>2],u=e[c+156>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+R>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|b)!=(0|(F=F+1|0)););for(u=e[c+160>>2],y=e[c+140>>2],S=e[c+136>>2],R=e[c+132>>2],F=c=0;e[(g=c<<2)+u>>2]=e[(d=F<<2)+R>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],c=c+4|0,(0|b)!=(0|(F=F+1|0)););}}(a),function(c){var E,F=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=c+172|0;if(L[e[1807]](F,e[c+196>>2],e[c+268>>2],e[c+264>>2]),L[e[1807]](F,e[c+200>>2],e[c+284>>2],e[c+264>>2]),L[e[1807]](F,e[c+204>>2],e[c+276>>2],e[c+264>>2]),L[e[1807]](F,e[c+208>>2],e[c+280>>2],e[c+264>>2]),L[e[1807]](F,e[c+212>>2],e[c+272>>2],e[c+264>>2]),!(H[e[c>>2]+4|0]<4||(L[e[1807]](F,e[c+216>>2],e[c+240>>2],e[c+264>>2]),L[e[1807]](F,e[c+220>>2],e[c+244>>2],e[c+264>>2]),L[e[1807]](F,e[c+224>>2],e[c+248>>2],e[c+264>>2]),L[e[1807]](F,e[c+228>>2],e[c+252>>2],e[c+264>>2]),L[e[1807]](F,e[c+232>>2],e[c+256>>2],e[c+264>>2]),L[e[1807]](F,e[c+236>>2],e[c+260>>2],e[c+264>>2]),(0|(b=e[c+164>>2]))<1))){for(S=e[c+248>>2],R=e[c+244>>2],E=e[c+240>>2],u=e[c+296>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+R>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|b)!=(0|(F=F+1|0)););for(u=e[c+300>>2],y=e[c+260>>2],S=e[c+256>>2],R=e[c+252>>2],F=c=0;e[(g=c<<2)+u>>2]=e[(d=F<<2)+R>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],c=c+4|0,(0|b)!=(0|(F=F+1|0)););}}(a),function(c){var E,u,d,g=0,y=0,b=0;if(1<=(0|(y=e[c+332>>2])))for(E=(g=e[c+336>>2])+j(y,20)|0,u=e[c+312>>2],d=e[c+40>>2],c=e[c+424>>2];y=0,e[g+12>>2]&&(b=e[g+4>>2],e[(b<<2)+d>>2]||(0|b)==-1)&&(b=e[g+8>>2],e[(b<<2)+u>>2]||(0|b)==-1)&&(y=!e[e[g>>2]+32>>2]),e[c>>2]=y,c=c+4|0,(g=g+20|0)>>>0<E>>>0;);}(a),function(c){var E,u,d,g,y,b,S,R,F=0,B=0,V=0,pe=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,we=0,Ue=0,He=0,pe=e[c>>2];if(1<=(0|(Bt=e[c+332>>2]))){for(Ht=e[c+336>>2],ce=e[pe+1052>>2],we=e[pe+856>>2];;){if(F=e[Ht+j(tt,20)>>2],(e[F+28>>2]||e[F+24>>2])&&(e[(B=tt<<2)+e[c+356>>2]>>2]=e[F+12>>2],e[F+24>>2])&&!((0|(z=e[F+12>>2]))<1))for(Ue=(V=e[F+16>>2])+(z<<2)|0,He=e[B+we>>2],B=(q=ut<<2)+e[c+372>>2]|0,z=q+e[c+364>>2]|0,q=q+e[c+368>>2]|0;mt=He+e[V>>2]<<2,e[B>>2]=ce+(e[mt+e[pe+1040>>2]>>2]<<2),e[z>>2]=e[mt+e[pe+1032>>2]>>2],e[q>>2]=e[mt+e[pe+1036>>2]>>2],q=q+4|0,z=z+4|0,B=B+4|0,(V=V+4|0)>>>0<Ue>>>0;);if(e[F+28>>2]&&!((0|(B=e[F+12>>2]))<1))for(z=(V=e[F+20>>2])+(B<<2)|0,B=e[c+360>>2]+(ut<<2)|0;e[B>>2]=e[V>>2],B=B+4|0,(V=V+4|0)>>>0<z>>>0;);if(ut=e[F+8>>2]+ut|0,(0|Bt)==(0|(tt=tt+1|0)))break}pe=e[c>>2]}if(!(H[pe+4|0]<4||(0|(we=e[c+332>>2]))<1))for(Ue=e[pe+864>>2],He=e[c+336>>2],V=ut=0;;){if(tt=e[He+j(V,20)>>2],e[tt+24>>2]&&!((0|(F=e[tt+12>>2]))<1))for(E=(B=e[tt+16>>2])+(F<<2)|0,u=e[Ue+(V<<2)>>2],z=(F=ut<<2)+e[c+376>>2]|0,q=F+e[c+380>>2]|0,mt=F+e[c+384>>2]|0,Bt=F+e[c+388>>2]|0,Ht=F+e[c+392>>2]|0,ce=F+e[c+396>>2]|0,d=e[pe+1308>>2],g=e[pe+1304>>2],y=e[pe+1300>>2],b=e[pe+1296>>2],S=e[pe+1292>>2],R=e[pe+1288>>2];F=e[B>>2]+u<<2,e[z>>2]=e[F+R>>2],e[q>>2]=e[F+S>>2],e[mt>>2]=e[F+b>>2],e[Bt>>2]=e[F+y>>2],e[Ht>>2]=e[F+g>>2],e[ce>>2]=e[F+d>>2],ce=ce+4|0,Ht=Ht+4|0,Bt=Bt+4|0,mt=mt+4|0,q=q+4|0,z=z+4|0,(B=B+4|0)>>>0<E>>>0;);if(ut=e[tt+8>>2]+ut|0,(0|we)==(0|(V=V+1|0)))break}}(a),function(c){var E,F=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=c+340|0;if(L[e[1807]](F,e[c+364>>2],e[c+448>>2],e[c+424>>2]),L[e[1808]](F,e[c+368>>2],e[c+440>>2],e[c+424>>2]),L[e[1809]](F,e[c+372>>2],e[c+444>>2],e[e[c>>2]+892>>2],2,e[c+424>>2]),!(H[e[c>>2]+4|0]<4||(L[e[1807]](F,e[c+376>>2],e[c+400>>2],e[c+424>>2]),L[e[1807]](F,e[c+380>>2],e[c+404>>2],e[c+424>>2]),L[e[1807]](F,e[c+384>>2],e[c+408>>2],e[c+424>>2]),L[e[1807]](F,e[c+388>>2],e[c+412>>2],e[c+424>>2]),L[e[1807]](F,e[c+392>>2],e[c+416>>2],e[c+424>>2]),L[e[1807]](F,e[c+396>>2],e[c+420>>2],e[c+424>>2]),(0|(b=e[c+332>>2]))<1))){for(S=e[c+408>>2],R=e[c+404>>2],E=e[c+400>>2],u=e[c+452>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+R>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|b)!=(0|(F=F+1|0)););for(u=e[c+456>>2],y=e[c+420>>2],S=e[c+416>>2],R=e[c+412>>2],F=c=0;e[(g=c<<2)+u>>2]=e[(d=F<<2)+R>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],c=c+4|0,(0|b)!=(0|(F=F+1|0)););}}(a),function(c){var E,u,d,g,y,b,S,R=0,F=0,B=0,V=0,z=0;if(1<=(0|(u=e[c+500>>2])))for(g=e[c+504>>2],d=e[c>>2],y=e[d+1252>>2];;){if(E=e[j(V,24)+g>>2],(e[E+28>>2]||e[E+24>>2])&&(e[(R=V<<2)+e[c+524>>2]>>2]=e[E+12>>2],e[E+24>>2])&&!((0|(B=e[E+12>>2]))<1))for(B=(F=e[E+16>>2])+(B<<2)|0,b=e[R+y>>2],R=e[c+532>>2]+(z<<2)|0,S=e[d+1284>>2];e[R>>2]=e[(e[F>>2]+b<<2)+S>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(e[E+28>>2]&&!((0|(R=e[E+12>>2]))<1))for(B=(F=e[E+20>>2])+(R<<2)|0,R=e[c+528>>2]+(z<<2)|0;e[R>>2]=e[F>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(z=e[E+8>>2]+z|0,(0|u)==(0|(V=V+1|0)))break}}(a),L[e[1807]](a+508|0,e[a+532>>2],e[a+536>>2],0),function(c){var E,u,d,g,y,b,S=v(0),R=0,F=0,B=0,V=0;if(v(0),K=E=K-16|0,B=e[c>>2],!(H[B+4|0]<5||(0|(V=e[c+596>>2]))<1))for(g=(F=e[c+600>>2])+j(V,12)|0,y=e[c+44>>2],V=e[B+976>>2];;){if(B=(e[F>>2]<<2)+y|0,S=v(e[B>>2]),1<=(0|(R=e[F+4>>2])))for(b=(c=e[F+8>>2])+j(R,48)|0;(R=e[c+8>>2])&&((u=R+-1|0)>>>0<=1?(R=e[c+4>>2],d=I[V+(R+e[c+12>>2]<<2)>>2],S=v(u-1?S+v(I[c+44>>2]*v(d*I[c+20>>2])):S+v(I[c+44>>2]*v(v(d*I[c+20>>2])+v(I[V+(R+e[c+16>>2]<<2)>>2]*I[c+24>>2]))))):(e[E>>2]=R,Ut(4,1024,E))),(c=c+48|0)>>>0<b>>>0;);if(S=(S=v(S+v(.0010000000474974513)))<v(0)?v(0):v(Mt(S,v(1e3))),c=v(St(S))<v(2147483648)?~~S:-2147483648,e[B>>2]=c,!((F=F+12|0)>>>0<g>>>0))break}K=16+E|0}(a),function(c){var E,u,d,g,y,b,S,R,F,B=0,V=0,z=0,q=0,tt=0,ut=v(0);if(K=E=K-16|0,B=e[c>>2],!(H[B+4|0]<4||(Yr(c,e[c+604>>2],e[c+608>>2],e[B+984>>2],e[c+152>>2],e[B+796>>2]),V=e[c>>2],H[V+4|0]<5))){if(z=e[c+608>>2],y=e[V+992>>2],b=e[V+988>>2],1<=(0|(B=e[c+604>>2]))){for(S=j(B,12)+z|0,R=e[c+148>>2],u=e[V+980>>2];;){if(d=(e[z>>2]<<2)+R|0,tt=e[d>>2],1<=(0|(q=e[z+4>>2])))for(F=(B=e[z+8>>2])+j(q,48)|0;(q=e[B+8>>2])&&((g=q+-1|0)>>>0<=1?(q=e[B+4>>2],ut=I[(q+e[B+12>>2]<<2)+u>>2],Qt(v(g-1?v(I[B+44>>2]*v(ut*I[B+20>>2]))+(Yt(0,tt),zt()):v(I[B+44>>2]*v(v(ut*I[B+20>>2])+v(I[(q+e[B+16>>2]<<2)+u>>2]*I[B+24>>2])))+(Yt(0,tt),zt()))),tt=Wt[0]):(e[E>>2]=q,Ut(4,1024,E))),(B=B+48|0)>>>0<F>>>0;);if(Yt(0,tt),ut=zt(),I[d>>2]=ut<v(0)?v(0):v(Mt(ut,v(1))),!((z=z+12|0)>>>0<S>>>0))break}z=e[c+608>>2],B=e[c+604>>2]}te(B,z,b,e[V+1288>>2],e[V+1292>>2],e[V+1296>>2],e[c+156>>2]),te(e[c+604>>2],e[c+608>>2],y,e[V+1300>>2],e[V+1304>>2],e[V+1308>>2],e[c+160>>2])}K=16+E|0}(a),function(c){var E,u=0,d=0,g=0,y=0,b=0,S=v(0),R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0;if(K=E=K-80|0,b=e[c>>2],!(H[b+4|0]<5)){if(q=e[b+1028>>2],tt=e[b+1024>>2],g=d=e[c+616>>2],!((0|(u=e[c+612>>2]))<1)){for(F=j(u,12)+d|0,B=e[c+276>>2],R=e[b+1004>>2];;){if(V=B+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((z=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=I[R+(y+e[u+12>>2]<<2)>>2],Qt(v(z-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[R+(y+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[64+E>>2]=y,Ut(4,1024,64+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(e[V>>2]=g,!((d=d+12|0)>>>0<F>>>0))break}if(g=d=e[c+616>>2],!((0|(u=e[c+612>>2]))<1)){for(F=j(u,12)+d|0,B=e[c+280>>2],R=e[e[c>>2]+1008>>2];;){if(V=B+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((z=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=I[R+(y+e[u+12>>2]<<2)>>2],Qt(v(z-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[R+(y+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[48+E>>2]=y,Ut(4,1024,48+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(e[V>>2]=g,!((d=d+12|0)>>>0<F>>>0))break}if(g=d=e[c+616>>2],!((0|(u=e[c+612>>2]))<1)){for(F=j(u,12)+d|0,B=e[c+268>>2],R=e[e[c>>2]+996>>2];;){if(V=B+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((z=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=I[R+(y+e[u+12>>2]<<2)>>2],Qt(v(z-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[R+(y+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[32+E>>2]=y,Ut(4,1024,32+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(Yt(0,g),S=zt(),I[V>>2]=S<v(0)?v(0):v(Mt(S,v(1))),!((d=d+12|0)>>>0<F>>>0))break}u=e[c+612>>2],g=e[c+616>>2]}}}if(te(u,g,tt,e[b+1288>>2],e[b+1292>>2],e[b+1296>>2],e[c+296>>2]),te(e[c+612>>2],e[c+616>>2],q,e[b+1300>>2],e[b+1304>>2],e[b+1308>>2],e[c+300>>2]),!((0|(u=e[c+612>>2]))<1)){for(y=(d=e[c+616>>2])+j(u,12)|0,q=e[c+284>>2],b=e[e[c>>2]+1e3>>2];;){if(tt=q+(e[d>>2]<<2)|0,g=e[tt>>2],1<=(0|(R=e[d+4>>2])))for(F=(u=e[d+8>>2])+j(R,48)|0;(R=e[u+8>>2])&&((B=R+-1|0)>>>0<=1?(R=e[u+4>>2],S=I[b+(R+e[u+12>>2]<<2)>>2],Qt(v(B-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[b+(R+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[16+E>>2]=R,Ut(4,1024,16+E|0))),(u=u+48|0)>>>0<F>>>0;);if(Yt(0,g),S=zt(),I[tt>>2]=S<v(-3600)?v(-3600):v(Mt(S,v(3600))),!((d=d+12|0)>>>0<y>>>0))break}if(!((0|(u=e[c+612>>2]))<1))for(R=(d=e[c+616>>2])+j(u,12)|0,y=e[c+272>>2],c=e[e[c>>2]+1012>>2];;){if(q=y+(e[d>>2]<<2)|0,g=e[q>>2],1<=(0|(b=e[d+4>>2])))for(tt=(u=e[d+8>>2])+j(b,48)|0;(b=e[u+8>>2])&&((F=b+-1|0)>>>0<=1?(b=e[u+4>>2],S=I[c+(b+e[u+12>>2]<<2)>>2],Qt(v(F-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[c+(b+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[E>>2]=b,Ut(4,1024,E))),(u=u+48|0)>>>0<tt>>>0;);if(Yt(0,g),S=zt(),I[q>>2]=S<v(9999999747378752e-20)?v(9999999747378752e-20):v(Mt(S,v(100))),!((d=d+12|0)>>>0<R>>>0))break}}}K=80+E|0}(a),function(c){var E,u,d,g,y,b=0,S=0,R=0,F=0,B=v(0),V=0,z=0,q=0,tt=0,ut=0,mt=0;if(v(0),K=E=K-32|0,R=e[c>>2],!(H[R+4|0]<4||(Yr(c,e[c+620>>2],e[c+624>>2],e[R+1040>>2],e[c+444>>2],e[R+892>>2]),V=e[c>>2],H[V+4|0]<5))){if(g=e[V+1048>>2],y=e[V+1044>>2],R=F=e[c+624>>2],!((0|(b=e[c+620>>2]))<1)){for(ut=j(b,12)+F|0,mt=e[c+440>>2],z=e[V+1036>>2];;){if(R=mt+(e[F>>2]<<2)|0,B=v(e[R>>2]),1<=(0|(S=e[F+4>>2])))for(q=(b=e[F+8>>2])+j(S,48)|0;(S=e[b+8>>2])&&((tt=S+-1|0)>>>0<=1?(S=e[b+4>>2],u=I[z+(S+e[b+12>>2]<<2)>>2],B=v(tt-1?B+v(I[b+44>>2]*v(u*I[b+20>>2])):B+v(I[b+44>>2]*v(v(u*I[b+20>>2])+v(I[z+(S+e[b+16>>2]<<2)>>2]*I[b+24>>2]))))):(e[16+E>>2]=S,Ut(4,1024,16+E|0))),(b=b+48|0)>>>0<q>>>0;);if(B=(B=v(B+v(.0010000000474974513)))<v(0)?v(0):v(Mt(B,v(1e3))),b=v(St(B))<v(2147483648)?~~B:-2147483648,e[R>>2]=b,!((F=F+12|0)>>>0<ut>>>0))break}if(R=F=e[c+624>>2],!((0|(b=e[c+620>>2]))<1)){for(ut=j(b,12)+F|0,mt=e[c+448>>2],z=e[e[c>>2]+1032>>2];;){if(q=mt+(e[F>>2]<<2)|0,R=e[q>>2],1<=(0|(S=e[F+4>>2])))for(tt=(b=e[F+8>>2])+j(S,48)|0;(S=e[b+8>>2])&&((d=S+-1|0)>>>0<=1?(S=e[b+4>>2],B=I[z+(S+e[b+12>>2]<<2)>>2],Qt(v(d-1?v(I[b+44>>2]*v(B*I[b+20>>2]))+(Yt(0,R),zt()):v(I[b+44>>2]*v(v(B*I[b+20>>2])+v(I[z+(S+e[b+16>>2]<<2)>>2]*I[b+24>>2])))+(Yt(0,R),zt()))),R=Wt[0]):(e[E>>2]=S,Ut(4,1024,E))),(b=b+48|0)>>>0<tt>>>0;);if(Yt(0,R),B=zt(),I[q>>2]=B<v(0)?v(0):v(Mt(B,v(1))),!((F=F+12|0)>>>0<ut>>>0))break}b=e[c+620>>2],R=e[c+624>>2]}}te(b,R,y,e[V+1288>>2],e[V+1292>>2],e[V+1296>>2],e[c+452>>2]),te(e[c+620>>2],e[c+624>>2],g,e[V+1300>>2],e[V+1304>>2],e[V+1308>>2],e[c+456>>2])}K=32+E|0}(a),function(c){var E,u,d,g,y,b,S=0,R=0,F=0,B=0,V=v(0);if(K=E=K-16|0,R=e[c>>2],!(H[R+4|0]<5||(0|(B=e[c+628>>2]))<1))for(g=(F=e[c+632>>2])+j(B,12)|0,y=e[c+536>>2],B=e[R+1284>>2];;){if(u=(e[F>>2]<<2)+y|0,R=e[u>>2],1<=(0|(S=e[F+4>>2])))for(b=(c=e[F+8>>2])+j(S,48)|0;(S=e[c+8>>2])&&((d=S+-1|0)>>>0<=1?(S=e[c+4>>2],V=I[B+(S+e[c+12>>2]<<2)>>2],Qt(v(d-1?v(I[c+44>>2]*v(V*I[c+20>>2]))+(Yt(0,R),zt()):v(I[c+44>>2]*v(v(V*I[c+20>>2])+v(I[B+(S+e[c+16>>2]<<2)>>2]*I[c+24>>2])))+(Yt(0,R),zt()))),R=Wt[0]):(e[E>>2]=S,Ut(4,1024,E))),(c=c+48|0)>>>0<b>>>0;);if(Yt(0,R),V=zt(),I[u>>2]=V<v(0)?v(0):v(Mt(V,v(1))),!((F=F+12|0)>>>0<g>>>0))break}K=16+E|0}(a),function(c){var E,u,d=0,g=0,y=0,b=v(0),S=0;if(1<=(0|(d=e[c+4>>2])))for(u=(g=e[c+8>>2])+j(d,12)|0,d=e[c+40>>2],y=e[c+52>>2],c=E=e[c+48>>2];e[d>>2]&&(b=I[y>>2],I[c>>2]=b,(0|(S=e[g+4>>2]))!=-1)&&(I[c>>2]=b*I[(S<<2)+E>>2]),c=c+4|0,y=y+4|0,d=d+4|0,(g=g+12|0)>>>0<u>>>0;);}(a),function(c){var E,u=0,d=0,g=0;if(1<=(0|(E=e[c+304>>2])))for(u=e[c+308>>2],d=e[c+312>>2];e[d>>2]&&L[e[u+20>>2]](c,g),d=d+4|0,u=u+32|0,(0|E)!=(0|(g=g+1|0)););}(a),function(c){var E,u,d,g,y,b=0,S=0,R=(v(0),v(0),0),F=0,B=0,V=(v(0),0),z=0,q=0;if(1<=(0|(b=e[c+332>>2])))for(z=(S=e[c+336>>2])+j(b,20)|0,q=e[c+308>>2],V=e[c+316>>2],y=e[c+48>>2],b=e[c+448>>2],R=e[c+444>>2],B=e[c+424>>2];e[B>>2]&&((0|(F=e[S+4>>2]))!=-1&&(I[b>>2]=I[(F<<2)+y>>2]*I[b>>2]),(0|(F=e[S+8>>2]))!=-1)&&(I[b>>2]=I[V+(F<<2)>>2]*I[b>>2],g=e[R>>2],L[e[24+(q+(F<<5)|0)>>2]](c,F,g,g,e[S+16>>2])),R=R+4|0,b=b+4|0,B=B+4|0,(S=S+20|0)>>>0<z>>>0;);if(!(H[e[c>>2]+4|0]<4||(0|(b=e[c+332>>2]))<1))for(F=(R=e[c+336>>2])+j(b,20)|0,z=e[c+328>>2],q=e[c+324>>2],S=e[c+452>>2],b=e[c+456>>2],B=e[c+424>>2];e[B>>2]&&(0|(c=e[R+8>>2]))!=-1&&(c=(V=c<<4)+q|0,E=v(I[S>>2]*I[c>>2]),I[S>>2]=E,u=v(I[S+4>>2]*I[c+4>>2]),I[S+4>>2]=u,d=I[c+8>>2],e[S+12>>2]=1065353216,I[S+4>>2]=u<v(0)?v(0):v(Mt(u,v(1))),I[S>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=v(d*I[S+8>>2]),I[S+8>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=I[b>>2],u=I[(c=z+V|0)>>2],E=v(v(E+u)-v(E*u)),I[b>>2]=E,u=I[b+4>>2],d=I[c+4>>2],u=v(v(u+d)-v(u*d)),I[b+4>>2]=u,d=I[c+8>>2],e[b+12>>2]=1065353216,I[b+4>>2]=u<v(0)?v(0):v(Mt(u,v(1))),I[b>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=I[b+8>>2],E=v(v(d+E)-v(E*d)),I[b+8>>2]=E<v(0)?v(0):v(Mt(E,v(1)))),b=b+16|0,S=S+16|0,B=B+4|0,(R=R+20|0)>>>0<F>>>0;);}(a),function(c){var E,u,d,g,y,b,S,R,F,B,V,z,q,tt,ut,mt,Bt,Ht,ce,we,Ue=0;if(v(0),v(0),v(0),v(0),v(0),v(0),v(0),1<=(0|(R=e[c+500>>2])))for(ce=e[c+536>>2],F=e[c+444>>2],we=e[c+504>>2];;){if(c=j(Ue,24)+we|0,0<(0|(B=e[c+12>>2])))for(d=I[(Ue<<2)+ce>>2],V=e[c+20>>2],z=e[c+16>>2],q=e[(e[c+4>>2]<<2)+F>>2],tt=e[(e[c+8>>2]<<2)+F>>2],c=0;ut=I[((E=1|c)<<2)+z>>2],u=W[(c<<1)+V>>1]<<3&262136,g=I[(mt=(4|u)+q|0)>>2],E=W[(E<<1)+V>>1]<<3&262136,y=I[(Bt=(4|E)+tt|0)>>2],b=I[(u=u+q|0)>>2],Ht=I[(c<<2)+z>>2],S=I[(E=E+tt|0)>>2],I[u>>2]=b+v(d*v(Ht*v(S-b))),I[mt>>2]=g+v(d*v(Ht*v(y-g))),I[E>>2]=S+v(d*v(ut*v(b-S))),I[Bt>>2]=y+v(d*v(ut*v(g-y))),(0|(c=c+2|0))<(0|B););if(!((0|(Ue=Ue+1|0))<(0|R)))break}}(a),L[e[1810]](a),function(c){var E,u,d,g,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0;if(!((0|(E=e[c+480>>2]))<1)){for(R=(u=e[c+484>>2])+j(E,28)|0,V=e[c+424>>2],z=e[c+40>>2],F=e[c+44>>2],ut=e[c+440>>2],y=u;;){if(1<=(0|(B=e[y+4>>2])))for(tt=y+20|0,q=e[y+12>>2],b=0;d=e[4+(S=q+(b<<4)|0)>>2]<<2,S=e[(g=S)>>2]==1,e[g+12>>2]=e[(e[(S?z:V)+d>>2]?(S?F:ut)+d|0:tt)>>2],(0|(b=b+1|0))<(0|B););if(!((y=y+28|0)>>>0<R>>>0))break}if(!((0|E)<1))for(ut=e[c+436>>2],z=0;;){if(R=j(z,28)+u|0,!(e[(V=R)+24>>2]<1)){for(S=e[c+488>>2],b=0;e[S+(b<<2)>>2]=-1,(0|(b=b+1|0))<(0|(y=e[V+24>>2])););if(!((0|y)<1))for(y=e[c+496>>2],b=0;e[y+(b<<2)>>2]=-1,(0|(b=b+1|0))<e[V+24>>2];);}if(!(e[R+4>>2]<1)){for(F=e[c+492>>2],b=0;e[F+(b<<2)>>2]=-1,(0|(b=b+1|0))<(0|(y=e[R+4>>2])););if(!((0|y)<1))for(B=e[R+12>>2],tt=e[c+496>>2],b=0;q=e[12+(B+(b<<4)|0)>>2]-e[R+20>>2]<<2,y=(0|(y=e[(S=q+tt|0)>>2]))==-1?q+e[c+488>>2]|0:F+(y<<2)|0,e[y>>2]=b,(0|(b=(e[S>>2]=b)+1|0))<e[R+4>>2];);}if(1<=(0|(y=e[V+24>>2])))for(F=e[R+8>>2],tt=e[c+488>>2],B=0;;){if((0|(b=e[tt+(B<<2)>>2]))!=-1){for(q=e[c+492>>2],S=e[R+12>>2];F=(y=e[(y=S+(b<<4)|0)>>2]==1?(y=j(e[y+8>>2],28)+u|0,e[y+8>>2]=F,e[y>>2]):(e[ut+(e[y+4>>2]<<2)>>2]=F,1))+F|0,(0|b)<(0|(y=e[q+(b<<2)>>2]))&&(0|(b=y))!=-1;);y=e[V+24>>2]}if(!((0|(B=B+1|0))<(0|y)))break}if((0|E)==(0|(z=z+1|0)))break}}}(a),function(c){var E=0,u=0,d=0,g=0,y=0,b=v(0),S=0,R=0,F=e[c+332>>2];if(e[c+644>>2]){if(!(((e[c+428>>2]=0)|F)<1))for(;E=126,S=e[c+432>>2]+d|0,!e[(u=d<<2)+e[c+424>>2]>>2]|I[u+e[c+448>>2]>>2]==v(0)||(E=127),O[0|S]=E,(0|F)!=(0|(d=d+1|0)););}else if(e[c+428>>2]){if(E=H[e[c>>2]+4|0],!(((e[c+428>>2]=0)|F)<1))if(4<=E>>>0)for(;b=I[(E=d<<2)+e[c+448>>2]>>2],g=e[E+e[c+424>>2]>>2],u=b!=v(0)&(0|g)!=0,S=e[c+432>>2]+d|0,u=(0|u)==(1&O[0|S])?u:2|u,u=b!=I[E+e[c+468>>2]>>2]?4|u:u,u=e[E+e[c+440>>2]>>2]==e[E+e[c+464>>2]>>2]?u:8|u,E=e[E+e[c+436>>2]>>2]==e[E+e[c+460>>2]>>2]?u:16|u,E=g?32|E:E,g=(u=R<<2)+e[c+452>>2]|0,y=u+e[c+472>>2]|0,(I[g>>2]!=I[y>>2]|I[g+4>>2]!=I[y+4>>2]|(I[g+8>>2]!=I[y+8>>2]|I[g+12>>2]!=I[y+12>>2])||(g=u+e[c+456>>2]|0,u=u+e[c+476>>2]|0,I[g>>2]!=I[u>>2]|I[g+4>>2]!=I[u+4>>2]|I[g+8>>2]!=I[u+8>>2])||I[g+12>>2]!=I[u+12>>2])&&(E|=64),O[0|S]=E,R=R+4|0,(0|F)!=(0|(d=d+1|0)););else for(;b=I[(E=d<<2)+e[c+448>>2]>>2],g=e[E+e[c+424>>2]>>2],u=b!=v(0)&(0|g)!=0,y=e[c+432>>2]+d|0,u=(0|u)==(1&O[0|y])?u:2|u,u=b!=I[E+e[c+468>>2]>>2]?4|u:u,u=e[E+e[c+440>>2]>>2]==e[E+e[c+464>>2]>>2]?u:8|u,E=e[E+e[c+436>>2]>>2]==e[E+e[c+460>>2]>>2]?u:16|u,O[0|y]=g?32|E:E,(0|F)!=(0|(d=d+1|0)););}else if(!((0|F)<1))for(;!e[(E=d<<2)+e[c+424>>2]>>2]|I[E+e[c+448>>2]>>2]==v(0)?(E=e[c+432>>2]+d|0,O[0|E]=254&H[0|E]):(E=e[c+432>>2]+d|0,O[0|E]=1|H[0|E]),(0|F)!=(0|(d=d+1|0)););}(a),e[a+644>>2]=0}function Yr(a,p,P,_,c,E){var u,d,g,y,b,S,R,F=0,B=0,V=0,z=0;if(K=S=K-32|0,1<=(0|p))for(b=j(p,12)+P|0;;){if(!((0|(F=e[P+4>>2]))<1))if(u=(p=e[P+8>>2])+j(F,48)|0,F=e[P>>2]<<2,1<=(0|(R=e[F+E>>2])))for(R<<=1,d=e[e[a>>2]+1052>>2],g=e[c+F>>2];;){r:if(F=e[p+8>>2]){t:{if((B=F+-1|0)>>>0<=1){if(F=(e[p+4>>2]<<2)+_|0,z=(e[F+(e[p+12>>2]<<2)>>2]<<2)+d|0,B-1)break t;for(V=(e[F+(e[p+16>>2]<<2)>>2]<<2)+d|0,F=0;I[(y=(B=F<<2)+g|0)>>2]=I[y>>2]+v(I[p+44>>2]*v(v(I[B+z>>2]*I[p+20>>2])+v(I[B+V>>2]*I[p+24>>2]))),(0|R)!=(0|(F=F+1|0)););break r}e[S>>2]=F,Ut(4,1024,S);break r}for(F=0;I[(V=(B=F<<2)+g|0)>>2]=I[V>>2]+v(I[p+44>>2]*v(I[B+z>>2]*I[p+20>>2])),(0|R)!=(0|(F=F+1|0)););}if(!((p=p+48|0)>>>0<u>>>0))break}else for(;3<=(F=e[p+8>>2])>>>0&&(e[16+S>>2]=F,Ut(4,1024,16+S|0)),(p=p+48|0)>>>0<u>>>0;);if(!((P=P+12|0)>>>0<b>>>0))break}K=32+S|0}function jr(a,p,P){var _;p|=0,P|=0,K=_=K+-64|0;r:{if(a|=0)if(p)if((p+15&-16)!=(0|p))e[52+_>>2]=1522,e[48+_>>2]=2361,Ut(4,1294,48+_|0);else{if(p=function(c,E,u){var d,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=v(0),Ht=0,ce=0,we=0,Ue=0,He=0;if(Ce(16+(K=d=K-576|0)|0,0,560),vi(c,16+d|0,12+d|0),(S=e[12+d>>2])>>>0<=u>>>0){if(g=(y=Ce(E,0,S))+e[16+d>>2]|0,e[g+8>>2]=y+e[20+d>>2],e[g+40>>2]=y+e[24+d>>2],e[g+44>>2]=y+e[28+d>>2],e[g+48>>2]=y+e[32+d>>2],e[g+52>>2]=y+e[36+d>>2],e[g+16>>2]=y+e[40+d>>2],e[g+24>>2]=y+e[44+d>>2],e[g+28>>2]=y+e[48+d>>2],e[g+32>>2]=y+e[52+d>>2],e[g+36>>2]=y+e[56+d>>2],E=e[c+704>>2],e[g+308>>2]=y+e[60+d>>2],e[g+312>>2]=y+e[64+d>>2],e[g+316>>2]=y+e[68+d>>2],e[g+320>>2]=y+e[72+d>>2],e[g+324>>2]=y+e[76+d>>2],e[g+328>>2]=y+e[80+d>>2],e[g+60>>2]=y+e[84+d>>2],e[g+144>>2]=y+e[88+d>>2],e[g+148>>2]=y+e[92+d>>2],u=y+e[96+d>>2]|0,e[g+152>>2]=u,!((0|(S=e[E+8>>2]))<1)&&(E=y+e[100+d>>2]|0,e[u>>2]=E,(0|S)!=1))for(u=1;E=(15+(e[e[c+796>>2]+(b<<2)>>2]<<3)&-16)+E|0,e[e[g+152>>2]+(u<<2)>>2]=E,(0|S)!=(0|(u=(b=u)+1|0)););if(e[g+156>>2]=y+e[104+d>>2],e[g+160>>2]=y+e[108+d>>2],e[g+68>>2]=y+e[112+d>>2],e[g+76>>2]=y+e[116+d>>2],e[g+80>>2]=y+e[120+d>>2],e[g+84>>2]=y+e[124+d>>2],e[g+88>>2]=y+e[128+d>>2],e[g+92>>2]=y+e[132+d>>2],e[g+96>>2]=y+e[136+d>>2],e[g+100>>2]=y+e[140+d>>2],e[g+104>>2]=y+e[144+d>>2],e[g+108>>2]=y+e[148+d>>2],e[g+112>>2]=y+e[152+d>>2],e[g+116>>2]=y+e[156+d>>2],e[g+120>>2]=y+e[160+d>>2],e[g+124>>2]=y+e[164+d>>2],e[g+128>>2]=y+e[168+d>>2],e[g+132>>2]=y+e[172+d>>2],e[g+136>>2]=y+e[176+d>>2],e[g+140>>2]=y+e[180+d>>2],e[g+168>>2]=y+e[184+d>>2],e[g+264>>2]=y+e[188+d>>2],e[g+268>>2]=y+e[192+d>>2],e[g+272>>2]=y+e[196+d>>2],e[g+276>>2]=y+e[200+d>>2],e[g+280>>2]=y+e[204+d>>2],e[g+284>>2]=y+e[208+d>>2],e[g+288>>2]=y+e[212+d>>2],e[g+292>>2]=y+e[216+d>>2],e[g+296>>2]=y+e[220+d>>2],e[g+300>>2]=y+e[224+d>>2],e[g+176>>2]=y+e[228+d>>2],e[g+184>>2]=y+e[232+d>>2],e[g+188>>2]=y+e[236+d>>2],e[g+192>>2]=y+e[240+d>>2],e[g+196>>2]=y+e[244+d>>2],e[g+200>>2]=y+e[248+d>>2],e[g+204>>2]=y+e[252+d>>2],e[g+208>>2]=y+e[256+d>>2],e[g+212>>2]=y+e[260+d>>2],e[g+216>>2]=y+e[264+d>>2],e[g+220>>2]=y+e[268+d>>2],e[g+224>>2]=y+e[272+d>>2],e[g+228>>2]=y+e[276+d>>2],e[g+232>>2]=y+e[280+d>>2],e[g+236>>2]=y+e[284+d>>2],e[g+240>>2]=y+e[288+d>>2],e[g+244>>2]=y+e[292+d>>2],e[g+248>>2]=y+e[296+d>>2],e[g+252>>2]=y+e[300+d>>2],e[g+256>>2]=y+e[304+d>>2],e[g+260>>2]=y+e[308+d>>2],E=e[c+704>>2],e[g+336>>2]=y+e[312+d>>2],e[g+424>>2]=y+e[316+d>>2],e[g+432>>2]=y+e[320+d>>2],e[g+436>>2]=y+e[324+d>>2],e[g+440>>2]=y+e[328+d>>2],u=y+e[332+d>>2]|0,e[g+444>>2]=u,!((0|(S=e[E+16>>2]))<1)&&(b=y+e[336+d>>2]|0,e[u>>2]=b,(u=1)!=(0|S)))for(E=0;b=(15+(e[e[c+892>>2]+(E<<2)>>2]<<3)&-16)+b|0,e[e[g+444>>2]+(u<<2)>>2]=b,(0|S)!=(0|(u=(E=u)+1|0)););if(e[g+448>>2]=y+e[340+d>>2],e[g+452>>2]=y+e[344+d>>2],e[g+456>>2]=y+e[348+d>>2],e[g+460>>2]=y+e[352+d>>2],e[g+464>>2]=y+e[356+d>>2],e[g+468>>2]=y+e[360+d>>2],e[g+472>>2]=y+e[364+d>>2],e[g+476>>2]=y+e[368+d>>2],e[g+344>>2]=y+e[372+d>>2],e[g+352>>2]=y+e[376+d>>2],e[g+356>>2]=y+e[380+d>>2],e[g+360>>2]=y+e[384+d>>2],e[g+364>>2]=y+e[388+d>>2],e[g+368>>2]=y+e[392+d>>2],e[g+372>>2]=y+e[396+d>>2],e[g+376>>2]=y+e[400+d>>2],e[g+380>>2]=y+e[404+d>>2],e[g+384>>2]=y+e[408+d>>2],e[g+388>>2]=y+e[412+d>>2],e[g+392>>2]=y+e[416+d>>2],e[g+396>>2]=y+e[420+d>>2],e[g+400>>2]=y+e[424+d>>2],e[g+404>>2]=y+e[428+d>>2],e[g+408>>2]=y+e[432+d>>2],e[g+412>>2]=y+e[436+d>>2],e[g+416>>2]=y+e[440+d>>2],e[g+420>>2]=y+e[444+d>>2],E=e[448+d>>2],u=e[452+d>>2],e[g+552>>2]=y+e[456+d>>2],e[g+548>>2]=u+y,e[g+544>>2]=E+y,e[g+560>>2]=y+e[460+d>>2],E=e[c+704>>2],B=y+e[464+d>>2]|0,e[g+568>>2]=B,1<=(0|(F=e[E+48>>2])))for(b=y+e[468+d>>2]|0,E=y+e[472+d>>2]|0,R=y+e[476+d>>2]|0,V=e[c+1072>>2],u=0;S=B+j(u,36)|0,e[S+20>>2]=R,e[S+16>>2]=E,e[S>>2]=b,b=((S=e[V+(u<<2)>>2])<<2)+b|0,R=(S=1<<S<<2)+R|0,E=E+S|0,(0|F)!=(0|(u=u+1|0)););if(E=e[c+704>>2],S=y+e[516+d>>2]|0,e[g+484>>2]=S,1<=(0|(E=e[E+72>>2])))for(b=y+e[520+d>>2]|0,R=e[c+1212>>2],u=0;e[12+(S+j(u,28)|0)>>2]=b,b=(e[R+(u<<2)>>2]<<4)+b|0,(0|E)!=(0|(u=u+1|0)););e[g+488>>2]=y+e[524+d>>2],e[g+492>>2]=y+e[528+d>>2],e[g+496>>2]=y+e[532+d>>2],e[g+504>>2]=y+e[536+d>>2],e[g+536>>2]=y+e[540+d>>2],e[g+512>>2]=y+e[544+d>>2],e[g+520>>2]=y+e[548+d>>2],e[g+524>>2]=y+e[552+d>>2],e[g+528>>2]=y+e[556+d>>2],e[g+532>>2]=y+e[560+d>>2];t:{if(4<=(F=H[c+4|0])>>>0){if(e[g+576>>2]=y+e[480+d>>2],e[g+584>>2]=y+e[484+d>>2],E=e[c+704>>2],u=e[492+d>>2],S=y+e[488+d>>2]|0,e[g+592>>2]=S,1<=(0|(E=e[E+104>>2])))for(b=u+y|0,R=e[c+1104>>2],u=0;e[40+(S+j(u,48)|0)>>2]=b,b=(e[R+(u<<2)>>2]<<2)+b|0,(0|E)!=(0|(u=u+1|0)););e[g+608>>2]=y+e[500+d>>2],e[g+624>>2]=y+e[508+d>>2]}else{if(E=e[572+d>>2],u=e[568+d>>2],e[g+636>>2]=y+e[564+d>>2],e[g+640>>2]=u+y,e[e[c+704>>2]+20>>2]<1)break t;for(S=E+y|0,B=0;;){e:{if((0|(b=e[(E=B<<2)+e[c+952>>2]>>2]))<=0)E=E+e[g+636>>2]|0;else{for(R=b+(u=e[E+e[c+948>>2]>>2])|0,V=e[c+1060>>2],b=0;b=e[V+(u<<2)>>2]+b|0,(0|(u=u+1|0))<(0|R););if(E=E+e[g+636>>2]|0,u=S,b)break e}u=b=0}if(e[E>>2]=u,S=(b<<2)+S|0,!((0|(B=B+1|0))<e[e[c+704>>2]+20>>2]))break}}F>>>0<5||(e[g+600>>2]=y+e[496+d>>2],e[g+616>>2]=y+e[504+d>>2],e[g+632>>2]=y+e[512+d>>2])}e[g+644>>2]=1,e[g>>2]=c,e[g+648>>2]=1&O[e[c+708>>2]+20|0],y=e[c+704>>2],B=e[y+20>>2];t:if(!((0|(e[g+540>>2]=B))<1)){if(E=B+-1|0,V=e[c+952>>2],z=e[c+940>>2],q=e[c+932>>2],tt=e[c+936>>2],ut=e[c+924>>2],mt=e[c+928>>2],Ht=e[g+552>>2],we=e[g+544>>2],F>>>0<4){for(;;)if(u=we+j(E,52)|0,b=(S=E<<2)+mt|(e[u>>2]=0),e[u+4>>2]=e[b>>2],e[u+8>>2]=e[(R=S+ut|0)>>2],I[u+12>>2]=I[R>>2]-I[b>>2],e[u+16>>2]=e[S+tt>>2],e[u+44>>2]=e[(b=S+q|0)>>2],Bt=Kr(v(e[S+z>>2])),I[u+20>>2]=Bt,I[u+24>>2]=Bt*v(1.5),ce=e[S+V>>2],R=0,R=(e[u+32>>2]=ce)?e[g+560>>2]+j(e[S+e[c+948>>2]>>2],28)|0:R,e[u+48>>2]=1,e[u+28>>2]=R,e[S+Ht>>2]=e[b>>2],u=0<(0|E),E=E+-1|0,!u)break t}for(ce=e[c+960>>2],He=e[c+944>>2];u=we+j(E,52)|0,e[u>>2]=e[(b=E<<2)+He>>2],e[u+4>>2]=e[(S=b+mt|0)>>2],e[u+8>>2]=e[(R=b+ut|0)>>2],I[u+12>>2]=I[R>>2]-I[S>>2],e[u+16>>2]=e[b+tt>>2],e[u+44>>2]=e[(Ue=b+q|0)>>2],Bt=Kr(v(e[b+z>>2])),I[u+20>>2]=Bt,I[u+24>>2]=Bt*v(1.5),R=e[b+V>>2],e[u+32>>2]=R,e[u+28>>2]=R?e[g+560>>2]+j(e[b+e[c+948>>2]>>2],28)|0:0,S=e[b+ce>>2],S=(e[u+40>>2]=S)?e[g+584>>2]+j(e[b+e[c+956>>2]>>2],28)|0:0,e[u+48>>2]=1,e[u+36>>2]=S,e[b+Ht>>2]=e[Ue>>2],u=0<(0|E),E=E+-1|0,u;);}if(4<=F>>>0?(e[g+548>>2]=e[c+944>>2],S=c):(Ce(e[g+548>>2],0,B<<2),S=e[g>>2],y=e[S+704>>2]),b=e[y+52>>2],1<=(0|(e[g+556>>2]=b)))for(u=e[S+1056>>2],R=e[S+1192>>2],B=e[S+1060>>2],F=e[g+560>>2];E=F+j(b=b+-1|0,28)|0,e[E>>2]=e[(V=b<<2)+B>>2],V=e[u+V>>2],e[E+24>>2]=1,e[E+16>>2]=0,e[E+20>>2]=1,e[E+8>>2]=0,e[E+12>>2]=0,e[E+4>>2]=R+(V<<2),0<(0|b););if(b=e[y+48>>2],1<=(0|(e[g+564>>2]=b))){for(;;){if(E=e[g+568>>2]+j(b=b+-1|0,36)|0,R=e[(y=b<<2)+e[S+1072>>2]>>2],1<=(0|(e[E+4>>2]=R)))for(u=0;e[e[E>>2]+(u<<2)>>2]=e[g+560>>2]+j(e[e[S+1064>>2]+(e[y+e[S+1068>>2]>>2]+u<<2)>>2],28),(0|R)!=(0|(u=u+1|0)););if(e[E+24>>2]=1,e[E+28>>2]=1,e[E+8>>2]=1<<R,!(0<(0|b)))break}S=e[g>>2],y=e[S+704>>2]}if(E=e[y>>2],(0|(e[g+4>>2]=E))<1)u=0;else{for(V=e[S+732>>2],z=e[S+736>>2],q=e[S+740>>2],R=e[S+720>>2],tt=e[g+52>>2],B=e[g+568>>2],ut=e[g+8>>2],b=E;F=ut+j(b=b+-1|0,12)|0,e[F>>2]=B+j(e[(u=b<<2)+R>>2],36),e[F+4>>2]=e[u+q>>2],e[F+8>>2]=e[u+z>>2],I[u+tt>>2]=e[u+V>>2]?v(1):v(0),0<(0|b););for(F=e[g+16>>2],u=0;b=e[8+(B+j(e[(V=(E=E+-1|0)<<2)+R>>2],36)|0)>>2],u=u+(e[F+V>>2]=b)|0,0<(0|E););E=e[g+4>>2]}if(e[g+12>>2]=E,e[g+20>>2]=u,E=e[y+4>>2],1<=(0|(e[g+304>>2]=E))){for(;u=e[g+308>>2]+((E=E+-1|0)<<5)|0,e[u>>2]=e[g+568>>2]+j(e[(b=E<<2)+e[S+752>>2]>>2],36),e[u+4>>2]=e[b+e[S+764>>2]>>2],e[u+8>>2]=e[b+e[S+768>>2]>>2],R=e[b+e[S+772>>2]>>2],e[u+12>>2]=R,y=e[b+e[S+776>>2]>>2],e[u+16>>2]=y,e[u+28>>2]=e[b+e[S+760>>2]>>2],R>>>0<=1?R-1?(e[20+(e[g+60>>2]+j(y,24)|0)>>2]=E,e[u+24>>2]=1,e[u+20>>2]=2):(e[8+(e[g+168>>2]+j(y,12)|0)>>2]=E,e[u+24>>2]=3,e[u+20>>2]=4):Ut(4,1179,0),0<(0|E););S=e[g>>2],y=e[S+704>>2]}b=e[y+8>>2];t:if(!((0|(e[g+56>>2]=b))<1)){if(u=b+-1|0,B=e[S+796>>2],F=e[S+804>>2],V=e[S+800>>2],z=e[S+780>>2],q=e[g+568>>2],tt=e[g+60>>2],H[S+4|0]<2){for(;;)if(E=tt+j(u,24)|0,e[E>>2]=q+j(e[(R=u<<2)+z>>2],36),e[E+4>>2]=e[R+V>>2],e[E+8>>2]=e[R+F>>2],R=e[R+B>>2],e[E+12>>2]=0,e[E+16>>2]=R,E=0<(0|u),u=u+-1|0,!E)break t}for(ut=e[S+808>>2];E=tt+j(u,24)|0,e[E>>2]=q+j(e[(R=u<<2)+z>>2],36),e[E+4>>2]=e[R+V>>2],e[E+8>>2]=e[R+F>>2],e[E+16>>2]=e[R+B>>2],e[E+12>>2]=e[R+ut>>2],E=0<(0|u),u=u+-1|0,E;);}if(u=e[y+12>>2],1<=(0|(e[g+164>>2]=u)))for(R=e[S+828>>2],B=e[S+812>>2],F=e[g+568>>2],V=e[g+168>>2],E=u;z=V+j(E=E+-1|0,12)|0,e[z>>2]=F+j(e[(q=E<<2)+B>>2],36),e[z+4>>2]=e[R+q>>2],0<(0|E););if(((E=0)|b)<1)R=0;else{for(B=e[g+68>>2],F=e[g+60>>2],R=0;u=e[e[F+j(b=b+-1|0,24)>>2]+8>>2],R=(e[B+(b<<2)>>2]=u)+R|0,0<(0|b););u=e[g+164>>2],b=e[g+56>>2]}if(e[g+64>>2]=b,e[g+72>>2]=R,b=g,1<=(0|u)){for(B=e[g+176>>2],F=e[g+168>>2];R=e[e[F+j(u=u+-1|0,12)>>2]+8>>2],E=E+(e[B+(u<<2)>>2]=R)|0,0<(0|u););u=e[g+164>>2]}if(e[b+172>>2]=u,e[g+180>>2]=E,R=e[y+16>>2],1<=(0|(e[g+332>>2]=R))){for(V=e[S+872>>2],z=e[S+892>>2],q=e[S+880>>2],tt=e[S+876>>2],B=e[S+852>>2],F=e[g+568>>2],ut=e[g+336>>2],E=R;u=ut+j(E=E+-1|0,20)|0,e[u>>2]=F+j(e[(b=E<<2)+B>>2],36),e[u+4>>2]=e[b+tt>>2],e[u+8>>2]=e[b+q>>2],e[u+16>>2]=e[b+z>>2],e[u+12>>2]=e[b+V>>2],0<(0|E););for(b=e[g+344>>2],u=0;E=e[8+(F+j(e[(V=(R=R+-1|0)<<2)+B>>2],36)|0)>>2],u=(e[b+V>>2]=E)+u|0,0<(0|R););if(e[g+348>>2]=u,R=e[g+332>>2],!((0|(e[g+340>>2]=R))<1))for(u=R<<2,b=e[g+456>>2],B=e[g+452>>2];e[(F=(E=u+-4|0)<<2)+B>>2]=1065353216,e[(V=(u<<=2)-4|0)+B>>2]=1065353216,e[(z=(u=u+-12|0)+B|0)>>2]=1065353216,e[z+4>>2]=1065353216,e[b+F>>2]=0,e[b+V>>2]=1065353216,e[(u=u+b|0)>>2]=0,e[u+4>>2]=0,u=E,0<(0|(R=R+-1|0)););}else e[g+340>>2]=R,e[g+348>>2]=0;if(R=e[y+72>>2],1<=(0|(e[g+480>>2]=R)))for(V=e[S+1208>>2],z=e[S+1224>>2],q=e[S+1220>>2],tt=e[S+1216>>2],ut=e[S+1212>>2],mt=e[g+484>>2],b=0;;){if(E=mt+j(b,28)|0,B=e[(u=b<<2)+ut>>2],e[E+4>>2]=B,e[E>>2]=e[u+tt>>2],F=e[u+q>>2],e[E+16>>2]=F,Ht=e[u+z>>2],e[E+20>>2]=Ht,e[E+8>>2]=0,e[E+24>>2]=1+(F-Ht|0),1<=(0|B))for(Ht=e[u+V>>2],we=e[E+12>>2],ce=e[S+1236>>2],He=e[S+1228>>2],Ue=e[S+1232>>2],u=0;e[4+(E=we+(u<<4)|0)>>2]=e[(F=u+Ht<<2)+Ue>>2],e[E>>2]=e[F+He>>2],F=e[F+ce>>2],e[E+12>>2]=0,e[E+8>>2]=F,(0|B)!=(0|(u=u+1|0)););if((0|R)==(0|(b=b+1|0)))break}if(u=e[y+80>>2],(0|(e[g+500>>2]=u))<1)b=0;else{for(F=e[S+1280>>2],V=e[S+1268>>2],z=e[S+1276>>2],q=e[S+1272>>2],tt=e[S+1264>>2],ut=e[S+1260>>2],R=e[S+1248>>2],B=e[g+568>>2],mt=e[g+504>>2];E=mt+j(u=u+-1|0,24)|0,e[E>>2]=B+j(e[(b=u<<2)+R>>2],36),e[E+4>>2]=e[b+ut>>2],e[E+8>>2]=e[b+tt>>2],e[E+12>>2]=e[b+q>>2],b=e[b+V>>2],e[E+20>>2]=F+(b<<1),e[E+16>>2]=z+(b<<2),0<(0|u););if((0|(u=e[g+500>>2]))<1)b=0;else{for(F=e[g+512>>2],b=0;E=e[8+(B+j(e[(V=(u=u+-1|0)<<2)+R>>2],36)|0)>>2],b=(e[F+V>>2]=E)+b|0,0<(0|u););u=e[g+500>>2]}}e[g+508>>2]=u,e[g+516>>2]=b;t:if(4<=H[c+4|0]){if(!((R=H[S+4|0])>>>0<4)){if(u=e[y+120>>2],1<=(0|(e[g+572>>2]=u))){for(F=e[S+1172>>2],V=e[g+576>>2];R=(0|(y=e[(E=(u=u+-1|0)<<2)+F>>2]))<0?y=B=b=0:(b=(R=e[E+e[S+1176>>2]>>2]<<2)+e[S+1188>>2]|0,B=e[E+e[S+1180>>2]>>2],y=e[g+544>>2]+j(y,52)|0,R+e[S+1184>>2]|0),E=V+j(u,20)|0,e[E+12>>2]=B,e[E+8>>2]=b,e[E+4>>2]=R,e[E>>2]=y,0<(0|u););if(S=e[g>>2],(R=H[S+4|0])>>>0<4)break t}if(y=e[S+704>>2],b=e[y+100>>2],1<=(0|(e[g+580>>2]=b)))for(B=e[S+1084>>2],F=e[S+1076>>2],V=e[S+1192>>2],z=e[S+1080>>2],q=e[g+584>>2];E=q+j(b=b+-1|0,28)|0,e[E>>2]=e[(u=b<<2)+z>>2],e[E+4>>2]=V+(e[u+F>>2]<<2),u=e[u+B>>2],e[E+20>>2]=1,e[E+24>>2]=1,e[E+12>>2]=0,e[E+16>>2]=0,e[E+8>>2]=u,0<(0|b););if(b=e[y+104>>2],1<=(0|(e[g+588>>2]=b))){for(;;){if(E=e[g+592>>2]+j(b=b+-1|0,48)|0,e[E>>2]=e[g+584>>2]+j(e[(R=b<<2)+e[S+1088>>2]>>2],28),u=e[R+e[S+1092>>2]>>2],e[E+28>>2]=1,e[E+32>>2]=1,e[E+8>>2]=0,e[E+4>>2]=u,y=e[R+e[S+1104>>2]>>2],1<=(0|(e[E+36>>2]=y)))for(u=0;e[e[E+40>>2]+(u<<2)>>2]=e[g+576>>2]+j(e[e[S+1168>>2]+(e[R+e[S+1100>>2]>>2]+u<<2)>>2],20),(0|y)!=(0|(u=u+1|0)););if(!(1<=(0|b)))break}S=e[g>>2],R=H[S+4|0]}if(!(R>>>0<4)){if(R=e[c+704>>2],u=e[R+108>>2],1<=(0|(e[g+604>>2]=u)))for(y=e[c+1124>>2],B=e[c+1128>>2],F=e[c+1120>>2],V=e[g+592>>2],z=e[g+608>>2];E=z+j(u=u+-1|0,12)|0,e[E>>2]=e[(b=u<<2)+F>>2],e[E+4>>2]=e[b+B>>2],e[E+8>>2]=V+j(e[y+b>>2],48),0<(0|u););if(u=e[R+112>>2],1<=(0|(e[g+620>>2]=u)))for(R=e[c+1148>>2],y=e[c+1152>>2],B=e[c+1144>>2],F=e[g+592>>2],V=e[g+624>>2];E=V+j(u=u+-1|0,12)|0,e[E>>2]=e[(b=u<<2)+B>>2],e[E+4>>2]=e[y+b>>2],e[E+8>>2]=F+j(e[b+R>>2],48),0<(0|u););if(b=e[S+1192>>2],E=e[e[S+704>>2]+20>>2],e[g+640>>2]=e[S+972>>2],R=e[S+964>>2],e[g+636>>2]=R,!((0|E)<(u=1))&&(e[R>>2]=b+(e[e[S+968>>2]>>2]<<2),(0|E)!=1))for(;e[(R=u<<2)+e[g+636>>2]>>2]=b+(e[R+e[S+968>>2]>>2]<<2),(0|E)!=(0|(u=u+1|0)););}}}else if(!(e[y+20>>2]<1))for(y=0;;){if(b=e[(B=y<<2)+e[g+636>>2]>>2],1<=((E=0)|(u=e[B+e[S+952>>2]>>2])))for(z=u+(F=e[B+e[S+948>>2]>>2])|0,q=e[S+1060>>2],tt=e[S+1056>>2];;){if(1<=(0|(V=e[(u=F<<2)+q>>2])))for(ut=V+(R=e[u+tt>>2])|0,mt=e[S+1192>>2];;){V=b+(E<<2)|0,Bt=I[mt+(R<<2)>>2],u=b;e:{if(0<(0|E))for(;;){if(I[u>>2]==Bt)break e;if(!((u=u+4|0)>>>0<V>>>0))break}I[V>>2]=Bt,E=E+1|0}if(!((0|(R=R+1|0))<(0|ut)))break}if(!((0|(F=F+1|0))<(0|z)))break}if(function(pe,tr){var Ot,fe,Te=0,ke=0,Ne=0;e[8+(K=Ot=K-208|0)>>2]=1,e[12+Ot>>2]=0;e:if(fe=tr<<2){for(e[16+Ot>>2]=4,Ne=tr=e[20+Ot>>2]=4,Te=2;tr=(Ne+4|0)+(ke=tr)|0,e[(16+Ot|0)+(Te<<2)>>2]=tr,Te=Te+1|0,Ne=ke,tr>>>0<fe>>>0;);if((ke=(pe+fe|0)-4|0)>>>0<=pe>>>0)tr=Te=1;else for(tr=Te=1;tr=(3&Te)==3?(Br(pe,tr,16+Ot|0),Le(8+Ot|0,2),tr+2|0):(rt[(16+Ot|0)+((Ne=tr+-1|0)<<2)>>2]>=ke-pe>>>0?je(pe,8+Ot|0,tr,0,16+Ot|0):Br(pe,tr,16+Ot|0),(0|tr)==1?(lr(8+Ot|0,1),0):(lr(8+Ot|0,Ne),1)),Te=1|e[8+Ot>>2],e[8+Ot>>2]=Te,(pe=pe+4|0)>>>0<ke>>>0;);for(je(pe,8+Ot|0,tr,0,16+Ot|0);;){i:{s:{o:{if(!((0|tr)!=1|(0|Te)!=1)){if(e[12+Ot>>2])break o;break e}if(1<(0|tr))break s}Le(8+Ot|0,ke=Co(8+Ot|0)),Te=e[8+Ot>>2],tr=tr+ke|0;break i}lr(8+Ot|0,2),e[8+Ot>>2]=7^e[8+Ot>>2],Le(8+Ot|0,1),je((Ne=pe+-4|0)-e[(16+Ot|0)+((ke=tr+-2|0)<<2)>>2]|0,8+Ot|0,tr+-1|0,1,16+Ot|0),lr(8+Ot|0,1),Te=1|e[8+Ot>>2],e[8+Ot>>2]=Te,je(Ne,8+Ot|0,ke,1,16+Ot|0),tr=ke}pe=pe+-4|0}}K=208+Ot|0}(b,E),e[B+e[g+640>>2]>>2]=E,!((0|(y=y+1|0))<e[e[S+704>>2]+20>>2]))break}if(!(H[c+4|0]<5|H[e[g>>2]+4|0]<4)){if(E=e[c+704>>2],u=e[E+128>>2],1<=(0|(e[g+596>>2]=u)))for(R=e[c+1112>>2],y=e[c+1116>>2],B=e[c+1108>>2],F=e[g+592>>2],V=e[g+600>>2];S=V+j(u=u+-1|0,12)|0,e[S>>2]=e[(b=u<<2)+B>>2],e[S+4>>2]=e[y+b>>2],e[S+8>>2]=F+j(e[b+R>>2],48),0<(0|u););if(u=e[E+132>>2],1<=(0|(e[g+612>>2]=u)))for(R=e[c+1136>>2],y=e[c+1140>>2],B=e[c+1132>>2],F=e[g+592>>2],V=e[g+616>>2];S=V+j(u=u+-1|0,12)|0,e[S>>2]=e[(b=u<<2)+B>>2],e[S+4>>2]=e[y+b>>2],e[S+8>>2]=F+j(e[b+R>>2],48),0<(0|u););if(u=e[E+136>>2],!((0|(e[g+628>>2]=u))<1))for(S=e[c+1160>>2],b=e[c+1164>>2],R=e[c+1156>>2],y=e[g+592>>2],B=e[g+632>>2];c=B+j(u=u+-1|0,12)|0,e[c>>2]=e[(E=u<<2)+R>>2],e[c+4>>2]=e[E+b>>2],e[c+8>>2]=y+j(e[E+S>>2],48),0<(0|u););}hi(g)}return K=576+d|0,g}(a,p,P))break r;e[36+_>>2]=2209,e[32+_>>2]=2361,Ut(4,1294,32+_|0)}else e[20+_>>2]=1444,e[16+_>>2]=2361,Ut(4,1294,16+_|0);else e[4+_>>2]=2132,e[_>>2]=2361,Ut(4,1294,_);p=0}return K=64+_|0,0|p}function cr(a){var p;return K=p=K-16|0,a=(a|=0)?function(P){var _;return Ce(16+(K=_=K-576|0)|0,0,560),vi(P,16+_|0,12+_|0),K=576+_|0,e[12+_>>2]}(a):(e[4+p>>2]=2132,e[p>>2]=2343,Ut(4,1294,p),0),K=16+p|0,0|a}function Ji(a){var p=H[a+4|0];vt(e[a+704>>2],4,64),Ee(e[a+708>>2],4),Ee(e[a+708>>2]+4|0,4),Ee(e[a+708>>2]+8|0,4),Ee(e[a+708>>2]+12|0,4),Ee(e[a+708>>2]+16|0,4),Ee(e[a+708>>2]+20|0,1),vt(e[a+720>>2],4,e[e[a+704>>2]>>2]),vt(e[a+724>>2],4,e[e[a+704>>2]>>2]),vt(e[a+728>>2],4,e[e[a+704>>2]>>2]),vt(e[a+732>>2],4,e[e[a+704>>2]>>2]),vt(e[a+736>>2],4,e[e[a+704>>2]>>2]),vt(e[a+740>>2],4,e[e[a+704>>2]>>2]),vt(e[a+752>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+756>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+760>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+764>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+768>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+772>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+776>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+780>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+784>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+788>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+796>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+800>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+804>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+812>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+816>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+820>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+828>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+852>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+856>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+860>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+868>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+872>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+876>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+880>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+884>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+888>>2],1,e[e[a+704>>2]+16>>2]),vt(e[a+892>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+896>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+900>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+904>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+908>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+912>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+924>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+928>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+932>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+936>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+940>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+948>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+952>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+976>>2],4,e[e[a+704>>2]+24>>2]),vt(e[a+980>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+984>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+996>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1e3>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1004>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1008>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1012>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1016>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1020>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1032>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1036>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1040>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1052>>2],4,e[e[a+704>>2]+40>>2]),vt(e[a+1064>>2],4,e[e[a+704>>2]+44>>2]),vt(e[a+1068>>2],4,e[e[a+704>>2]+48>>2]),vt(e[a+1072>>2],4,e[e[a+704>>2]+48>>2]),vt(e[a+1056>>2],4,e[e[a+704>>2]+52>>2]),vt(e[a+1060>>2],4,e[e[a+704>>2]+52>>2]),vt(e[a+1192>>2],4,e[e[a+704>>2]+56>>2]),vt(e[a+1196>>2],4,e[e[a+704>>2]+60>>2]),vt(e[a+1200>>2],2,e[e[a+704>>2]+64>>2]),vt(e[a+1204>>2],4,e[e[a+704>>2]+68>>2]),vt(e[a+1208>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1212>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1216>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1220>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1224>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1228>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1232>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1236>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1248>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1252>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1256>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1260>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1264>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1268>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1272>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1276>>2],4,e[e[a+704>>2]+84>>2]),vt(e[a+1280>>2],2,e[e[a+704>>2]+84>>2]),vt(e[a+1284>>2],4,e[e[a+704>>2]+88>>2]),p>>>0<2||(vt(e[a+808>>2],4,e[e[a+704>>2]+8>>2]),p>>>0<4)||(vt(e[a+968>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+972>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+792>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+824>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+864>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+1288>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1292>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1296>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1300>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+1304>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+1308>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+944>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+956>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+960>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+1076>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1080>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1084>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1088>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1092>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1096>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1100>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1104>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1120>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1124>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1128>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1144>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1148>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1152>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1168>>2],4,e[e[a+704>>2]+116>>2]),vt(e[a+1172>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1176>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1180>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1184>>2],4,e[e[a+704>>2]+124>>2]),vt(e[a+1188>>2],4,e[e[a+704>>2]+124>>2]),(0|p)!=4&&(vt(e[a+988>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+992>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+1024>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1028>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1044>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1048>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1108>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1112>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1116>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1132>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1136>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1140>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1156>>2],4,e[e[a+704>>2]+136>>2]),vt(e[a+1160>>2],4,e[e[a+704>>2]+136>>2]),vt(e[a+1164>>2],4,e[e[a+704>>2]+136>>2])))}function ts(a,p){var P=0,_=0,c=0,E=0,u=0,d=0,g=a+p|0;r:{t:if(!(1&(P=e[a+4>>2]))){if(!(3&P))break r;if(p=(P=e[a>>2])+p|0,(0|(a=a-P|0))!=e[2092])if(P>>>0<=255)c=P>>>3,P=e[a+8>>2],(0|(_=e[a+12>>2]))==(0|P)?(d=e[2087]&kr(c),e[2087]=d):(e[P+12>>2]=_,e[_+8>>2]=P);else{if(u=e[a+24>>2],(0|(P=e[a+12>>2]))!=(0|a))_=e[a+8>>2],e[_+12>>2]=P,e[P+8>>2]=_;else if(c=(c=e[(_=a+20|0)>>2])||e[(_=a+16|0)>>2]){for(;E=_,(c=e[(_=(P=c)+20|0)>>2])||(_=P+16|0,c=e[P+16>>2]););e[E>>2]=0}else P=0;if(u){_=e[a+28>>2];e:{if(e[(c=8652+(_<<2)|0)>>2]==(0|a)){if(e[c>>2]=P)break e;d=e[2088]&kr(_),e[2088]=d;break t}if(!(e[u+(e[u+16>>2]==(0|a)?16:20)>>2]=P))break t}e[P+24>>2]=u,(_=e[a+16>>2])&&(e[P+16>>2]=_,e[_+24>>2]=P),(_=e[a+20>>2])&&(e[P+20>>2]=_,e[_+24>>2]=P)}}else if((3&(P=e[4+g>>2]))==3)return e[2089]=p,e[4+g>>2]=-2&P,e[a+4>>2]=1|p,e[g>>2]=p}t:{if(!(2&(P=e[4+g>>2]))){if(e[2093]==(0|g)){if(e[2093]=a,p=e[2090]+p|0,e[2090]=p,e[a+4>>2]=1|p,e[2092]!=(0|a))break r;return e[2089]=0,e[2092]=0}if(e[2092]==(0|g))return e[2092]=a,p=e[2089]+p|0,e[2089]=p,e[a+4>>2]=1|p,e[a+p>>2]=p;p=(-8&P)+p|0;e:if(P>>>0<=255)c=P>>>3,P=e[8+g>>2],(0|(_=e[12+g>>2]))==(0|P)?(d=e[2087]&kr(c),e[2087]=d):(e[P+12>>2]=_,e[_+8>>2]=P);else{if(u=e[24+g>>2],(0|g)!=(0|(P=e[12+g>>2])))_=e[8+g>>2],e[_+12>>2]=P,e[P+8>>2]=_;else if(c=(c=e[(_=20+g|0)>>2])||e[(_=16+g|0)>>2]){for(;E=_,(c=e[(_=(P=c)+20|0)>>2])||(_=P+16|0,c=e[P+16>>2]););e[E>>2]=0}else P=0;if(u){_=e[28+g>>2];i:{if(e[(c=8652+(_<<2)|0)>>2]==(0|g)){if(e[c>>2]=P)break i;d=e[2088]&kr(_),e[2088]=d;break e}if(!(e[u+(e[u+16>>2]==(0|g)?16:20)>>2]=P))break e}e[P+24>>2]=u,(_=e[16+g>>2])&&(e[P+16>>2]=_,e[_+24>>2]=P),(_=e[20+g>>2])&&(e[P+20>>2]=_,e[_+24>>2]=P)}}if(e[a+4>>2]=1|p,e[a+p>>2]=p,e[2092]!=(0|a))break t;return e[2089]=p}e[4+g>>2]=-2&P,e[a+4>>2]=1|p,e[a+p>>2]=p}if(p>>>0<=255)return p=8388+((P=p>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[p+8>>2]:(e[2087]=P|_,p),e[p+8>>2]=a,e[P+12>>2]=a,e[a+12>>2]=p,e[a+8>>2]=P;e[a+16>>2]=0,P=e[a+20>>2]=0,(c=p>>>8)&&(P=31,16777215<p>>>0||(P=28+((P=((g=(c<<=E=c+1048320>>>16&8)<<(P=c+520192>>>16&4))<<(c=245760+g>>>16&2)>>>15)-(c|P|E)|0)<<1|p>>>P+21&1)|0)),c=8652+((e[(_=a)+28>>2]=P)<<2)|0;t:{if((_=e[2088])&(E=1<<P)){for(_=p<<((0|P)==31?0:25-(P>>>1)|0),P=e[c>>2];;){if((-8&e[(c=P)+4>>2])==(0|p))break t;if(P=_>>>29,_<<=1,!(P=e[16+(E=c+(4&P)|0)>>2]))break}e[E+16>>2]=a}else e[2088]=_|E,e[c>>2]=a;return e[a+24>>2]=c,e[a+12>>2]=a,e[a+8>>2]=a}p=e[c+8>>2],e[p+12>>2]=a,e[c+8>>2]=a,e[a+24>>2]=0,e[a+12>>2]=c,e[a+8>>2]=p}}function Kr(a){var p,P,_,c,E,u,d,g,y=v(0),b=(v(0),0),S=0,R=(v(0),v(0),v(0),v(0),0);v(0),v(0);r:{t:{if(Qt(a),S=2147483647&(b=Wt[0])){if(!(S>>>0<2139095041))return v(v(.10000000149011612)+a);if((0|S)==1065353216)return v(-1<(0|b)?.10000000149011612:10);if((0|S)==2139095040)return v(-1<(0|b)?0:-a);if((0|b)==1073741824)return v(.010000000707805157);if((0|b)==1056964608)return v(.3162277638912201);if(1291845633<=S>>>0)return v((0|b)<0?Nt:0);if(p=I[1701],g=v(v(1.600000023841858)-p),P=v(v(1)/v(p+v(1.600000023841858))),Yt(0,-4096&(Qt(d=v(g*P)),Wt[0])),y=zt(),_=v(y*y),E=I[1705],p=v(P*v(v(g-v((c=y)*v(3.099609375)))-v(y*v(v(1.600000023841858)-v(v(3.099609375)-p))))),P=v(v(d+y)*p),y=v(d*d),g=v(P+v(v(y*y)*v(v(y*v(v(y*v(v(y*v(v(y*v(v(y*v(.20697501301765442))+v(.23066075146198273)))+v(.2727281153202057)))+v(.3333333432674408)))+v(.4285714328289032)))+v(.6000000238418579)))),Yt(0,-4096&(Qt(v(v(_+v(3))+g)),Wt[0])),y=zt(),P=v(c*y),d=v(v(p*y)+v(d*v(g-v(v(y+v(-3))-_)))),Yt(0,-4096&(Qt(v(P+d)),Wt[0])),y=zt(),p=v(y*v(.9619140625)),_=v(I[1703]+v(v(v(d-v(y-P))*v(.9617967009544373))+v(y*v(-.00011736857413779944)))),Yt(0,-4096&(Qt(v(v(E+v(p+_))+v(-4))),Wt[0])),d=zt(),Yt(0,-4096&b),g=zt(),y=v(d*g),a=v(v(v(_-v(v(v(d-v(-4))-E)-p))*a)+v(v(a-g)*d)),Qt(d=v(y+a)),1124073473<=(0|(b=Wt[0])))break t;e:{if((S=1124073472)==(0|b)){if(v(a+v(4299566569443414e-23))>v(d-y))break t}else{if(S=2147483647&b,!(a<=v(d-y)^1|(0|b)!=-1021968384)|1125515265<=S>>>0)break r;if(S>>>0<1056964609)break e}R=(8388607&(S=(8388608>>>(S>>>23)-126)+b|0)|8388608)>>>150-(u=S>>>23&255),R=(0|b)<0?0-R|0:R,y=v(y-(Yt(0,S&-8388608>>u-127),zt())),Qt(v(a+y)),b=Wt[0]}Yt(0,-32768&b),d=zt(),p=v(d*v(.693145751953125)),d=v(v(d*v(14286065379565116e-22))+v(v(a-v(d-y))*v(.6931471824645996))),a=v(p+d),y=v(a*a),y=v(a-v(y*v(v(y*v(v(y*v(v(y*v(v(y*v(4138136944220605e-23))+v(-16533901998627698e-22)))+v(661375597701408e-19)))+v(-.0027777778450399637)))+v(.1666666716337204)))),c=v(v(a*y)/v(y+v(-2))),y=v(d-v(a-p)),a=(0|(b=0|(Qt(a=v(v(a-v(c-v(y+v(a*y))))+v(1))),Wt[0]+(R<<23))))<=8388607?function(F,B){var V=0;return 128<=(0|B)?(F=v(F*v(17014118346046923e22)),B=(0|(V=B+-127|0))<128?V:(F=v(F*v(17014118346046923e22)),((0|B)<381?B:381)+-254|0)):-127<(0|B)||(F=v(F*v(11754943508222875e-54)),B=-127<(0|(V=B+126|0))?V:(F=v(F*v(11754943508222875e-54)),(-378<(0|B)?B:-378)+252|0)),v(F*(Yt(0,1065353216+(B<<23)|0),zt()))}(a,R):(Yt(0,b),zt()),a=v(v(1)*a)}else a=v(1);return a}return v(Nt)}return v(0)}function Bi(a,p){var P,_,c,E=0,u=0,d=v(0);if(Qt(p),!((c=2147483647&(_=Wt[0]))>>>0<=2139095040&&(Qt(a),(E=2147483647&(u=Wt[0]))>>>0<2139095041)))return v(a+p);if((0|_)==1065353216)return li(a);_=(P=_>>>30&2)|u>>>31;r:{t:{e:{i:{if(!E){switch(_-2|0){case 0:break i;case 1:break;default:break e}return v(-3.1415927410125732)}if((0|c)!=2139095040){if(!c|!(E>>>0<=218103808+c>>>0&&(0|E)!=2139095040))break r;if(a=d=E+218103808>>>0<c>>>0&&(d=v(0),P)?d:li(v(St(v(a/p)))),_>>>0<=2){switch(_-1|0){case 0:return v(-a);case 1:break;default:break e}return v(v(3.1415927410125732)-v(a+v(8742277657347586e-23)))}return v(v(a+v(8742277657347586e-23))+v(-3.1415927410125732))}if((0|E)==2139095040)break t;return I[6784+(_<<2)>>2]}a=v(3.1415927410125732)}return a}return I[6768+(_<<2)>>2]}return v((0|u)<0?-1.5707963705062866:1.5707963705062866)}function li(a){v(0);var p,P,_,c,E,u=0;v(0),v(0),Qt(a);r:{if(1283457024<=(c=2147483647&(E=Wt[0]))>>>0){if(2139095040<c>>>0)break r;return v((0|E)<0?-1.570796251296997:1.570796251296997)}t:{if(c>>>0<=1054867455){if(u=-1,964689920<=c>>>0)break t;break r}a=v(St(a)),u=c>>>0<=1066926079?c>>>0<=1060110335?(a=v(v(v(a+a)+v(-1))/v(a+v(2))),0):(a=v(v(a+v(-1))/v(a+v(1))),1):c>>>0<=1075576831?(a=v(v(a+v(-1.5))/v(v(a*v(1.5))+v(1))),2):(a=v(v(-1)/a),3)}if(c=u,P=v(a*a),p=v(P*P),_=v(p*v(v(p*v(-.106480173766613))+v(-.19999158382415771))),p=v(P*v(v(p*v(v(p*v(.06168760731816292))+v(.14253635704517365)))+v(.333333283662796))),(0|c)<=-1)return v(a-v(a*v(_+p)));a=v(I[6736+(c<<=2)>>2]-v(v(v(a*v(_+p))-I[6752+c>>2])-a)),a=(0|E)<0?v(-a):a}return a}function Qe(a,p){var P,_,c,E=0,u=0;return K=_=K-16|0,Qt(a),(E=2147483647&(c=Wt[0]))>>>0<=1305022426?(ct[p>>3]=(P=+a)+-1.5707963109016418*(u=.6366197723675814*P+6755399441055744-6755399441055744)+-15893254773528196e-24*u,E=St(u)<2147483648?~~u:-2147483648):2139095040<=E>>>0?(ct[p>>3]=v(a-a),E=0):(P=E,ct[8+_>>3]=(Yt(0,P-((E=(E>>>23)-150|0)<<23)|0),zt()),E=function(d,g,y){var b,S,R,F,B,V,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,we=0,Ue=0,He=0;if(K=b=K-560|0,Ht=(q=y)+j(R=0<(0|(y=(y+-3|0)/24|0))?y:0,-24)|0,0<=(0|(S=e[972])))for(q=S+1|0,y=R;ct[(320+b|0)+(tt<<3)>>3]=(0|y)<0?0:+e[3904+(y<<2)>>2],y=y+1|0,(0|q)!=(0|(tt=tt+1|0)););for(mt=Ht+-24|0,q=0;;){for(z=y=0;z+=ct[(y<<3)+d>>3]*ct[(320+b|0)+(q-y<<3)>>3],(0|(y=y+1|0))!=1;);if(ct[(q<<3)+b>>3]=z,y=(0|q)<(0|S),q=q+1|0,!y)break}V=23-mt|0,F=24-mt|0,q=S;r:{for(;;){if(z=ct[(q<<3)+b>>3],!(we=((y=0)|(tt=q))<1))for(;Bt=(480+b|0)+(y<<2)|0,ce=z,ut=St(z*=5960464477539063e-23)<2147483648?~~z:-2147483648,ut=St(ce+=-16777216*(z=0|ut))<2147483648?~~ce:-2147483648,e[Bt>>2]=ut,z=ct[((tt=tt+-1|0)<<3)+b>>3]+z,(0|q)!=(0|(y=y+1|0)););z=Be(z,mt),z=(z+=-8*Ft(.125*z))-(0|(Bt=St(z)<2147483648?~~z:-2147483648));t:{e:{i:{if(He=(0|mt)<1){if(mt)break i;ut=e[476+((q<<2)+b|0)>>2]>>23}else ut=e[476+(tt=(q<<2)+b|0)>>2],Ue=tt,tt=ut-((y=ut>>F)<<F)|0,Bt=y+Bt|0,ut=(e[Ue+476>>2]=tt)>>V;if((0|ut)<1)break t;break e}if(ut=2,!(.5<=z)){ut=0;break t}}if(tt=y=0,!we)for(;;){we=e[(B=(480+b|0)+(y<<2)|0)>>2],Ue=16777215;e:{i:{if(!tt){if(!we)break i;Ue=16777216,tt=1}e[B>>2]=Ue-we;break e}tt=0}if((0|q)==(0|(y=y+1|0)))break}He||1<(y=mt+-1|0)>>>0||(e[476+(y=(q<<2)+b|0)>>2]=y-1?8388607&e[y+476>>2]:4194303&e[y+476>>2]),Bt=Bt+1|0,(0|ut)==2&&(z=1-z,ut=2,tt)&&(z-=Be(1,mt))}if(z!=0)break;if(!(((tt=0)|(y=q))<=(0|S))){for(;tt=e[(480+b|0)+((y=y+-1|0)<<2)>>2]|tt,(0|S)<(0|y););if(tt){for(Ht=mt;Ht=Ht+-24|0,!e[(480+b|0)+((q=q+-1|0)<<2)>>2];);break r}}for(y=1;y=(tt=y)+1|0,!e[(480+b|0)+(S-tt<<2)>>2];);for(tt=q+tt|0;;){for(q=Bt=q+1|0,ct[(320+b|0)+(Bt<<3)>>3]=e[3904+(R+q<<2)>>2],z=y=0;z+=ct[(y<<3)+d>>3]*ct[(320+b|0)+(Bt-y<<3)>>3],(0|(y=y+1|0))!=1;);if(ct[(q<<3)+b>>3]=z,!((0|q)<(0|tt)))break}q=tt}16777216<=(z=Be(z,0-mt|0))?(d=(480+b|0)+(q<<2)|0,ce=z,y=St(z*=5960464477539063e-23)<2147483648?~~z:-2147483648,tt=St(z=ce+-16777216*(0|y))<2147483648?~~z:-2147483648,e[d>>2]=tt,q=q+1|0):(y=St(z)<2147483648?~~z:-2147483648,Ht=mt),e[(480+b|0)+(q<<2)>>2]=y}if(z=Be(1,Ht),!((0|q)<=-1)){for(y=q;ct[(y<<3)+b>>3]=z*+e[(480+b|0)+(y<<2)>>2],z*=5960464477539063e-23,d=0<(0|y),y=y+-1|0,d;);if(!((0|q)<=-1))for(y=q;;){for(mt=q-(d=y)|0,y=z=0;z+=ct[6672+(y<<3)>>3]*ct[(d+y<<3)+b>>3],!((0|S)<=(0|y))&&(Ht=y>>>0<mt>>>0,y=y+1|0,Ht););if(ct[(160+b|0)+(mt<<3)>>3]=z,y=d+-1|0,!(0<(0|d)))break}}if(0<=(q|(z=0)))for(;z+=ct[(160+b|0)+(q<<3)>>3],d=0<(0|q),q=q+-1|0,d;);return ct[g>>3]=ut?-z:z,K=560+b|0,7&Bt}(8+_|0,_,E),u=ct[_>>3],(0|c)<=-1?(ct[p>>3]=-u,E=0-E|0):ct[p>>3]=u),K=16+_|0,E}function vo(a,p){return a?function(P,_){r:{if(P){if(_>>>0<=127)break r;if(e[e[1789]>>2]){if(_>>>0<=2047)return O[P+1|0]=63&_|128,O[0|P]=_>>>6|192,2;if(!((-8192&_)!=57344&&55296<=_>>>0))return O[P+2|0]=63&_|128,O[0|P]=_>>>12|224,O[P+1|0]=_>>>6&63|128,3;if(_+-65536>>>0<=1048575)return O[P+3|0]=63&_|128,O[0|P]=_>>>18|240,O[P+2|0]=_>>>6&63|128,O[P+1|0]=_>>>12&63|128,4}else if((-128&_)==57216)break r;e[2086]=25,P=-1}else P=1;return P}return O[0|P]=_,1}(a,p):0}function vi(a,p,P){var _,c,E=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=0,B=H[a+4|0];if(e[p>>2]=652,u=e[a+704>>2],1<=(0|(g=e[u>>2]))){for(y=e[a+720>>2],S=e[a+1072>>2];d=(1<<e[S+(e[y+(E<<2)>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+4>>2]=j(g,12),e[p+8>>2]=e[u>>2]<<2,e[p+12>>2]=e[u>>2]<<2,e[p+16>>2]=e[u>>2]<<2,e[p+20>>2]=e[u>>2]<<2,d=e[u>>2],e[p+28>>2]=E,e[p+24>>2]=d<<2,d=e[u>>2],e[p+40>>2]=E,e[p+36>>2]=E,e[p+32>>2]=d<<2,e[p+44>>2]=e[u+4>>2]<<5,e[p+48>>2]=e[u+4>>2]<<2,e[p+52>>2]=e[u+4>>2]<<2,e[p+56>>2]=e[u+4>>2]<<2,e[p+60>>2]=e[u+4>>2]<<4,e[p+64>>2]=e[u+4>>2]<<4,1<=((E=0)|(g=e[u+8>>2]))){for(y=e[a+780>>2],S=e[a+1072>>2],F=e[a+796>>2],d=0;b=(15+(e[(R=E<<2)+F>>2]<<3)&-16)+b|0,d=(1<<e[S+(e[y+R>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+68>>2]=j(g,24),e[p+72>>2]=e[u+8>>2]<<2,e[p+76>>2]=e[u+8>>2]<<2,d=e[u+8>>2],e[p+84>>2]=b,e[p+80>>2]=d<<2,e[p+88>>2]=e[u+8>>2]<<4,e[p+92>>2]=e[u+8>>2]<<4,d=e[u+8>>2],e[p+100>>2]=E,e[p+96>>2]=d<<2,d=e[u+8>>2],e[p+140>>2]=E,e[p+136>>2]=E,e[p+132>>2]=E,e[p+128>>2]=E,e[p+124>>2]=E,e[p+120>>2]=E,e[p+116>>2]=E,e[p+112>>2]=E,e[p+108>>2]=E,e[p+104>>2]=d<<2,e[p+144>>2]=e[u+8>>2]<<2,e[p+148>>2]=e[u+8>>2]<<2,e[p+152>>2]=e[u+8>>2]<<2,e[p+156>>2]=e[u+8>>2]<<2,e[p+160>>2]=e[u+8>>2]<<2,e[p+164>>2]=e[u+8>>2]<<2,1<=((E=b=0)|(g=e[u+12>>2]))){for(y=e[a+812>>2],S=e[a+1072>>2],d=0;d=(1<<e[S+(e[y+(E<<2)>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+168>>2]=j(g,12),e[p+172>>2]=e[u+12>>2]<<2,e[p+176>>2]=e[u+12>>2]<<2,e[p+180>>2]=e[u+12>>2]<<2,e[p+184>>2]=e[u+12>>2]<<2,e[p+188>>2]=e[u+12>>2]<<2,e[p+192>>2]=e[u+12>>2]<<2,e[p+196>>2]=e[u+12>>2]<<2,e[p+200>>2]=e[u+12>>2]<<2,e[p+204>>2]=e[u+12>>2]<<4,e[p+208>>2]=e[u+12>>2]<<4,d=e[u+12>>2],e[p+216>>2]=E,e[p+212>>2]=d<<2,d=e[u+12>>2],e[p+268>>2]=E,e[p+264>>2]=E,e[p+260>>2]=E,e[p+256>>2]=E,e[p+252>>2]=E,e[p+248>>2]=E,e[p+244>>2]=E,e[p+240>>2]=E,e[p+236>>2]=E,e[p+232>>2]=E,e[p+228>>2]=E,e[p+224>>2]=E,e[p+220>>2]=d<<2,e[p+272>>2]=e[u+12>>2]<<2,e[p+276>>2]=e[u+12>>2]<<2,e[p+280>>2]=e[u+12>>2]<<2,e[p+284>>2]=e[u+12>>2]<<2,e[p+288>>2]=e[u+12>>2]<<2,e[p+292>>2]=e[u+12>>2]<<2,1<=((E=0)|(d=e[u+16>>2]))){for(y=e[a+852>>2],S=e[a+1072>>2],F=e[a+892>>2],g=0;b=(15+(e[(R=E<<2)+F>>2]<<3)&-16)+b|0,g=(1<<e[S+(e[y+R>>2]<<2)>>2])+g|0,(0|d)!=(0|(E=E+1|0)););E=g<<2}if(e[p+296>>2]=j(d,20),e[p+300>>2]=e[u+16>>2]<<2,e[p+304>>2]=e[u+16>>2],e[p+308>>2]=e[u+16>>2]<<2,e[p+312>>2]=e[u+16>>2]<<2,d=e[u+16>>2],e[p+320>>2]=b,e[p+316>>2]=d<<2,e[p+324>>2]=e[u+16>>2]<<2,e[p+328>>2]=e[u+16>>2]<<4,e[p+332>>2]=e[u+16>>2]<<4,e[p+336>>2]=e[u+16>>2]<<2,e[p+340>>2]=e[u+16>>2]<<2,e[p+344>>2]=e[u+16>>2]<<2,e[p+348>>2]=e[u+16>>2]<<4,e[p+352>>2]=e[u+16>>2]<<4,d=e[u+16>>2],e[p+360>>2]=E,e[p+356>>2]=d<<2,d=e[u+16>>2],e[p+404>>2]=E,e[p+400>>2]=E,e[p+396>>2]=E,e[p+392>>2]=E,e[p+388>>2]=E,e[p+384>>2]=E,e[p+380>>2]=E,e[p+376>>2]=E,e[p+372>>2]=E,e[p+368>>2]=E,e[p+364>>2]=d<<2,e[p+408>>2]=e[u+16>>2]<<2,e[p+412>>2]=e[u+16>>2]<<2,e[p+416>>2]=e[u+16>>2]<<2,e[p+420>>2]=e[u+16>>2]<<2,e[p+424>>2]=e[u+16>>2]<<2,e[p+428>>2]=e[u+16>>2]<<2,y=e[a+704>>2],e[p+432>>2]=j(e[y+20>>2],52),e[p+436>>2]=B>>>(E=g=0)<=3?e[y+20>>2]<<2:0,e[p+440>>2]=e[y+20>>2]<<2,e[p+444>>2]=j(e[y+52>>2],28),1<=(0|(u=e[y+48>>2]))){for(d=e[a+1072>>2],b=0;b=(S=e[d+(E<<2)>>2])+b|0,g=(1<<S)+g|0,(0|u)!=(0|(E=E+1|0)););E=g<<2,g=b<<2}if(e[p+460>>2]=E,e[p+456>>2]=E,e[p+452>>2]=g,e[p+448>>2]=j(u,36),e[p+500>>2]=j(e[y+72>>2],28),1<=((b=E=d=0)|(S=e[y+72>>2]))){for(F=e[a+1224>>2],R=e[a+1220>>2],c=e[a+1212>>2],g=0;g=(0|(_=e[(u=b<<2)+R>>2]-e[u+F>>2]|0))<(0|g)?g:1+_|0,E=(0|E)<(0|(u=e[u+c>>2]))?u:E,(0|S)!=(0|(b=b+1|0)););b=E<<2,E=g<<2}if(u=e[y+76>>2],e[p+516>>2]=E,e[p+512>>2]=b,e[p+508>>2]=E,e[p+504>>2]=u<<4,1<=(0|(u=e[y+80>>2]))){for(d=e[a+1248>>2],b=e[a+1072>>2],g=E=0;g=(1<<e[b+(e[d+(E<<2)>>2]<<2)>>2])+g|0,(0|u)!=(0|(E=E+1|0)););d=g<<2}if(e[p+520>>2]=j(u,24),e[p+524>>2]=e[y+80>>2]<<2,u=e[y+80>>2],e[p+532>>2]=d,e[p+528>>2]=u<<2,u=e[y+80>>2],e[p+544>>2]=d,e[p+540>>2]=d,e[p+536>>2]=u<<2,u=p,4<=B>>>0){if(e[p+464>>2]=j(e[y+120>>2],20),e[p+468>>2]=j(e[y+100>>2],28),d=p,1<=((E=b=0)|(S=e[y+104>>2]))){for(a=e[a+1104>>2],g=0;g=e[a+(E<<2)>>2]+g|0,(0|S)!=(0|(E=E+1|0)););a=g<<2}else a=0;e[d+476>>2]=a,e[p+472>>2]=j(S,48),e[p+484>>2]=j(e[y+108>>2],12),a=e[y+112>>2],e[p+552>>2]=0,e[p+492>>2]=j(a,12),a=0}else{if((0|(b=e[y+20>>2]))<1)g=0;else for(S=e[a+1060>>2],F=e[a+952>>2],a=e[a+948>>2],d=g=0;;){if(1<=(0|(R=e[(E=d<<2)+F>>2])))for(R=(E=S+(e[a+E>>2]<<2)|0)+(R<<2)|0;g=e[E>>2]+g|0,(E=E+4|0)>>>0<R>>>0;);if((0|b)==(0|(d=d+1|0)))break}e[p+552>>2]=b<<2,b=e[y+20>>2]<<2,a=g<<2}for(e[u+556>>2]=a,e[p+548>>2]=b,4<B>>>0&&(e[p+480>>2]=j(e[y+128>>2],12),e[p+488>>2]=j(e[y+132>>2],12),e[p+496>>2]=j(e[y+136>>2],12)),E=g=0;E=((u=e[(a=(g<<2)+p|0)>>2])+15&-16)+(e[a>>2]=E)|0,(0|(g=g+1|0))!=140;);e[P>>2]=E}function ki(a,p,P,_){r:{if(!(20<p>>>0||9<(p=p+-9|0)>>>0)){switch(p-1|0){default:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=e[p>>2];case 0:return p=e[P>>2],e[P>>2]=p+4,p=e[p>>2],e[a>>2]=p,e[a+4>>2]=p>>31;case 1:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=e[p>>2],e[a+4>>2]=0;case 3:return p=e[P>>2],e[P>>2]=p+4,p=N[p>>1],e[a>>2]=p,e[a+4>>2]=p>>31;case 4:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=W[p>>1],e[a+4>>2]=0;case 5:return p=e[P>>2],e[P>>2]=p+4,p=O[0|p],e[a>>2]=p,e[a+4>>2]=p>>31;case 6:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=H[0|p],e[a+4>>2]=0;case 2:case 7:break r;case 8:}L[_](a,P)}return}p=e[P>>2]+7&-8,e[P>>2]=p+8,P=e[p+4>>2],e[a>>2]=e[p>>2],e[a+4>>2]=P}function xo(a){var p,P,_=0;if(ie(O[e[a>>2]]))for(;p=e[a>>2],P=O[0|p],e[a>>2]=p+1,_=(j(_,10)+P|0)-48|0,ie(O[p+1|0]););return _}function bo(a,p,P,_,c){var E,u;e[204+(K=u=K-208|0)>>2]=P,Ce(160+u|(P=0),0,40),e[200+u>>2]=e[204+u>>2],(0|mr(0,p,200+u|0,80+u|0,160+u|0,_,c))<0||(P=0<=e[a+76>>2]?1:P,P=e[a>>2],O[a+74|0]<=0&&(e[a>>2]=-33&P),E=32&P,e[a+48>>2]?mr(a,p,200+u|0,80+u|0,160+u|0,_,c):(e[a+48>>2]=80,e[a+16>>2]=80+u,e[a+28>>2]=u,e[a+20>>2]=u,P=e[a+44>>2],mr(a,p,200+(e[a+44>>2]=u)|0,80+u|0,160+u|0,_,c),P&&(L[e[a+36>>2]](a,0,0),e[a+48>>2]=0,e[a+44>>2]=P,e[a+28>>2]=0,e[a+16>>2]=0,e[a+20>>2]=0)),e[a>>2]=e[a>>2]|E),K=208+u|0}function Ao(a,p,P){var _,c;ge(8+(K=c=K-160|0)|0,3192,144),e[52+c>>2]=a,e[28+c>>2]=a,e[56+c>>2]=_=(_=-2-a|0)>>>0<256?_:256,e[36+c>>2]=a=a+_|0,e[24+c>>2]=a,bo(8+c|0,p,P,11,12),_&&(a=e[28+c>>2],O[a-((0|a)==e[24+c>>2])|0]=0),K=160+c|0}function wo(a,p){var P,_,c=0,c=(0|p)!=0;r:{t:{e:{i:if(!(!p|!(3&a)))for(;;){if(!H[0|a])break e;if(a=a+1|0,c=(0|(p=p+-1|0))!=0,!p)break i;if(!(3&a))break}if(!c)break t}if(!H[0|a])break r;e:{if(4<=p>>>0){for(c=(c=p+-4|0)-(P=-4&c)|0,P=4+(a+P|0)|0;;){if((-1^(_=e[a>>2]))&_+-16843009&-2139062144)break e;if(a=a+4|0,!(3<(p=p+-4|0)>>>0))break}p=c,a=P}if(!p)break t}for(;;){if(!H[0|a])break r;if(a=a+1|0,!(p=p+-1|0))break}}return 0}return a}function To(a){var p,P=0;if(!a)return 32;if(!(1&a))for(;P=P+1|0,p=2&a,a>>>=1,!p;);return P}function Eo(a,p){var P,_,c,E,u=0,d=0,d=4;K=E=K-256|0;r:if(!((0|p)<2))for(u=e[(c=(p<<2)+a|0)>>2]=E;;){for(ge(u,e[a>>2],P=d>>>0<256?d:256),u=0;ge(e[(_=(u<<2)+a|0)>>2],e[((u=u+1|0)<<2)+a>>2],P),e[_>>2]=e[_>>2]+P,(0|p)!=(0|u););if(!(d=d-P|0))break r;u=e[c>>2]}K=256+E|0}function Co(a){return To(e[a>>2]+-1|0)||((a=To(e[a+4>>2]))?a+32|0:0)}function Is(a,p){p|=0,Wt[0]=a|=0,Wt[1]=p}function So(a,p,P){return function(_,c,E){var u,d,g,y,b=j(d=E>>>16,g=_>>>16);return _=(65535&(g=((u=j(y=65535&E,_&=65535))>>>16)+j(g,y)|0))+j(_,d)|0,Vt=((b+j(c,E)|0)+(g>>>16)|0)+(_>>>16)|0,65535&u|_<<16}(a,p,P)}function Po(a,p,P){return function(_,c,E){var u,d,g=0,y=0,b=0,S=0,R=0,F=0,B=0;r:{t:{e:{i:{s:{if(!(y=c))return Is((c=_)-j(_=(_>>>0)/(E>>>0)|0,E)|0,0),Vt=0,_;if(g=E){if(!((S=g+-1|0)&g))break s;R=0-(S=(yt(g)+33|0)-yt(y)|0)|0;break e}if(!_)return Is(0,y-j(_=(y>>>0)/0|0,0)|0),Vt=0,_;if((g=32-yt(y)|0)>>>0<31)break i;break t}if(Is(_&S,0),(0|g)==1)break r;return E=31&(g=g?31-yt(g+-1^g)|0:32),_=32<=(63&g)>>>0?(y=0,c>>>E):(y=c>>>E,((1<<E)-1&c)<<32-E|_>>>E),Vt=y,_}S=g+1|0,R=63-g|0}if(g=c,b=31&(y=63&S),b=32<=y>>>0?(y=0,g>>>b):(y=g>>>b,((1<<b)-1&g)<<32-b|_>>>b),g=31&(R&=63),32<=R>>>0?(c=_<<g,_=0):(c=(1<<g)-1&_>>>32-g|c<<g,_<<=g),S)for((R=E+(g=-1)|0)>>>0<4294967295&&(g=0);b=(d=F=b<<1|c>>>31)-(u=E&(F=g-((y=y<<1|b>>>31)+(R>>>0<F>>>0)|0)>>31))|0,y=y-(d>>>0<u>>>0)|0,c=c<<1|_>>>31,_=B|_<<1,B=F&=1,S=S+-1|0;);return Is(b,y),Vt=c<<1|_>>>31,F|_<<1}Is(_,c),c=_=0}return Vt=c,_}(a,p,P)}function kr(a){var p;return(-1>>>(p=31&a)&-2)<<p|(-1<<(a=0-a&31)&-2)>>>a}function $o(){return w.byteLength/65536|0}}(Pt,It,pt)}}D=null,x.wasmBinary&&(Rt=x.wasmBinary);var wt={},Rt=[];typeof wt!="object"&&et("no native wasm support detected");var It,pt=new function(Tt){var $t=Array(16);return $t.grow=function(){17<=$t.length&&Jt("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."),$t.push(null)},$t.set=function(at,lt){$t[at]=lt},$t.get=function(at){return $t[at]},$t},xt=!1;function Ct(Tt,$t){Tt||Jt("Assertion failed: "+$t)}var Gt,st,nt,Y,gt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ot(Tt,$t,at){var lt=$t+at;for(at=$t;Tt[at]&&!(lt<=at);)++at;if(16<at-$t&&Tt.subarray&&gt)return gt.decode(Tt.subarray($t,at));for(lt="";$t<at;){var Wt,Ae,de=Tt[$t++];128&de?(Wt=63&Tt[$t++],(224&de)==192?lt+=String.fromCharCode((31&de)<<6|Wt):(Ae=63&Tt[$t++],(de=(240&de)==224?(15&de)<<12|Wt<<6|Ae:(7&de)<<18|Wt<<12|Ae<<6|63&Tt[$t++])<65536?lt+=String.fromCharCode(de):(de-=65536,lt+=String.fromCharCode(55296|de>>10,56320|1023&de)))):lt+=String.fromCharCode(de)}return lt}function ht(Tt,$t){return Tt?ot(nt,Tt,$t):""}function dt(Tt){return 0<Tt%65536&&(Tt+=65536-Tt%65536),Tt}function At(Tt){Gt=Tt,x.HEAP8=st=new Int8Array(Tt),x.HEAP16=new Int16Array(Tt),x.HEAP32=Y=new Int32Array(Tt),x.HEAPU8=nt=new Uint8Array(Tt),x.HEAPU16=new Uint16Array(Tt),x.HEAPU32=new Uint32Array(Tt),x.HEAPF32=new Float32Array(Tt),x.HEAPF64=new Float64Array(Tt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");var Et=x.TOTAL_MEMORY||16777216;function Dt(Tt){for(;0<Tt.length;){var $t,at=Tt.shift();typeof at=="function"?at():typeof($t=at.ea)=="number"?at.da===void 0?x.dynCall_v($t):x.dynCall_vi($t,at.da):$t(at.da===void 0?null:at.da)}}(It=x.wasmMemory||new function(){return{buffer:new ArrayBuffer(Et/65536*65536),grow:function(Tt){return hr(Tt)}}})&&(Gt=It.buffer),Gt.byteLength,At(Gt),Y[2216]=5251936;var oe,kt=[],se=[],Kt=[],Xt=[],_e=(Math.imul&&Math.imul(4294967295,5)===-5||(Math.imul=function(Tt,$t){var at=65535&Tt,lt=65535&$t;return at*lt+((Tt>>>16)*lt+at*($t>>>16)<<16)|0}),Math.fround||(oe=new Float32Array(1),Math.fround=function(Tt){return oe[0]=Tt,oe[0]}),Math.clz32||(Math.clz32=function(Tt){var $t=32,at=Tt>>16;return at&&($t-=16,Tt=at),(at=Tt>>8)&&($t-=8,Tt=at),(at=Tt>>4)&&($t-=4,Tt=at),(at=Tt>>2)&&($t-=2,Tt=at),Tt>>1?$t-2:$t-Tt}),Math.trunc||(Math.trunc=function(Tt){return Tt<0?Math.ceil(Tt):Math.floor(Tt)}),0),$e=null;function Jt(Tt){throw x.onAbort&&x.onAbort(Tt),_t(Tt),et(Tt),xt=!0,"abort("+Tt+"). Build with -s ASSERTIONS=1 for more info."}x.preloadedImages={},x.preloadedAudios={};var De="data:application/octet-stream;base64,";function xe(Tt){return String.prototype.startsWith?Tt.startsWith(De):Tt.indexOf(De)===0}var ae="_em_module.wasm";function Lr(){try{if(Rt)return new Uint8Array(Rt);var Tt=Wr(ae);if(Tt)return Tt;if(X)return X(ae);throw"both async and sync fetching of the wasm failed"}catch($t){Jt($t)}}xe(ae)||(Q=ae,ae=x.locateFile?x.locateFile(Q,Ar):Ar+Q),se.push({ea:function(){Hr()}});var vr=[null,[],[]];function Fi(Tt){for(var $t=[],at=0;at<Tt.length;at++){var lt=Tt[at];255<lt&&(lt&=255),$t.push(String.fromCharCode(lt))}return $t.join("")}var sr=typeof atob=="function"?atob:function(Tt){var $t="",at=0;Tt=Tt.replace(/[^A-Za-z0-9\+\/=]/g,"");do var Ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),Ae=Ae<<2|de>>4,de=(15&de)<<4|lt>>2,Yt=(3&lt)<<6|Wt;while($t+=String.fromCharCode(Ae),lt!==64&&($t+=String.fromCharCode(de)),Wt!==64&&($t+=String.fromCharCode(Yt)),at<Tt.length);return $t};function Wr(Tt){if(xe(Tt)){if(Tt=Tt.slice(De.length),typeof it=="boolean"&&it){try{var $t=Buffer.from(Tt,"base64")}catch{$t=new Buffer(Tt,"base64")}var at=new Uint8Array($t.buffer,$t.byteOffset,$t.byteLength)}else try{for(var lt=sr(Tt),Wt=new Uint8Array(lt.length),$t=0;$t<lt.length;++$t)Wt[$t]=lt.charCodeAt($t);at=Wt}catch{throw Error("Converting base64 string to bytes failed.")}return at}}var fr,Pt={a:function(Tt,$t,at){nt.set(nt.subarray($t,$t+at),Tt)},b:function(Tt){if(2147418112<Tt)return!1;for(var $t=Math.max(st.length,16777216);$t<Tt;)$t=$t<=536870912?dt(2*$t):Math.min(dt((3*$t+2147483648)/4),2147418112);r:{try{It.grow($t-Gt.byteLength+65535>>16),At(It.buffer);var at=1;break r}catch{}at=void 0}return!!at},c:function(Tt,$t,at,lt){try{for(var Wt=0,Ae=0;Ae<at;Ae++){for(var de=Y[$t+8*Ae>>2],Yt=Y[$t+(8*Ae+4)>>2],ze=0;ze<Yt;ze++){var Ye=nt[de+ze],Qt=vr[Tt];Ye===0||Ye===10?((Tt===1?_t:et)(ot(Qt,0)),Qt.length=0):Qt.push(Ye)}Wt+=Yt}return Y[lt>>2]=Wt,0}catch(zt){return typeof FS<"u"&&zt instanceof FS.fa||Jt(zt),zt.ga}},memory:It,table:pt},Ar=function(){function Tt(Wt){x.asm=Wt.exports,_e--,x.monitorRunDependencies&&x.monitorRunDependencies(_e),_e==0&&$e&&(Wt=$e,$e=null,Wt())}function $t(Wt){Tt(Wt.instance)}function at(Wt){(Rt||!J&&!Z||typeof fetch!="function"?new Promise(function(Ae){Ae(Lr())}):fetch(ae,{credentials:"same-origin"}).then(function(Ae){if(Ae.ok)return Ae.arrayBuffer();throw"failed to load wasm binary file at '"+ae+"'"}).catch(Lr)).then(function(){return{then:function(Ae){Ae({instance:new ft})}}}).then(Wt,function(Ae){et("failed to asynchronously prepare wasm: "+Ae),Jt(Ae)})}var lt={env:Pt,wasi_unstable:Pt};if(_e++,x.monitorRunDependencies&&x.monitorRunDependencies(_e),x.instantiateWasm)try{return x.instantiateWasm(lt,Tt)}catch(Wt){return et("Module.instantiateWasm callback failed with error: "+Wt),!1}return Rt||typeof wt.instantiateStreaming!="function"||xe(ae)||typeof fetch!="function"?at($t):fetch(ae,{credentials:"same-origin"}).then(function(Wt){return wt.instantiateStreaming(Wt,lt).then($t,function(Ae){et("wasm streaming compile failed: "+Ae),et("falling back to ArrayBuffer instantiation"),at($t)})}),{}}(),Hr=(x.asm=Ar,x.___wasm_call_ctors=function(){return x.asm.d.apply(null,arguments)}),Xe=(x._csmGetLogFunction=function(){return x.asm.e.apply(null,arguments)},x._csmGetVersion=function(){return x.asm.f.apply(null,arguments)},x._csmGetLatestMocVersion=function(){return x.asm.g.apply(null,arguments)},x._csmGetMocVersion=function(){return x.asm.h.apply(null,arguments)},x._csmHasMocConsistency=function(){return x.asm.i.apply(null,arguments)},x._csmSetLogFunction=function(){return x.asm.j.apply(null,arguments)},x._csmReviveMocInPlace=function(){return x.asm.k.apply(null,arguments)},x._csmReadCanvasInfo=function(){return x.asm.l.apply(null,arguments)},x._csmGetSizeofModel=function(){return x.asm.m.apply(null,arguments)},x._csmInitializeModelInPlace=function(){return x.asm.n.apply(null,arguments)},x._csmUpdateModel=function(){return x.asm.o.apply(null,arguments)},x._csmGetParameterCount=function(){return x.asm.p.apply(null,arguments)},x._csmGetParameterIds=function(){return x.asm.q.apply(null,arguments)},x._csmGetParameterTypes=function(){return x.asm.r.apply(null,arguments)},x._csmGetParameterMinimumValues=function(){return x.asm.s.apply(null,arguments)},x._csmGetParameterMaximumValues=function(){return x.asm.t.apply(null,arguments)},x._csmGetParameterDefaultValues=function(){return x.asm.u.apply(null,arguments)},x._csmGetParameterValues=function(){return x.asm.v.apply(null,arguments)},x._csmGetPartCount=function(){return x.asm.w.apply(null,arguments)},x._csmGetPartIds=function(){return x.asm.x.apply(null,arguments)},x._csmGetPartOpacities=function(){return x.asm.y.apply(null,arguments)},x._csmGetPartParentPartIndices=function(){return x.asm.z.apply(null,arguments)},x._csmGetDrawableCount=function(){return x.asm.A.apply(null,arguments)},x._csmGetDrawableIds=function(){return x.asm.B.apply(null,arguments)},x._csmGetDrawableConstantFlags=function(){return x.asm.C.apply(null,arguments)},x._csmGetDrawableDynamicFlags=function(){return x.asm.D.apply(null,arguments)},x._csmGetDrawableTextureIndices=function(){return x.asm.E.apply(null,arguments)},x._csmGetDrawableDrawOrders=function(){return x.asm.F.apply(null,arguments)},x._csmGetDrawableRenderOrders=function(){return x.asm.G.apply(null,arguments)},x._csmGetDrawableOpacities=function(){return x.asm.H.apply(null,arguments)},x._csmGetDrawableMaskCounts=function(){return x.asm.I.apply(null,arguments)},x._csmGetDrawableMasks=function(){return x.asm.J.apply(null,arguments)},x._csmGetDrawableVertexCounts=function(){return x.asm.K.apply(null,arguments)},x._csmGetDrawableVertexPositions=function(){return x.asm.L.apply(null,arguments)},x._csmGetDrawableVertexUvs=function(){return x.asm.M.apply(null,arguments)},x._csmGetDrawableIndexCounts=function(){return x.asm.N.apply(null,arguments)},x._csmGetDrawableIndices=function(){return x.asm.O.apply(null,arguments)},x._csmGetDrawableMultiplyColors=function(){return x.asm.P.apply(null,arguments)},x._csmGetDrawableScreenColors=function(){return x.asm.Q.apply(null,arguments)},x._csmGetDrawableParentPartIndices=function(){return x.asm.R.apply(null,arguments)},x._csmResetDrawableDynamicFlags=function(){return x.asm.S.apply(null,arguments)},x._csmGetParameterKeyCounts=function(){return x.asm.T.apply(null,arguments)},x._csmGetParameterKeyValues=function(){return x.asm.U.apply(null,arguments)},x._csmMallocMoc=function(){return x.asm.V.apply(null,arguments)},x._csmMallocModelAndInitialize=function(){return x.asm.W.apply(null,arguments)},x._csmMalloc=function(){return x.asm.X.apply(null,arguments)},x._csmFree=function(){return x.asm.Y.apply(null,arguments)},x._csmInitializeAmountOfMemory=function(){return x.asm.Z.apply(null,arguments)},x.stackSave=function(){return x.asm._.apply(null,arguments)}),Li=x.stackAlloc=function(){return x.asm.$.apply(null,arguments)},Rs=x.stackRestore=function(){return x.asm.aa.apply(null,arguments)},hr=x.__growWasmMemory=function(){return x.asm.ba.apply(null,arguments)};function Qr(){function Tt(){if(!fr&&(fr=!0,!xt)){if(Dt(se),Dt(Kt),x.onRuntimeInitialized&&x.onRuntimeInitialized(),x.postRun)for(typeof x.postRun=="function"&&(x.postRun=[x.postRun]);x.postRun.length;){var $t=x.postRun.shift();Xt.unshift($t)}Dt(Xt)}}if(!(0<_e)){if(x.preRun)for(typeof x.preRun=="function"&&(x.preRun=[x.preRun]);x.preRun.length;)(function(){var $t=x.preRun.shift();kt.unshift($t)})();Dt(kt),0<_e||(x.setStatus?(x.setStatus("Running..."),setTimeout(function(){setTimeout(function(){x.setStatus("")},1),Tt()},1)):Tt())}}if(x.dynCall_vi=function(){return x.asm.ca.apply(null,arguments)},x.asm=Ar,x.ccall=function(Tt,$t,at,lt){var Wt={string:function(Ye){var Qt=0;if(Ye!=null&&Ye!==0){var zt=1+(Ye.length<<2),l=Qt=Li(zt),w=nt;if(0<zt){for(var zt=l+zt-1,$=0;$<Ye.length;++$){var L=Ye.charCodeAt($);if((L=55296<=L&&L<=57343?65536+((1023&L)<<10)|1023&Ye.charCodeAt(++$):L)<=127){if(zt<=l)break;w[l++]=L}else{if(L<=2047){if(zt<=l+1)break;w[l++]=192|L>>6}else{if(L<=65535){if(zt<=l+2)break;w[l++]=224|L>>12}else{if(zt<=l+3)break;w[l++]=240|L>>18,w[l++]=128|L>>12&63}w[l++]=128|L>>6&63}w[l++]=128|63&L}}w[l]=0}}return Qt},array:function(Ye){var Qt=Li(Ye.length);return st.set(Ye,Qt),Qt}},Ae=function(Ye){var Qt=x["_"+Ye];return Ct(Qt,"Cannot call unknown function "+Ye+", make sure it is exported"),Qt}(Tt),de=[];if(Tt=0,lt)for(var Yt=0;Yt<lt.length;Yt++){var ze=Wt[at[Yt]];ze?(Tt===0&&(Tt=Xe()),de[Yt]=ze(lt[Yt])):de[Yt]=lt[Yt]}return at=function(Ye){return $t==="string"?ht(Ye):$t==="boolean"?!!Ye:Ye}(at=Ae.apply(null,de)),Tt!==0&&Rs(Tt),at},x.UTF8ToString=ht,x.addFunction=function(Tt,$t){var at=pt.length;try{pt.grow(1)}catch(lt){throw!lt instanceof RangeError?lt:"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{pt.set(at,Tt)}catch(lt){if(!lt instanceof TypeError)throw lt;Ct($t!==void 0,"Missing signature argument to addFunction"),pt.set(at,Tt)}return at},x.then=function(Tt){var $t;return fr?Tt(x):($t=x.onRuntimeInitialized,x.onRuntimeInitialized=function(){$t&&$t(),Tt(x)}),x},$e=function Tt(){fr||Qr(),fr||($e=Tt)},x.run=Qr,x.preInit)for(typeof x.preInit=="function"&&(x.preInit=[x.preInit]);0<x.preInit.length;)x.preInit.pop()();return Qr(),C}),T=(typeof qr=="object"&&typeof module=="object"?module.exports=A:typeof define=="function"&&define.amd?define([],function(){return A}):typeof qr=="object"&&(qr._em_module=A),A())})(Ds=Ds||{}),window.Live2DCubismCore=Ds;var ys=(s=>(s[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s))(ys||{}),Ya=(s=>(s[s.UNKNOWN=0]="UNKNOWN",s[s.WEBGL=1]="WEBGL",s[s.CANVAS=2]="CANVAS",s))(Ya||{}),Lo=(s=>(s[s.COLOR=16384]="COLOR",s[s.DEPTH=256]="DEPTH",s[s.STENCIL=1024]="STENCIL",s))(Lo||{}),Re=(s=>(s[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",s))(Re||{}),Ai=(s=>(s[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",s))(Ai||{}),qt=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(qt||{}),Fs=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(Fs||{}),Pe=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(Pe||{}),le=(s=>(s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s))(le||{}),Gi=(s=>(s[s.NEAREST=0]="NEAREST",s[s.LINEAR=1]="LINEAR",s))(Gi||{}),Vi=(s=>(s[s.CLAMP=33071]="CLAMP",s[s.REPEAT=10497]="REPEAT",s[s.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",s))(Vi||{}),wi=(s=>(s[s.OFF=0]="OFF",s[s.POW2=1]="POW2",s[s.ON=2]="ON",s[s.ON_MANUAL=3]="ON_MANUAL",s))(wi||{}),Vr=(s=>(s[s.NPM=0]="NPM",s[s.UNPACK=1]="UNPACK",s[s.PMA=2]="PMA",s[s.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",s[s.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",s[s.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",s))(Vr||{}),Ti=(s=>(s[s.NO=0]="NO",s[s.YES=1]="YES",s[s.AUTO=2]="AUTO",s[s.BLEND=0]="BLEND",s[s.CLEAR=1]="CLEAR",s[s.BLIT=2]="BLIT",s))(Ti||{}),Bo=(s=>(s[s.AUTO=0]="AUTO",s[s.MANUAL=1]="MANUAL",s))(Bo||{}),ri=(s=>(s.LOW="lowp",s.MEDIUM="mediump",s.HIGH="highp",s))(ri||{}),xr=(s=>(s[s.NONE=0]="NONE",s[s.SCISSOR=1]="SCISSOR",s[s.STENCIL=2]="STENCIL",s[s.SPRITE=3]="SPRITE",s[s.COLOR=4]="COLOR",s))(xr||{}),Fu=(s=>(s[s.RED=1]="RED",s[s.GREEN=2]="GREEN",s[s.BLUE=4]="BLUE",s[s.ALPHA=8]="ALPHA",s))(Fu||{}),yr=(s=>(s[s.NONE=0]="NONE",s[s.LOW=2]="LOW",s[s.MEDIUM=4]="MEDIUM",s[s.HIGH=8]="HIGH",s))(yr||{}),Ei=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(Ei||{});const Lu={createCanvas:(s,t)=>{const r=document.createElement("canvas");return r.width=s,r.height=t,r},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")},ue={ADAPTER:Lu,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var ja=/iPhone/i,Bu=/iPod/i,ku=/iPad/i,Ou=/\biOS-universal(?:.+)Mac\b/i,qa=/\bAndroid(?:.+)Mobile\b/i,Nu=/Android/i,Ks=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ko=/Silk/i,ss=/Windows Phone/i,Uu=/\bWindows(?:.+)ARM\b/i,Gu=/BlackBerry/i,Vu=/BB10/i,zu=/Opera Mini/i,Xu=/\b(CriOS|Chrome)(?:.+)Mobile/i,Wu=/Mobile(?:.+)Firefox\b/i,Hu=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function v2(s){return function(t){return t.test(s)}}function Yu(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var r=t.userAgent,i=r.split("[FBAN");typeof i[1]<"u"&&(r=i[0]),i=r.split("Twitter"),typeof i[1]<"u"&&(r=i[0]);var n=v2(r),o={apple:{phone:n(ja)&&!n(ss),ipod:n(Bu),tablet:!n(ja)&&(n(ku)||Hu(t))&&!n(ss),universal:n(Ou),device:(n(ja)||n(Bu)||n(ku)||n(Ou)||Hu(t))&&!n(ss)},amazon:{phone:n(Ks),tablet:!n(Ks)&&n(ko),device:n(Ks)||n(ko)},android:{phone:!n(ss)&&n(Ks)||!n(ss)&&n(qa),tablet:!n(ss)&&!n(Ks)&&!n(qa)&&(n(ko)||n(Nu)),device:!n(ss)&&(n(Ks)||n(ko)||n(qa)||n(Nu))||n(/\bokhttp\b/i)},windows:{phone:n(ss),tablet:n(Uu),device:n(ss)||n(Uu)},other:{blackberry:n(Gu),blackberry10:n(Vu),opera:n(zu),firefox:n(Wu),chrome:n(Xu),device:n(Gu)||n(Vu)||n(zu)||n(Wu)||n(Xu)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}const x2=Yu.default??Yu,Ci=x2(globalThis.navigator);ue.RETINA_PREFIX=/@([0-9\.]+)x/,ue.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Za=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ju(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function b2(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var r=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var n=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return s[i]}})}),r}var Qa={exports:{}},qu;function A2(){return qu||(qu=1,function(s){var t=Object.prototype.hasOwnProperty,r="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function n(A,T,C){this.fn=A,this.context=T,this.once=C||!1}function o(A,T,C,x,M){if(typeof C!="function")throw new TypeError("The listener must be a function");var D=new n(C,x||A,M),k=r?r+T:T;return A._events[k]?A._events[k].fn?A._events[k]=[A._events[k],D]:A._events[k].push(D):(A._events[k]=D,A._eventsCount++),A}function h(A,T){--A._eventsCount===0?A._events=new i:delete A._events[T]}function f(){this._events=new i,this._eventsCount=0}f.prototype.eventNames=function(){var T=[],C,x;if(this._eventsCount===0)return T;for(x in C=this._events)t.call(C,x)&&T.push(r?x.slice(1):x);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(C)):T},f.prototype.listeners=function(T){var C=r?r+T:T,x=this._events[C];if(!x)return[];if(x.fn)return[x.fn];for(var M=0,D=x.length,k=new Array(D);M<D;M++)k[M]=x[M].fn;return k},f.prototype.listenerCount=function(T){var C=r?r+T:T,x=this._events[C];return x?x.fn?1:x.length:0},f.prototype.emit=function(T,C,x,M,D,k){var U=r?r+T:T;if(!this._events[U])return!1;var G=this._events[U],X=arguments.length,J,Z;if(G.fn){switch(G.once&&this.removeListener(T,G.fn,void 0,!0),X){case 1:return G.fn.call(G.context),!0;case 2:return G.fn.call(G.context,C),!0;case 3:return G.fn.call(G.context,C,x),!0;case 4:return G.fn.call(G.context,C,x,M),!0;case 5:return G.fn.call(G.context,C,x,M,D),!0;case 6:return G.fn.call(G.context,C,x,M,D,k),!0}for(Z=1,J=new Array(X-1);Z<X;Z++)J[Z-1]=arguments[Z];G.fn.apply(G.context,J)}else{var it=G.length,Q;for(Z=0;Z<it;Z++)switch(G[Z].once&&this.removeListener(T,G[Z].fn,void 0,!0),X){case 1:G[Z].fn.call(G[Z].context);break;case 2:G[Z].fn.call(G[Z].context,C);break;case 3:G[Z].fn.call(G[Z].context,C,x);break;case 4:G[Z].fn.call(G[Z].context,C,x,M);break;default:if(!J)for(Q=1,J=new Array(X-1);Q<X;Q++)J[Q-1]=arguments[Q];G[Z].fn.apply(G[Z].context,J)}}return!0},f.prototype.on=function(T,C,x){return o(this,T,C,x,!1)},f.prototype.once=function(T,C,x){return o(this,T,C,x,!0)},f.prototype.removeListener=function(T,C,x,M){var D=r?r+T:T;if(!this._events[D])return this;if(!C)return h(this,D),this;var k=this._events[D];if(k.fn)k.fn===C&&(!M||k.once)&&(!x||k.context===x)&&h(this,D);else{for(var U=0,G=[],X=k.length;U<X;U++)(k[U].fn!==C||M&&!k[U].once||x&&k[U].context!==x)&&G.push(k[U]);G.length?this._events[D]=G.length===1?G[0]:G:h(this,D)}return this},f.prototype.removeAllListeners=function(T){var C;return T?(C=r?r+T:T,this._events[C]&&h(this,C)):(this._events=new i,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=r,f.EventEmitter=f,s.exports=f}(Qa)),Qa.exports}var w2=A2();const ns=ju(w2);var Oo={exports:{}},Zu;function T2(){if(Zu)return Oo.exports;Zu=1,Oo.exports=s,Oo.exports.default=s;function s(st,nt,Y){Y=Y||2;var gt=nt&&nt.length,ot=gt?nt[0]*Y:st.length,ht=t(st,0,ot,Y,!0),dt=[];if(!ht||ht.next===ht.prev)return dt;var At,Et,Dt,oe,kt,se,Kt;if(gt&&(ht=A(st,nt,ht,Y)),st.length>80*Y){At=Dt=st[0],Et=oe=st[1];for(var Xt=Y;Xt<ot;Xt+=Y)kt=st[Xt],se=st[Xt+1],kt<At&&(At=kt),se<Et&&(Et=se),kt>Dt&&(Dt=kt),se>oe&&(oe=se);Kt=Math.max(Dt-At,oe-Et),Kt=Kt!==0?32767/Kt:0}return i(ht,dt,Y,At,Et,Kt,0),dt}function t(st,nt,Y,gt,ot){var ht,dt;if(ot===Gt(st,nt,Y,gt)>0)for(ht=nt;ht<Y;ht+=gt)dt=pt(ht,st[ht],st[ht+1],dt);else for(ht=Y-gt;ht>=nt;ht-=gt)dt=pt(ht,st[ht],st[ht+1],dt);return dt&&it(dt,dt.next)&&(xt(dt),dt=dt.next),dt}function r(st,nt){if(!st)return st;nt||(nt=st);var Y=st,gt;do if(gt=!1,!Y.steiner&&(it(Y,Y.next)||Z(Y.prev,Y,Y.next)===0)){if(xt(Y),Y=nt=Y.prev,Y===Y.next)break;gt=!0}else Y=Y.next;while(gt||Y!==nt);return nt}function i(st,nt,Y,gt,ot,ht,dt){if(st){!dt&&ht&&D(st,gt,ot,ht);for(var At=st,Et,Dt;st.prev!==st.next;){if(Et=st.prev,Dt=st.next,ht?o(st,gt,ot,ht):n(st)){nt.push(Et.i/Y|0),nt.push(st.i/Y|0),nt.push(Dt.i/Y|0),xt(st),st=Dt.next,At=Dt.next;continue}if(st=Dt,st===At){dt?dt===1?(st=h(r(st),nt,Y),i(st,nt,Y,gt,ot,ht,2)):dt===2&&f(st,nt,Y,gt,ot,ht):i(r(st),nt,Y,gt,ot,ht,1);break}}}}function n(st){var nt=st.prev,Y=st,gt=st.next;if(Z(nt,Y,gt)>=0)return!1;for(var ot=nt.x,ht=Y.x,dt=gt.x,At=nt.y,Et=Y.y,Dt=gt.y,oe=ot<ht?ot<dt?ot:dt:ht<dt?ht:dt,kt=At<Et?At<Dt?At:Dt:Et<Dt?Et:Dt,se=ot>ht?ot>dt?ot:dt:ht>dt?ht:dt,Kt=At>Et?At>Dt?At:Dt:Et>Dt?Et:Dt,Xt=gt.next;Xt!==nt;){if(Xt.x>=oe&&Xt.x<=se&&Xt.y>=kt&&Xt.y<=Kt&&X(ot,At,ht,Et,dt,Dt,Xt.x,Xt.y)&&Z(Xt.prev,Xt,Xt.next)>=0)return!1;Xt=Xt.next}return!0}function o(st,nt,Y,gt){var ot=st.prev,ht=st,dt=st.next;if(Z(ot,ht,dt)>=0)return!1;for(var At=ot.x,Et=ht.x,Dt=dt.x,oe=ot.y,kt=ht.y,se=dt.y,Kt=At<Et?At<Dt?At:Dt:Et<Dt?Et:Dt,Xt=oe<kt?oe<se?oe:se:kt<se?kt:se,_e=At>Et?At>Dt?At:Dt:Et>Dt?Et:Dt,$e=oe>kt?oe>se?oe:se:kt>se?kt:se,Jt=U(Kt,Xt,nt,Y,gt),De=U(_e,$e,nt,Y,gt),xe=st.prevZ,ae=st.nextZ;xe&&xe.z>=Jt&&ae&&ae.z<=De;){if(xe.x>=Kt&&xe.x<=_e&&xe.y>=Xt&&xe.y<=$e&&xe!==ot&&xe!==dt&&X(At,oe,Et,kt,Dt,se,xe.x,xe.y)&&Z(xe.prev,xe,xe.next)>=0||(xe=xe.prevZ,ae.x>=Kt&&ae.x<=_e&&ae.y>=Xt&&ae.y<=$e&&ae!==ot&&ae!==dt&&X(At,oe,Et,kt,Dt,se,ae.x,ae.y)&&Z(ae.prev,ae,ae.next)>=0))return!1;ae=ae.nextZ}for(;xe&&xe.z>=Jt;){if(xe.x>=Kt&&xe.x<=_e&&xe.y>=Xt&&xe.y<=$e&&xe!==ot&&xe!==dt&&X(At,oe,Et,kt,Dt,se,xe.x,xe.y)&&Z(xe.prev,xe,xe.next)>=0)return!1;xe=xe.prevZ}for(;ae&&ae.z<=De;){if(ae.x>=Kt&&ae.x<=_e&&ae.y>=Xt&&ae.y<=$e&&ae!==ot&&ae!==dt&&X(At,oe,Et,kt,Dt,se,ae.x,ae.y)&&Z(ae.prev,ae,ae.next)>=0)return!1;ae=ae.nextZ}return!0}function h(st,nt,Y){var gt=st;do{var ot=gt.prev,ht=gt.next.next;!it(ot,ht)&&Q(ot,gt,gt.next,ht)&&wt(ot,ht)&&wt(ht,ot)&&(nt.push(ot.i/Y|0),nt.push(gt.i/Y|0),nt.push(ht.i/Y|0),xt(gt),xt(gt.next),gt=st=ht),gt=gt.next}while(gt!==st);return r(gt)}function f(st,nt,Y,gt,ot,ht){var dt=st;do{for(var At=dt.next.next;At!==dt.prev;){if(dt.i!==At.i&&J(dt,At)){var Et=It(dt,At);dt=r(dt,dt.next),Et=r(Et,Et.next),i(dt,nt,Y,gt,ot,ht,0),i(Et,nt,Y,gt,ot,ht,0);return}At=At.next}dt=dt.next}while(dt!==st)}function A(st,nt,Y,gt){var ot=[],ht,dt,At,Et,Dt;for(ht=0,dt=nt.length;ht<dt;ht++)At=nt[ht]*gt,Et=ht<dt-1?nt[ht+1]*gt:st.length,Dt=t(st,At,Et,gt,!1),Dt===Dt.next&&(Dt.steiner=!0),ot.push(G(Dt));for(ot.sort(T),ht=0;ht<ot.length;ht++)Y=C(ot[ht],Y);return Y}function T(st,nt){return st.x-nt.x}function C(st,nt){var Y=x(st,nt);if(!Y)return nt;var gt=It(Y,st);return r(gt,gt.next),r(Y,Y.next)}function x(st,nt){var Y=nt,gt=st.x,ot=st.y,ht=-1/0,dt;do{if(ot<=Y.y&&ot>=Y.next.y&&Y.next.y!==Y.y){var At=Y.x+(ot-Y.y)*(Y.next.x-Y.x)/(Y.next.y-Y.y);if(At<=gt&&At>ht&&(ht=At,dt=Y.x<Y.next.x?Y:Y.next,At===gt))return dt}Y=Y.next}while(Y!==nt);if(!dt)return null;var Et=dt,Dt=dt.x,oe=dt.y,kt=1/0,se;Y=dt;do gt>=Y.x&&Y.x>=Dt&&gt!==Y.x&&X(ot<oe?gt:ht,ot,Dt,oe,ot<oe?ht:gt,ot,Y.x,Y.y)&&(se=Math.abs(ot-Y.y)/(gt-Y.x),wt(Y,st)&&(se<kt||se===kt&&(Y.x>dt.x||Y.x===dt.x&&M(dt,Y)))&&(dt=Y,kt=se)),Y=Y.next;while(Y!==Et);return dt}function M(st,nt){return Z(st.prev,st,nt.prev)<0&&Z(nt.next,st,st.next)<0}function D(st,nt,Y,gt){var ot=st;do ot.z===0&&(ot.z=U(ot.x,ot.y,nt,Y,gt)),ot.prevZ=ot.prev,ot.nextZ=ot.next,ot=ot.next;while(ot!==st);ot.prevZ.nextZ=null,ot.prevZ=null,k(ot)}function k(st){var nt,Y,gt,ot,ht,dt,At,Et,Dt=1;do{for(Y=st,st=null,ht=null,dt=0;Y;){for(dt++,gt=Y,At=0,nt=0;nt<Dt&&(At++,gt=gt.nextZ,!!gt);nt++);for(Et=Dt;At>0||Et>0&&gt;)At!==0&&(Et===0||!gt||Y.z<=gt.z)?(ot=Y,Y=Y.nextZ,At--):(ot=gt,gt=gt.nextZ,Et--),ht?ht.nextZ=ot:st=ot,ot.prevZ=ht,ht=ot;Y=gt}ht.nextZ=null,Dt*=2}while(dt>1);return st}function U(st,nt,Y,gt,ot){return st=(st-Y)*ot|0,nt=(nt-gt)*ot|0,st=(st|st<<8)&16711935,st=(st|st<<4)&252645135,st=(st|st<<2)&858993459,st=(st|st<<1)&1431655765,nt=(nt|nt<<8)&16711935,nt=(nt|nt<<4)&252645135,nt=(nt|nt<<2)&858993459,nt=(nt|nt<<1)&1431655765,st|nt<<1}function G(st){var nt=st,Y=st;do(nt.x<Y.x||nt.x===Y.x&&nt.y<Y.y)&&(Y=nt),nt=nt.next;while(nt!==st);return Y}function X(st,nt,Y,gt,ot,ht,dt,At){return(ot-dt)*(nt-At)>=(st-dt)*(ht-At)&&(st-dt)*(gt-At)>=(Y-dt)*(nt-At)&&(Y-dt)*(ht-At)>=(ot-dt)*(gt-At)}function J(st,nt){return st.next.i!==nt.i&&st.prev.i!==nt.i&&!ft(st,nt)&&(wt(st,nt)&&wt(nt,st)&&Rt(st,nt)&&(Z(st.prev,st,nt.prev)||Z(st,nt.prev,nt))||it(st,nt)&&Z(st.prev,st,st.next)>0&&Z(nt.prev,nt,nt.next)>0)}function Z(st,nt,Y){return(nt.y-st.y)*(Y.x-nt.x)-(nt.x-st.x)*(Y.y-nt.y)}function it(st,nt){return st.x===nt.x&&st.y===nt.y}function Q(st,nt,Y,gt){var ot=et(Z(st,nt,Y)),ht=et(Z(st,nt,gt)),dt=et(Z(Y,gt,st)),At=et(Z(Y,gt,nt));return!!(ot!==ht&&dt!==At||ot===0&&_t(st,Y,nt)||ht===0&&_t(st,gt,nt)||dt===0&&_t(Y,st,gt)||At===0&&_t(Y,nt,gt))}function _t(st,nt,Y){return nt.x<=Math.max(st.x,Y.x)&&nt.x>=Math.min(st.x,Y.x)&&nt.y<=Math.max(st.y,Y.y)&&nt.y>=Math.min(st.y,Y.y)}function et(st){return st>0?1:st<0?-1:0}function ft(st,nt){var Y=st;do{if(Y.i!==st.i&&Y.next.i!==st.i&&Y.i!==nt.i&&Y.next.i!==nt.i&&Q(Y,Y.next,st,nt))return!0;Y=Y.next}while(Y!==st);return!1}function wt(st,nt){return Z(st.prev,st,st.next)<0?Z(st,nt,st.next)>=0&&Z(st,st.prev,nt)>=0:Z(st,nt,st.prev)<0||Z(st,st.next,nt)<0}function Rt(st,nt){var Y=st,gt=!1,ot=(st.x+nt.x)/2,ht=(st.y+nt.y)/2;do Y.y>ht!=Y.next.y>ht&&Y.next.y!==Y.y&&ot<(Y.next.x-Y.x)*(ht-Y.y)/(Y.next.y-Y.y)+Y.x&&(gt=!gt),Y=Y.next;while(Y!==st);return gt}function It(st,nt){var Y=new Ct(st.i,st.x,st.y),gt=new Ct(nt.i,nt.x,nt.y),ot=st.next,ht=nt.prev;return st.next=nt,nt.prev=st,Y.next=ot,ot.prev=Y,gt.next=Y,Y.prev=gt,ht.next=gt,gt.prev=ht,gt}function pt(st,nt,Y,gt){var ot=new Ct(st,nt,Y);return gt?(ot.next=gt.next,ot.prev=gt,gt.next.prev=ot,gt.next=ot):(ot.prev=ot,ot.next=ot),ot}function xt(st){st.next.prev=st.prev,st.prev.next=st.next,st.prevZ&&(st.prevZ.nextZ=st.nextZ),st.nextZ&&(st.nextZ.prevZ=st.prevZ)}function Ct(st,nt,Y){this.i=st,this.x=nt,this.y=Y,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}s.deviation=function(st,nt,Y,gt){var ot=nt&&nt.length,ht=ot?nt[0]*Y:st.length,dt=Math.abs(Gt(st,0,ht,Y));if(ot)for(var At=0,Et=nt.length;At<Et;At++){var Dt=nt[At]*Y,oe=At<Et-1?nt[At+1]*Y:st.length;dt-=Math.abs(Gt(st,Dt,oe,Y))}var kt=0;for(At=0;At<gt.length;At+=3){var se=gt[At]*Y,Kt=gt[At+1]*Y,Xt=gt[At+2]*Y;kt+=Math.abs((st[se]-st[Xt])*(st[Kt+1]-st[se+1])-(st[se]-st[Kt])*(st[Xt+1]-st[se+1]))}return dt===0&&kt===0?0:Math.abs((kt-dt)/dt)};function Gt(st,nt,Y,gt){for(var ot=0,ht=nt,dt=Y-gt;ht<Y;ht+=gt)ot+=(st[dt]-st[ht])*(st[ht+1]+st[dt+1]),dt=ht;return ot}return s.flatten=function(st){for(var nt=st[0][0].length,Y={vertices:[],holes:[],dimensions:nt},gt=0,ot=0;ot<st.length;ot++){for(var ht=0;ht<st[ot].length;ht++)for(var dt=0;dt<nt;dt++)Y.vertices.push(st[ot][ht][dt]);ot>0&&(gt+=st[ot-1].length,Y.holes.push(gt))}return Y},Oo.exports}var E2=T2();const Qu=ju(E2);var Ls={},Sn={exports:{}};var C2=Sn.exports,Ku;function S2(){return Ku||(Ku=1,function(s,t){(function(r){var i=t&&!t.nodeType&&t,n=s&&!s.nodeType&&s,o=typeof Za=="object"&&Za;(o.global===o||o.window===o||o.self===o)&&(r=o);var h,f=2147483647,A=36,T=1,C=26,x=38,M=700,D=72,k=128,U="-",G=/^xn--/,X=/[^\x20-\x7E]/,J=/[\x2E\u3002\uFF0E\uFF61]/g,Z={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},it=A-T,Q=Math.floor,_t=String.fromCharCode,et;function ft(ot){throw new RangeError(Z[ot])}function wt(ot,ht){for(var dt=ot.length,At=[];dt--;)At[dt]=ht(ot[dt]);return At}function Rt(ot,ht){var dt=ot.split("@"),At="";dt.length>1&&(At=dt[0]+"@",ot=dt[1]),ot=ot.replace(J,".");var Et=ot.split("."),Dt=wt(Et,ht).join(".");return At+Dt}function It(ot){for(var ht=[],dt=0,At=ot.length,Et,Dt;dt<At;)Et=ot.charCodeAt(dt++),Et>=55296&&Et<=56319&&dt<At?(Dt=ot.charCodeAt(dt++),(Dt&64512)==56320?ht.push(((Et&1023)<<10)+(Dt&1023)+65536):(ht.push(Et),dt--)):ht.push(Et);return ht}function pt(ot){return wt(ot,function(ht){var dt="";return ht>65535&&(ht-=65536,dt+=_t(ht>>>10&1023|55296),ht=56320|ht&1023),dt+=_t(ht),dt}).join("")}function xt(ot){return ot-48<10?ot-22:ot-65<26?ot-65:ot-97<26?ot-97:A}function Ct(ot,ht){return ot+22+75*(ot<26)-((ht!=0)<<5)}function Gt(ot,ht,dt){var At=0;for(ot=dt?Q(ot/M):ot>>1,ot+=Q(ot/ht);ot>it*C>>1;At+=A)ot=Q(ot/it);return Q(At+(it+1)*ot/(ot+x))}function st(ot){var ht=[],dt=ot.length,At,Et=0,Dt=k,oe=D,kt,se,Kt,Xt,_e,$e,Jt,De,xe;for(kt=ot.lastIndexOf(U),kt<0&&(kt=0),se=0;se<kt;++se)ot.charCodeAt(se)>=128&&ft("not-basic"),ht.push(ot.charCodeAt(se));for(Kt=kt>0?kt+1:0;Kt<dt;){for(Xt=Et,_e=1,$e=A;Kt>=dt&&ft("invalid-input"),Jt=xt(ot.charCodeAt(Kt++)),(Jt>=A||Jt>Q((f-Et)/_e))&&ft("overflow"),Et+=Jt*_e,De=$e<=oe?T:$e>=oe+C?C:$e-oe,!(Jt<De);$e+=A)xe=A-De,_e>Q(f/xe)&&ft("overflow"),_e*=xe;At=ht.length+1,oe=Gt(Et-Xt,At,Xt==0),Q(Et/At)>f-Dt&&ft("overflow"),Dt+=Q(Et/At),Et%=At,ht.splice(Et++,0,Dt)}return pt(ht)}function nt(ot){var ht,dt,At,Et,Dt,oe,kt,se,Kt,Xt,_e,$e=[],Jt,De,xe,ae;for(ot=It(ot),Jt=ot.length,ht=k,dt=0,Dt=D,oe=0;oe<Jt;++oe)_e=ot[oe],_e<128&&$e.push(_t(_e));for(At=Et=$e.length,Et&&$e.push(U);At<Jt;){for(kt=f,oe=0;oe<Jt;++oe)_e=ot[oe],_e>=ht&&_e<kt&&(kt=_e);for(De=At+1,kt-ht>Q((f-dt)/De)&&ft("overflow"),dt+=(kt-ht)*De,ht=kt,oe=0;oe<Jt;++oe)if(_e=ot[oe],_e<ht&&++dt>f&&ft("overflow"),_e==ht){for(se=dt,Kt=A;Xt=Kt<=Dt?T:Kt>=Dt+C?C:Kt-Dt,!(se<Xt);Kt+=A)ae=se-Xt,xe=A-Xt,$e.push(_t(Ct(Xt+ae%xe,0))),se=Q(ae/xe);$e.push(_t(Ct(se,0))),Dt=Gt(dt,De,At==Et),dt=0,++At}++dt,++ht}return $e.join("")}function Y(ot){return Rt(ot,function(ht){return G.test(ht)?st(ht.slice(4).toLowerCase()):ht})}function gt(ot){return Rt(ot,function(ht){return X.test(ht)?"xn--"+nt(ht):ht})}if(h={version:"1.4.1",ucs2:{decode:It,encode:pt},decode:st,encode:nt,toASCII:gt,toUnicode:Y},i&&n)if(s.exports==i)n.exports=h;else for(et in h)h.hasOwnProperty(et)&&(i[et]=h[et]);else r.punycode=h})(C2)}(Sn,Sn.exports)),Sn.exports}var Ka,Ju;function P2(){return Ju||(Ju=1,Ka=Error),Ka}var Ja,t0;function $2(){return t0||(t0=1,Ja=EvalError),Ja}var th,e0;function M2(){return e0||(e0=1,th=RangeError),th}var eh,r0;function R2(){return r0||(r0=1,eh=ReferenceError),eh}var rh,i0;function s0(){return i0||(i0=1,rh=SyntaxError),rh}var ih,n0;function Pn(){return n0||(n0=1,ih=TypeError),ih}var sh,o0;function I2(){return o0||(o0=1,sh=URIError),sh}var nh,a0;function D2(){return a0||(a0=1,nh=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var n=42;t[r]=n;for(r in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var h=Object.getOwnPropertyDescriptor(t,r);if(h.value!==n||h.enumerable!==!0)return!1}return!0}),nh}var oh,h0;function F2(){if(h0)return oh;h0=1;var s=typeof Symbol<"u"&&Symbol,t=D2();return oh=function(){return typeof s!="function"||typeof Symbol!="function"||typeof s("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},oh}var ah,l0;function L2(){if(l0)return ah;l0=1;var s={__proto__:null,foo:{}},t=Object;return ah=function(){return{__proto__:s}.foo===s.foo&&!(s instanceof t)},ah}var hh,u0;function B2(){if(u0)return hh;u0=1;var s="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,i="[object Function]",n=function(A,T){for(var C=[],x=0;x<A.length;x+=1)C[x]=A[x];for(var M=0;M<T.length;M+=1)C[M+A.length]=T[M];return C},o=function(A,T){for(var C=[],x=T,M=0;x<A.length;x+=1,M+=1)C[M]=A[x];return C},h=function(f,A){for(var T="",C=0;C<f.length;C+=1)T+=f[C],C+1<f.length&&(T+=A);return T};return hh=function(A){var T=this;if(typeof T!="function"||t.apply(T)!==i)throw new TypeError(s+T);for(var C=o(arguments,1),x,M=function(){if(this instanceof x){var X=T.apply(this,n(C,arguments));return Object(X)===X?X:this}return T.apply(A,n(C,arguments))},D=r(0,T.length-C.length),k=[],U=0;U<D;U++)k[U]="$"+U;if(x=Function("binder","return function ("+h(k,",")+"){ return binder.apply(this,arguments); }")(M),T.prototype){var G=function(){};G.prototype=T.prototype,x.prototype=new G,G.prototype=null}return x},hh}var lh,c0;function uh(){if(c0)return lh;c0=1;var s=B2();return lh=Function.prototype.bind||s,lh}var ch,f0;function k2(){if(f0)return ch;f0=1;var s=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=uh();return ch=r.call(s,t),ch}var fh,d0;function Js(){if(d0)return fh;d0=1;var s,t=P2(),r=$2(),i=M2(),n=R2(),o=s0(),h=Pn(),f=I2(),A=Function,T=function(nt){try{return A('"use strict"; return ('+nt+").constructor;")()}catch{}},C=Object.getOwnPropertyDescriptor;if(C)try{C({},"")}catch{C=null}var x=function(){throw new h},M=C?function(){try{return arguments.callee,x}catch{try{return C(arguments,"callee").get}catch{return x}}}():x,D=F2()(),k=L2()(),U=Object.getPrototypeOf||(k?function(nt){return nt.__proto__}:null),G={},X=typeof Uint8Array>"u"||!U?s:U(Uint8Array),J={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?s:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?s:ArrayBuffer,"%ArrayIteratorPrototype%":D&&U?U([][Symbol.iterator]()):s,"%AsyncFromSyncIteratorPrototype%":s,"%AsyncFunction%":G,"%AsyncGenerator%":G,"%AsyncGeneratorFunction%":G,"%AsyncIteratorPrototype%":G,"%Atomics%":typeof Atomics>"u"?s:Atomics,"%BigInt%":typeof BigInt>"u"?s:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?s:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?s:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?s:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":r,"%Float32Array%":typeof Float32Array>"u"?s:Float32Array,"%Float64Array%":typeof Float64Array>"u"?s:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?s:FinalizationRegistry,"%Function%":A,"%GeneratorFunction%":G,"%Int8Array%":typeof Int8Array>"u"?s:Int8Array,"%Int16Array%":typeof Int16Array>"u"?s:Int16Array,"%Int32Array%":typeof Int32Array>"u"?s:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":D&&U?U(U([][Symbol.iterator]())):s,"%JSON%":typeof JSON=="object"?JSON:s,"%Map%":typeof Map>"u"?s:Map,"%MapIteratorPrototype%":typeof Map>"u"||!D||!U?s:U(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?s:Promise,"%Proxy%":typeof Proxy>"u"?s:Proxy,"%RangeError%":i,"%ReferenceError%":n,"%Reflect%":typeof Reflect>"u"?s:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?s:Set,"%SetIteratorPrototype%":typeof Set>"u"||!D||!U?s:U(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?s:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":D&&U?U(""[Symbol.iterator]()):s,"%Symbol%":D?Symbol:s,"%SyntaxError%":o,"%ThrowTypeError%":M,"%TypedArray%":X,"%TypeError%":h,"%Uint8Array%":typeof Uint8Array>"u"?s:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?s:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?s:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?s:Uint32Array,"%URIError%":f,"%WeakMap%":typeof WeakMap>"u"?s:WeakMap,"%WeakRef%":typeof WeakRef>"u"?s:WeakRef,"%WeakSet%":typeof WeakSet>"u"?s:WeakSet};if(U)try{null.error}catch(nt){var Z=U(U(nt));J["%Error.prototype%"]=Z}var it=function nt(Y){var gt;if(Y==="%AsyncFunction%")gt=T("async function () {}");else if(Y==="%GeneratorFunction%")gt=T("function* () {}");else if(Y==="%AsyncGeneratorFunction%")gt=T("async function* () {}");else if(Y==="%AsyncGenerator%"){var ot=nt("%AsyncGeneratorFunction%");ot&&(gt=ot.prototype)}else if(Y==="%AsyncIteratorPrototype%"){var ht=nt("%AsyncGenerator%");ht&&U&&(gt=U(ht.prototype))}return J[Y]=gt,gt},Q={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},_t=uh(),et=k2(),ft=_t.call(Function.call,Array.prototype.concat),wt=_t.call(Function.apply,Array.prototype.splice),Rt=_t.call(Function.call,String.prototype.replace),It=_t.call(Function.call,String.prototype.slice),pt=_t.call(Function.call,RegExp.prototype.exec),xt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ct=/\\(\\)?/g,Gt=function(Y){var gt=It(Y,0,1),ot=It(Y,-1);if(gt==="%"&&ot!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(ot==="%"&&gt!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var ht=[];return Rt(Y,xt,function(dt,At,Et,Dt){ht[ht.length]=Et?Rt(Dt,Ct,"$1"):At||dt}),ht},st=function(Y,gt){var ot=Y,ht;if(et(Q,ot)&&(ht=Q[ot],ot="%"+ht[0]+"%"),et(J,ot)){var dt=J[ot];if(dt===G&&(dt=it(ot)),typeof dt>"u"&&!gt)throw new h("intrinsic "+Y+" exists, but is not available. Please file an issue!");return{alias:ht,name:ot,value:dt}}throw new o("intrinsic "+Y+" does not exist!")};return fh=function(Y,gt){if(typeof Y!="string"||Y.length===0)throw new h("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof gt!="boolean")throw new h('"allowMissing" argument must be a boolean');if(pt(/^%?[^%]*%?$/,Y)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var ot=Gt(Y),ht=ot.length>0?ot[0]:"",dt=st("%"+ht+"%",gt),At=dt.name,Et=dt.value,Dt=!1,oe=dt.alias;oe&&(ht=oe[0],wt(ot,ft([0,1],oe)));for(var kt=1,se=!0;kt<ot.length;kt+=1){var Kt=ot[kt],Xt=It(Kt,0,1),_e=It(Kt,-1);if((Xt==='"'||Xt==="'"||Xt==="`"||_e==='"'||_e==="'"||_e==="`")&&Xt!==_e)throw new o("property names with quotes must have matching quotes");if((Kt==="constructor"||!se)&&(Dt=!0),ht+="."+Kt,At="%"+ht+"%",et(J,At))Et=J[At];else if(Et!=null){if(!(Kt in Et)){if(!gt)throw new h("base intrinsic for "+Y+" exists, but the property is not available.");return}if(C&&kt+1>=ot.length){var $e=C(Et,Kt);se=!!$e,se&&"get"in $e&&!("originalValue"in $e.get)?Et=$e.get:Et=Et[Kt]}else se=et(Et,Kt),Et=Et[Kt];se&&!Dt&&(J[At]=Et)}}return Et},fh}var dh={exports:{}},ph,p0;function _h(){if(p0)return ph;p0=1;var s=Js(),t=s("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return ph=t,ph}var gh,_0;function g0(){if(_0)return gh;_0=1;var s=Js(),t=s("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return gh=t,gh}var mh,m0;function O2(){if(m0)return mh;m0=1;var s=_h(),t=s0(),r=Pn(),i=g0();return mh=function(o,h,f){if(!o||typeof o!="object"&&typeof o!="function")throw new r("`obj` must be an object or a function`");if(typeof h!="string"&&typeof h!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var A=arguments.length>3?arguments[3]:null,T=arguments.length>4?arguments[4]:null,C=arguments.length>5?arguments[5]:null,x=arguments.length>6?arguments[6]:!1,M=!!i&&i(o,h);if(s)s(o,h,{configurable:C===null&&M?M.configurable:!C,enumerable:A===null&&M?M.enumerable:!A,value:f,writable:T===null&&M?M.writable:!T});else if(x||!A&&!T&&!C)o[h]=f;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},mh}var yh,y0;function N2(){if(y0)return yh;y0=1;var s=_h(),t=function(){return!!s};return t.hasArrayLengthDefineBug=function(){if(!s)return null;try{return s([],"length",{value:1}).length!==1}catch{return!0}},yh=t,yh}var vh,v0;function U2(){if(v0)return vh;v0=1;var s=Js(),t=O2(),r=N2()(),i=g0(),n=Pn(),o=s("%Math.floor%");return vh=function(f,A){if(typeof f!="function")throw new n("`fn` is not a function");if(typeof A!="number"||A<0||A>4294967295||o(A)!==A)throw new n("`length` must be a positive 32-bit integer");var T=arguments.length>2&&!!arguments[2],C=!0,x=!0;if("length"in f&&i){var M=i(f,"length");M&&!M.configurable&&(C=!1),M&&!M.writable&&(x=!1)}return(C||x||!T)&&(r?t(f,"length",A,!0,!0):t(f,"length",A)),f},vh}var x0;function G2(){return x0||(x0=1,function(s){var t=uh(),r=Js(),i=U2(),n=Pn(),o=r("%Function.prototype.apply%"),h=r("%Function.prototype.call%"),f=r("%Reflect.apply%",!0)||t.call(h,o),A=_h(),T=r("%Math.max%");s.exports=function(M){if(typeof M!="function")throw new n("a function is required");var D=f(t,h,arguments);return i(D,1+T(0,M.length-(arguments.length-1)),!0)};var C=function(){return f(t,o,arguments)};A?A(s.exports,"apply",{value:C}):s.exports.apply=C}(dh)),dh.exports}var xh,b0;function V2(){if(b0)return xh;b0=1;var s=Js(),t=G2(),r=t(s("String.prototype.indexOf"));return xh=function(n,o){var h=s(n,!!o);return typeof h=="function"&&r(n,".prototype.")>-1?t(h):h},xh}const z2=b2(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var bh,A0;function X2(){if(A0)return bh;A0=1;var s=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&s?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=s&&t&&typeof t.get=="function"?t.get:null,i=s&&Map.prototype.forEach,n=typeof Set=="function"&&Set.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,h=n&&o&&typeof o.get=="function"?o.get:null,f=n&&Set.prototype.forEach,A=typeof WeakMap=="function"&&WeakMap.prototype,T=A?WeakMap.prototype.has:null,C=typeof WeakSet=="function"&&WeakSet.prototype,x=C?WeakSet.prototype.has:null,M=typeof WeakRef=="function"&&WeakRef.prototype,D=M?WeakRef.prototype.deref:null,k=Boolean.prototype.valueOf,U=Object.prototype.toString,G=Function.prototype.toString,X=String.prototype.match,J=String.prototype.slice,Z=String.prototype.replace,it=String.prototype.toUpperCase,Q=String.prototype.toLowerCase,_t=RegExp.prototype.test,et=Array.prototype.concat,ft=Array.prototype.join,wt=Array.prototype.slice,Rt=Math.floor,It=typeof BigInt=="function"?BigInt.prototype.valueOf:null,pt=Object.getOwnPropertySymbols,xt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ct=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Gt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ct||!0)?Symbol.toStringTag:null,st=Object.prototype.propertyIsEnumerable,nt=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(at){return at.__proto__}:null);function Y(at,lt){if(at===1/0||at===-1/0||at!==at||at&&at>-1e3&&at<1e3||_t.call(/e/,lt))return lt;var Wt=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof at=="number"){var Ae=at<0?-Rt(-at):Rt(at);if(Ae!==at){var de=String(Ae),Yt=J.call(lt,de.length+1);return Z.call(de,Wt,"$&_")+"."+Z.call(Z.call(Yt,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Z.call(lt,Wt,"$&_")}var gt=z2,ot=gt.custom,ht=_e(ot)?ot:null;bh=function at(lt,Wt,Ae,de){var Yt=Wt||{};if(De(Yt,"quoteStyle")&&Yt.quoteStyle!=="single"&&Yt.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(De(Yt,"maxStringLength")&&(typeof Yt.maxStringLength=="number"?Yt.maxStringLength<0&&Yt.maxStringLength!==1/0:Yt.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var ze=De(Yt,"customInspect")?Yt.customInspect:!0;if(typeof ze!="boolean"&&ze!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(De(Yt,"indent")&&Yt.indent!==null&&Yt.indent!==" "&&!(parseInt(Yt.indent,10)===Yt.indent&&Yt.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(De(Yt,"numericSeparator")&&typeof Yt.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Ye=Yt.numericSeparator;if(typeof lt>"u")return"undefined";if(lt===null)return"null";if(typeof lt=="boolean")return lt?"true":"false";if(typeof lt=="string")return Ar(lt,Yt);if(typeof lt=="number"){if(lt===0)return 1/0/lt>0?"0":"-0";var Qt=String(lt);return Ye?Y(lt,Qt):Qt}if(typeof lt=="bigint"){var zt=String(lt)+"n";return Ye?Y(lt,zt):zt}var l=typeof Yt.depth>"u"?5:Yt.depth;if(typeof Ae>"u"&&(Ae=0),Ae>=l&&l>0&&typeof lt=="object")return Et(lt)?"[Array]":"[Object]";var w=Qr(Yt,Ae);if(typeof de>"u")de=[];else if(Lr(de,lt)>=0)return"[Circular]";function $(Lt,re,Zt){if(re&&(de=wt.call(de),de.push(re)),Zt){var K={depth:Yt.depth};return De(Yt,"quoteStyle")&&(K.quoteStyle=Yt.quoteStyle),at(Lt,K,Ae+1,de)}return at(Lt,Yt,Ae+1,de)}if(typeof lt=="function"&&!oe(lt)){var L=ae(lt),O=$t(lt,$);return"[Function"+(L?": "+L:" (anonymous)")+"]"+(O.length>0?" { "+ft.call(O,", ")+" }":"")}if(_e(lt)){var N=Ct?Z.call(String(lt),/^(Symbol\(.*\))_[^)]*$/,"$1"):xt.call(lt);return typeof lt=="object"&&!Ct?Xe(N):N}if(Pt(lt)){for(var e="<"+Q.call(String(lt.nodeName)),H=lt.attributes||[],W=0;W<H.length;W++)e+=" "+H[W].name+"="+dt(At(H[W].value),"double",Yt);return e+=">",lt.childNodes&&lt.childNodes.length&&(e+="..."),e+="</"+Q.call(String(lt.nodeName))+">",e}if(Et(lt)){if(lt.length===0)return"[]";var rt=$t(lt,$);return w&&!hr(rt)?"["+Tt(rt,w)+"]":"[ "+ft.call(rt,", ")+" ]"}if(kt(lt)){var I=$t(lt,$);return!("cause"in Error.prototype)&&"cause"in lt&&!st.call(lt,"cause")?"{ ["+String(lt)+"] "+ft.call(et.call("[cause]: "+$(lt.cause),I),", ")+" }":I.length===0?"["+String(lt)+"]":"{ ["+String(lt)+"] "+ft.call(I,", ")+" }"}if(typeof lt=="object"&&ze){if(ht&&typeof lt[ht]=="function"&&gt)return gt(lt,{depth:l-Ae});if(ze!=="symbol"&&typeof lt.inspect=="function")return lt.inspect()}if(vr(lt)){var ct=[];return i&&i.call(lt,function(Lt,re){ct.push($(re,lt,!0)+" => "+$(Lt,lt))}),Rs("Map",r.call(lt),ct,w)}if(Wr(lt)){var j=[];return f&&f.call(lt,function(Lt){j.push($(Lt,lt))}),Rs("Set",h.call(lt),j,w)}if(Fi(lt))return Li("WeakMap");if(fr(lt))return Li("WeakSet");if(sr(lt))return Li("WeakRef");if(Kt(lt))return Xe($(Number(lt)));if($e(lt))return Xe($(It.call(lt)));if(Xt(lt))return Xe(k.call(lt));if(se(lt))return Xe($(String(lt)));if(typeof window<"u"&&lt===window)return"{ [object Window] }";if(lt===Za)return"{ [object globalThis] }";if(!Dt(lt)&&!oe(lt)){var v=$t(lt,$),St=nt?nt(lt)===Object.prototype:lt instanceof Object||lt.constructor===Object,yt=lt instanceof Object?"":"null prototype",Mt=!St&&Gt&&Object(lt)===lt&&Gt in lt?J.call(xe(lt),8,-1):yt?"Object":"",Ft=St||typeof lt.constructor!="function"?"":lt.constructor.name?lt.constructor.name+" ":"",Nt=Ft+(Mt||yt?"["+ft.call(et.call([],Mt||[],yt||[]),": ")+"] ":"");return v.length===0?Nt+"{}":w?Nt+"{"+Tt(v,w)+"}":Nt+"{ "+ft.call(v,", ")+" }"}return String(lt)};function dt(at,lt,Wt){var Ae=(Wt.quoteStyle||lt)==="double"?'"':"'";return Ae+at+Ae}function At(at){return Z.call(String(at),/"/g,"&quot;")}function Et(at){return xe(at)==="[object Array]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Dt(at){return xe(at)==="[object Date]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function oe(at){return xe(at)==="[object RegExp]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function kt(at){return xe(at)==="[object Error]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function se(at){return xe(at)==="[object String]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Kt(at){return xe(at)==="[object Number]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Xt(at){return xe(at)==="[object Boolean]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function _e(at){if(Ct)return at&&typeof at=="object"&&at instanceof Symbol;if(typeof at=="symbol")return!0;if(!at||typeof at!="object"||!xt)return!1;try{return xt.call(at),!0}catch{}return!1}function $e(at){if(!at||typeof at!="object"||!It)return!1;try{return It.call(at),!0}catch{}return!1}var Jt=Object.prototype.hasOwnProperty||function(at){return at in this};function De(at,lt){return Jt.call(at,lt)}function xe(at){return U.call(at)}function ae(at){if(at.name)return at.name;var lt=X.call(G.call(at),/^function\s*([\w$]+)/);return lt?lt[1]:null}function Lr(at,lt){if(at.indexOf)return at.indexOf(lt);for(var Wt=0,Ae=at.length;Wt<Ae;Wt++)if(at[Wt]===lt)return Wt;return-1}function vr(at){if(!r||!at||typeof at!="object")return!1;try{r.call(at);try{h.call(at)}catch{return!0}return at instanceof Map}catch{}return!1}function Fi(at){if(!T||!at||typeof at!="object")return!1;try{T.call(at,T);try{x.call(at,x)}catch{return!0}return at instanceof WeakMap}catch{}return!1}function sr(at){if(!D||!at||typeof at!="object")return!1;try{return D.call(at),!0}catch{}return!1}function Wr(at){if(!h||!at||typeof at!="object")return!1;try{h.call(at);try{r.call(at)}catch{return!0}return at instanceof Set}catch{}return!1}function fr(at){if(!x||!at||typeof at!="object")return!1;try{x.call(at,x);try{T.call(at,T)}catch{return!0}return at instanceof WeakSet}catch{}return!1}function Pt(at){return!at||typeof at!="object"?!1:typeof HTMLElement<"u"&&at instanceof HTMLElement?!0:typeof at.nodeName=="string"&&typeof at.getAttribute=="function"}function Ar(at,lt){if(at.length>lt.maxStringLength){var Wt=at.length-lt.maxStringLength,Ae="... "+Wt+" more character"+(Wt>1?"s":"");return Ar(J.call(at,0,lt.maxStringLength),lt)+Ae}var de=Z.call(Z.call(at,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Hr);return dt(de,"single",lt)}function Hr(at){var lt=at.charCodeAt(0),Wt={8:"b",9:"t",10:"n",12:"f",13:"r"}[lt];return Wt?"\\"+Wt:"\\x"+(lt<16?"0":"")+it.call(lt.toString(16))}function Xe(at){return"Object("+at+")"}function Li(at){return at+" { ? }"}function Rs(at,lt,Wt,Ae){var de=Ae?Tt(Wt,Ae):ft.call(Wt,", ");return at+" ("+lt+") {"+de+"}"}function hr(at){for(var lt=0;lt<at.length;lt++)if(Lr(at[lt],`
43
+ `,this.motions.length,$.toString())}};function Tt(){this._$w0=null,this._$AT=!0,this._$9L=!1,this._$z2=-1,this._$bs=-1,this._$Do=-1,this._$sr=null,this._$sr=Tt._$Gs++}Tt._$Gs=0,Tt.prototype.isFinished=function(){return this._$9L},Tt.prototype._$qS=function(l){var w=pt.getUserTimeMSec(),$=w+l;(this._$Do<0||$<this._$Do)&&(this._$Do=$)},Tt.prototype._$Bs=function(){return this._$sr};function $t(){this.m=new Array(1,0,0,0,1,0,0,0,1)}$t.prototype.setContext=function(l){var w=this.m;l.transform(w[0],w[1],w[3],w[4],w[6],w[7])},$t.prototype.toString=function(){for(var l="LDTransform { ",w=0;w<9;w++)l+=this.m[w].toFixed(2)+" ,";return l+=" }",l},$t.prototype.identity=function(){var l=this.m;l[0]=l[4]=l[8]=1,l[1]=l[2]=l[3]=l[5]=l[6]=l[7]=0},$t.prototype._$PS=function(l,w,$){$==null&&($=new Array(0,0));var L=this.m;return $[0]=L[0]*l+L[3]*w+L[6],$[1]=L[1]*l+L[4]*w+L[7],$},$t.prototype._$P2=function(l){l||(l=new $t);var w=this.m,$=w[0],L=w[1],O=w[2],N=w[3],e=w[4],H=w[5],W=w[6],rt=w[7],I=w[8],ct=$*e*I+L*H*W+O*N*rt-$*H*rt-O*e*W-L*N*I;if(ct==0)return null;var j=1/ct;return l.m[0]=j*(e*I-rt*H),l.m[1]=j*(rt*O-L*I),l.m[2]=j*(L*H-e*O),l.m[3]=j*(W*H-N*I),l.m[4]=j*($*I-W*O),l.m[5]=j*(N*O-$*H),l.m[6]=j*(N*rt-W*e),l.m[7]=j*(W*L-$*rt),l.m[8]=j*($*e-N*L),l},$t.prototype.transform=function(l,w,$){$==null&&($=new Array(0,0));var L=this.m;return $[0]=L[0]*l+L[3]*w+L[6],$[1]=L[1]*l+L[4]*w+L[7],$},$t.prototype.translate=function(l,w){var $=this.m;$[6]=$[0]*l+$[3]*w+$[6],$[7]=$[1]*l+$[4]*w+$[7],$[8]=$[2]*l+$[5]*w+$[8]},$t.prototype.scale=function(l,w){var $=this.m;$[0]*=l,$[1]*=l,$[2]*=l,$[3]*=w,$[4]*=w,$[5]*=w},$t.prototype.shear=function(l,w){var $=this.m,L=$[0]+$[3]*w,O=$[1]+$[4]*w,N=$[2]+$[5]*w;$[3]=$[0]*l+$[3],$[4]=$[1]*l+$[4],$[5]=$[2]*l+$[5],$[0]=L,$[1]=O,$[2]=N},$t.prototype.rotate=function(l){var w=this.m,$=Math.cos(l),L=Math.sin(l),O=w[0]*$+w[3]*L,N=w[1]*$+w[4]*L,e=w[2]*$+w[5]*L;w[3]=-w[0]*L+w[3]*$,w[4]=-w[1]*L+w[4]*$,w[5]=-w[2]*L+w[5]*$,w[0]=O,w[1]=N,w[2]=e},$t.prototype.concatenate=function(l){var w=this.m,$=l.m,L=w[0]*$[0]+w[3]*$[1]+w[6]*$[2],O=w[1]*$[0]+w[4]*$[1]+w[7]*$[2],N=w[2]*$[0]+w[5]*$[1]+w[8]*$[2],e=w[0]*$[3]+w[3]*$[4]+w[6]*$[5],H=w[1]*$[3]+w[4]*$[4]+w[7]*$[5],W=w[2]*$[3]+w[5]*$[4]+w[8]*$[5],rt=w[0]*$[6]+w[3]*$[7]+w[6]*$[8],I=w[1]*$[6]+w[4]*$[7]+w[7]*$[8],ct=w[2]*$[6]+w[5]*$[7]+w[8]*$[8];m[0]=L,m[1]=O,m[2]=N,m[3]=e,m[4]=H,m[5]=W,m[6]=rt,m[7]=I,m[8]=ct};function at(l){zt||vr.prototype.constructor.call(this,l)}at.prototype=new vr,at._$eT=null,at._$tP=new Object,at._$2o=function(){return at._$eT==null&&(at._$eT=at.getID("DST_BASE")),at._$eT},at._$27=function(){at._$tP.clear(),at._$eT=null},at.getID=function(l){var w=at._$tP[l];return w==null&&(w=new at(l),at._$tP[l]=w),w},at.prototype._$3s=function(){return new at};function lt(l){zt||(wt.prototype.constructor.call(this),this.textures=new Array,this.transform=null,this.gl=null,this.glno=l,this.firstDraw=!0,this.anisotropyExt=null,this.maxAnisotropy=0,this._$As=32,this._$Gr=!1,this._$NT=null,this._$vS=null,this._$no=null,this.vertShader=null,this.fragShader=null,this.vertShaderOff=null,this.fragShaderOff=null)}lt.prototype=new wt,lt._$9r=function(l){var w=new Float32Array(l);return w},lt._$vb=function(l){var w=new Int16Array(l);return w},lt._$cr=function(l,w){return l==null||l._$yL()<w.length?(l=lt._$9r(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},lt._$mb=function(l,w){return l==null||l._$yL()<w.length?(l=lt._$vb(w.length*2),l.put(w),l._$oT(0)):(l.clear(),l.put(w),l._$oT(0)),l},lt._$Hs=function(){return this._$Gr},lt._$as=function(l){this._$Gr=l},lt.prototype.getGL=function(){return this.gl},lt.prototype.setGL=function(l){this.gl=l},lt.prototype.setTransform=function(l){this.transform=l},lt.prototype._$ZT=function(){var l=this.gl;this.firstDraw&&(this.initShader(),this.firstDraw=!1,this.anisotropyExt=l.getExtension("EXT_texture_filter_anisotropic")||l.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||l.getExtension("MOZ_EXT_texture_filter_anisotropic"),this.anisotropyExt&&(this.maxAnisotropy=l.getParameter(this.anisotropyExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),l.disable(l.SCISSOR_TEST),l.disable(l.STENCIL_TEST),l.disable(l.DEPTH_TEST),l.frontFace(l.CW),l.enable(l.BLEND),l.colorMask(1,1,1,1),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)},lt.prototype._$Uo=function(l,w,$,L,O,N,e,H){if(!(N<.01&&this.clipBufPre_clipContextMask==null)){N>.9&&Pt.EXPAND_W;var W=this.gl;if(this.gl==null)throw new Error("gl is null");var rt=!1,I=1,ct=1,j=1,v=this._$C0*I*N,St=this._$tT*ct*N,yt=this._$WL*j*N,Mt=this._$lT*N;if(this.clipBufPre_clipContextMask!=null){W.frontFace(W.CCW),W.useProgram(this.shaderProgram),this._$vS=Wt(W,this._$vS,L),this._$no=be(W,this._$no,$),W.enableVertexAttribArray(this.a_position_Loc),W.vertexAttribPointer(this.a_position_Loc,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc,1),W.enableVertexAttribArray(this.a_texCoord_Loc),W.vertexAttribPointer(this.a_texCoord_Loc,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_matrix_Loc,!1,this.getClipBufPre_clipContextMask().matrixForMask);var Ft=this.getClipBufPre_clipContextMask().layoutChannelNo,Nt=this.getChannelFlagAsColor(Ft);W.uniform4f(this.u_channelFlag,Nt.r,Nt.g,Nt.b,Nt.a);var Lt=this.getClipBufPre_clipContextMask().layoutBounds;W.uniform4f(this.u_baseColor_Loc,Lt.x*2-1,Lt.y*2-1,Lt._$EL()*2-1,Lt._$5T()*2-1),W.uniform1i(this.u_maskFlag_Loc,!0)}else if(rt=this.getClipBufPre_clipContextDraw()!=null,rt){W.useProgram(this.shaderProgramOff),this._$vS=Wt(W,this._$vS,L),this._$no=be(W,this._$no,$),W.enableVertexAttribArray(this.a_position_Loc_Off),W.vertexAttribPointer(this.a_position_Loc_Off,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc_Off,1),W.enableVertexAttribArray(this.a_texCoord_Loc_Off),W.vertexAttribPointer(this.a_texCoord_Loc_Off,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_clipMatrix_Loc_Off,!1,this.getClipBufPre_clipContextDraw().matrixForDraw),W.uniformMatrix4fv(this.u_matrix_Loc_Off,!1,this.matrix4x4),W.activeTexture(W.TEXTURE2),W.bindTexture(W.TEXTURE_2D,Pt.fTexture[this.glno]),W.uniform1i(this.s_texture1_Loc_Off,2);var Ft=this.getClipBufPre_clipContextDraw().layoutChannelNo,Nt=this.getChannelFlagAsColor(Ft);W.uniform4f(this.u_channelFlag_Loc_Off,Nt.r,Nt.g,Nt.b,Nt.a),W.uniform4f(this.u_baseColor_Loc_Off,v,St,yt,Mt)}else W.useProgram(this.shaderProgram),this._$vS=Wt(W,this._$vS,L),this._$no=be(W,this._$no,$),W.enableVertexAttribArray(this.a_position_Loc),W.vertexAttribPointer(this.a_position_Loc,2,W.FLOAT,!1,0,0),this._$NT=Wt(W,this._$NT,O),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,this.textures[l]),W.uniform1i(this.s_texture0_Loc,1),W.enableVertexAttribArray(this.a_texCoord_Loc),W.vertexAttribPointer(this.a_texCoord_Loc,2,W.FLOAT,!1,0,0),W.uniformMatrix4fv(this.u_matrix_Loc,!1,this.matrix4x4),W.uniform4f(this.u_baseColor_Loc,v,St,yt,Mt),W.uniform1i(this.u_maskFlag_Loc,!1);this.culling?this.gl.enable(W.CULL_FACE):this.gl.disable(W.CULL_FACE),this.gl.enable(W.BLEND);var re,Zt,K,Vt;if(this.clipBufPre_clipContextMask!=null)re=W.ONE,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ONE,Vt=W.ONE_MINUS_SRC_ALPHA;else switch(e){case Xe._$ms:re=W.ONE,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ONE,Vt=W.ONE_MINUS_SRC_ALPHA;break;case Xe._$ns:re=W.ONE,Zt=W.ONE,K=W.ZERO,Vt=W.ONE;break;case Xe._$_s:re=W.DST_COLOR,Zt=W.ONE_MINUS_SRC_ALPHA,K=W.ZERO,Vt=W.ONE;break}W.blendEquationSeparate(W.FUNC_ADD,W.FUNC_ADD),W.blendFuncSeparate(re,Zt,K,Vt),this.anisotropyExt&&W.texParameteri(W.TEXTURE_2D,this.anisotropyExt.TEXTURE_MAX_ANISOTROPY_EXT,this.maxAnisotropy);var jt=$.length;W.drawElements(W.TRIANGLES,jt,W.UNSIGNED_SHORT,0),W.bindTexture(W.TEXTURE_2D,null)}};function Wt(l,w,$){return w==null&&(w=l.createBuffer()),l.bindBuffer(l.ARRAY_BUFFER,w),l.bufferData(l.ARRAY_BUFFER,$,l.DYNAMIC_DRAW),w}function be(l,w,$){return w==null&&(w=l.createBuffer()),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,w),l.bufferData(l.ELEMENT_ARRAY_BUFFER,$,l.DYNAMIC_DRAW),w}lt.prototype._$Rs=function(){throw new Error("_$Rs")},lt.prototype._$Ds=function(l){throw new Error("_$Ds")},lt.prototype._$K2=function(){for(var l=0;l<this.textures.length;l++){var w=this.textures[l];w!=0&&(this.gl._$K2(1,this.textures,l),this.textures[l]=null)}},lt.prototype.setTexture=function(l,w){this.textures[l]=w},lt.prototype.initShader=function(){var l=this.gl;this.loadShaders2(),this.a_position_Loc=l.getAttribLocation(this.shaderProgram,"a_position"),this.a_texCoord_Loc=l.getAttribLocation(this.shaderProgram,"a_texCoord"),this.u_matrix_Loc=l.getUniformLocation(this.shaderProgram,"u_mvpMatrix"),this.s_texture0_Loc=l.getUniformLocation(this.shaderProgram,"s_texture0"),this.u_channelFlag=l.getUniformLocation(this.shaderProgram,"u_channelFlag"),this.u_baseColor_Loc=l.getUniformLocation(this.shaderProgram,"u_baseColor"),this.u_maskFlag_Loc=l.getUniformLocation(this.shaderProgram,"u_maskFlag"),this.a_position_Loc_Off=l.getAttribLocation(this.shaderProgramOff,"a_position"),this.a_texCoord_Loc_Off=l.getAttribLocation(this.shaderProgramOff,"a_texCoord"),this.u_matrix_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_mvpMatrix"),this.u_clipMatrix_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_ClipMatrix"),this.s_texture0_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"s_texture0"),this.s_texture1_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"s_texture1"),this.u_channelFlag_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_channelFlag"),this.u_baseColor_Loc_Off=l.getUniformLocation(this.shaderProgramOff,"u_baseColor")},lt.prototype.disposeShader=function(){var l=this.gl;this.shaderProgram&&(l.deleteProgram(this.shaderProgram),this.shaderProgram=null),this.shaderProgramOff&&(l.deleteProgram(this.shaderProgramOff),this.shaderProgramOff=null)},lt.prototype.compileShader=function(l,w){var $=this.gl,N,L=w,O=$.createShader(l);if(O==null)return h._$Ji("_$L0 to create shader"),null;$.shaderSource(O,L),$.compileShader(O);var N=$.getShaderParameter(O,$.COMPILE_STATUS);if(!N){var e=$.getShaderInfoLog(O);return h._$Ji("_$L0 to compile shader : "+e),$.deleteShader(O),null}return O},lt.prototype.loadShaders2=function(){var l=this.gl;if(this.shaderProgram=l.createProgram(),!this.shaderProgram||(this.shaderProgramOff=l.createProgram(),!this.shaderProgramOff))return!1;var w="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform mat4 u_mvpMatrix;void main(){ gl_Position = u_mvpMatrix * a_position; v_ClipPos = u_mvpMatrix * a_position; v_texCoord = a_texCoord;}",$="precision mediump float;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform sampler2D s_texture0;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform bool u_maskFlag;void main(){ vec4 smpColor; if(u_maskFlag){ float isInside = step(u_baseColor.x, v_ClipPos.x/v_ClipPos.w) * step(u_baseColor.y, v_ClipPos.y/v_ClipPos.w) * step(v_ClipPos.x/v_ClipPos.w, u_baseColor.z) * step(v_ClipPos.y/v_ClipPos.w, u_baseColor.w); smpColor = u_channelFlag * texture2D(s_texture0 , v_texCoord).a * isInside; }else{ smpColor = texture2D(s_texture0 , v_texCoord) * u_baseColor; } gl_FragColor = smpColor;}",L="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform mat4 u_mvpMatrix;uniform mat4 u_ClipMatrix;void main(){ gl_Position = u_mvpMatrix * a_position; v_ClipPos = u_ClipMatrix * a_position; v_texCoord = a_texCoord ;}",O="precision mediump float ;varying vec2 v_texCoord;varying vec4 v_ClipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor ;void main(){ vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor; vec4 clipMask = texture2D(s_texture1, v_ClipPos.xy / v_ClipPos.w) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}";if(this.vertShader=this.compileShader(l.VERTEX_SHADER,w),!this.vertShader)return h._$Ji("Vertex shader compile _$li!"),!1;if(this.vertShaderOff=this.compileShader(l.VERTEX_SHADER,L),!this.vertShaderOff)return h._$Ji("OffVertex shader compile _$li!"),!1;if(this.fragShader=this.compileShader(l.FRAGMENT_SHADER,$),!this.fragShader)return h._$Ji("Fragment shader compile _$li!"),!1;if(this.fragShaderOff=this.compileShader(l.FRAGMENT_SHADER,O),!this.fragShaderOff)return h._$Ji("OffFragment shader compile _$li!"),!1;l.attachShader(this.shaderProgram,this.vertShader),l.attachShader(this.shaderProgram,this.fragShader),l.attachShader(this.shaderProgramOff,this.vertShaderOff),l.attachShader(this.shaderProgramOff,this.fragShaderOff),l.linkProgram(this.shaderProgram),l.linkProgram(this.shaderProgramOff);var N=l.getProgramParameter(this.shaderProgram,l.LINK_STATUS);if(!N){var e=l.getProgramInfoLog(this.shaderProgram);return h._$Ji("_$L0 to link program: "+e),this.vertShader&&(l.deleteShader(this.vertShader),this.vertShader=0),this.fragShader&&(l.deleteShader(this.fragShader),this.fragShader=0),this.shaderProgram&&(l.deleteProgram(this.shaderProgram),this.shaderProgram=0),this.vertShaderOff&&(l.deleteShader(this.vertShaderOff),this.vertShaderOff=0),this.fragShaderOff&&(l.deleteShader(this.fragShaderOff),this.fragShaderOff=0),this.shaderProgramOff&&(l.deleteProgram(this.shaderProgramOff),this.shaderProgramOff=0),!1}return!0},lt.prototype.createFramebuffer=function(){var l=this.gl,w=Pt.clippingMaskBufferSize,$=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,$);var L=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,L),l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,w,w),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.RENDERBUFFER,L);var O=l.createTexture();return l.bindTexture(l.TEXTURE_2D,O),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,w,w,0,l.RGBA,l.UNSIGNED_BYTE,null),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,O,0),l.bindTexture(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),l.bindFramebuffer(l.FRAMEBUFFER,null),Pt.fTexture[this.glno]=O,{framebuffer:$,renderbuffer:L,texture:Pt.fTexture[this.glno]}};function de(l){zt||(this._$P=new Int8Array(8),this._$R0=new DataView(this._$P.buffer),this._$3i=new Int8Array(1e3),this._$hL=0,this._$v0=0,this._$S2=0,this._$Ko=new Array,this._$T=l,this._$F=0)}de.prototype._$fP=function(){var l=this._$ST(),w,$,L;if((l&128)==0)return l&255;if(((w=this._$ST())&128)==0)return(l&127)<<7|w&127;if((($=this._$ST())&128)==0)return(l&127)<<14|(w&127)<<7|$&255;if(((L=this._$ST())&128)==0)return(l&127)<<21|(w&127)<<14|($&127)<<7|L&255;throw new Hr("_$L _$0P _")},de.prototype.getFormatVersion=function(){return this._$S2},de.prototype._$gr=function(l){this._$S2=l},de.prototype._$3L=function(){return this._$fP()},de.prototype._$mP=function(){return this._$zT(),this._$F+=8,this._$T.getFloat64(this._$F-8)},de.prototype._$_T=function(){return this._$zT(),this._$F+=4,this._$T.getFloat32(this._$F-4)},de.prototype._$6L=function(){return this._$zT(),this._$F+=4,this._$T.getInt32(this._$F-4)},de.prototype._$ST=function(){return this._$zT(),this._$T.getInt8(this._$F++)},de.prototype._$9T=function(){return this._$zT(),this._$F+=2,this._$T.getInt16(this._$F-2)},de.prototype._$2T=function(){throw this._$zT(),this._$F+=8,new Hr("_$L _$q read long")},de.prototype._$po=function(){return this._$zT(),this._$T.getInt8(this._$F++)!=0};var Yt=!0;de.prototype._$bT=function(){this._$zT();var l=this._$3L(),w=null;if(Yt)try{var $=new ArrayBuffer(l*2);w=new Uint16Array($);for(var L=0;L<l;++L)w[L]=this._$T.getUint8(this._$F++);return String.fromCharCode.apply(null,w)}catch{Yt=!1}try{var O=new Array;if(w==null)for(var L=0;L<l;++L)O[L]=this._$T.getUint8(this._$F++);else for(var L=0;L<l;++L)O[L]=w[L];return String.fromCharCode.apply(null,O)}catch(N){console.log("read utf8 / _$rT _$L0 !! : "+N)}},de.prototype._$cS=function(){this._$zT();for(var l=this._$3L(),w=new Int32Array(l),$=0;$<l;$++)w[$]=this._$T.getInt32(this._$F),this._$F+=4;return w},de.prototype._$Tb=function(){this._$zT();for(var l=this._$3L(),w=new Float32Array(l),$=0;$<l;$++)w[$]=this._$T.getFloat32(this._$F),this._$F+=4;return w},de.prototype._$5b=function(){this._$zT();for(var l=this._$3L(),w=new Float64Array(l),$=0;$<l;$++)w[$]=this._$T.getFloat64(this._$F),this._$F+=8;return w},de.prototype._$nP=function(){return this._$Jb(-1)},de.prototype._$Jb=function(l){if(this._$zT(),l<0&&(l=this._$3L()),l==ht._$7P){var w=this._$6L();if(0<=w&&w<this._$Ko.length)return this._$Ko[w];throw new Hr("_$sL _$4i @_$m0")}else{var $=this._$4b(l);return this._$Ko.push($),$}},de.prototype._$4b=function(l){if(l==0)return null;if(l==50){var w=this._$bT(),$=nt.getID(w);return $}else if(l==51){var w=this._$bT(),$=at.getID(w);return $}else if(l==134){var w=this._$bT(),$=T.getID(w);return $}else if(l==60){var w=this._$bT(),$=x.getID(w);return $}if(l>=48){var L=ht._$9o(l);return L!=null?(L._$F0(this),L):null}switch(l){case 1:return this._$bT();case 10:return this._$6L(),new n;case 11:return new Q(this._$mP(),this._$mP(),this._$mP(),this._$mP());case 12:return new Q(this._$_T(),this._$_T(),this._$_T(),this._$_T());case 13:return new et(this._$mP(),this._$mP());case 14:return new et(this._$_T(),this._$_T());case 15:for(var O=this._$3L(),$=new Array(O),N=0;N<O;N++)$[N]=this._$nP();return $;case 17:var $=new Y(this._$mP(),this._$mP(),this._$mP(),this._$mP(),this._$mP(),this._$mP());return $;case 21:return new A(this._$6L(),this._$6L(),this._$6L(),this._$6L());case 22:return new Rs(this._$6L(),this._$6L());case 23:throw new Error("_$L _$ro ");case 16:case 25:return this._$cS();case 26:return this._$5b();case 27:return this._$Tb();case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 18:case 19:case 20:case 24:case 28:throw new Hr("_$6 _$q : _$nP() of 2-9 ,18,19,20,24,28 : "+l);default:throw new Hr("_$6 _$q : _$nP() NO _$i : "+l)}},de.prototype._$8L=function(){return this._$hL==0?this._$v0=this._$ST():this._$hL==8&&(this._$v0=this._$ST(),this._$hL=0),(this._$v0>>7-this._$hL++&1)==1},de.prototype._$zT=function(){this._$hL!=0&&(this._$hL=0)};function ze(){}ze._$2S=Math.PI/180,ze._$bS=Math.PI/180,ze._$wS=180/Math.PI,ze._$NS=180/Math.PI,ze.PI_F=Math.PI,ze._$kT=[0,.012368,.024734,.037097,.049454,.061803,.074143,.086471,.098786,.111087,.12337,.135634,.147877,.160098,.172295,.184465,.196606,.208718,.220798,.232844,.244854,.256827,.268761,.280654,.292503,.304308,.316066,.327776,.339436,.351044,.362598,.374097,.385538,.396921,.408243,.419502,.430697,.441826,.452888,.463881,.474802,.485651,.496425,.507124,.517745,.528287,.538748,.549126,.559421,.56963,.579752,.589785,.599728,.609579,.619337,.629,.638567,.648036,.657406,.666676,.675843,.684908,.693867,.70272,.711466,.720103,.72863,.737045,.745348,.753536,.76161,.769566,.777405,.785125,.792725,.800204,.807561,.814793,.821901,.828884,.835739,.842467,.849066,.855535,.861873,.868079,.874153,.880093,.885898,.891567,.897101,.902497,.907754,.912873,.917853,.922692,.92739,.931946,.936359,.940629,.944755,.948737,.952574,.956265,.959809,.963207,.966457,.96956,.972514,.97532,.977976,.980482,.982839,.985045,.987101,.989006,.990759,.992361,.993811,.995109,.996254,.997248,.998088,.998776,.999312,.999694,.999924,1],ze._$92=function(l,w){var $=Math.atan2(l[1],l[0]),L=Math.atan2(w[1],w[0]);return ze._$tS($,L)},ze._$tS=function(l,w){for(var $=l-w;$<-Math.PI;)$+=2*Math.PI;for(;$>Math.PI;)$-=2*Math.PI;return $},ze._$9=function(l){return Math.sin(l)},ze.fcos=function(l){return Math.cos(l)};function Ye(l){zt||(this._$e0=null,this._$IP=null,this._$Us=null,this._$7s=null,this._$IS=[!1],this._$VS=null,this._$AT=!0,this.baseOpacity=1,this.clipBufPre_clipContext=null,this._$e0=l)}Ye.prototype._$u2=function(){return this._$IS[0]},Ye.prototype._$yo=function(){return this._$AT&&!this._$IS[0]},Ye.prototype._$GT=function(){return this._$e0};function Qt(){}Qt._$W2=0,Qt.SYSTEM_INFO=null,Qt.USER_AGENT=navigator.userAgent,Qt.isIPhone=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone},Qt.isIOS=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone||Qt.SYSTEM_INFO._isIPad},Qt.isAndroid=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isAndroid},Qt.getOSVersion=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO.version},Qt.getOS=function(){return Qt.SYSTEM_INFO||Qt.setup(),Qt.SYSTEM_INFO._isIPhone||Qt.SYSTEM_INFO._isIPad?"iOS":Qt.SYSTEM_INFO._isAndroid?"Android":"_$Q0 OS"},Qt.setup=function(){var l=Qt.USER_AGENT;function w(O,N){for(var e=O.substring(N).split(/[ _,;\.]/),H=0,W=0;W<=2&&!isNaN(e[W]);W++){var rt=parseInt(e[W]);if(rt<0||rt>999){h._$li("err : "+rt+" @UtHtml5.setup()"),H=0;break}H+=rt*Math.pow(1e3,2-W)}return H}var $,L=Qt.SYSTEM_INFO={userAgent:l};if(($=l.indexOf("iPhone OS "))>=0)L.os="iPhone",L._isIPhone=!0,L.version=w(l,$+10);else if(($=l.indexOf("iPad"))>=0){if($=l.indexOf("CPU OS"),$<0){h._$li(" err : "+l+" @UtHtml5.setup()");return}L.os="iPad",L._isIPad=!0,L.version=w(l,$+7)}else($=l.indexOf("Android"))>=0?(L.os="Android",L._isAndroid=!0,L.version=w(l,$+8)):(L.os="-",L.version=-1)},window.UtSystem=pt,window.UtDebug=h,window.LDTransform=$t,window.LDGL=sr,window.Live2D=Pt,window.Live2DModelWebGL=hr,window.Live2DModelJS=Kt,window.Live2DMotion=Xt,window.MotionQueueManager=Qr,window.PhysicsHair=D,window.AMotion=o,window.PartsDataID=T,window.DrawDataID=nt,window.BaseDataID=at,window.ParamID=x,Pt.init();var zt=!1})();var Ds;(function(s){var t,r=function(){function C(){}return C.getVersion=function(){return T.ccall("csmGetVersion","number",[],[])},C.getLatestMocVersion=function(){return T.ccall("csmGetLatestMocVersion","number",[],[])},C.getMocVersion=function(x,M){return T.ccall("csmGetMocVersion","number",["number","number"],[x,M])},C.getLogFunction=function(){return T.ccall("csmGetLogFunction","number",[],[])},C.getSizeofModel=function(x){return T.ccall("csmGetSizeofModel","number",["number"],[x])},C.reviveMocInPlace=function(x,M){return T.ccall("csmReviveMocInPlace","number",["number","number"],[x,M])},C.initializeModelInPlace=function(x,M,D){return T.ccall("csmInitializeModelInPlace","number",["number","number","number"],[x,M,D])},C.hasMocConsistency=function(x,M){return T.ccall("csmHasMocConsistency","number",["number","number"],[x,M])},C.getParameterCount=function(x){return T.ccall("csmGetParameterCount","number",["number"],[x])},C.getParameterIds=function(x){return T.ccall("csmGetParameterIds","number",["number"],[x])},C.getParameterMinimumValues=function(x){return T.ccall("csmGetParameterMinimumValues","number",["number"],[x])},C.getParameterTypes=function(x){return T.ccall("csmGetParameterTypes","number",["number"],[x])},C.getParameterMaximumValues=function(x){return T.ccall("csmGetParameterMaximumValues","number",["number"],[x])},C.getParameterDefaultValues=function(x){return T.ccall("csmGetParameterDefaultValues","number",["number"],[x])},C.getParameterValues=function(x){return T.ccall("csmGetParameterValues","number",["number"],[x])},C.getParameterKeyCounts=function(x){return T.ccall("csmGetParameterKeyCounts","number",["number"],[x])},C.getParameterKeyValues=function(x){return T.ccall("csmGetParameterKeyValues","number",["number"],[x])},C.getPartCount=function(x){return T.ccall("csmGetPartCount","number",["number"],[x])},C.getPartIds=function(x){return T.ccall("csmGetPartIds","number",["number"],[x])},C.getPartOpacities=function(x){return T.ccall("csmGetPartOpacities","number",["number"],[x])},C.getPartParentPartIndices=function(x){return T.ccall("csmGetPartParentPartIndices","number",["number"],[x])},C.getDrawableCount=function(x){return T.ccall("csmGetDrawableCount","number",["number"],[x])},C.getDrawableIds=function(x){return T.ccall("csmGetDrawableIds","number",["number"],[x])},C.getDrawableConstantFlags=function(x){return T.ccall("csmGetDrawableConstantFlags","number",["number"],[x])},C.getDrawableDynamicFlags=function(x){return T.ccall("csmGetDrawableDynamicFlags","number",["number"],[x])},C.getDrawableTextureIndices=function(x){return T.ccall("csmGetDrawableTextureIndices","number",["number"],[x])},C.getDrawableDrawOrders=function(x){return T.ccall("csmGetDrawableDrawOrders","number",["number"],[x])},C.getDrawableRenderOrders=function(x){return T.ccall("csmGetDrawableRenderOrders","number",["number"],[x])},C.getDrawableOpacities=function(x){return T.ccall("csmGetDrawableOpacities","number",["number"],[x])},C.getDrawableMaskCounts=function(x){return T.ccall("csmGetDrawableMaskCounts","number",["number"],[x])},C.getDrawableMasks=function(x){return T.ccall("csmGetDrawableMasks","number",["number"],[x])},C.getDrawableVertexCounts=function(x){return T.ccall("csmGetDrawableVertexCounts","number",["number"],[x])},C.getDrawableVertexPositions=function(x){return T.ccall("csmGetDrawableVertexPositions","number",["number"],[x])},C.getDrawableVertexUvs=function(x){return T.ccall("csmGetDrawableVertexUvs","number",["number"],[x])},C.getDrawableIndexCounts=function(x){return T.ccall("csmGetDrawableIndexCounts","number",["number"],[x])},C.getDrawableIndices=function(x){return T.ccall("csmGetDrawableIndices","number",["number"],[x])},C.getDrawableMultiplyColors=function(x){return T.ccall("csmGetDrawableMultiplyColors","number",["number"],[x])},C.getDrawableScreenColors=function(x){return T.ccall("csmGetDrawableScreenColors","number",["number"],[x])},C.getDrawableParentPartIndices=function(x){return T.ccall("csmGetDrawableParentPartIndices","number",["number"],[x])},C.mallocMoc=function(x){return T.ccall("csmMallocMoc","number",["number"],[x])},C.mallocModelAndInitialize=function(x){return T.ccall("csmMallocModelAndInitialize","number",["number"],[x])},C.malloc=function(x){return T.ccall("csmMalloc","number",["number"],[x])},C.setLogFunction=function(x){T.ccall("csmSetLogFunction",null,["number"],[x])},C.updateModel=function(x){T.ccall("csmUpdateModel",null,["number"],[x])},C.readCanvasInfo=function(x,M,D,k){T.ccall("csmReadCanvasInfo",null,["number","number","number","number"],[x,M,D,k])},C.resetDrawableDynamicFlags=function(x){T.ccall("csmResetDrawableDynamicFlags",null,["number"],[x])},C.free=function(x){T.ccall("csmFree",null,["number"],[x])},C.initializeAmountOfMemory=function(x){T.ccall("csmInitializeAmountOfMemory",null,["number"],[x])},C}(),f=(s.AlignofMoc=64,s.AlignofModel=16,s.MocVersion_Unknown=0,s.MocVersion_30=1,s.MocVersion_33=2,s.MocVersion_40=3,s.MocVersion_42=4,s.MocVersion_50=5,s.ParameterType_Normal=0,s.ParameterType_BlendShape=1,function(){function C(){}return C.csmGetVersion=function(){return r.getVersion()},C.csmGetLatestMocVersion=function(){return r.getLatestMocVersion()},C.csmGetMocVersion=function(x,M){return r.getMocVersion(x._ptr,M.byteLength)},C}()),f=(s.Version=f,function(){function C(){}return C.csmSetLogFunction=function(x){C.logFunction=x,x=T.addFunction(C.wrapLogFunction,"vi"),r.setLogFunction(x)},C.csmGetLogFunction=function(){return C.logFunction},C.wrapLogFunction=function(x){x=T.UTF8ToString(x),C.logFunction(x)},C}()),f=(s.Logging=f,function(){function C(x){var M=r.mallocMoc(x.byteLength);M&&(new Uint8Array(T.HEAPU8.buffer,M,x.byteLength).set(new Uint8Array(x)),this._ptr=r.reviveMocInPlace(M,x.byteLength),this._ptr||r.free(M))}return C.prototype.hasMocConsistency=function(x){var M=r.mallocMoc(x.byteLength);if(M)return new Uint8Array(T.HEAPU8.buffer,M,x.byteLength).set(new Uint8Array(x)),x=r.hasMocConsistency(M,x.byteLength),r.free(M),x},C.fromArrayBuffer=function(x){return x&&(x=new C(x))._ptr?x:null},C.prototype._release=function(){r.free(this._ptr),this._ptr=0},C}()),f=(s.Moc=f,function(){function C(x){this._ptr=r.mallocModelAndInitialize(x._ptr),this._ptr&&(this.parameters=new n(this._ptr),this.parts=new o(this._ptr),this.drawables=new h(this._ptr),this.canvasinfo=new i(this._ptr))}return C.fromMoc=function(x){return x=new C(x),x._ptr?x:null},C.prototype.update=function(){r.updateModel(this._ptr)},C.prototype.release=function(){r.free(this._ptr),this._ptr=0},C}()),i=(s.Model=f,function(C){var x,M,D,k,U,G,X;C&&(D=(x=new Float32Array(2)).length*x.BYTES_PER_ELEMENT,M=r.malloc(D),(M=new Uint8Array(T.HEAPU8.buffer,M,D)).set(new Uint8Array(x.buffer)),U=(D=new Float32Array(2)).length*D.BYTES_PER_ELEMENT,k=r.malloc(U),(k=new Uint8Array(T.HEAPU8.buffer,k,U)).set(new Uint8Array(D.buffer)),G=(U=new Float32Array(1)).length*U.BYTES_PER_ELEMENT,X=r.malloc(G),(X=new Uint8Array(T.HEAPU8.buffer,X,G)).set(new Uint8Array(U.buffer)),r.readCanvasInfo(C,M.byteOffset,k.byteOffset,X.byteOffset),x=new Float32Array(M.buffer,M.byteOffset,M.length),D=new Float32Array(k.buffer,k.byteOffset,k.length),U=new Float32Array(X.buffer,X.byteOffset,X.length),this.CanvasWidth=x[0],this.CanvasHeight=x[1],this.CanvasOriginX=D[0],this.CanvasOriginY=D[1],this.PixelsPerUnit=U[0],r.free(M.byteOffset),r.free(k.byteOffset),r.free(X.byteOffset))}),n=(s.CanvasInfo=i,function(C){this.count=r.getParameterCount(C),x=r.getParameterCount(C),this.ids=new Array(x);for(var x,M,D=new Uint32Array(T.HEAPU32.buffer,r.getParameterIds(C),x),k=0;k<D.length;k++)this.ids[k]=T.UTF8ToString(D[k]);x=r.getParameterCount(C),this.minimumValues=new Float32Array(T.HEAPF32.buffer,r.getParameterMinimumValues(C),x),x=r.getParameterCount(C),this.types=new Int32Array(T.HEAP32.buffer,r.getParameterTypes(C),x),x=r.getParameterCount(C),this.maximumValues=new Float32Array(T.HEAPF32.buffer,r.getParameterMaximumValues(C),x),x=r.getParameterCount(C),this.defaultValues=new Float32Array(T.HEAPF32.buffer,r.getParameterDefaultValues(C),x),x=r.getParameterCount(C),this.values=new Float32Array(T.HEAPF32.buffer,r.getParameterValues(C),x),x=r.getParameterCount(C),this.keyCounts=new Int32Array(T.HEAP32.buffer,r.getParameterKeyCounts(C),x),x=r.getParameterCount(C),M=new Int32Array(T.HEAP32.buffer,r.getParameterKeyCounts(C),x),this.keyValues=new Array(x);for(var U=new Uint32Array(T.HEAPU32.buffer,r.getParameterKeyValues(C),x),k=0;k<U.length;k++)this.keyValues[k]=new Float32Array(T.HEAPF32.buffer,U[k],M[k])}),o=(s.Parameters=n,function(C){this.count=r.getPartCount(C),x=r.getPartCount(C),this.ids=new Array(x);for(var x,M=new Uint32Array(T.HEAPU32.buffer,r.getPartIds(C),x),D=0;D<M.length;D++)this.ids[D]=T.UTF8ToString(M[D]);x=r.getPartCount(C),this.opacities=new Float32Array(T.HEAPF32.buffer,r.getPartOpacities(C),x),x=r.getPartCount(C),this.parentIndices=new Int32Array(T.HEAP32.buffer,r.getPartParentPartIndices(C),x)}),h=(s.Parts=o,function(){function C(x){this._modelPtr=x;for(var M,D=null,k=(this.count=r.getDrawableCount(x),M=r.getDrawableCount(x),this.ids=new Array(M),new Uint32Array(T.HEAPU32.buffer,r.getDrawableIds(x),M)),U=0;U<k.length;U++)this.ids[U]=T.UTF8ToString(k[U]);M=r.getDrawableCount(x),this.constantFlags=new Uint8Array(T.HEAPU8.buffer,r.getDrawableConstantFlags(x),M),M=r.getDrawableCount(x),this.dynamicFlags=new Uint8Array(T.HEAPU8.buffer,r.getDrawableDynamicFlags(x),M),M=r.getDrawableCount(x),this.textureIndices=new Int32Array(T.HEAP32.buffer,r.getDrawableTextureIndices(x),M),M=r.getDrawableCount(x),this.drawOrders=new Int32Array(T.HEAP32.buffer,r.getDrawableDrawOrders(x),M),M=r.getDrawableCount(x),this.renderOrders=new Int32Array(T.HEAP32.buffer,r.getDrawableRenderOrders(x),M),M=r.getDrawableCount(x),this.opacities=new Float32Array(T.HEAPF32.buffer,r.getDrawableOpacities(x),M),M=r.getDrawableCount(x),this.maskCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableMaskCounts(x),M),M=r.getDrawableCount(x),this.vertexCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),M),M=r.getDrawableCount(x),this.indexCounts=new Int32Array(T.HEAP32.buffer,r.getDrawableIndexCounts(x),M),M=r.getDrawableCount(x),this.multiplyColors=new Float32Array(T.HEAPF32.buffer,r.getDrawableMultiplyColors(x),4*M),M=r.getDrawableCount(x),this.screenColors=new Float32Array(T.HEAPF32.buffer,r.getDrawableScreenColors(x),4*M),M=r.getDrawableCount(x),this.parentPartIndices=new Int32Array(T.HEAP32.buffer,r.getDrawableParentPartIndices(x),M),M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableMaskCounts(x),M),this.masks=new Array(M);for(var G=new Uint32Array(T.HEAPU32.buffer,r.getDrawableMasks(x),M),U=0;U<G.length;U++)this.masks[U]=new Int32Array(T.HEAP32.buffer,G[U],D[U]);M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),M),this.vertexPositions=new Array(M);for(var X=new Uint32Array(T.HEAPU32.buffer,r.getDrawableVertexPositions(x),M),U=0;U<X.length;U++)this.vertexPositions[U]=new Float32Array(T.HEAPF32.buffer,X[U],2*D[U]);M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableVertexCounts(x),M),this.vertexUvs=new Array(M);for(var J=new Uint32Array(T.HEAPU32.buffer,r.getDrawableVertexUvs(x),M),U=0;U<J.length;U++)this.vertexUvs[U]=new Float32Array(T.HEAPF32.buffer,J[U],2*D[U]);M=r.getDrawableCount(x),D=new Int32Array(T.HEAP32.buffer,r.getDrawableIndexCounts(x),M),this.indices=new Array(M);for(var Z=new Uint32Array(T.HEAPU32.buffer,r.getDrawableIndices(x),M),U=0;U<Z.length;U++)this.indices[U]=new Uint16Array(T.HEAPU16.buffer,Z[U],D[U])}return C.prototype.resetDynamicFlags=function(){r.resetDrawableDynamicFlags(this._modelPtr)},C}()),f=(s.Drawables=h,function(){function C(){}return C.hasBlendAdditiveBit=function(x){return(1&x)==1},C.hasBlendMultiplicativeBit=function(x){return(2&x)==2},C.hasIsDoubleSidedBit=function(x){return(4&x)==4},C.hasIsInvertedMaskBit=function(x){return(8&x)==8},C.hasIsVisibleBit=function(x){return(1&x)==1},C.hasVisibilityDidChangeBit=function(x){return(2&x)==2},C.hasOpacityDidChangeBit=function(x){return(4&x)==4},C.hasDrawOrderDidChangeBit=function(x){return(8&x)==8},C.hasRenderOrderDidChangeBit=function(x){return(16&x)==16},C.hasVertexPositionsDidChangeBit=function(x){return(32&x)==32},C.hasBlendColorDidChangeBit=function(x){return(64&x)==64},C}()),f=(s.Utils=f,function(){function C(){}return C.initializeAmountOfMemory=function(x){16777216<x&&r.initializeAmountOfMemory(x)},C}()),A=(s.Memory=f,t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,function(C){C=C||{};var x,M,D={};for(M in x=x||(C!==void 0?C:{}))x.hasOwnProperty(M)&&(D[M]=x[M]);var k,U,G,X,it=!1,J=typeof window=="object",Z=typeof importScripts=="function",it=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!J&&!Z,Q=!J&&!it&&!Z,Ar="",_t=(it?(Ar=__dirname+"/",G=function(Tt,$t){var at=Wr(Tt);return at||(k=k||require("fs"),Tt=(U=U||require("path")).normalize(Tt),at=k.readFileSync(Tt)),$t?at:at.toString()},X=function(Tt){return Ct((Tt=(Tt=G(Tt,!0)).buffer?Tt:new Uint8Array(Tt)).buffer),Tt},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(Tt){throw Tt}),process.on("unhandledRejection",Jt),x.inspect=function(){return"[Emscripten Module object]"}):Q?(typeof read<"u"&&(G=function(Tt){var $t=Wr(Tt);return $t?Fi($t):read(Tt)}),X=function(Tt){var $t;if(!($t=Wr(Tt))){if(typeof readbuffer=="function")return new Uint8Array(readbuffer(Tt));Ct(typeof($t=read(Tt,"binary"))=="object")}return $t},typeof print<"u"&&((console=typeof console>"u"?{}:console).log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)):(J||Z)&&(Z?Ar=self.location.href:document.currentScript&&(Ar=document.currentScript.src),Ar=(Ar=t||Ar).indexOf("blob:")!==0?Ar.substr(0,Ar.lastIndexOf("/")+1):"",G=function(Tt){try{var $t=new XMLHttpRequest;return $t.open("GET",Tt,!1),$t.send(null),$t.responseText}catch(at){if(Tt=Wr(Tt))return Fi(Tt);throw at}},Z)&&(X=function(Tt){try{var $t=new XMLHttpRequest;return $t.open("GET",Tt,!1),$t.responseType="arraybuffer",$t.send(null),new Uint8Array($t.response)}catch(at){if(Tt=Wr(Tt))return Tt;throw at}}),x.print||console.log.bind(console)),et=x.printErr||console.warn.bind(console);for(M in D)D.hasOwnProperty(M)&&(x[M]=D[M]);function ft(){return{exports:function(Tt,$t,at){var lt=new ArrayBuffer(8),Wt=new Int32Array(lt),be=new Float32Array(lt),de=new Float64Array(lt);function Yt(a,p){Wt[a]=p}function ze(){return de[0]}function Ye(a){de[0]=a}function Qt(a){be[0]=a}function zt(){return be[0]}lt=$t.buffer;var jt,l,w,$,L,O,N,e,H,W,rt,I,ct,j,v,St,yt,Mt,Ft,Nt,Lt,re,Zt,K,Vt,jt=new Uint8Array(lt);return(lt=function(a,p){var P,_;if(typeof Buffer>"u")for(P=atob(p),_=0;_<P.length;_++)jt[a+_]=P.charCodeAt(_);else for(P=Buffer.from(p,"base64"),_=0;_<P.length;_++)jt[a+_]=P[_]})(1024,"QW4gZXJyb3Igb2NjdXJyZWQgaW4gdGhlIGludGVycG9sYXRpb24gZm9yIGJsZW5kIHNoYXBlcy4gQ29tYmluYXRpb25Db3VudCBpcyAlZC4ACgBbQ1NNXSBbRV1XYXJwRGVmb3JtZXI6OlRyYW5zZm9ybVRhcmdldCgpIGVycm9yLiBbJWRdIHAwMT0oJS40ZiAsICUuNGYpCgBbQ1NNXSBbRV1Jbml0aWFsaXplRGVmb3JtZXJzKCk6IFVua25vd24gRGVmb3JtZXIgVHlwZS4KAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBUaGlzIG1vYzMgc2l6ZSBpcyBpbnZhbGlkLgoAW0NTTV0gW0VdJXM6ICVzCgBbQ1NNXSBbV11Sb3RhdGlvbkRlZm9ybWVyOiBOb3QgZm91bmQgdHJhbnNmb3JtZWQgRGlyZWN0aW9uLgoAW0NTTV0gW0VdVXBkYXRlRGVmb3JtZXJIaWVyYXJjaHkoKTogVW5rbm93biBEZWZvcm1lciBUeXBlLgoAJXMKACAgAE1PQzMAImFkZHJlc3MiIGlzIG51bGwuACUwMlggAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBGaWxlVHlwZSBpcyBpbnZhbGlkLgoAImFkZHJlc3MiIGFsaWdubWVudCBpcyBpbnZhbGlkLgBbQ1NNXSBbRV1jc21IYXNNb2NDb25zaXN0ZW5jeTogVGhpcyBtb2MzIHZlciBpcyBpbnZhbGlkIFt2ZXI6JWRdLgoAInNpemUiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBUaGUgQ29yZSB1bnN1cHBvcnQgbGF0ZXIgdGhhbiBtb2MzIHZlcjpbJWRdLiBUaGlzIG1vYzMgdmVyIGlzIFslZF0uCgAibW9kZWwiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUhhc01vY0NvbnNpc3RlbmN5OiBIZWFkZXIgc2VjdGlvbiBpcyBpbnZhbGlkLgoAIm91dFNpemVJblBpeGVscyIgaXMgbnVsbC4AW0NTTV0gW0VdY3NtSGFzTW9jQ29uc2lzdGVuY3k6IERhdGEgc2VjdGlvbiBpcyBpbnZhbGlkLgoAIm91dE9yaWdpbkluUGl4ZWxzIiBpcyBudWxsLgBbQ1NNXSBbRV1jc21SZXZpdmVNb2NJblBsYWNlIGlzIGZhaWxlZC4gQ29ycnVwdGVkICBtb2MzIGZpbGUuCgAib3V0UGl4ZWxzUGVyVW5pdCIgaXMgbnVsbC4AW0NTTV0gW0VdY3NtUmV2aXZlTW9jSW5QbGFjZSBpcyBmYWlsZWQuIFRoZSBDb3JlIHVuc3VwcG9ydCBsYXRlciB0aGFuIG1vYzMgdmVyOlslZF0uIFRoaXMgbW9jMyB2ZXIgaXMgWyVkXS4KACJtb2MiIGlzIGludmFsaWQuAFtDU01dIFtFXWNzbUdldE1vY1ZlcnNpb24gaXMgZmFpbGVkLiBDb3JydXB0ZWQgbW9jMyBmaWxlLgoAInNpemUiIGlzIGludmFsaWQATGl2ZTJEIEN1YmlzbSBTREsgQ29yZSBWZXJzaW9uICVkLiVkLiVkAGNzbUdldE1vY1ZlcnNpb24AY3NtSGFzTW9jQ29uc2lzdGVuY3kAY3NtUmV2aXZlTW9jSW5QbGFjZQBjc21SZWFkQ2FudmFzSW5mbwBjc21HZXRTaXplb2ZNb2RlbABjc21Jbml0aWFsaXplTW9kZWxJblBsYWNlAGNzbVVwZGF0ZU1vZGVsAGNzbUdldFBhcmFtZXRlckNvdW50AGNzbUdldFBhcmFtZXRlcklkcwBjc21HZXRQYXJhbWV0ZXJUeXBlcwBjc21HZXRQYXJhbWV0ZXJNaW5pbXVtVmFsdWVzAGNzbUdldFBhcmFtZXRlck1heGltdW1WYWx1ZXMAY3NtR2V0UGFyYW1ldGVyRGVmYXVsdFZhbHVlcwBjc21HZXRQYXJhbWV0ZXJWYWx1ZXMAY3NtR2V0UGFydENvdW50AGNzbUdldFBhcnRJZHMAY3NtR2V0UGFydE9wYWNpdGllcwBjc21HZXRQYXJ0UGFyZW50UGFydEluZGljZXMAY3NtR2V0RHJhd2FibGVDb3VudABjc21HZXREcmF3YWJsZUlkcwBjc21HZXREcmF3YWJsZUNvbnN0YW50RmxhZ3MAY3NtR2V0RHJhd2FibGVEeW5hbWljRmxhZ3MAY3NtR2V0RHJhd2FibGVUZXh0dXJlSW5kaWNlcwBjc21HZXREcmF3YWJsZURyYXdPcmRlcnMAY3NtR2V0RHJhd2FibGVSZW5kZXJPcmRlcnMAY3NtR2V0RHJhd2FibGVPcGFjaXRpZXMAY3NtR2V0RHJhd2FibGVNYXNrQ291bnRzAGNzbUdldERyYXdhYmxlTWFza3MAY3NtR2V0RHJhd2FibGVWZXJ0ZXhDb3VudHMAY3NtR2V0RHJhd2FibGVWZXJ0ZXhQb3NpdGlvbnMAY3NtR2V0RHJhd2FibGVWZXJ0ZXhVdnMAY3NtR2V0RHJhd2FibGVJbmRleENvdW50cwBjc21HZXREcmF3YWJsZUluZGljZXMAY3NtR2V0RHJhd2FibGVNdWx0aXBseUNvbG9ycwBjc21HZXREcmF3YWJsZVNjcmVlbkNvbG9ycwBjc21HZXREcmF3YWJsZVBhcmVudFBhcnRJbmRpY2VzAGNzbVJlc2V0RHJhd2FibGVEeW5hbWljRmxhZ3MAY3NtR2V0UGFyYW1ldGVyS2V5Q291bnRzAGNzbUdldFBhcmFtZXRlcktleVZhbHVlcw=="),lt(3228,"Cg=="),lt(3267,"//////8="),lt(3336,"LSsgICAwWDB4AChudWxsKQ=="),lt(3360,"EQAKABEREQAAAAAFAAAAAAAACQAAAAAL"),lt(3392,"EQAPChEREQMKBwABEwkLCwAACQYLAAALAAYRAAAAERER"),lt(3441,"Cw=="),lt(3450,"EQAKChEREQAKAAACAAkLAAAACQALAAAL"),lt(3499,"DA=="),lt(3511,"DAAAAAAMAAAAAAkMAAAAAAAMAAAM"),lt(3557,"Dg=="),lt(3569,"DQAAAAQNAAAAAAkOAAAAAAAOAAAO"),lt(3615,"EA=="),lt(3627,"DwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhIS"),lt(3682,"EgAAABISEgAAAAAAAAk="),lt(3731,"Cw=="),lt(3743,"CgAAAAAKAAAAAAkLAAAAAAALAAAL"),lt(3789,"DA=="),lt(3801,"DAAAAAAMAAAAAAkMAAAAAAAMAAAMAAAwMTIzNDU2Nzg5QUJDREVGLTBYKzBYIDBYLTB4KzB4IDB4AGluZgBJTkYAbmFuAE5BTgAuAAAAAKgaAAAAAAAAAwAAAAQAAAAEAAAABgAAAIP5ogBETm4A/CkVANFXJwDdNPUAYtvAADyZlQBBkEMAY1H+ALveqwC3YcUAOm4kANJNQgBJBuAACeouAByS0QDrHf4AKbEcAOg+pwD1NYIARLsuAJzphAC0JnAAQX5fANaROQBTgzkAnPQ5AItfhAAo+b0A+B87AN7/lwAPmAUAES/vAApaiwBtH20Az342AAnLJwBGT7cAnmY/AC3qXwC6J3UA5evHAD178QD3OQcAklKKAPtr6gAfsV8ACF2NADADVgB7/EYA8KtrACC8zwA29JoA46kdAF5hkQAIG+YAhZllAKAUXwCNQGgAgNj/ACdzTQAGBjEAylYVAMmocwB74mAAa4zAABnERwDNZ8MACejcAFmDKgCLdsQAphyWAESv3QAZV9EApT4FAAUH/wAzfj8AwjLoAJhP3gC7fTIAJj3DAB5r7wCf+F4ANR86AH/yygDxhx0AfJAhAGokfADVbvoAMC13ABU7QwC1FMYAwxmdAK3EwgAsTUEADABdAIZ9RgDjcS0Am8aaADNiAAC00nwAtKeXADdV1QDXPvYAoxAYAE12/ABknSoAcNerAGN8+AB6sFcAFxXnAMBJVgA71tkAp4Q4ACQjywDWincAWlQjAAAfuQDxChsAGc7fAJ8x/wBmHmoAmVdhAKz7RwB+f9gAImW3ADLoiQDmv2AA78TNAGw2CQBdP9QAFt7XAFg73gDem5IA0iIoACiG6ADiWE0AxsoyAAjjFgDgfcsAF8BQAPMdpwAY4FsALhM0AIMSYgCDSAEA9Y5bAK2wfwAe6fIASEpDABBn0wCq3dgArl9CAGphzgAKKKQA05m0AAam8gBcd38Ao8KDAGE8iACKc3gAr4xaAG/XvQAtpmMA9L/LAI2B7wAmwWcAVcpFAMrZNgAoqNIAwmGNABLJdwAEJhQAEkabAMRZxADIxUQATbKRAAAX8wDUQ60AKUnlAP3VEAAAvvwAHpTMAHDO7gATPvUA7PGAALPnwwDH+CgAkwWUAMFxPgAuCbMAC0XzAIgSnACrIHsALrWfAEeSwgB7Mi8ADFVtAHKnkABr5x8AMcuWAHkWSgBBeeIA9N+JAOiUlwDi5oQAmTGXAIjtawBfXzYAu/0OAEiatABnpGwAcXJCAI1dMgCfFbgAvOUJAI0xJQD3dDkAMAUcAA0MAQBLCGgALO5YAEeqkAB05wIAvdYkAPd9pgBuSHIAnxbvAI6UpgC0kfYA0VNRAM8K8gAgmDMA9Ut+ALJjaADdPl8AQF0DAIWJfwBVUikAN2TAAG3YEAAySDIAW0x1AE5x1ABFVG4ACwnBACr1aQAUZtUAJwedAF0EUAC0O9sA6nbFAIf5FwBJa30AHSe6AJZpKQDGzKwArRRUAJDiagCI2YkALHJQAASkvgB3B5QA8zBwAAD8JwDqcagAZsJJAGTgPQCX3YMAoz+XAEOU/QANhowAMUHeAJI5nQDdcIwAF7fnAAjfOwAVNysAXICgAFqAkwAQEZIAD+jYAGyArwDb/0sAOJAPAFkYdgBipRUAYcu7AMeJuQAQQL0A0vIEAEl1JwDrtvYA2yK7AAoUqgCJJi8AZIN2AAk7MwAOlBoAUTqqAB2jwgCv7a4AXCYSAG3CTQAtepwAwFaXAAM/gwAJ8PYAK0CMAG0xmQA5tAcADCAVANjDWwD1ksQAxq1LAE7KpQCnN80A5qk2AKuSlADdQmgAGWPeAHaM7wBoi1IA/Ns3AK6hqwDfFTEAAK6hAAz72gBkTWYA7QW3ACllMABXVr8AR/86AGr5uQB1vvMAKJPfAKuAMABmjPYABMsVAPoiBgDZ5B0APbOkAFcbjwA2zQkATkLpABO+pAAzI7UA8KoaAE9lqADSwaUACz8PAFt4zQAj+XYAe4sEAIkXcgDGplMAb27iAO/rAACbSlgAxNq3AKpmugB2z88A0QIdALHxLQCMmcEAw613AIZI2gD3XaAAxoD0AKzwLwDd7JoAP1y8ANDebQCQxx8AKtu2AKMlOgAAr5oArVOTALZXBAApLbQAS4B+ANoHpwB2qg4Ae1mhABYSKgDcty0A+uX9AInb/gCJvv0A5HZsAAap/AA+gHAAhW4VAP2H/wAoPgcAYWczACoYhgBNveoAs+evAI9tbgCVZzkAMb9bAITXSAAw3xYAxy1DACVhNQDJcM4AMMu4AL9s/QCkAKIABWzkAFrdoAAhb0cAYhLSALlchABwYUkAa1bgAJlSAQBQVTcAHtW3ADPxxAATbl8AXTDkAIUuqQAdssMAoTI2AAi3pADqsdQAFvchAI9p5AAn/3cADAOAAI1ALQBPzaAAIKWZALOi0wAvXQoAtPlCABHaywB9vtAAm9vBAKsXvQDKooEACGpcAC5VFwAnAFUAfxTwAOEHhgAUC2QAlkGNAIe+3gDa/SoAayW2AHuJNAAF8/4Aub+eAGhqTwBKKqgAT8RaAC34vADXWpgA9MeVAA1NjQAgOqYApFdfABQ/sQCAOJUAzCABAHHdhgDJ3rYAv2D1AE1lEQABB2sAjLCsALLA0ABRVUgAHvsOAJVywwCjBjsAwEA1AAbcewDgRcwATin6ANbKyADo80EAfGTeAJtk2ADZvjEApJfDAHdY1ABp48UA8NoTALo6PABGGEYAVXVfANK99QBuksYArC5dAA5E7QAcPkIAYcSHACn96QDn1vMAInzKAG+RNQAI4MUA/9eNAG5q4gCw/cYAkwjBAHxddABrrbIAzW6dAD5yewDGEWoA98+pAClz3wC1yboAtwBRAOKyDQB0uiQA5X1gAHTYigANFSwAgRgMAH5mlAABKRYAn3p2AP39vgBWRe8A2X42AOzZEwCLurkAxJf8ADGoJwDxbsMAlMU2ANioVgC0qLUAz8wOABKJLQBvVzQALFaJAJnO4wDWILkAa16qAD4qnAARX8wA/QtKAOH0+wCOO20A4oYsAOnUhAD8tKkA7+7RAC41yQAvOWEAOCFEABvZyACB/AoA+0pqAC8c2ABTtIQATpmMAFQizAAqVdwAwMbWAAsZlgAacLgAaZVkACZaYAA/Uu4AfxEPAPS1EQD8y/UANLwtADS87gDoXcwA3V5gAGeOmwCSM+8AyRe4AGFYmwDhV7wAUYPGANg+EADdcUgALRzdAK8YoQAhLEYAWfPXANl6mACeVMAAT4b6AFYG/ADlea4AiSI2ADitIgBnk9wAVeiqAIImOADK55sAUQ2kAJkzsQCp1w4AaQVIAGWy8AB/iKcAiEyXAPnRNgAhkrMAe4JKAJjPIQBAn9wA3EdVAOF0OgBn60IA/p3fAF7UXwB7Z6QAuqx6AFX2ogAriCMAQbpVAFluCAAhKoYAOUeDAInj5gDlntQASftAAP9W6QAcD8oAxVmKAJT6KwDTwcUAD8XPANtargBHxYYAhUNiACGGOwAseZQAEGGHACpMewCALBoAQ78SAIgmkAB4PIkAqMTkAOXbewDEOsIAJvTqAPdnigANkr8AZaMrAD2TsQC9fAsApFHcACfdYwBp4d0AmpQZAKgplQBozigACe20AESfIABOmMoAcIJjAH58IwAPuTIAp/WOABRW5wAh8QgAtZ0qAG9+TQClGVEAtfmrAILf1gCW3WEAFjYCAMQ6nwCDoqEAcu1tADmNegCCuKkAazJcAEYnWwAANO0A0gB3APz0VQABWU0A4HGA"),lt(6675,"QPsh+T8AAAAALUR0PgAAAICYRvg8AAAAYFHMeDsAAACAgxvwOQAAAEAgJXo4AAAAgCKC4zYAAAAAHfNpNThj7T7aD0k/Xph7P9oPyT9pN6wxaCEiM7QPFDNoIaIz2w9JP9sPSb/kyxZA5MsWwAAAAAAAAACA2w9JQNsPScAAAIA/AADAPwAAAADcz9E1AAAAAADAFT8="),lt(6824,"BQ=="),lt(6836,"DQ=="),lt(6860,"DgAAAA8AAABYHAAAAAQ="),lt(6884,"AQ=="),lt(6899,"Cv////8="),lt(7156,"gCA="),l={Int8Array,Int16Array,Int32Array,Uint8Array,Uint16Array,Uint32Array,Float32Array,Float64Array,NaN:NaN,Infinity:1/0,Math},w=$t.buffer,$=(lt=Tt).memory,L=at,O=new l.Int8Array(w),N=new l.Int16Array(w),e=new l.Int32Array(w),H=new l.Uint8Array(w),W=new l.Uint16Array(w),rt=new l.Uint32Array(w),I=new l.Float32Array(w),ct=new l.Float64Array(w),j=l.Math.imul,v=l.Math.fround,St=l.Math.abs,yt=l.Math.clz32,Mt=l.Math.min,l.Math.max,Ft=l.Math.floor,l.Math.ceil,l.Math.sqrt,lt.abort,l.NaN,Nt=l.Infinity,Lt=lt.a,re=lt.b,Zt=lt.c,K=5251744,Vt=0,L[1]=function(a,p,P,_,c){a|=0,p|=0,P|=0,_|=0,c|=0;var E,u,d,g,y,b,S,R,F,B,V,z,q,tt,ut,mt,Bt,Ht,ce,Ae,Ue,He,pe,tr,Ot=0,fe=v(0),we=v(0),ke=0,Ne=v(0),er=v(0),ar=v(0),wr=v(0),Tr=v(0),Er=v(0),Cr=v(0),Sr=v(0),Rr=v(0),Or=v(0),Nr=v(0),Jr=v(0),ti=v(0),xi=v(0),bi=v(0),Oi=v(0),Ni=v(0),es=v(0),rs=v(0),d2=(v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),0);if(K=tr=K-32|0,1<=(0|c))for(E=e[16+(e[a+308>>2]+(p<<5)|0)>>2],Ot=e[a+60>>2]+j(E,24)|0,p=(u=e[Ot+8>>2])+-1|0,z=(y=e[Ot+4>>2])+-1|0,q=F=(E=e[e[a+152>>2]+(E<<2)>>2])+(u<<3)|0,tt=B=E+((R=j(y,d=u+1|0))<<3)|0,ut=V=E+(u+R<<3)|0,pe=e[Ot+12>>2],b=v(0|y),S=v(0|u),a=0;ar=I[4+(Ot=(g=a<<3)+P|0)>>2],we=v(ar*b),wr=I[Ot>>2],fe=v(wr*S),Ot=ar>=v(1),we=!(ar<v(0)^1)||Ot|wr>=v(1)|wr<v(0)?(d2||(Rr=I[4+ut>>2],mt=I[E+4>>2],Tr=v(Rr-mt),Bt=I[4+q>>2],Ht=I[4+tt>>2],Er=v(Bt-Ht),Or=v(v(Tr-Er)*v(.5)),ce=I[V>>2],Ae=I[E>>2],Cr=v(ce-Ae),Ue=I[F>>2],He=I[B>>2],Sr=v(Ue-He),Nr=v(v(Cr-Sr)*v(.5)),Er=v(v(Er+Tr)*v(.5)),Sr=v(v(Sr+Cr)*v(.5)),d2=1,Tr=v(v(v(v(v(mt+Bt)+Ht)+Rr)*v(.25))-v(Tr*v(.5))),Cr=v(v(v(v(v(Ae+Ue)+He)+ce)*v(.25))-v(Cr*v(.5)))),ar<v(3)^1|wr>v(-2)^1|(wr<v(3)^1|ar>v(-2)^1)?(I[_+g>>2]=v(ar*Nr)+v(v(wr*Sr)+Cr),fe=v(ar*Or),v(v(wr*Er)+Tr)):(wr<=v(0)?ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ne=v(v(wr+v(2))*v(.5)),fe=v(Or+Or),es=v(Tr-fe),we=v(Nr+Nr),rs=v(Cr-we),Oi=v(Tr-v(Er+Er)),Jr=v(Oi-fe),Ni=v(Cr-v(Sr+Sr)),ti=v(Ni-we),xi=I[E+4>>2],bi=I[E>>2]):Ot?(fe=v(Or*v(3)),we=v(Tr-v(Er+Er)),Oi=v(fe+we),Jr=v(Nr*v(3)),ti=v(Cr-v(Sr+Sr)),Ni=v(Jr+ti),er=v(v(ar+v(-1))*v(.5)),Ne=v(v(wr+v(2))*v(.5)),xi=v(fe+Tr),bi=v(Jr+Cr),Jr=v(Or+we),ti=v(Nr+ti),es=I[4+tt>>2],rs=I[B>>2]):(fe=v(Tr-v(Er+Er)),Ot=z,ke=v(St(we))<v(2147483648)?~~we:-2147483648,er=v(0|(Ot=(0|ke)==(0|y)?Ot:ke)),Ne=v(er/b),Jr=v(v(Ne*Or)+fe),Rr=v(Ne*Nr),Ne=v(Cr-v(Sr+Sr)),ti=v(Rr+Ne),ar=v(v(0|(ke=Ot+1|0))/b),Oi=v(v(ar*Or)+fe),Ni=v(v(ar*Nr)+Ne),Ne=v(v(wr+v(2))*v(.5)),er=v(we-er),Ot=E+(j(Ot,d)<<3)|0,es=I[Ot+4>>2],rs=I[Ot>>2],Ot=E+(j(ke,d)<<3)|0,xi=I[Ot+4>>2],bi=I[Ot>>2]):wr>=v(1)?ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ne=v(v(wr+v(-1))*v(.5)),fe=v(Or+Or),Jr=v(v(Er+Tr)-fe),we=v(Nr+Nr),ti=v(v(Sr+Cr)-we),xi=v(v(Er*v(3))+Tr),es=v(xi-fe),bi=v(v(Sr*v(3))+Cr),rs=v(bi-we),Oi=I[4+q>>2],Ni=I[F>>2]):Ot?(fe=v(Or*v(3)),Oi=v(fe+v(Er+Tr)),we=v(Nr*v(3)),Ni=v(we+v(Sr+Cr)),Rr=fe,fe=v(v(Er*v(3))+Tr),xi=v(Rr+fe),Rr=we,we=v(v(Sr*v(3))+Cr),bi=v(Rr+we),er=v(v(ar+v(-1))*v(.5)),Ne=v(v(wr+v(-1))*v(.5)),es=v(Or+fe),rs=v(Nr+we),Jr=I[4+ut>>2],ti=I[V>>2]):(fe=v(v(Er*v(3))+Tr),Ot=z,ke=v(St(we))<v(2147483648)?~~we:-2147483648,er=v(0|(Ot=(0|ke)==(0|y)?Ot:ke)),Ne=v(er/b),es=v(v(Ne*Or)+fe),Rr=v(Ne*Nr),Ne=v(v(Sr*v(3))+Cr),rs=v(Rr+Ne),ar=v(v(0|(ke=Ot+1|0))/b),xi=v(v(ar*Or)+fe),bi=v(v(ar*Nr)+Ne),Ne=v(v(wr+v(-1))*v(.5)),er=v(we-er),Ot=E+(j(Ot,d)+u<<3)|0,Jr=I[Ot+4>>2],ti=I[Ot>>2],Ot=E+(j(ke,d)+u<<3)|0,Oi=I[Ot+4>>2],Ni=I[Ot>>2]):ar<=v(0)?(er=v(v(ar+v(2))*v(.5)),Ot=p,ke=v(St(we=fe))<v(2147483648)?~~fe:-2147483648,fe=v(0|(Ot=(0|ke)==(0|u)?Ot:ke)),Ne=v(we-fe),fe=v(fe/S),we=v(Or+Or),Jr=v(v(v(fe*Er)+Tr)-we),Rr=v(v(fe*Sr)+Cr),fe=v(Nr+Nr),ti=v(Rr-fe),ar=v(v(0|(ke=Ot+1|0))/S),es=v(v(v(ar*Er)+Tr)-we),rs=v(v(v(ar*Sr)+Cr)-fe),Oi=I[4+(Ot=E+(Ot<<3)|0)>>2],Ni=I[Ot>>2],xi=I[4+(Ot=E+(ke<<3)|0)>>2],bi=I[Ot>>2]):Ot?(Rr=we=v(Or*v(3)),Ot=p,ke=v(St(fe))<v(2147483648)?~~fe:-2147483648,Ne=v(0|(Ot=(0|ke)==(0|u)?Ot:ke)),er=v(Ne/S),Oi=v(Rr+v(v(er*Er)+Tr)),wr=v(Nr*v(3)),Ni=v(wr+v(v(er*Sr)+Cr)),Rr=we,we=v(v(0|(ke=Ot+1|0))/S),xi=v(Rr+v(v(we*Er)+Tr)),bi=v(wr+v(v(we*Sr)+Cr)),er=v(v(ar+v(-1))*v(.5)),Ne=v(fe-Ne),Jr=I[4+(Ot=E+(Ot+R<<3)|0)>>2],ti=I[Ot>>2],es=I[4+(Ot=E+(ke+R<<3)|0)>>2],rs=I[Ot>>2]):(ct[16+tr>>3]=ar,e[tr>>2]=a,ct[8+tr>>3]=wr,Ut(4,1107,tr)),v(Ne+er)<=v(1)?(I[_+g>>2]=v(ti+v(v(rs-ti)*Ne))+v(v(Ni-ti)*er),fe=v(Jr+v(v(es-Jr)*Ne)),v(v(Oi-Jr)*er)):(fe=v(v(1)-Ne),we=v(v(1)-er),I[_+g>>2]=v(bi+v(v(Ni-bi)*fe))+v(v(rs-bi)*we),fe=v(xi+v(v(Oi-xi)*fe)),v(v(es-xi)*we)))):(Ot=v(St(Rr=we))<v(2147483648)?~~we:-2147483648,er=v(Rr-v(0|Ot)),ke=v(St(we=fe))<v(2147483648)?~~fe:-2147483648,Ne=v(we-v(0|ke)),Ot=ke+j(Ot,d)|0,pe?(fe=v(v(1)-er),we=v(v(1)-Ne),ke=E+(Ot<<3)|0,Ot=E+(Ot+d<<3)|0,I[_+g>>2]=v(v(v(fe*v(we*I[ke>>2]))+v(fe*v(Ne*I[ke+8>>2])))+v(er*v(we*I[Ot>>2])))+v(er*v(Ne*I[Ot+8>>2])),fe=v(v(v(fe*v(we*I[ke+4>>2]))+v(fe*v(Ne*I[ke+12>>2])))+v(er*v(we*I[Ot+4>>2]))),v(er*v(Ne*I[Ot+12>>2]))):v(Ne+er)<=v(1)?(fe=v(v(v(1)-Ne)-er),ke=E+(Ot<<3)|0,Ot=E+(Ot+d<<3)|0,I[_+g>>2]=v(v(fe*I[ke>>2])+v(Ne*I[ke+8>>2]))+v(er*I[Ot>>2]),fe=v(v(fe*I[ke+4>>2])+v(Ne*I[ke+12>>2])),v(er*I[Ot+4>>2])):(fe=v(v(Ne+v(-1))+er),ke=E+(Ot+d<<3)|0,we=v(v(1)-Ne),ar=v(v(1)-er),Ot=E+(Ot<<3)|0,I[_+g>>2]=v(v(fe*I[ke+8>>2])+v(we*I[ke>>2]))+v(ar*I[Ot+8>>2]),fe=v(v(fe*I[ke+12>>2])+v(we*I[ke+4>>2])),v(ar*I[Ot+12>>2]))),I[4+(_+g|0)>>2]=fe+we,(0|c)!=(0|(a=a+1|0)););K=32+tr|0},L[2]=function(a,p){a|=0,p|=0;var b=0,P=0,_=0,y=0,S=0,c=v(0),E=0,u=0,d=(v(0),0),g=0,y=e[a+320>>2],b=e[a+316>>2],S=e[a+308>>2];(0|(P=e[8+(_=S+(p<<5)|0)>>2]))==-1?(e[(g=b)+(b=p<<2)>>2]=e[e[a+148>>2]+(e[_+16>>2]<<2)>>2],e[b+y>>2]=1065353216):(E=e[_+16>>2],u=e[e[a+152>>2]+(E<<2)>>2],L[e[24+(S+(P<<5)|0)>>2]](a,P,u,u,e[16+(e[a+60>>2]+j(E,24)|0)>>2]),c=I[e[a+148>>2]+(e[_+16>>2]<<2)>>2],_=e[_+8>>2]<<2,I[(P=p<<2)+b>>2]=c*I[_+b>>2],e[P+y>>2]=e[_+y>>2]),4<=H[e[a>>2]+4|0]&&(y=p<<2,b=e[a+308>>2]+(p<<5)|0,P=e[b+16>>2]<<2,_=e[a+328>>2],p=e[a+324>>2],(0|(S=e[b+8>>2]))==-1?(S=e[a+156>>2],e[(b=y<<2)+p>>2]=e[S+(P<<=2)>>2],e[(E=4|b)+p>>2]=e[(u=4|P)+S>>2],e[(d=8|b)+p>>2]=e[S+(g=8|P)>>2],e[p+((y|=3)<<2)>>2]=1065353216,a=e[a+160>>2],e[b+_>>2]=e[a+P>>2],e[_+E>>2]=e[a+u>>2],e[_+d>>2]=e[a+g>>2]):(P=(u=P<<2)+e[a+156>>2]|0,I[(b=(E=y<<2)+p|0)>>2]=I[P>>2]*I[(S=(d=S<<4)+p|0)>>2],I[b+4>>2]=I[P+4>>2]*I[S+4>>2],I[b+8>>2]=I[P+8>>2]*I[S+8>>2],e[p+((y|=3)<<2)>>2]=1065353216,a=u+e[a+160>>2]|0,g=I[a>>2],c=I[(b=_+d|0)>>2],I[(p=_+E|0)>>2]=v(g+c)-v(g*c),g=I[a+4>>2],c=I[b+4>>2],I[p+4>>2]=v(g+c)-v(g*c),g=I[a+8>>2],c=I[b+8>>2],I[p+8>>2]=v(g+c)-v(g*c)),e[_+(y<<2)>>2]=1065353216)},L[3]=function(a,p,P,_,c){a|=0,p|=0,P|=0,_|=0,c|=0;var E,u,d,g,y,b=0,b=(v(0),v(0),v(0),v(0),v(0),v(0),v(0),v(0),(p=e[16+(e[a+308>>2]+(p<<5)|0)>>2])<<2),S=function(V){var z,q,tt,ut,mt=v(0);K=tt=K-16|0,Qt(V);r:if((z=2147483647&(ut=Wt[0]))>>>0<=1061752794)mt=v(1),z>>>0<964689920||(mt=ve(+V));else if(z>>>0<=1081824209)q=+V,mt=1075235812<=z>>>0?v(-ve(((0|ut)<0?3.141592653589793:-3.141592653589793)+q)):me((0|ut)<=-1?1.5707963267948966+q:1.5707963267948966-q);else if(z>>>0<=1088565717)mt=1085271520<=z>>>0?ve(+V+((0|ut)<0?6.283185307179586:-6.283185307179586)):me((0|ut)<=-1?-4.71238898038469-+V:+V-4.71238898038469);else if(mt=v(V-V),!(2139095040<=z>>>0))if((z=3&Qe(V,8+tt|0))>>>0<=2){switch(z-1|0){default:mt=ve(ct[8+tt>>3]);break r;case 0:mt=me(-ct[8+tt>>3]);break r;case 1:}mt=v(-ve(ct[8+tt>>3]))}else mt=me(ct[8+tt>>3]);return K=16+tt|0,mt}(B=v(v(v(I[4+(e[a+168>>2]+j(p,12)|0)>>2]+I[b+e[a+284>>2]>>2])*v(3.1415927410125732))/v(180))),R=I[b+e[a+272>>2]>>2],F=e[b+e[a+292>>2]>>2],B=function(V){var z,q,tt,ut=0;K=q=K-16|0,Qt(V);r:if((z=2147483647&(tt=Wt[0]))>>>0<=1061752794)z>>>0<964689920||(V=me(+V));else if(z>>>0<=1081824209)ut=+V,V=z>>>0<=1075235811?(0|tt)<=-1?v(-ve(ut+1.5707963267948966)):ve(ut+-1.5707963267948966):me(-(((0|tt)<0?3.141592653589793:-3.141592653589793)+ut));else if(z>>>0<=1088565717)ut=+V,V=z>>>0<=1085271519?(0|tt)<=-1?ve(ut+4.71238898038469):v(-ve(ut+-4.71238898038469)):me(((0|tt)<0?6.283185307179586:-6.283185307179586)+ut);else if(2139095040<=z>>>0)V=v(V-V);else if((z=3&Qe(V,8+q|0))>>>0<=2){switch(z-1|0){default:V=me(ct[8+q>>3]);break r;case 0:V=ve(ct[8+q>>3]);break r;case 1:}V=me(-ct[8+q>>3])}else V=v(-ve(ct[8+q>>3]));return K=16+q|0,V}(B);if((p=0)<(0|c))for(S=v(R*S),u=v(F?-1:1),g=v(S*u),E=e[b+e[a+288>>2]>>2]?v(-1):v(1),y=v(v(R*B)*E),S=v(S*E),R=v(v(R*v(-B))*u),B=I[b+e[a+280>>2]>>2],u=I[b+e[a+276>>2]>>2];b=(a=p<<3)+_|0,E=I[(a=a+P|0)>>2],d=I[a+4>>2],I[b+4>>2]=B+v(v(y*E)+v(g*d)),I[b>>2]=u+v(v(S*E)+v(R*d)),(0|c)!=(0|(p=p+1|0)););},L[4]=function(a,p){a|=0,p|=0;var P,_,c,E,u,d,g=0,y=0,b=0,S=v(0),R=0,F=0,B=v(0),V=0,z=0,q=0;if(v(0),v(0),v(0),v(0),K=d=K+-64|0,V=e[a+320>>2],z=e[a+316>>2],y=e[a+308>>2],(0|(R=e[8+(b=y+(p<<5)|0)>>2]))==-1)g=e[b+16>>2]<<2,e[(y=p<<2)+z>>2]=e[g+e[a+268>>2]>>2],e[y+V>>2]=e[g+e[a+272>>2]>>2];else{g=e[b+16>>2]<<2,q=e[g+e[a+276>>2]>>2],e[24+d>>2]=q,g=e[g+e[a+280>>2]>>2],e[28+d>>2]=g,e[16+d>>2]=0,_=e[12+(F=y+(R<<5)|0)>>2]==1?v(-10):v(-.10000000149011612),I[20+d>>2]=_,e[60+d>>2]=g,e[56+d>>2]=q,L[e[F+24>>2]](a,R,56+d|0,48+d|0,1),S=v(1),y=9;r:{for(;;){if(g=y,B=v(S*v(0)),I[32+d>>2]=B+I[56+d>>2],P=v(_*S),I[36+d>>2]=P+I[60+d>>2],L[e[F+24>>2]](a,R,32+d|0,40+d|0,1),c=v(I[44+d>>2]-I[52+d>>2]),I[44+d>>2]=c,E=v(I[40+d>>2]-I[48+d>>2]),I[40+d>>2]=E,c!=v(0)||E!=v(0)){y=e[44+d>>2],e[8+d>>2]=e[40+d>>2],e[12+d>>2]=y;break r}if(I[32+d>>2]=I[56+d>>2]-B,I[36+d>>2]=I[60+d>>2]-P,L[e[F+24>>2]](a,R,32+d|0,40+d|0,1),B=v(I[40+d>>2]-I[48+d>>2]),I[40+d>>2]=B,P=v(I[44+d>>2]-I[52+d>>2]),(I[44+d>>2]=P)!=v(0)||B!=v(0)){I[12+d>>2]=-P,I[8+d>>2]=-B;break r}if(y=g+-1|0,S=v(S*v(.10000000149011612)),!g)break}Ut(3,1311,0)}S=function(tt,ut){var mt=v(0);if((mt=v(Bi(I[4+tt>>2],I[tt>>2])-Bi(I[4+ut>>2],I[ut>>2])))<v(-3.1415927410125732))for(;(mt=v(mt+v(6.2831854820251465)))<v(-3.1415927410125732););if(mt>v(3.1415927410125732))for(;(mt=v(mt+v(-6.2831854820251465)))>v(3.1415927410125732););return mt}(16+d|0,8+d|0),L[e[F+24>>2]](a,e[b+8>>2],24+d|0,24+d|0,1),y=e[b+16>>2]<<2,e[y+e[a+276>>2]>>2]=e[24+d>>2],e[y+e[a+280>>2]>>2]=e[28+d>>2],g=y+e[a+284>>2]|0,I[g>>2]=I[g>>2]+v(v(S*v(-180))/v(3.1415927410125732)),b=e[b+8>>2]<<2,I[(g=p<<2)+z>>2]=I[y+e[a+268>>2]>>2]*I[b+z>>2],y=y+e[a+272>>2]|0,S=v(I[y>>2]*I[b+V>>2]),I[g+V>>2]=S,I[y>>2]=S}4<=H[e[a>>2]+4|0]&&(g=p<<2,b=e[a+308>>2]+(p<<5)|0,R=e[b+16>>2]<<2,y=e[a+328>>2],p=e[a+324>>2],(0|(F=e[b+8>>2]))==-1?(F=e[a+296>>2],e[(b=g<<2)+p>>2]=e[F+(R<<=2)>>2],e[(V=4|b)+p>>2]=e[(z=4|R)+F>>2],e[(q=8|b)+p>>2]=e[F+(u=8|R)>>2],e[p+((g|=3)<<2)>>2]=1065353216,a=e[a+300>>2],e[y+b>>2]=e[a+R>>2],e[y+V>>2]=e[a+z>>2],e[y+q>>2]=e[a+u>>2]):(R=(z=R<<2)+e[a+296>>2]|0,I[(b=(V=g<<2)+p|0)>>2]=I[R>>2]*I[(F=(q=F<<4)+p|0)>>2],I[b+4>>2]=I[R+4>>2]*I[F+4>>2],I[b+8>>2]=I[R+8>>2]*I[F+8>>2],e[p+((g|=3)<<2)>>2]=1065353216,a=z+e[a+300>>2]|0,S=I[a>>2],B=I[(b=y+q|0)>>2],I[(p=y+V|0)>>2]=v(S+B)-v(S*B),S=I[a+4>>2],B=I[b+4>>2],I[p+4>>2]=v(S+B)-v(S*B),S=I[a+8>>2],B=I[b+8>>2],I[p+8>>2]=v(S+B)-v(S*B)),e[y+(g<<2)>>2]=1065353216),K=64+d|0},L[5]=function(a,p){return a|=0,p|=0,v(0),v(0),0|((a=I[a>>2])<(p=I[p>>2])?-1:p<a)},L[6]=function(a,p,P,_){a|=0,p|=0,P|=0,_|=0;var c=0,E=0,u=v(0),d=0,g=0,y=0,b=0,S=0;if(1<=(0|(d=e[a+8>>2])))for(y=e[a+12>>2],g=e[a+20>>2];I[(E=c<<2)+y>>2]=I[p+E>>2]*I[E+g>>2],(0|(c=c+1|0))<(0|d););if(!((0|(d=e[a>>2]))<1))if(y=e[a+4>>2],_)for(E=p=0;;){if(e[_>>2]){if((0|(c=e[(g=p<<2)+e[a+16>>2]>>2]))<1)u=v(0);else for(b=c+E|0,S=e[a+12>>2],u=v(0),c=E;u=v(u+I[S+(c<<2)>>2]),(0|(c=c+1|0))<(0|b););I[P+g>>2]=u}if(_=_+4|0,E=e[y+(p<<2)>>2]+E|0,!((0|(p=p+1|0))<(0|d)))break}else for(g=e[a+16>>2],p=_=0;;){if((0|(c=e[(E=_<<2)+g>>2]))<=0)u=v(0);else for(b=p+c|0,S=e[a+12>>2],u=v(0),c=p;u=v(u+I[S+(c<<2)>>2]),(0|(c=c+1|0))<(0|b););if(I[P+E>>2]=u,p=e[E+y>>2]+p|0,!((0|(_=_+1|0))<(0|d)))break}},L[7]=function(a,p,P,_){a|=0,p|=0,P|=0,_|=0;var c=0,E=v(0),u=0,d=0,g=0,y=0,b=0;if(1<=(0|(y=e[a+8>>2])))for(d=e[a+12>>2],g=e[a+20>>2];I[(u=c<<2)+d>>2]=I[p+u>>2]*I[u+g>>2],(0|(c=c+1|0))<(0|y););if(!((0|(c=e[a>>2]))<1))if(y=e[a+4>>2],_)for(u=p=0;;){if(e[_>>2]){if((0|(c=e[(d=p<<2)+e[a+16>>2]>>2]))<1)E=v(0);else for(g=c+u|0,b=e[a+12>>2],E=v(0),c=u;E=v(E+I[b+(c<<2)>>2]),(0|(c=c+1|0))<(0|g););c=P+d|0,E=v(E+v(.0010000000474974513)),d=v(St(E))<v(2147483648)?~~E:-2147483648,e[c>>2]=d,c=e[a>>2]}if(_=_+4|0,u=e[y+(p<<2)>>2]+u|0,!((0|(p=p+1|0))<(0|c)))break}else for(d=e[a+16>>2],p=_=0;;){if((0|(c=e[(u=_<<2)+d>>2]))<=0)E=v(0);else for(g=p+c|0,b=e[a+12>>2],E=v(0),c=p;E=v(E+I[b+(c<<2)>>2]),(0|(c=c+1|0))<(0|g););if(c=P+u|0,E=v(E+v(.0010000000474974513)),g=v(St(E))<v(2147483648)?~~E:-2147483648,e[c>>2]=g,p=e[u+y>>2]+p|0,!((0|(_=_+1|0))<e[a>>2]))break}},L[8]=function(a,p,P,_,c,E){a|=0,p|=0,P|=0,_|=0,c|=0,E|=0;var u,d,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=v(0),ut=0,mt=e[a>>2];if(!((0|mt)<1))if(u=c<<2,d=e[a+4>>2],E)for(;;){if(e[E>>2]&&(b=e[(g=S<<2)+e[a+16>>2]>>2],B=e[P+g>>2],y=e[_+g>>2],(g=(0|(V=j(y,c)))<1)||Ce(B,0,j(y,u)),!(g|(0|b)<1)))for(z=b+F|0,q=e[a+20>>2],g=F;;){for(tt=I[(y=g<<2)+q>>2],ut=e[p+y>>2],R=0;I[(y=(b=R<<2)+B|0)>>2]=I[y>>2]+v(tt*I[b+ut>>2]),(0|V)!=(0|(R=R+1|0)););if(!((0|(g=g+1|0))<(0|z)))break}if(E=E+4|0,F=e[(S<<2)+d>>2]+F|0,!((0|(S=S+1|0))<(0|mt)))break}else for(E=0;;){if(b=e[(S=E<<2)+e[a+16>>2]>>2],B=e[P+S>>2],y=e[_+S>>2],(g=(0|(V=j(y,c)))<1)||Ce(B,0,j(y,u)),!(g|(0|b)<=0))for(z=b+F|0,q=e[a+20>>2],g=F;;){for(tt=I[(y=g<<2)+q>>2],ut=e[p+y>>2],R=0;I[(y=(b=R<<2)+B|0)>>2]=I[y>>2]+v(tt*I[b+ut>>2]),(0|V)!=(0|(R=R+1|0)););if(!((0|(g=g+1|0))<(0|z)))break}if(F=e[S+d>>2]+F|0,!((0|(E=E+1|0))<(0|mt)))break}},L[9]=function(a){var p,P,_,c=0,E=0,u=0,d=0;if(!(e[(a|=0)+648>>2]||(0|(c=e[a+332>>2]))<1))for(P=(E=e[a+336>>2])+j(c,20)|0,c=e[a+424>>2],d=e[a+444>>2];;){if(e[c>>2]&&!((0|(u=e[E+16>>2]))<(a=1)))for(u<<=1,_=e[d>>2];I[(p=(a<<2)+_|0)>>2]=-I[p>>2],(0|(a=a+2|0))<(0|u););if(d=d+4|0,c=c+4|0,!((E=E+20|0)>>>0<P>>>0))break}},L[10]=function(a,p,P){var _;return ge(_=e[20+(a|=0)>>2],p|=0,p=(P|=0)>>>0<(p=e[a+16>>2]-_|0)>>>0?P:p),e[a+20>>2]=p+e[a+20>>2],0|P},L[11]=function(a,p,P,_,c,E){a|=0,p=+p,P|=0,_|=0,c|=0,E|=0;var u,d,g,y,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,Ae=0;if(e[44+(K=g=K-560|0)>>2]=0,Ye(+p),b=0|Wt[1],d=4294967295<Wt[0]>>>0?0:1,y=(0|b)<-1||(0|b)<=-1&&d?(Ye(p=-p),b=0|Wt[1],Wt[0],ce=1,3840):2048&c?(ce=1,3843):(ce=1&c)?3846:3841,(2146435072&b)==2146435072)We(a,32,P,V=ce+3|0,-65537&c),Fe(a,y,ce),_=E>>>5&1,Fe(a,p!=p?_?3867:3871:_?3859:3863,3);else if(p=function Ue(He,pe){var tr,Ot,fe=0;if(Ye(+He),fe=0|Wt[1],tr=0|Wt[0],(0|(fe=(Ot=fe)>>>20&2047))!=2047){if(!fe)return fe=pe,pe=He==0?0:(He=Ue(18446744073709552e3*He,pe),e[pe>>2]+-64|0),e[fe>>2]=pe,He;e[pe>>2]=fe+-1022,Yt(0,0|tr),Yt(1,-2146435073&Ot|1071644672),He=+ze()}return He}(p,44+g|0),(p+=p)!=0&&(e[44+g>>2]=e[44+g>>2]+-1),u=16+g|0,(0|(d=32|E))==97){if(mt=(ut=32&E)?9+y|0:y,!(11<_>>>0)&&(b=12-_|0)){for(Bt=8;Bt*=16,b=b+-1|0;);p=H[0|mt]==45?-(Bt+(-p-Bt)):p+Bt-Bt}for((0|u)==(0|(b=ye((R=(b=e[44+g>>2])>>31)^b+R,0,u)))&&(O[15+g|0]=48,b=15+g|0),B=2|ce,R=e[44+g>>2],O[0|(tt=b+-2|0)]=E+15,O[b+-1|0]=(0|R)<0?45:43,b=8&c,S=16+g|0;E=S,q=ut,R=St(p)<2147483648?~~p:-2147483648,O[0|S]=q|H[R+3824|0],((S=E+1|0)-(16+g|0)|0)!=1|((p=16*(p-(0|R)))==0?!(b|0<(0|_)):0)||(O[E+1|0]=46,S=E+2|0),p!=0;);We(a,32,P,V=(E=!_|(0|_)<=((S-g|0)-18|0)?((u-(16+g|0)|0)-tt|0)+S|0:2+((_+u|0)-tt|0)|0)+B|0,c),Fe(a,mt,B),We(a,48,P,V,65536^c),Fe(a,16+g|0,_=S-(16+g|0)|0),We(a,48,E-((b=_)+(_=u-tt|0)|0)|0,0,0),Fe(a,tt,_)}else{for(b=(0|_)<0,p==0?F=e[44+g>>2]:(F=e[44+g>>2]+-28|0,e[44+g>>2]=F,p*=268435456),z=b?6:_,R=ut=(0|F)<0?48+g|0:336+g|0;R=(_=R)+4|0,(p=1e9*(p-((e[_>>2]=b=p<4294967296&0<=p?~~p>>>0:0)>>>0)))!=0;);if((0|F)<1)b=R,S=ut;else for(S=ut;;){if(tt=(0|F)<29?F:29,!((b=R+-4|0)>>>0<S>>>0)){for(_=tt,q=0;Ae=q,q=e[(mt=b)>>2],B=31&_,B=32<=(63&_)>>>(V=0)?(F=q<<B,0):(F=(1<<B)-1&q>>>32-B,q<<B),V=F+V|0,V=(q=Ae+B|0)>>>0<B>>>0?V+1|0:V,Ae=mt,mt=So(q=Po(B=q,V,1e9),Vt,1e9),e[Ae>>2]=B-mt,S>>>0<=(b=b+-4|0)>>>0;);(_=q)&&(e[(S=S+-4|0)>>2]=_)}for(;S>>>0<(b=R)>>>0&&!e[(R=b+-4|0)>>2];);if(F=e[44+g>>2]-tt|0,R=b,!(0<(0|(e[44+g>>2]=F))))break}if((0|F)<=-1)for(Ht=1+((z+25|0)/9|0)|0,tt=(0|d)==102;;){if(q=(0|F)<-9?9:0-F|0,b>>>0<=S>>>0)S=e[S>>2]?S:S+4|0;else{for(mt=1e9>>>q,B=-1<<q^-1,F=0,R=S;_=e[R>>2],e[R>>2]=(_>>>q)+F,F=j(mt,_&B),(R=R+4|0)>>>0<b>>>0;);S=e[S>>2]?S:S+4|0,F&&(e[b>>2]=F,b=b+4|0)}if(F=q+e[44+g>>2]|0,b=(0|Ht)<b-(_=tt?ut:S)>>2?_+(Ht<<2)|0:b,!((0|(e[44+g>>2]=F))<0))break}if(!(b>>>(R=0)<=S>>>0||(R=j(ut-S>>2,9),(_=e[S>>2])>>>0<(F=10))))for(;R=R+1|0,(F=j(F,10))>>>0<=_>>>0;);if((0|(_=(z-((0|d)==102?0:R)|0)-((0|d)==103&(0|z)!=0)|0))<(j(b-ut>>2,9)+-9|0)){if(V=(ut+((_=(0|(B=_+9216|0))/9|0)<<2)|0)-4092|0,F=10,(0|(_=1+(B-j(_,9)|0)|0))<=8)for(;F=j(F,10),(0|(_=_+1|0))!=9;);if(Ht=V+4|0,((tt=(mt=e[V>>2])-j(F,B=(mt>>>0)/(F>>>0)|0)|0)||(0|Ht)!=(0|b))&&(Bt=tt>>>0<(_=F>>>1)>>>0?.5:(0|b)==(0|Ht)&&(0|_)==(0|tt)?1:1.5,p=1&B?9007199254740994:9007199254740992,!ce|H[0|y]!=45||(Bt=-Bt,p=-p),e[V>>2]=_=mt-tt|0,p+Bt!=p)){if(1e9<=(e[V>>2]=_=_+F|0)>>>0)for(;(V=V+-4|(e[V>>2]=0))>>>0<S>>>0&&(e[(S=S+-4|0)>>2]=0),_=e[V>>2]+1|0,999999999<(e[V>>2]=_)>>>0;);if(R=j(ut-S>>2,9),!((_=e[S>>2])>>>0<(F=10)))for(;R=R+1|0,(F=j(F,10))>>>0<=_>>>0;);}b=(_=V+4|0)>>>0<b>>>0?_:b}r:{for(;;){if((tt=b)>>>(mt=0)<=S>>>0)break r;if(e[(b=tt+-4|0)>>2])break}mt=1}if((0|d)!=103)B=8&c;else if(z=((_=(0|R)<(0|(b=z||1))&-5<(0|R))?-1^R:-1)+b|0,E=(_?-1:-2)+E|0,!(B=8&c)){if(b=9,mt&&(B=e[tt+-4>>2])&&!((B>>>(b=0))%(_=10)))for(;b=b+1|0,!((B>>>0)%((_=j(_,10))>>>0)););_=j(tt-ut>>2,9)+-9|0,z=(32|E)==102?((B=0)|z)<(0|(_=0<(0|(_=_-b|0))?_:0))?z:_:((B=0)|z)<(0|(_=0<(0|(_=(_+R|0)-b|0))?_:0))?z:_}if(V=(0|(F=z|B))!=0,_=a,Ae=P,b=0<(0|R)?R:0,(0|(q=32|E))!=102){if((u-(b=ye((b=R>>31)+R^b,0,u))|0)<=1)for(;O[0|(b=b+-1|0)]=48,(u-b|0)<2;);O[0|(Ht=b+-2|0)]=E,O[b+-1|0]=(0|R)<0?45:43,b=u-Ht|0}if(We(_,32,Ae,V=1+(b+(V+(z+ce|0)|0)|0)|0,c),Fe(a,y,ce),We(a,48,P,V,65536^c),(0|q)==102){for(_=16+g|8,R=16+g|9,S=E=ut>>>0<S>>>0?ut:S;;){if(b=ye(e[S>>2],0,R),(0|E)!=(0|S)){if(!(b>>>0<=16+g>>>0))for(;O[0|(b=b+-1|0)]=48,16+g>>>0<b>>>0;);}else(0|b)==(0|R)&&(O[24+g|0]=48,b=_);if(Fe(a,b,R-b|0),!((S=S+4|0)>>>0<=ut>>>0))break}F&&Fe(a,3875,1);r:if(!((0|z)<1|tt>>>0<=S>>>0))for(;;){if(16+g>>>0<(b=ye(e[S>>2],0,R))>>>0)for(;O[0|(b=b+-1|0)]=48,16+g>>>0<b>>>0;);if(Fe(a,b,(0|z)<9?z:9),z=z+-9|0,tt>>>0<=(S=S+4|0)>>>0)break r;if(!(0<(0|z)))break}We(a,48,z+9|0,9,0)}else{r:if(!((0|z)<0))for(E=mt?tt:S+4|0,_=16+g|8,ut=16+g|9,R=S;;){if((0|ut)==(0|(b=ye(e[R>>2],0,ut)))&&(O[24+g|0]=48,b=_),(0|S)!=(0|R)){if(!(b>>>0<=16+g>>>0))for(;O[0|(b=b+-1|0)]=48,16+g>>>0<b>>>0;);}else Fe(a,b,1),b=b+1|0,(0|z)<1&&!B||Fe(a,3875,1);if(Fe(a,q=b,(0|(b=ut-b|0))<(0|z)?b:z),z=z-b|0,E>>>0<=(R=R+4|0)>>>0)break r;if(!(-1<(0|z)))break}We(a,48,z+18|0,18,0),Fe(a,Ht,u-Ht|0)}}return We(a,32,P,V,8192^c),K=560+g|0,0|((0|V)<(0|P)?P:V)},L[12]=function(a,p){a|=0;var P=p|=0;p=e[p>>2]+15&-16,e[P>>2]=p+16,P=a,a=function(_,c,E,u){var d,g,y=0,b=0,S=0,R=0;return K=g=K-32|0,y=(R=y=2147483647&u)-1006698496|0,b=y=(d=b=S=E)>>>0<0?y+1|0:y,y=R-1140785152|0,(0|(y=S>>>0<0?y+1|0:y))==(0|b)&d>>>0<S>>>0|b>>>0<y>>>0?(y=u<<4|E>>>28,E=E<<4|c>>>28,(0|(S=c&=268435455))==134217728&1<=_>>>0|134217728<c>>>0?(y=y+1073741824|0,(_=E+1|0)>>>0<1&&(y=y+1|0),b=_):(y=y-(((b=E)>>>0<0)+-1073741824|0)|0,_|134217728^S||((_=b+(1&b)|0)>>>0<b>>>0&&(y=y+1|0),b=_))):(!S&(0|R)==2147418112?!(_|c):(0|R)==2147418112&S>>>0<0|R>>>0<2147418112)?(y=2146435072,((b=0)|R)==1140785151&4294967295<S>>>0|1140785151<R>>>0||(S=R>>>16)>>>(y=0)<15249||(function(F,B,V,z,q,tt){var ut,mt,Bt=0,Ht=0;64&tt?(B=31&(V=tt-64|0),B=32<=(63&V)>>>0?(V=0,q>>>B):(V=q>>>B,((1<<B)-1&q)<<32-B|z>>>B),q=z=0):tt&&(Ht=q,Bt=31&(mt=64-tt|0),mt=32<=(63&mt)>>>0?(Ht=z<<Bt,0):(Ht=(1<<Bt)-1&z>>>32-Bt|Ht<<Bt,z<<Bt),ut=B,B=31&(Bt=tt),B=32<=(63&Bt)>>>0?(Bt=0,V>>>B):(Bt=V>>>B,((1<<B)-1&V)<<32-B|ut>>>B),B|=mt,V=Bt|Ht,Bt=z,z=31&tt,z=32<=(63&tt)>>>0?(Ht=0,q>>>z):(Ht=q>>>z,((1<<z)-1&q)<<32-z|Bt>>>z),q=Ht),e[F>>2]=B,e[4+F>>2]=V,e[8+F>>2]=z,e[12+F>>2]=q}(g,_,c,E,y=65535&u|65536,15361-S|0),function(F,B,V,z,q,tt){var ut,mt,Bt=0;64&tt?(z=B,B=31&(q=tt+-64|0),32<=(63&q)>>>0?(q=z<<B,z=0):(q=(1<<B)-1&z>>>32-B|V<<B,z<<=B),V=B=0):tt&&(mt=z,z=31&(ut=tt),mt=32<=(63&tt)>>>0?(Bt=mt<<z,0):(Bt=(1<<z)-1&mt>>>32-z|q<<z,mt<<z),z=V,q=31&(tt=64-tt|0),32<=(63&tt)>>>0?(tt=0,z>>>=q):(tt=z>>>q,z=((1<<q)-1&z)<<32-q|B>>>q),z|=mt,q=tt|Bt,tt=B,B=31&ut,B=32<=(63&ut)>>>0?(Bt=tt<<B,0):(Bt=(1<<B)-1&tt>>>32-B|V<<B,tt<<B),V=Bt),e[F>>2]=B,e[4+F>>2]=V,e[8+F>>2]=z,e[12+F>>2]=q}(16+g|0,_,c,E,y,S+-15233|0),E=e[4+g>>2],_=e[8+g>>2],y=e[12+g>>2]<<4|_>>>28,b=_<<4|E>>>28,(0|(E=_=268435455&E))==134217728&1<=(c=e[g>>2]|((e[16+g>>2]|e[24+g>>2])!=0|(e[20+g>>2]|e[28+g>>2])!=0))>>>0|134217728<_>>>0?((_=b+1|0)>>>0<1&&(y=y+1|0),b=_):c|134217728^E||((_=b+(1&b)|0)>>>0<b>>>0&&(y=y+1|0),b=_))):(b=E<<4|c>>>28,y=524287&(y=u<<4|E>>>28)|2146959360),K=32+g|0,Yt(0,0|b),Yt(1,-2147483648&u|y),+ze()}(e[p>>2],e[p+4>>2],e[p+8>>2],e[p+12>>2]),ct[P>>3]=a},L[13]=function(a){return 0},L[14]=function(a,p,P){p|=0,P|=0;var _,c,E=0,u=0,d=0,g=0;for(K=c=K-32|0,E=e[28+(a|=0)>>2],e[16+c>>2]=E,d=e[a+20>>2],e[28+c>>2]=P,e[24+c>>2]=p,d=(e[20+c>>2]=p=d-E|0)+P|0,g=2,p=16+c|0;;){r:{if((u=(E=0)|Zt(e[a+60>>2],0|p,0|g,12+c|0))&&(e[2086]=u,E=-1),(0|(E=E?e[12+c>>2]=-1:e[12+c>>2]))==(0|d))p=e[a+44>>2],e[a+28>>2]=p,e[a+20>>2]=p,e[a+16>>2]=p+e[a+48>>2],a=P;else{if(-1<(0|E))break r;e[a+28>>2]=0,e[a+16>>2]=0,e[a+20>>2]=0,e[a>>2]=32|e[a>>2],((a=0)|g)!=2&&(a=P-e[p+4>>2]|0)}return K=32+c|0,0|a}u=e[p+4>>2],e[(p=(_=u>>>0<E>>>0)?p+8|0:p)>>2]=(u=E-(_?u:0)|0)+e[p>>2],e[p+4>>2]=e[p+4>>2]-u,d=d-E|0,g=g-_|0}},L[15]=function(a,p,P,_){return Vt=0},{d:function(){},e:function(){return e[1805]},f:function(){return 83886080},g:function(){return 5},h:function(a,p){return p|=0,K=p=K-16|0,a=(a|=0)?ur(a)?(Ut(4,2150,0),0):H[a+4|0]:(e[p+4>>2]=1444,e[p>>2]=2267,Ut(4,1294,p),0),K=p+16|0,0|a},i:function(a,p){var P;return p|=0,K=P=K-48|0,a=(a|=0)?(a+63&-64)!=(0|a)?(e[36+P>>2]=1522,e[32+P>>2]=2284,Ut(4,1294,32+P|0),0):(p+63&-64)==(0|p)&&p?function(_,c){var E,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,Ae=0,Ue=0,He=0;K=b=(E=d=K)-704&-64;r:if(c>>>0<=1343)Ut(4,1235,0);else if(ur(_))Ut(4,1469,0);else if(d=H[0|(Ue=_+4|0)]){if(!(6<=d>>>0)){(Bt=(0|!H[_+5|0])==1)||(Ee(Ue,1),vt(_- -64|0,4,160)),Ce(b- -64|0,0,640),ir(_,b- -64|0),d=_+c|0,c=e[b+64>>2];t:{e:{i:{if(5<=(mt=H[_+4|0])>>>0){if(c>>>0<_>>>0|d>>>0<c>>>0||(y=c+256|0)>>>0<_>>>0)break e;if(y>>>0<=d>>>0)break i;break e}if(c>>>0<_>>>0|d>>>0<c>>>0||(y=c+128|0)>>>0<_>>>0|d>>>0<y>>>0)break e}if(!((g=e[b+68>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<y>>>0||(g=g- -64|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(V=e[c>>2]))<0||(y=e[b+72>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(u=y)+(y=V<<2)|0)>>>0<_>>>0|d>>>0<g>>>0||(R=e[b+76>>2])>>>0<_>>>0|d>>>0<R>>>0|R>>>0<g>>>0||(u=(V<<6)+R|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+80>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+84>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+88>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+92>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+96>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+100>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+4>>2]))<0||(y=e[b+104>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(S=(g=y)+(y=u<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(g=e[b+108>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<S>>>0||(u=g+(u<<6)|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+112>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+116>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+120>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+124>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+128>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+132>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+136>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+8>>2]))<0||(y=e[b+140>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(z=u<<2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+144>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+148>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+156>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+160>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+164>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+z|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+12>>2]))<0||(y=e[b+172>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(q=u<<2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+176>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+q|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+180>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+q|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+188>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=y+q|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(g=e[c+16>>2]))<0||(y=e[b+192>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(S=(u=y)+(y=g<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+196>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+200>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+204>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+208>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+(g<<6)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+212>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+216>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+220>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+228>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+232>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+236>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+240>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+244>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+y|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+248>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(u=u+g|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+252>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+256>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+260>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+264>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+268>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+272>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(S=e[c+20>>2]))<0||(g=e[b+276>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(tt=(u=g)+(g=S<<2)|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+280>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(S=u+(S<<6)|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+284>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+288>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+292>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+296>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+300>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+308>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+312>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+g|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[c+24>>2]))<0||(u=e[b+336>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+(tt<<2)|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[c+28>>2]))<0||(u=e[b+340>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=(ce=tt<<2)+u|0)>>>0<_>>>0|d>>>0<S>>>0||(u=e[b+344>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(S=u+ce|0)>>>0<_>>>0|d>>>0<S>>>0||(0|(tt=e[c+32>>2]))<0||(u=e[b+356>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<S>>>0||(tt=(S=tt<<2)+u|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+360>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+364>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+368>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+372>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+376>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(u=e[b+380>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(tt=u+S|0)>>>0<_>>>0|d>>>0<tt>>>0||(0|(F=e[c+36>>2]))<0||(u=e[b+392>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<tt>>>0||(F=(tt=F<<2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+396>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+tt|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+400>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+tt|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+40>>2]))<0||(u=e[b+412>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+44>>2]))<0||(u=e[b+424>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+48>>2]))<0||(u=e[b+428>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=(B<<=2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+432>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+B|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+52>>2]))<0||(u=e[b+416>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=(B<<=2)+u|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+420>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+B|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+56>>2]))<0||(u=e[b+552>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+60>>2]))<0||(u=e[b+556>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+64>>2]))<0||(u=e[b+560>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<1)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+68>>2]))<0||(u=e[b+564>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+72>>2]))<0||(u=e[b+568>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(B=(F=u)+(u=B<<2)|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+572>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+576>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+580>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+584>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+76>>2]))<0||(u=e[b+588>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(B=(F=B<<2)+u|0)>>>0<_>>>0|d>>>0<B>>>0||(u=e[b+592>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(u=e[b+596>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<B>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+80>>2]))<0||(u=e[b+600>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(ut=(F=u)+(u=B<<2)|0)>>>0<_>>>0|d>>>0<ut>>>0||(F=e[b+604>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<ut>>>0||(B=F+(B<<6)|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+608>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+612>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+616>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+620>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+624>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+628>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(B=u+F|0)>>>0<_>>>0|d>>>0<B>>>0||(F=e[b+632>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<B>>>0||(F=u+F|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+84>>2]))<0||(u=e[b+636>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<2)|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+640>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+(B<<1)|0)>>>0<_>>>0|d>>>0<F>>>0||(0|(B=e[c+88>>2]))<0||(u=e[b+644>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(u=u+(B<<2)|0)>>>0<_>>>0|d>>>0<u>>>0)){if(!(mt>>>0<2)&&((F=e[b+168>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<u>>>0||(u=F+z|0)>>>0<_>>>0|d>>>0<u>>>0||!(mt>>>0<4)&&((F=e[b+324>>2])>>>0<_>>>0|d>>>0<F>>>0|F>>>0<u>>>0||(F=g+F|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+328>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+g|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+332>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(F=u+g|0)>>>0<_>>>0|d>>>0<F>>>0||(u=e[b+152>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<F>>>0||(z=u+z|0)>>>0<_>>>0|d>>>0<z>>>0||(u=e[b+184>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<z>>>0||(z=u+q|0)>>>0<_>>>0|d>>>0<z>>>0||(u=e[b+224>>2])>>>0<_>>>0|d>>>0<u>>>0|u>>>0<z>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(z=e[c+92>>2]))<0||(y=e[b+648>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(z=(u=z<<2)+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+652>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(z=u+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+656>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(0|(z=e[c+96>>2]))<0||(y=e[b+660>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(z=(u=z<<2)+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+664>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(z=u+y|0)>>>0<_>>>0|d>>>0<z>>>0||(y=e[b+668>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<z>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+304>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+316>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+320>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+100>>2]))<0||(y=e[b+436>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+440>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+444>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+104>>2]))<0||(y=e[b+448>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=y)+(y=u<<2)|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+452>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+456>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+460>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(g=e[b+464>>2])>>>0<_>>>0|d>>>0<g>>>0|g>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+108>>2]))<0||(y=e[b+480>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+484>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+488>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+112>>2]))<0||(y=e[b+504>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+508>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+512>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+116>>2]))<0||(y=e[b+528>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+(u<<2)|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+120>>2]))<0||(y=e[b+532>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+536>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+540>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+124>>2]))<0||(y=e[b+544>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=(u<<=2)+y|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+548>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=u+y|0)>>>0<_>>>0|d>>>0<u>>>0)))break e;if(mt>>>0<5||!((y=e[b+348>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=y+ce|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+352>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+ce|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+384>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+S|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+388>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+S|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+404>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+tt|0)>>>0<_>>>0|d>>>0<g>>>0||(y=e[b+408>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(g=y+tt|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+128>>2]))<0||(y=e[b+468>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+472>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+476>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+132>>2]))<0||(y=e[b+492>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+496>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+500>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(g=g+y|0)>>>0<_>>>0|d>>>0<g>>>0||(0|(u=e[c+136>>2]))<0||(y=e[b+516>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<g>>>0||(u=(g=u<<2)+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+520>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(u=g+y|0)>>>0<_>>>0|d>>>0<u>>>0||(y=e[b+524>>2])>>>0<_>>>0|d>>>0<y>>>0|y>>>0<u>>>0||(y=g+y|0)>>>0<_>>>0)&&y>>>0<=d>>>0)break t}}Ut(4,1760,0),Ee(Ue,1),vt(_- -64|0,4,160);break r}Bt||(Ji(_),O[_+5|0]=0,c=e[b+64>>2],V=e[c>>2],R=e[b+76>>2],mt=H[_+4|0]);t:{if((_=0)<(0|V)){for(;;){if(63<he((_<<6)+R|0)>>>0)break t;if((0|V)==(0|(_=_+1|0)))break}if(u=c+48|0,(d=0)<(0|(_=e[c>>2]))){for(y=e[c+48>>2],g=e[b+80>>2];;){if((0|(R=e[g+(d<<2)>>2]))<0|(0|y)<=(0|R))break t;if((0|_)==(0|(d=d+1|0)))break}for(tt=c+24|0,y=e[c+24>>2],S=e[b+88>>2],V=e[b+84>>2],d=0;;){if((g=e[(R=d<<2)+S>>2])&&((0|g)<0|(0|y)<(0|g)||(0|(R=e[R+V>>2]))<0|(0|y)<=(0|R)||(g=g+R|0)>>>31|(0|y)<(0|g)))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+92>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+96>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+100>>2];;){if((0|(g=e[y+(d<<2)>>2]))<-1|(0|_)<=(0|g))break t;if((0|_)==(0|(d=d+1|0)))break}}else tt=c+24|0}else tt=c+24|0,u=c+48|0;if((_=0)<(0|(d=e[c+4>>2]))){for(y=e[b+108>>2];;){if(63<he(y+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(S=(y=e[c+48>>2])+-1|0,!(((d=0)|(_=e[c+4>>2]))<=0)){for(g=e[b+112>>2];;){if((0|(R=e[g+(d<<2)>>2]))<0|(0|y)<=(0|R))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+116>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+120>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(y=e[c>>2],d=0,g=e[b+124>>2];;){if((0|(R=e[g+(d<<2)>>2]))<-1|(0|y)<=(0|R))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+128>>2];;){if((0|(g=e[y+(d<<2)>>2]))<-1|(0|_)<=(0|g))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,y=e[b+132>>2];;){if(1<rt[y+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(g=c+8|0,R=c+12|0,V=e[b+136>>2],d=0;;){if(1<(q=e[(z=d<<2)+y>>2])>>>0||(0|(z=e[V+z>>2]))<0|(0|z)>=e[(q-1|0?g:R)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}}}else S=e[u>>2]+-1|0;if((_=0)<(0|(d=e[c+8>>2]))){for(y=e[b+140>>2];;){if((0|(g=e[y+(_<<2)>>2]))<0|(0|S)<(0|g))break t;if((0|d)==(0|(_=_+1|0)))break}for(ce=c+28|0,y=e[c+28>>2],V=e[b+148>>2],z=e[b+144>>2],_=0;;){if((g=e[(R=_<<2)+V>>2])&&((0|g)<0|(0|y)<(0|g)||(0|(R=e[R+z>>2]))<0|(0|y)<=(0|R)||(g=g+R|0)>>>31|(0|y)<(0|g)))break t;if((0|d)==(0|(_=_+1|0)))break}for(_=0,g=e[b+156>>2],R=e[b+164>>2],V=e[b+160>>2];;){if((0|(z=e[(y=_<<2)+V>>2]))<1||(0|(q=e[y+R>>2]))<1||(0|(y=e[g+y>>2]))<1|(0|y)!=(0|j(q+1|0,z+1|0)))break t;if((0|d)==(0|(_=_+1|0)))break}}else ce=c+28|0;if((_=0)<(0|(g=e[c+12>>2]))){for(d=e[b+172>>2];;){if((0|(y=e[d+(_<<2)>>2]))<0|(0|S)<(0|y))break t;if((0|g)==(0|(_=_+1|0)))break}for(F=c+32|0,d=e[c+32>>2],S=e[b+180>>2],V=e[b+176>>2],_=0;;){if((y=e[(R=_<<2)+S>>2])&&((0|y)<0|(0|d)<(0|y)||(0|(R=e[R+V>>2]))<0|(0|d)<=(0|R)||(y=y+R|0)>>>31|(0|d)<(0|y)))break t;if((0|g)==(0|(_=_+1|0)))break}}else F=c+32|0;y=c+16|0;e:{i:{if(!(((_=0)|(d=e[c+16>>2]))<=0)){for(g=e[b+208>>2];;){if(63<he(g+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(!(((d=0)|(_=e[y>>2]))<=0)){for(g=e[u>>2],R=e[b+212>>2];;){if((0|(S=e[R+(d<<2)>>2]))<0|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(Ue=c+36|0,g=e[c+36>>2],V=e[b+220>>2],z=e[b+216>>2],d=0;;){if((R=e[(S=d<<2)+V>>2])&&((0|R)<0|(0|g)<(0|R)||(0|(S=e[S+z>>2]))<0|(0|g)<=(0|S)||(R=R+S|0)>>>31|(0|g)<(0|R)))break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[b+228>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[b+232>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[c>>2],d=0,R=e[b+236>>2];;){if((0|(S=e[R+(d<<2)>>2]))<-1|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[c+4>>2],d=0,R=e[b+240>>2];;){if((0|(S=e[R+(d<<2)>>2]))<-1|(0|g)<=(0|S))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[b+244>>2],d=0;;){if(e[g+(d<<2)>>2]<0)break t;if((0|_)==(0|(d=d+1|0)))break}break i}}R=c+68|0,Ue=c+36|0;break e}for(g=e[b+252>>2],d=0;;){if(e[g+(d<<2)>>2]<0)break t;if((0|_)==(0|(d=d+1|0)))break}for(R=e[c+60>>2],d=0,S=e[b+256>>2];;){if((V=e[(V=d<<2)+S>>2]+(e[g+V>>2]<<1)|0)>>>31|(0|R)<(0|V))break t;if((0|_)==(0|(d=d+1|0)))break}for(g=e[c+64>>2],V=e[b+264>>2],z=e[b+260>>2],d=0;;){if((R=e[(S=d<<2)+V>>2])&&((0|R)<0|(0|g)<(0|R)||(0|(S=e[S+z>>2]))<0|(0|g)<=(0|S)||(R=R+S|0)>>>31|(0|g)<(0|R)))break t;if((0|_)==(0|(d=d+1|0)))break}for(R=c+68|0,g=e[c+68>>2],z=e[b+272>>2],q=e[b+268>>2],d=0;;){if((S=e[(V=d<<2)+z>>2])&&((0|S)<0|(0|g)<(0|S)||(0|(V=e[V+q>>2]))<0|(0|g)<=(0|V)||(S=S+V|0)>>>31|(0|g)<(0|S)))break t;if((0|_)==(0|(d=d+1|0)))break}}e:{i:{if(!(((_=0)|(d=e[c+20>>2]))<=0)){for(g=e[b+280>>2];;){if(63<he(g+(_<<6)|0)>>>0)break t;if((0|d)==(0|(_=_+1|0)))break}if(!(((_=0)|(d=e[c+20>>2]))<=0)){for(g=e[b+296>>2];;){if(1<rt[g+(_<<2)>>2])break t;if((0|d)==(0|(_=_+1|0)))break}for(g=e[b+300>>2],_=0;;){if(e[g+(_<<2)>>2]<0)break t;if((0|d)==(0|(_=_+1|0)))break}break i}}_=e[c+52>>2];break e}for(_=e[c+52>>2],z=e[b+312>>2],q=e[b+308>>2],S=0;;){if((g=e[(V=S<<2)+z>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(V=e[V+q>>2]))<0|(0|_)<=(0|V)||(g=g+V|0)>>>31|(0|_)<(0|g)))break t;if((0|d)==(0|(S=S+1|0)))break}}if(g=e[c+40>>2],(d=0)<(0|(S=e[c+8>>2])))for(V=e[b+344>>2],z=e[b+156>>2];;){if((q=e[(q=d<<2)+V>>2]+(e[z+q>>2]<<1)|0)>>>31|(0|g)<(0|q))break t;if((0|S)==(0|(d=d+1|0)))break}if((d=0)<(0|(S=e[F>>2]))){for(V=e[b+376>>2];;){if(1<rt[V+(d<<2)>>2])break t;if((0|S)==(0|(d=d+1|0)))break}for(d=0,V=e[b+380>>2];;){if(1<rt[V+(d<<2)>>2])break t;if((0|S)==(0|(d=d+1|0)))break}}if((d=0)<(0|(S=e[y>>2])))for(V=e[b+400>>2],z=e[b+252>>2];;){if((q=e[(q=d<<2)+V>>2]+(e[z+q>>2]<<1)|0)>>>31|(0|g)<(0|q))break t;if((0|S)==(0|(d=d+1|0)))break}if((d=0)<(0|(g=e[c+44>>2])))for(V=e[b+424>>2];;){if((0|(z=e[V+(d<<2)>>2]))<0|(0|_)<=(0|z))break t;if((0|g)==(0|(d=d+1|0)))break}if(1<=(0|(z=e[u>>2])))for(d=0,q=e[b+432>>2],B=e[b+428>>2];;){if((u=e[(V=d<<2)+q>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(V=e[B+V>>2]))<0|(0|g)<=(0|V)||(u=u+V|0)>>>31|(0|g)<(0|u)))break t;if((0|z)==(0|(d=d+1|0)))break}if(1<=(0|_))for(g=e[c+56>>2],d=0,z=e[b+420>>2],q=e[b+416>>2];;){if((u=e[(V=d<<2)+z>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(V=e[V+q>>2]))<0|(0|g)<=(0|V)||(u=u+V|0)>>>31|(0|g)<(0|u)))break t;if((0|(d=d+1|0))==(0|_))break}if((_=0)<(0|(d=e[R>>2])))for(g=e[b+564>>2];;){if((0|(R=e[g+(_<<2)>>2]))<-1|(0|S)<=(0|R))break t;if((0|d)==(0|(_=_+1|0)))break}if(_=e[c+76>>2],1<=(0|(R=e[c+72>>2])))for(d=0,S=e[b+572>>2],V=e[b+568>>2];;){if((g=e[(u=d<<2)+S>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+V>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|R)==(0|(d=d+1|0)))break}if((d=0)<(0|_)){for(g=e[b+588>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(u=e[b+592>>2],d=0;;){if(1<(V=e[(S=d<<2)+g>>2])>>>0||(0|(S=e[u+S>>2]))<0|(0|S)>=e[(V-1|0?y:c)>>2])break t;if((0|_)==(0|(d=d+1|0)))break}for(d=0,g=e[b+596>>2];;){if((0|(u=e[g+(d<<2)>>2]))<-1|(0|R)<=(0|u))break t;if((0|_)==(0|(d=d+1|0)))break}}e:{if(!(((_=0)|(S=e[c+80>>2]))<=0)){for(d=e[b+604>>2];;){if(63<he(d+(_<<6)|0)>>>0)break t;if((0|S)==(0|(_=_+1|0)))break}if(!(((_=0)|(S=e[c+80>>2]))<=0)){for(d=e[c+48>>2],g=e[b+608>>2];;){if((0|(R=e[g+(_<<2)>>2]))<0|(0|d)<=(0|R))break t;if((0|S)==(0|(_=_+1|0)))break}for(z=e[c+88>>2],R=e[b+616>>2],u=e[b+612>>2],_=0;;){if((d=e[(g=_<<2)+R>>2])&&((0|d)<0|(0|z)<(0|d)||(0|(g=e[u+g>>2]))<0|(0|z)<=(0|g)||(d=d+g|0)>>>31|(0|z)<(0|d)))break t;if((0|S)==(0|(_=_+1|0)))break}for(y=e[y>>2],R=e[b+620>>2],_=0;;){if((0|(d=e[R+(_<<2)>>2]))<0|(0|y)<=(0|d))break t;if((0|S)==(0|(_=_+1|0)))break}for(u=e[b+624>>2],_=0;;){if((0|(d=e[u+(_<<2)>>2]))<0|(0|y)<=(0|d))break t;if((0|S)==(0|(_=_+1|0)))break}for(d=e[c+84>>2],V=e[b+632>>2],q=e[b+628>>2],_=0;;){if((g=e[(B=_<<2)+V>>2])&&((0|g)<0|(0|d)<(0|g)||(0|(B=e[B+q>>2]))<0|(0|d)<=(0|B)||(g=g+B|0)>>>31|(0|d)<(0|g)))break t;if((0|S)==(0|(_=_+1|0)))break}for(ut=e[b+640>>2],d=e[b+252>>2],g=0;;){if(0<(0|(Bt=e[(_=g<<2)+V>>2])))for(B=ut+(e[_+q>>2]<<1)|0,He=e[d+(e[_+u>>2]<<2)>>2],Ht=e[d+(e[_+R>>2]<<2)>>2],_=0;;){if((0|He)<=W[B+(2|(Ae=_<<1))>>1]|(0|Ht)<=W[B+Ae>>1])break t;if(!((0|(_=_+2|0))<(0|Bt)))break}if((0|S)==(0|(g=g+1|0)))break}break e}}y=e[c+16>>2],z=e[c+88>>2]}if(!((255&mt)>>>0<2)){if((_=0)<(0|(V=e[c+8>>2])))for(d=e[b+168>>2];;){if(1<rt[d+(_<<2)>>2])break t;if((0|V)==(0|(_=_+1|0)))break}if(!((255&mt)>>>0<4)){if(R=e[c+56>>2],1<=(0|(q=e[c+20>>2])))for(u=e[b+332>>2],B=e[b+328>>2],_=0;;){if((d=e[(g=_<<2)+u>>2])&&((0|d)<0|(0|R)<(0|d)||(0|(g=e[g+B>>2]))<0|(0|R)<=(0|g)||(d=d+g|0)>>>31|(0|R)<(0|d)))break t;if((0|q)==(0|(_=_+1|0)))break}if((0|(_=e[c+92>>2]))!=e[c+96>>2])break t;if(1<=(0|V))for(B=e[b+152>>2],d=0,ut=e[b+148>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+B>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|V)==(0|(d=d+1|0)))break}if(1<=(0|(He=e[c+12>>2])))for(B=e[b+184>>2],d=0,ut=e[b+180>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+B>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|He)==(0|(d=d+1|0)))break}if(1<=(0|y))for(B=e[b+224>>2],d=0,ut=e[b+220>>2];;){if((g=e[(u=d<<2)+ut>>2])&&((0|g)<0|(0|_)<(0|g)||(0|(u=e[u+B>>2]))<0|(0|_)<=(0|u)||(g=u+g|0)>>>31|(0|_)<(0|g)))break t;if((0|y)==(0|(d=d+1|0)))break}if((d=0)<(0|q)){for(g=e[b+304>>2];;){if(1<rt[g+(d<<2)>>2])break t;if((0|q)==(0|(d=d+1|0)))break}for(g=e[c+100>>2],ut=e[b+320>>2],Bt=e[b+316>>2],d=0;;){if((u=e[(B=d<<2)+ut>>2])&&((0|u)<0|(0|g)<(0|u)||(0|(B=e[B+Bt>>2]))<0|(0|g)<=(0|B)||(u=u+B|0)>>>31|(0|g)<(0|u)))break t;if((0|q)==(0|(d=d+1|0)))break}}else g=e[c+100>>2];if(1<=(0|g)){for(B=e[b+440>>2],d=0,Bt=e[b+436>>2];;){if((u=e[(ut=d<<2)+B>>2])&&((0|u)<0|(0|R)<(0|u)||(0|(ut=e[ut+Bt>>2]))<0|(0|R)<=(0|ut)||(u=u+ut|0)>>>31|(0|R)<(0|u)))break t;if((0|g)==(0|(d=d+1|0)))break}for(R=e[b+444>>2],d=0;;){if((0|(ut=e[(u=d<<2)+R>>2]))<0|(0|ut)>=e[u+B>>2])break t;if((0|g)==(0|(d=d+1|0)))break}}if((R=0)<(0|(d=e[c+104>>2]))){for(u=e[b+448>>2];;){if((0|(B=e[u+(R<<2)>>2]))<0|(0|g)<=(0|B))break t;if((0|d)==(0|(R=R+1|0)))break}for(u=e[c+116>>2],ut=e[b+464>>2],Bt=e[b+460>>2],g=0;;){if((R=e[(B=g<<2)+ut>>2])&&((0|R)<0|(0|u)<(0|R)||(0|(B=e[B+Bt>>2]))<0|(0|u)<=(0|B)||(R=R+B|0)>>>31|(0|u)<(0|R)))break t;if((0|d)==(0|(g=g+1|0)))break}}else u=e[c+116>>2];if((g=0)<(0|(B=e[c+108>>2]))){for(R=e[b+480>>2];;){if((0|(ut=e[R+(g<<2)>>2]))<0|(0|V)<=(0|ut))break t;if((0|B)==(0|(g=g+1|0)))break}for(ut=e[b+488>>2],Ht=e[b+484>>2],g=0;;){if((R=e[(V=g<<2)+ut>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(V=e[V+Ht>>2]))<0|(0|d)<=(0|V)||(R=R+V|0)>>>31|(0|d)<(0|R)))break t;if((0|B)==(0|(g=g+1|0)))break}for(ut=e[ce>>2],g=e[b+456>>2],V=e[b+452>>2],R=0;;){if(Ae=e[Ht+(R<<2)>>2]<<2,(Bt=e[Ae+g>>2])&&((0|Bt)<0|(0|ut)<(0|Bt)||(0|(Ae=e[V+Ae>>2]))<0|(0|ut)<=(0|Ae)||(0|(Bt=Bt+Ae|0))<0|(0|ut)<(0|Bt)))break t;if((0|B)==(0|(R=R+1|0)))break}}else g=e[b+456>>2],V=e[b+452>>2];if((R=0)<(0|(B=e[c+112>>2]))){for(ut=e[b+504>>2];;){if((0|(Bt=e[ut+(R<<2)>>2]))<0|(0|y)<=(0|Bt))break t;if((0|B)==(0|(R=R+1|0)))break}for(Ht=e[b+512>>2],Bt=e[b+508>>2],y=0;;){if((R=e[(ut=y<<2)+Ht>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(ut=e[ut+Bt>>2]))<0|(0|d)<=(0|ut)||(R=R+ut|0)>>>31|(0|d)<(0|R)))break t;if((0|B)==(0|(y=y+1|0)))break}for(R=e[Ue>>2],y=0;;){if(Ht=e[Bt+(y<<2)>>2]<<2,(ut=e[Ht+g>>2])&&((0|ut)<0|(0|R)<(0|ut)||(0|(Ht=e[V+Ht>>2]))<0|(0|R)<=(0|Ht)||(0|(ut=ut+Ht|0))<0|(0|R)<(0|ut)))break t;if((0|B)==(0|(y=y+1|0)))break}}if(R=e[c+120>>2],(y=0)<(0|u))for(B=e[b+528>>2];;){if((0|(ut=e[B+(y<<2)>>2]))<0|(0|R)<=(0|ut))break t;if((0|(y=y+1|0))==(0|u))break}if((y=0)<(0|R)){for(u=e[b+532>>2];;){if((0|(B=e[u+(y<<2)>>2]))<-1|(0|q)<=(0|B))break t;if((0|R)==(0|(y=y+1|0)))break}for(u=e[c+124>>2],ut=e[b+540>>2],Bt=e[b+536>>2],y=0;;){if((q=e[(B=y<<2)+ut>>2])&&((0|q)<0|(0|u)<(0|q)||(0|(B=e[B+Bt>>2]))<0|(0|u)<=(0|B)||(q=B+q|0)>>>31|(0|u)<(0|q)))break t;if((0|R)==(0|(y=y+1|0)))break}}if(!((255&mt)>>>0<5)){if((y=0)<(0|(mt=e[ce>>2]))){for(R=e[b+348>>2];;){if((0|(u=e[R+(y<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|mt)==(0|(y=y+1|0)))break}for(R=e[b+352>>2],y=0;;){if((0|(u=e[R+(y<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|mt)==(0|(y=y+1|0)))break}}if((mt=0)<(0|(y=e[F>>2]))){for(R=e[b+384>>2];;){if((0|(u=e[R+(mt<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|y)==(0|(mt=mt+1|0)))break}for(R=e[b+388>>2],mt=0;;){if((0|(u=e[R+(mt<<2)>>2]))<0|(0|_)<(0|u))break t;if((0|y)==(0|(mt=mt+1|0)))break}}if((mt=0)<(0|(R=e[Ue>>2]))){for(u=e[b+404>>2];;){if((0|(q=e[u+(mt<<2)>>2]))<0|(0|_)<(0|q))break t;if((0|R)==(0|(mt=mt+1|0)))break}for(u=e[b+408>>2],mt=0;;){if((0|(q=e[u+(mt<<2)>>2]))<0|(0|_)<(0|q))break t;if((0|R)==(0|(mt=mt+1|0)))break}}if((_=0)<(0|(mt=e[c+128>>2]))){for(R=e[c>>2],u=e[b+468>>2];;){if((0|(q=e[u+(_<<2)>>2]))<0|(0|R)<=(0|q))break t;if((0|mt)==(0|(_=_+1|0)))break}for(ce=e[b+476>>2],q=e[b+472>>2],_=0;;){if((R=e[(u=_<<2)+ce>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(u=e[u+q>>2]))<0|(0|d)<=(0|u)||(R=u+R|0)>>>31|(0|d)<(0|R)))break t;if((0|mt)==(0|(_=_+1|0)))break}for(R=e[tt>>2],_=0;;){if(tt=e[q+(_<<2)>>2]<<2,(u=e[tt+g>>2])&&((0|u)<0|(0|R)<(0|u)||(0|(tt=e[V+tt>>2]))<0|(0|R)<=(0|tt)||(0|(u=u+tt|0))<0|(0|R)<(0|u)))break t;if((0|mt)==(0|(_=_+1|0)))break}}if((_=0)<(0|(mt=e[c+132>>2]))){for(R=e[b+492>>2];;){if((0|(u=e[R+(_<<2)>>2]))<0|(0|He)<=(0|u))break t;if((0|mt)==(0|(_=_+1|0)))break}for(tt=e[b+500>>2],u=e[b+496>>2],_=0;;){if((R=e[(q=_<<2)+tt>>2])&&((0|R)<0|(0|d)<(0|R)||(0|(q=e[u+q>>2]))<0|(0|d)<=(0|q)||(R=R+q|0)>>>31|(0|d)<(0|R)))break t;if((0|mt)==(0|(_=_+1|0)))break}for(_=0;;){if(q=e[u+(_<<2)>>2]<<2,(R=e[q+g>>2])&&((0|R)<0|(0|y)<(0|R)||(0|(q=e[V+q>>2]))<0|(0|y)<=(0|q)||(0|(R=R+q|0))<0|(0|y)<(0|R)))break t;if((0|mt)==(0|(_=_+1|0)))break}}if(!(((_=0)|(c=e[c+136>>2]))<=0)){for(y=e[b+516>>2];;){if((0|(mt=e[y+(_<<2)>>2]))<0|(0|S)<=(0|mt))break t;if((0|c)==(0|(_=_+1|0)))break}for(R=e[b+524>>2],y=e[b+520>>2],_=0;;){if((b=e[(mt=_<<2)+R>>2])&&((0|b)<0|(0|d)<(0|b)||(0|(mt=e[y+mt>>2]))<0|(0|d)<=(0|mt)||(b=b+mt|0)>>>31|(0|d)<(0|b)))break t;if((0|c)==(0|(_=_+1|0)))break}for(_=0;;){if(b=e[y+(_<<2)>>2]<<2,(d=e[b+g>>2])&&((0|d)<0|(0|z)<(0|d)||(0|(b=e[b+V>>2]))<0|(0|z)<=(0|b)||(0|(d=d+b|0))<0|(0|z)<(0|d)))break t;if((0|c)==(0|(_=_+1|0)))break}}}}}return K=E,1}return Ut(4,1846,0),K=E,0}e[b+52>>2]=d,e[b+48>>2]=5,Ut(4,1640,b+48|0)}else e[b+32>>2]=d,Ut(4,1554,b+32|0);return K=E,0}(a,p):(e[20+P>>2]=1621,e[16+P>>2]=2284,Ut(4,1294,16+P|0),0):(e[4+P>>2]=1444,e[P>>2]=2284,Ut(4,1294,P),0),K=48+P|0,0|a},j:function(a){e[1805]=a|=0},k:function(a,p){var P;return p|=0,K=P=K-48|0,a=(a|=0)?(a+63&-64)!=(0|a)?(e[36+P>>2]=1522,e[32+P>>2]=2305,Ut(4,1294,32+P|0),0):(p+63&-64)==(0|p)&&p?function(_){var c,E,u,d,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0;e[24+(K=c=K-32|0)>>2]=0,e[16+c>>2]=5,e[20+c>>2]=0,Ao(16+(K=d=K-272|0)|0,2227,e[12+d>>2]=16+c|0),function(z){var q;e[(K=q=K-16|0)>>2]=z,function(tt,ut){var mt;e[12+(K=mt=K-16|0)>>2]=ut,bo(tt,1432,ut,0,0),K=16+mt|0}(e[970],q),K=16+q|0}(16+d|0),K=272+d|0;r:{if(ur(_))Ut(4,1932,0);else{if(!(6<=(b=H[_+4|0])>>>0)){if((0|!H[_+5|0])!=1?(Ee(_+4|0,1),vt(_- -64|0,4,160),ir(_,_+704|(O[_+5|0]=0)),Ji(_)):ir(_,_+704|0),H[7224]||(e[1807]=6,O[7224]=1,e[1808]=7,e[1809]=8,e[1810]=9),y=e[_+704>>2],1<=(0|(b=e[y+16>>2]))){for(V=(S=e[_+912>>2])+(b<<2)|0,R=e[_+908>>2];;){B=e[_+1204>>2]+(e[R>>2]<<2)|0;t:if(!(((y=0)|(g=(b=e[S>>2])+-1|0))<1))e:for(;;){for(;;){if(e[(F=B+(y<<2)|0)>>2]<=-1){if(function(z,q,tt){var ut=0,mt=0;i:if((0|z)!=(0|q)){if(!(z>>>0<q+tt>>>0&&q>>>0<(mt=z+tt|0)>>>0))return ge(z,q,tt);if(ut=3&(z^q),z>>>0<q>>>0){if(!ut){if(3&z)for(;;){if(!tt)break i;if(O[0|z]=H[0|q],q=q+1|0,tt=tt+-1|0,!(3&(z=z+1|0)))break}if(!(tt>>>0<=3)){for(ut=tt;e[z>>2]=e[q>>2],q=q+4|0,z=z+4|0,3<(ut=ut+-4|0)>>>0;);tt&=3}}if(tt)for(;O[0|z]=H[0|q],z=z+1|0,q=q+1|0,tt=tt+-1|0;);}else{if(!ut){if(3&mt)for(;;){if(!tt)break i;if(O[0|(ut=(tt=tt+-1|0)+z|0)]=H[q+tt|0],!(3&ut))break}if(!(tt>>>0<=3))for(;e[(tt=tt+-4|0)+z>>2]=e[q+tt>>2],3<tt>>>0;);}if(tt)for(;O[(tt=tt+-1|0)+z|0]=H[q+tt|0],tt;);}}}(F,F+4|0,(-1^y)+b<<2),(0|y)<(0|(g=(b=g)+-1|0)))continue e;break t}if(!((0|(y=y+1|0))<(0|g)))break}break}if(y=S,0<(0|b)&&(b=e[B+(g<<2)>>2]<0?g:b),e[y>>2]=b,R=R+4|0,!((S=S+4|0)>>>0<V>>>0))break}y=e[_+704>>2]}if(1<=e[y>>2])for(g=0;e[e[_+712>>2]+(g<<2)>>2]=e[_+716>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y>>2];);if(1<=e[y+4>>2])for(g=0;e[e[_+744>>2]+(g<<2)>>2]=e[_+748>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+4>>2];);if(1<=e[y+16>>2])for(g=0;e[(b=g<<2)+e[_+832>>2]>>2]=e[_+848>>2]+(g<<6),e[b+e[_+836>>2]>>2]=e[_+1196>>2]+(e[b+e[_+896>>2]>>2]<<2),e[b+e[_+840>>2]>>2]=e[_+1200>>2]+(e[b+e[_+900>>2]>>2]<<1),e[b+e[_+844>>2]>>2]=e[_+1204>>2]+(e[b+e[_+908>>2]>>2]<<2),y=e[_+704>>2],(0|(g=g+1|0))<e[y+16>>2];);if(1<=e[y+20>>2])for(g=0;e[e[_+916>>2]+(g<<2)>>2]=e[_+920>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+20>>2];);if(1<=e[y+80>>2])for(g=0;e[e[_+1240>>2]+(g<<2)>>2]=e[_+1244>>2]+(g<<6),y=e[_+704>>2],(0|(g=g+1|0))<e[y+80>>2];);if(1&O[e[_+708>>2]+20|0]||(0|(S=e[y+16>>2]))<1)break r;for(g=e[_+904>>2],B=e[_+900>>2],F=e[_+1200>>2],R=0;;){if(0<(0|(V=e[(b=R<<2)+g>>2]+-1|0)))for(E=F+(e[b+B>>2]<<1)|0,y=0;u=W[(b=E+(y<<1)|0)>>1],N[b>>1]=W[b+4>>1],N[b+4>>1]=u,(0|(y=y+3|0))<(0|V););if((0|S)==(0|(R=R+1|0)))break}for(b=e[_+892>>2],R=e[_+896>>2],B=e[_+1196>>2],g=0;;){if(1<=(0|(F=e[(y=g<<2)+b>>2])))for(F=(y=B+(e[y+R>>2]<<2)|0)+(F<<3)|0,y=y+4|0;I[y>>2]=v(1)-I[y>>2],(y=y+8|0)>>>0<F>>>0;);if((0|S)==(0|(g=g+1|0)))break}break r}e[4+c>>2]=b,e[c>>2]=5,Ut(4,2023,c)}_=0}return K=32+c|0,_}(a):(e[20+P>>2]=1621,e[16+P>>2]=2305,Ut(4,1294,16+P|0),0):(e[4+P>>2]=1444,e[P>>2]=2305,Ut(4,1294,P),0),K=48+P|0,0|a},l:function(a,p,P,_){var c;p|=0,P|=0,_|=0,K=c=K+-64|0,(a|=0)?p?P?_?(a=e[e[a>>2]+708>>2],e[p>>2]=e[a+12>>2],e[p+4>>2]=e[a+16>>2],e[P>>2]=e[a+4>>2],e[P+4>>2]=e[a+8>>2],e[_>>2]=e[a>>2]):(e[52+c>>2]=1995,e[48+c>>2]=2325,Ut(4,1294,48+c|0)):(e[36+c>>2]=1903,e[32+c>>2]=2325,Ut(4,1294,32+c|0)):(e[20+c>>2]=1819,e[16+c>>2]=2325,Ut(4,1294,16+c|0)):(e[4+c>>2]=1740,e[c>>2]=2325,Ut(4,1294,c)),K=64+c|0},m:cr,n:jr,o:function(a){var p;K=p=K-16|0,(a|=0)?hi(a):(e[4+p>>2]=1740,e[p>>2]=2387,Ut(4,1294,p)),K=16+p|0},p:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+540>>2]:(e[4+p>>2]=1740,e[p>>2]=2402,Ut(4,1294,p),-1),K=16+p|0,0|a},q:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+916>>2]:(e[4+p>>2]=1740,e[p>>2]=2423,Ut(4,1294,p),0),K=16+p|0,0|a},r:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+548>>2]:(e[4+p>>2]=1740,e[p>>2]=2442,Ut(4,1294,p),0),K=16+p|0,0|a},s:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+928>>2]:(e[4+p>>2]=1740,e[p>>2]=2463,Ut(4,1294,p),0),K=16+p|0,0|a},t:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+924>>2]:(e[4+p>>2]=1740,e[p>>2]=2492,Ut(4,1294,p),0),K=16+p|0,0|a},u:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+932>>2]:(e[4+p>>2]=1740,e[p>>2]=2521,Ut(4,1294,p),0),K=16+p|0,0|a},v:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+552>>2]:(e[4+p>>2]=1740,e[p>>2]=2550,Ut(4,1294,p),0),K=16+p|0,0|a},w:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+4>>2]:(e[4+p>>2]=1740,e[p>>2]=2572,Ut(4,1294,p),-1),K=16+p|0,0|a},x:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+712>>2]:(e[4+p>>2]=1740,e[p>>2]=2588,Ut(4,1294,p),0),K=16+p|0,0|a},y:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+52>>2]:(e[4+p>>2]=1740,e[p>>2]=2602,Ut(4,1294,p),0),K=16+p|0,0|a},z:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+740>>2]:(e[4+p>>2]=1740,e[p>>2]=2622,Ut(4,1294,p),0),K=16+p|0,0|a},A:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+332>>2]:(e[4+p>>2]=1740,e[p>>2]=2650,Ut(4,1294,p),-1),K=16+p|0,0|a},B:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+832>>2]:(e[4+p>>2]=1740,e[p>>2]=2670,Ut(4,1294,p),0),K=16+p|0,0|a},C:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+888>>2]:(e[4+p>>2]=1740,e[p>>2]=2688,Ut(4,1294,p),0),K=16+p|0,0|a},D:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+432>>2]:(e[4+p>>2]=1740,e[p>>2]=2716,Ut(4,1294,p),0),K=16+p|0,0|a},E:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+884>>2]:(e[4+p>>2]=1740,e[p>>2]=2743,Ut(4,1294,p),0),K=16+p|0,0|a},F:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+440>>2]:(e[4+p>>2]=1740,e[p>>2]=2772,Ut(4,1294,p),0),K=16+p|0,0|a},G:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+436>>2]:(e[4+p>>2]=1740,e[p>>2]=2797,Ut(4,1294,p),0),K=16+p|0,0|a},H:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+448>>2]:(e[4+p>>2]=1740,e[p>>2]=2824,Ut(4,1294,p),0),K=16+p|0,0|a},I:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+912>>2]:(e[4+p>>2]=1740,e[p>>2]=2848,Ut(4,1294,p),0),K=16+p|0,0|a},J:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+844>>2]:(e[4+p>>2]=1740,e[p>>2]=2873,Ut(4,1294,p),0),K=16+p|0,0|a},K:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+892>>2]:(e[4+p>>2]=1740,e[p>>2]=2893,Ut(4,1294,p),0),K=16+p|0,0|a},L:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+444>>2]:(e[4+p>>2]=1740,e[p>>2]=2920,Ut(4,1294,p),0),K=16+p|0,0|a},M:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+836>>2]:(e[4+p>>2]=1740,e[p>>2]=2950,Ut(4,1294,p),0),K=16+p|0,0|a},N:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+904>>2]:(e[4+p>>2]=1740,e[p>>2]=2974,Ut(4,1294,p),0),K=16+p|0,0|a},O:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+840>>2]:(e[4+p>>2]=1740,e[p>>2]=3e3,Ut(4,1294,p),0),K=16+p|0,0|a},P:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+452>>2]:(e[4+p>>2]=1740,e[p>>2]=3022,Ut(4,1294,p),0),K=16+p|0,0|a},Q:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+456>>2]:(e[4+p>>2]=1740,e[p>>2]=3051,Ut(4,1294,p),0),K=16+p|0,0|a},R:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[e[a>>2]+876>>2]:(e[4+p>>2]=1740,e[p>>2]=3078,Ut(4,1294,p),0),K=16+p|0,0|a},S:function(a){var p;K=p=K-16|0,(a|=0)?e[a+428>>2]=1:(e[4+p>>2]=1740,e[p>>2]=3110,Ut(4,1294,p)),K=16+p|0},T:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+640>>2]:(e[4+p>>2]=1740,e[p>>2]=3139,Ut(4,1294,p),0),K=16+p|0,0|a},U:function(a){var p;return K=p=K-16|0,a=(a|=0)?e[a+636>>2]:(e[4+p>>2]=1740,e[p>>2]=3164,Ut(4,1294,p),0),K=16+p|0,0|a},V:function(a){var p;return qe(12+(K=p=K-16|0)|0,64,a|=0),K=16+p|0,e[12+p>>2]},W:function(a){var p,P,_=0;return K=P=K-16|0,!(a|=0)||qe(12+P|0,16,p=cr(a))||(_=jr(a,e[12+P>>2],p))||(gr(e[12+P>>2]),_=0),K=16+P|0,0|_},X:function(a){return 0|Je(a|=0)},Y:function(a){gr(a|=0)},Z:function(a){var p;qe(12+(K=p=K-16|0)|0,64,a|=0),gr(e[12+p>>2]),K=16+p|0},_:function(){return 0|K},$:function(a){return 0|(K=K-(0|a)&-16)},aa:function(a){K=0|a},ba:function(a){return 0|(a=0|(a|=0),(P=0|$o())<(a=P+(a|=0)|0)&&a<65536&&(a=new ArrayBuffer(j(a,65536)),(p=new l.Int8Array(a)).set(O),O=p,O=new l.Int8Array(a),N=new l.Int16Array(a),e=new l.Int32Array(a),H=new l.Uint8Array(a),W=new l.Uint16Array(a),rt=new l.Uint32Array(a),I=new l.Float32Array(a),ct=new l.Float64Array(a),w=a,$.buffer=a),P);var p,P},ca:function(a,p){L[a|=0](p|=0)}};function vt(a,p,P){var _,c,E=0;if(P)for(;;){if(P=P+-1|0,a>>>0<(E=(_=a+p|0)-1|0)>>>0)for(;c=H[0|a],O[0|a]=H[0|E],O[0|E]=c,(a=a+1|0)>>>0<(E=E+-1|0)>>>0;);if(a=_,!P)break}}function Ut(a,p,P){var _;K=_=K-272|0,rt[1804]>a>>>0||(a=e[1805])&&(Ao(16+_|0,p,e[12+_>>2]=P),L[a](16+_|0)),K=272+_|0}function Fe(a,p,P){32&H[0|a]||function(_,c,E){var u=0,d=0,g=0;r:{if(!(u=e[E+16>>2])){if(function(y){var b;return b=H[y+74|0],O[y+74|0]=b+-1|b,8&(b=e[y>>2])?(e[y>>2]=32|b,1):(e[y+4>>2]=0,e[y+8>>2]=0,b=e[y+44>>2],e[y+28>>2]=b,e[y+20>>2]=b,e[y+16>>2]=b+e[y+48>>2],0)}(E))break r;u=e[E+16>>2]}if(u-(g=e[E+20>>2])>>>0<c>>>0)return L[e[E+36>>2]](E,_,c);t:if(!(O[E+75|0]<0)){for(u=c;;){if(!(d=u))break t;if(H[(u=d+-1|0)+_|0]==10)break}if(L[e[E+36>>2]](E,_,d)>>>0<d>>>0)break r;c=c-d|0,_=_+d|0,g=e[E+20>>2]}ge(g,_,c),e[E+20>>2]=e[E+20>>2]+c}}(p,P,a)}function We(a,p,P,_,c){var E,u,d;if(K=d=K-256|0,!(73728&c|(0|P)<=(0|_))){if(Ce(d,p,(E=(c=P-_|0)>>>0<256)?c:256),p=a,u=d,!E){for(P=P-_|0;Fe(a,d,256),255<(c=c+-256|0)>>>0;);c=255&P}Fe(p,u,c)}K=256+d|0}function ge(a,p,P){var _,c=0;if(8192<=P>>>0)Lt(0|a,0|p,0|P);else{if(_=a+P|0,3&(a^p))if(_>>>0<4)P=a;else if((c=_-4|0)>>>0<a>>>0)P=a;else for(P=a;O[0|P]=H[0|p],O[P+1|0]=H[p+1|0],O[P+2|0]=H[p+2|0],O[P+3|0]=H[p+3|0],p=p+4|0,(P=P+4|0)>>>0<=c>>>0;);else{r:if((0|P)<1)P=a;else if(3&a)for(P=a;;){if(O[0|P]=H[0|p],p=p+1|0,_>>>0<=(P=P+1|0)>>>0)break r;if(!(3&P))break}else P=a;if(!((a=-4&_)>>>0<64||(c=a+-64|0)>>>0<P>>>0))for(;e[P>>2]=e[p>>2],e[P+4>>2]=e[p+4>>2],e[P+8>>2]=e[p+8>>2],e[P+12>>2]=e[p+12>>2],e[P+16>>2]=e[p+16>>2],e[P+20>>2]=e[p+20>>2],e[P+24>>2]=e[p+24>>2],e[P+28>>2]=e[p+28>>2],e[P+32>>2]=e[p+32>>2],e[P+36>>2]=e[p+36>>2],e[P+40>>2]=e[p+40>>2],e[P+44>>2]=e[p+44>>2],e[P+48>>2]=e[p+48>>2],e[P+52>>2]=e[p+52>>2],e[P+56>>2]=e[p+56>>2],e[P+60>>2]=e[p+60>>2],p=p- -64|0,(P=P- -64|0)>>>0<=c>>>0;);if(!(a>>>0<=P>>>0))for(;e[P>>2]=e[p>>2],p=p+4|0,(P=P+4|0)>>>0<a>>>0;);}if(P>>>0<_>>>0)for(;O[0|P]=H[0|p],p=p+1|0,(0|_)!=(0|(P=P+1|0)););}}function me(a){var p,P;return v((p=a*a)*p*(P=p*a)*(2718311493989822e-21*p-.00019839334836096632)+(P*(.008333329385889463*p-.16666666641626524)+a))}function ve(a){var p;return v(-.499999997251031*(a*=a)+1+.04166662332373906*(p=a*a)+a*p*(2439044879627741e-20*a-.001388676377460993))}function Ce(a,p,P){var _,c,E,u;if(P&&(O[(_=a+P|0)-1|0]=p,O[0|a]=p,!(P>>>0<3||(O[_-2|0]=p,O[a+1|0]=p,O[_-3|0]=p,O[a+2|0]=p,P>>>0<7)||(O[_-4|0]=p,O[a+3|0]=p,P>>>0<9)||(c=(_=0-a&3)+a|0,p=j(255&p,16843009),e[c>>2]=p,e[(_=(P=P-_&-4)+c|0)-4>>2]=p,P>>>0<9)||(e[8+c>>2]=p,e[4+c>>2]=p,e[_-8>>2]=p,e[_-12>>2]=p,P>>>0<25)||(e[24+c>>2]=p,e[20+c>>2]=p,e[16+c>>2]=p,e[12+c>>2]=p,e[_-16>>2]=p,e[_-20>>2]=p,e[_-24>>2]=p,e[_-28>>2]=p,(P=P-(u=4&c|24)|0)>>>0<32))))for(E=_=p,p=c+u|0;e[p+24>>2]=E,e[p+28>>2]=_,e[p+16>>2]=E,e[p+20>>2]=_,e[p+8>>2]=E,e[p+12>>2]=_,e[p>>2]=E,e[p+4>>2]=_,p=p+32|0,31<(P=P+-32|0)>>>0;);return a}function Ee(a,p){var P;if(a>>>0<(p=(a+p|0)-1|0)>>>0)for(;P=H[0|a],O[0|a]=H[0|p],O[0|p]=P,(a=a+1|0)>>>0<(p=p+-1|0)>>>0;);}function Me(a){var p,P=$o();return(a=(p=e[2216])+a|0)>>>0<=P<<16>>>0||re(0|a)?(e[2216]=a,p):(e[2086]=48,-1)}function te(a,p,P,_,c,E,u){var d,g,y,b,S,R,F,B,V,z,q=0,tt=v(0),ut=v(0),mt=v(0);if(v(0),v(0),v(0),v(0),K=z=K-16|0,1<=(0|a))for(R=j(a,12)+p|0;;){if(1<=(0|(g=e[p+4>>2])))for(F=(a=e[p+8>>2])+j(g,48)|0,g=(d=e[p>>2]<<4)+u|0,y=(8|d)+u|0,d=(4|d)+u|0;(q=e[a+8>>2])&&((B=q+-1|0)>>>0<=1?(V=(e[a+4>>2]<<2)+P|0,q=e[V+(e[a+12>>2]<<2)>>2]<<2,tt=I[q+E>>2],S=I[c+q>>2],ut=I[_+q>>2],B-1?(mt=ut,ut=I[a+20>>2],I[g>>2]=I[g>>2]+v(I[a+44>>2]*v(mt*ut)),I[d>>2]=I[d>>2]+v(v(S*ut)*I[a+44>>2]),I[y>>2]=I[y>>2]+v(v(tt*ut)*I[a+44>>2])):(q=e[(e[a+16>>2]<<2)+V>>2]<<2,B=I[q+E>>2],V=I[c+q>>2],mt=ut,ut=I[a+20>>2],b=I[a+24>>2],I[g>>2]=I[g>>2]+v(I[a+44>>2]*v(v(mt*ut)+v(I[_+q>>2]*b))),I[d>>2]=I[d>>2]+v(v(v(S*ut)+v(V*b))*I[a+44>>2]),I[y>>2]=I[y>>2]+v(v(v(tt*ut)+v(B*b))*I[a+44>>2]))):(e[z>>2]=q,Ut(4,1024,z))),(a=a+48|0)>>>0<F>>>0;);if(a=(e[p>>2]<<4)+u|0,tt=I[a>>2],I[a>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),tt=I[a+4>>2],I[a+4>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),tt=I[a+8>>2],I[a+8>>2]=tt<v(0)?v(0):v(Mt(tt,v(1))),!((p=p+12|0)>>>0<R>>>0))break}K=16+z|0}function ye(a,p,P){var _,c,E=0;if((0|p)==1&a>>>0<0|p>>>0<1)E=a;else for(;_=So(E=Po(a,p,10),c=Vt,10),O[0|(P=P+-1|0)]=a-_|48,_=(0|p)==9&4294967295<a>>>0|9<p>>>0,a=E,p=c,_;);if(E)for(;O[0|(P=P+-1|0)]=E-j(a=(E>>>0)/10|0,10)|48,p=9<E>>>0,E=a,p;);return P}function ie(a){return a+-48>>>0<10}function he(a){var p;return(p=wo(a,64))?p-a|0:64}function Be(a,p){var P=0;return 1024<=(0|p)?(a*=898846567431158e293,p=(0|(P=p+-1023|0))<1024?P:(a*=898846567431158e293,((0|p)<3069?p:3069)+-2046|0)):-1023<(0|p)||(a*=22250738585072014e-324,p=-1023<(0|(P=p+1022|0))?P:(a*=22250738585072014e-324,(-3066<(0|p)?p:-3066)+2044|0)),Yt(0,0),Yt(1,p+1023<<20),a*+ze()}function lr(a,p){var P=0,_=a,c=p>>>0<=31?(P=e[a+4>>2],e[a>>2]):(P=e[a>>2],e[a+4>>2]=P,p=p+-32|(e[a>>2]=0),0);e[_>>2]=c<<p,e[a+4>>2]=P<<p|c>>>32-p}function je(a,p,P,_,c){var E,u=0,d=0,g=0;K=E=K-240|0,u=e[p>>2],e[232+E>>2]=u,p=e[p+4>>2],e[E>>2]=a,d=1;r:{t:{e:{if(((e[236+E>>2]=p)||(0|u)!=1)&&(u=a-e[(P<<2)+c>>2]|0,!((0|L[5](u,a))<1))){for(g=!_;;){i:{if(p=u,!(!g|(0|P)<2)&&(_=e[((P<<2)+c|0)-8>>2],-1<(0|L[5](u=a+-4|0,p))||-1<(0|L[5](u-_|0,p))))break i;if(e[(d<<2)+E>>2]=p,d=d+1|0,Le(232+E|0,a=Co(232+E|0)),P=a+P|0,!e[236+E>>2]&&e[232+E>>2]==1)break t;if(g=1,u=(a=p)-e[(P<<2)+c>>2]|(_=0),0<(0|L[5](u,e[E>>2])))continue;break e}break}p=a;break t}p=a}if(_)break r}Eo(E,d),Br(p,P,c)}K=240+E|0}function Le(a,p){var P=0,_=a,c=p>>>0<=31?(P=e[a>>2],e[a+4>>2]):(P=e[a+4>>2],e[a+4>>2]=0,e[a>>2]=P,p=p+-32|0,0);e[_+4>>2]=c>>>p,e[a>>2]=c<<32-p|P>>>p}function ir(a,p){var P=H[a+4|0];e[p>>2]=e[a+64>>2]+a,e[p+4>>2]=e[a+68>>2]+a,e[p+8>>2]=e[a+72>>2]+a,e[p+12>>2]=e[a+76>>2]+a,e[p+16>>2]=e[a+80>>2]+a,e[p+20>>2]=e[a+84>>2]+a,e[p+24>>2]=e[a+88>>2]+a,e[p+28>>2]=e[a+92>>2]+a,e[p+32>>2]=e[a+96>>2]+a,e[p+36>>2]=e[a+100>>2]+a,e[p+40>>2]=e[a+104>>2]+a,e[p+44>>2]=e[a+108>>2]+a,e[p+48>>2]=e[a+112>>2]+a,e[p+52>>2]=e[a+116>>2]+a,e[p+56>>2]=e[a+120>>2]+a,e[p+60>>2]=e[a+124>>2]+a,e[p- -64>>2]=e[a+128>>2]+a,e[p+68>>2]=e[a+132>>2]+a,e[p+72>>2]=e[a+136>>2]+a,e[p+76>>2]=e[a+140>>2]+a,e[p+80>>2]=e[a+144>>2]+a,e[p+84>>2]=e[a+148>>2]+a,e[p+92>>2]=e[a+152>>2]+a,e[p+96>>2]=e[a+156>>2]+a,e[p+100>>2]=e[a+160>>2]+a,e[p+108>>2]=e[a+164>>2]+a,e[p+112>>2]=e[a+168>>2]+a,e[p+116>>2]=e[a+172>>2]+a,e[p+124>>2]=e[a+176>>2]+a,e[p+128>>2]=e[a+180>>2]+a,e[p+132>>2]=e[a+184>>2]+a,e[p+136>>2]=e[a+188>>2]+a,e[p+140>>2]=e[a+192>>2]+a,e[p+144>>2]=e[a+196>>2]+a,e[p+148>>2]=e[a+200>>2]+a,e[p+152>>2]=e[a+204>>2]+a,e[p+156>>2]=e[a+208>>2]+a,e[p+164>>2]=e[a+212>>2]+a,e[p+168>>2]=e[a+216>>2]+a,e[p+172>>2]=e[a+220>>2]+a,e[p+176>>2]=e[a+224>>2]+a,e[p+180>>2]=e[a+228>>2]+a,e[p+184>>2]=e[a+232>>2]+a,e[p+188>>2]=e[a+236>>2]+a,e[p+192>>2]=e[a+240>>2]+a,e[p+196>>2]=e[a+244>>2]+a,e[p+200>>2]=e[a+248>>2]+a,e[p+204>>2]=e[a+252>>2]+a,e[p+208>>2]=e[a+256>>2]+a,e[p+212>>2]=e[a+260>>2]+a,e[p+216>>2]=e[a+264>>2]+a,e[p+220>>2]=e[a+268>>2]+a,e[p+224>>2]=e[a+272>>2]+a,e[p+228>>2]=e[a+276>>2]+a,e[p+232>>2]=e[a+280>>2]+a,e[p+236>>2]=e[a+284>>2]+a,e[p+244>>2]=e[a+288>>2]+a,e[p+248>>2]=e[a+292>>2]+a,e[p+272>>2]=e[a+296>>2]+a,e[p+276>>2]=e[a+300>>2]+a,e[p+280>>2]=e[a+304>>2]+a,e[p+292>>2]=e[a+308>>2]+a,e[p+296>>2]=e[a+312>>2]+a,e[p+300>>2]=e[a+316>>2]+a,e[p+304>>2]=e[a+320>>2]+a,e[p+308>>2]=e[a+324>>2]+a,e[p+312>>2]=e[a+328>>2]+a,e[p+316>>2]=e[a+332>>2]+a,e[p+328>>2]=e[a+336>>2]+a,e[p+332>>2]=e[a+340>>2]+a,e[p+336>>2]=e[a+344>>2]+a,e[p+348>>2]=e[a+348>>2]+a,e[p+360>>2]=e[a+352>>2]+a,e[p+364>>2]=e[a+356>>2]+a,e[p+368>>2]=e[a+360>>2]+a,e[p+352>>2]=e[a+364>>2]+a,e[p+356>>2]=e[a+368>>2]+a,e[p+488>>2]=e[a+372>>2]+a,e[p+492>>2]=e[a+376>>2]+a,e[p+496>>2]=e[a+380>>2]+a,e[p+500>>2]=e[a+384>>2]+a,e[p+504>>2]=e[a+388>>2]+a,e[p+508>>2]=e[a+392>>2]+a,e[p+512>>2]=e[a+396>>2]+a,e[p+516>>2]=e[a+400>>2]+a,e[p+520>>2]=e[a+404>>2]+a,e[p+524>>2]=e[a+408>>2]+a,e[p+528>>2]=e[a+412>>2]+a,e[p+532>>2]=e[a+416>>2]+a,e[p+536>>2]=e[a+420>>2]+a,e[p+540>>2]=e[a+424>>2]+a,e[p+544>>2]=e[a+428>>2]+a,e[p+548>>2]=e[a+432>>2]+a,e[p+552>>2]=e[a+436>>2]+a,e[p+556>>2]=e[a+440>>2]+a,e[p+560>>2]=e[a+444>>2]+a,e[p+564>>2]=e[a+448>>2]+a,e[p+568>>2]=e[a+452>>2]+a,e[p+572>>2]=e[a+456>>2]+a,e[p+576>>2]=e[a+460>>2]+a,e[p+580>>2]=e[a+464>>2]+a,P>>>0<2||(e[p+104>>2]=e[a+468>>2]+a,P>>>0<4)||(e[p+260>>2]=e[a+472>>2]+a,e[p+264>>2]=e[a+476>>2]+a,e[p+268>>2]=e[a+480>>2]+a,e[p+88>>2]=e[a+484>>2]+a,e[p+120>>2]=e[a+488>>2]+a,e[p+160>>2]=e[a+492>>2]+a,e[p+584>>2]=e[a+496>>2]+a,e[p+588>>2]=e[a+500>>2]+a,e[p+592>>2]=e[a+504>>2]+a,e[p+596>>2]=e[a+508>>2]+a,e[p+600>>2]=e[a+512>>2]+a,e[p+604>>2]=e[a+516>>2]+a,e[p+240>>2]=e[a+520>>2]+a,e[p+252>>2]=e[a+524>>2]+a,e[p+256>>2]=e[a+528>>2]+a,e[p+372>>2]=e[a+532>>2]+a,e[p+376>>2]=e[a+536>>2]+a,e[p+380>>2]=e[a+540>>2]+a,e[p+384>>2]=e[a+544>>2]+a,e[p+388>>2]=e[a+548>>2]+a,e[p+392>>2]=e[a+552>>2]+a,e[p+396>>2]=e[a+556>>2]+a,e[p+400>>2]=e[a+560>>2]+a,e[p+416>>2]=e[a+564>>2]+a,e[p+420>>2]=e[a+568>>2]+a,e[p+424>>2]=e[a+572>>2]+a,e[p+440>>2]=e[a+576>>2]+a,e[p+444>>2]=e[a+580>>2]+a,e[p+448>>2]=e[a+584>>2]+a,e[p+464>>2]=e[a+588>>2]+a,e[p+468>>2]=e[a+592>>2]+a,e[p+472>>2]=e[a+596>>2]+a,e[p+476>>2]=e[a+600>>2]+a,e[p+480>>2]=e[a+604>>2]+a,e[p+484>>2]=e[a+608>>2]+a,(0|P)!=4&&(e[p+284>>2]=e[a+612>>2]+a,e[p+288>>2]=e[a+616>>2]+a,e[p+320>>2]=e[a+620>>2]+a,e[p+324>>2]=e[a+624>>2]+a,e[p+340>>2]=e[a+628>>2]+a,e[p+344>>2]=e[a+632>>2]+a,e[p+404>>2]=e[a+636>>2]+a,e[p+408>>2]=e[a+640>>2]+a,e[p+412>>2]=e[a+644>>2]+a,e[p+428>>2]=e[a+648>>2]+a,e[p+432>>2]=e[a+652>>2]+a,e[p+436>>2]=e[a+656>>2]+a,e[p+452>>2]=e[a+660>>2]+a,e[p+456>>2]=e[a+664>>2]+a,e[p+460>>2]=e[a+668>>2]+a))}function qe(a,p,P){var _=0;r:{if((0|p)==8)p=Je(P);else{if(_=28,3&p|(0|function(c){for(var E=0,u=0;u=E,c;)c&=c-1,E=E+1|0;return u}(p>>>2))!=1||(_=48,-64-p>>>0<P>>>0))break r;p=function(c,E){var u,d,g=0,y=0,b=0;if((y=c>>>0>(g=16)?c:16)+-1&y)for(;g=(c=g)<<1,c>>>0<y>>>0;);else c=y;return-64-c>>>0<=E>>>0?(e[2086]=48,0):(g=Je(12+((y=E>>>0<11?16:E+11&-8)+c|0)|0))?(E=g+-8|0,g&c+-1?(b=(-8&(d=e[(u=g+-4|0)>>2]))-(g=(c=15<(g=((c+g|0)-1&0-c)-8|0)-E>>>0?g:c+g|0)-E|0)|0,3&d?(e[c+4>>2]=b|1&e[c+4>>2]|2,e[4+(b=c+b|0)>>2]=1|e[4+b>>2],e[u>>2]=g|1&e[u>>2]|2,e[c+4>>2]=1|e[c+4>>2],ts(E,g)):(E=e[E>>2],e[c+4>>2]=b,e[c>>2]=E+g)):c=E,3&(E=e[c+4>>2])&&((g=-8&E)>>>0<=y+16>>>0||(e[c+4>>2]=y|1&E|2,e[(E=c+y|0)+4>>2]=3|(y=g-y|0),e[4+(g=c+g|0)>>2]=1|e[g+4>>2],ts(E,y))),c+8|0):0}(16<p>>>0?p:16,P)}if(!p)return 1;e[a>>2]=p,_=0}return _}function gr(a){var p,P=0,_=0,c=0,E=0,u=0,d=0,g=0;r:if(a){p=(c=a+-8|0)+(a=-8&(_=e[a+-4>>2]))|0;t:if(!(1&_)){if(!(3&_)||(c=c-(_=e[c>>2])|0)>>>0<rt[2091])break r;if(a=a+_|0,e[2092]!=(0|c))if(_>>>0<=255)E=e[c+8>>2],_>>>=3,(0|(P=e[c+12>>2]))==(0|E)?(g=e[2087]&kr(_),e[2087]=g):(e[E+12>>2]=P,e[P+8>>2]=E);else{if(d=e[c+24>>2],(0|c)!=(0|(_=e[c+12>>2])))P=e[c+8>>2],e[P+12>>2]=_,e[_+8>>2]=P;else if(P=(P=e[(E=c+20|0)>>2])||e[(E=c+16|0)>>2]){for(;u=E,(P=e[(E=(_=P)+20|0)>>2])||(E=_+16|0,P=e[_+16>>2]););e[u>>2]=0}else _=0;if(d){E=e[c+28>>2];e:{if(e[(P=8652+(E<<2)|0)>>2]==(0|c)){if(e[P>>2]=_)break e;g=e[2088]&kr(E),e[2088]=g;break t}if(!(e[d+(e[d+16>>2]==(0|c)?16:20)>>2]=_))break t}e[_+24>>2]=d,(P=e[c+16>>2])&&(e[_+16>>2]=P,e[P+24>>2]=_),(P=e[c+20>>2])&&(e[_+20>>2]=P,e[P+24>>2]=_)}}else if((3&(_=e[4+p>>2]))==3)return e[2089]=a,e[4+p>>2]=-2&_,e[c+4>>2]=1|a,e[a+c>>2]=a}if(!(p>>>0<=c>>>0)&&1&(_=e[4+p>>2])){t:{if(!(2&_)){if(e[2093]==(0|p)){if(e[2093]=c,a=e[2090]+a|0,e[2090]=a,e[c+4>>2]=1|a,e[2092]!=(0|c))break r;return e[2089]=0,e[2092]=0}if(e[2092]==(0|p))return e[2092]=c,a=e[2089]+a|0,e[2089]=a,e[c+4>>2]=1|a,e[a+c>>2]=a;a=(-8&_)+a|0;e:if(_>>>0<=255)_>>>=3,(0|(P=e[8+p>>2]))==(0|(E=e[12+p>>2]))?(g=e[2087]&kr(_),e[2087]=g):(e[P+12>>2]=E,e[E+8>>2]=P);else{if(d=e[24+p>>2],(0|p)!=(0|(_=e[12+p>>2])))P=e[8+p>>2],e[P+12>>2]=_,e[_+8>>2]=P;else if(P=(P=e[(E=20+p|0)>>2])||e[(E=16+p|0)>>2]){for(;u=E,(P=e[(E=(_=P)+20|0)>>2])||(E=_+16|0,P=e[_+16>>2]););e[u>>2]=0}else _=0;if(d){E=e[28+p>>2];i:{if(e[(P=8652+(E<<2)|0)>>2]==(0|p)){if(e[P>>2]=_)break i;g=e[2088]&kr(E),e[2088]=g;break e}if(!(e[d+(e[d+16>>2]==(0|p)?16:20)>>2]=_))break e}e[_+24>>2]=d,(P=e[16+p>>2])&&(e[_+16>>2]=P,e[P+24>>2]=_),(P=e[20+p>>2])&&(e[_+20>>2]=P,e[P+24>>2]=_)}}if(e[c+4>>2]=1|a,e[a+c>>2]=a,e[2092]!=(0|c))break t;return e[2089]=a}e[4+p>>2]=-2&_,e[c+4>>2]=1|a,e[a+c>>2]=a}if(a>>>0<=255)return _=8388+((a>>>=3)<<3)|0,a=(P=e[2087])&(a=1<<a)?e[_+8>>2]:(e[2087]=a|P,_),e[_+8>>2]=c,e[a+12>>2]=c,e[c+12>>2]=_,e[c+8>>2]=a;e[c+16>>2]=0,P=e[c+20>>2]=0,(E=a>>>8)&&(P=31,16777215<a>>>0||(P=E,P=28+((P=((P=(P<<=E=E+1048320>>>16&8)<<(d=P+520192>>>16&4))<<(u=P+245760>>>16&2)>>>15)-(u|E|d)|0)<<1|a>>>P+21&1)|0)),u=8652+((e[(_=c)+28>>2]=P)<<2)|0;t:if((E=e[2088])&(_=1<<P)){E=a<<((0|P)==31?0:25-(P>>>1)|0),_=e[u>>2];e:{for(;;){if((-8&e[(P=_)+4>>2])==(0|a))break e;if(_=E>>>29,E<<=1,!(_=e[16+(u=P+(4&_)|0)>>2]))break}e[u+16>>2]=c,e[c+12>>2]=c,e[c+24>>2]=P,e[c+8>>2]=c;break t}a=e[P+8>>2],e[a+12>>2]=c,e[P+8>>2]=c,e[c+24>>2]=0,e[c+12>>2]=P,e[c+8>>2]=a}else e[2088]=_|E,e[u>>2]=c,e[c+12>>2]=c,e[c+24>>2]=u,e[c+8>>2]=c;if(a=e[2095]+-1|0,!(e[2095]=a)){for(c=8804;c=(a=e[c>>2])+8|0,a;);e[2095]=-1}}}}function Je(a){var p,P=0,_=0,c=0,E=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0;K=p=K-16|0;r:{t:{e:{i:{s:{o:{n:{c:{f:{l:{a:{if(a>>>0<=244){if(3&(P=(u=e[2087])>>>(a=(d=a>>>0<11?16:a+11&-8)>>>3))){a=(P=e[8396+(E=(_=a+(1&(-1^P))|0)<<3)>>2])+8|0,(0|(c=e[P+8>>2]))==(0|(E=E+8388|0))?(R=kr(_)&u,e[2087]=R):(e[c+12>>2]=E,e[E+8>>2]=c),e[P+4>>2]=3|(_<<=3),e[4+(P=P+_|0)>>2]=1|e[P+4>>2];break r}if(d>>>0<=(y=e[2089])>>>0)break a;if(P){_=P=(a=(0-(a=(0-(_=2<<a)|_)&P<<a)&a)-1|0)>>>12&16,P=e[8396+(c=(_=((_=(_|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)|0)<<3)>>2],(0|(a=e[P+8>>2]))==(0|(c=c+8388|0))?(u=kr(_)&u,e[2087]=u):(e[a+12>>2]=c,e[c+8>>2]=a),a=P+8|0,e[P+4>>2]=3|d,e[4+(g=P+d|0)>>2]=1|(E=(_<<=3)-d|0),e[P+_>>2]=E,y&&(P=8388+((_=y>>>3)<<3)|0,c=e[2092],_=(_=1<<_)&u?e[P+8>>2]:(e[2087]=_|u,P),e[P+8>>2]=c,e[_+12>>2]=c,e[c+12>>2]=P,e[c+8>>2]=_),e[2092]=g,e[2089]=E;break r}if(!(S=e[2088]))break a;for(_=P=(a=(S&0-S)-1|0)>>>12&16,P=e[8652+(((_=(_|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)<<2)>>2],c=(-8&e[P+4>>2])-d|0,_=P;a=(a=e[_+16>>2])||e[_+20>>2];)c=(_=(E=(-8&e[a+4>>2])-d|0)>>>0<c>>>0)?E:c,P=_?a:P,_=a;if(b=e[P+24>>2],(0|(E=e[P+12>>2]))!=(0|P)){a=e[P+8>>2],e[a+12>>2]=E,e[E+8>>2]=a;break t}if(!(a=e[(_=P+20|0)>>2])){if(!(a=e[P+16>>2]))break l;_=P+16|0}for(;g=_,(a=e[(_=(E=a)+20|0)>>2])||(_=E+16|0,a=e[E+16>>2]););e[g>>2]=0;break t}if(d=-1,!(4294967231<a>>>0)&&(d=-8&(P=a+11|0),y=e[2088])){_=0-d|0,u=0,(P>>>=8)&&(u=31,16777215<d>>>0||(u=28+((a=((u=(P<<=c=P+1048320>>>16&8)<<(a=P+520192>>>16&4))<<(P=u+245760>>>16&2)>>>15)-(P|a|c)|0)<<1|d>>>a+21&1)|0));d:{p:{if(c=e[8652+(u<<2)>>2])for(P=d<<((0|u)==31?0:25-(u>>>1)|0),a=0;;){if(!(_>>>0<=(g=(-8&e[c+4>>2])-d|0)>>>0||(E=c,_=g))){_=0,a=c;break p}if(g=e[c+20>>2],c=e[16+((P>>>29&4)+c|0)>>2],a=g&&(0|g)!=(0|c)?g:a,P<<=(0|c)!=0,!c)break}else a=0;if(!(a|E)){if(!(a=(0-(a=2<<u)|a)&y))break a;c=P=(a=(a&0-a)-1|0)>>>12&16,a=e[8652+(((c=(c|=P=(a>>>=P)>>>5&8)|(P=(a>>>=P)>>>2&4)|(P=(a>>>=P)>>>1&2))|(P=(a>>>=P)>>>1&1))+(a>>>P)<<2)>>2]}if(!a)break d}for(;_=(P=(c=(-8&e[a+4>>2])-d|0)>>>0<_>>>0)?c:_,E=P?a:E,a=(P=e[a+16>>2])||e[a+20>>2];);}if(!(!E|_>>>0>=e[2089]-d>>>0)){if(g=e[E+24>>2],(0|E)!=(0|(P=e[E+12>>2]))){a=e[E+8>>2],e[a+12>>2]=P,e[P+8>>2]=a;break e}if(!(a=e[(c=E+20|0)>>2])){if(!(a=e[E+16>>2]))break f;c=E+16|0}for(;u=c,(a=e[(c=(P=a)+20|0)>>2])||(c=P+16|0,a=e[P+16>>2]););e[u>>2]=0;break e}}}if(d>>>0<=(P=e[2089])>>>0){a=e[2092],16<=(_=P-d|0)>>>0?(e[2089]=_,e[2092]=c=a+d|0,e[c+4>>2]=1|_,e[a+P>>2]=_,e[a+4>>2]=3|d):(e[2092]=0,e[2089]=0,e[a+4>>2]=3|P,e[4+(P=a+P|0)>>2]=1|e[P+4>>2]),a=a+8|0;break r}if(d>>>0<(c=e[2090])>>>0){e[2090]=P=c-d|0,a=e[2093],e[2093]=_=a+d|0,e[_+4>>2]=1|P,e[a+4>>2]=3|d,a=a+8|0;break r}if((_=(u=(_=E=d+47|(a=0))+(P=e[2205]?e[2207]:(e[2208]=-1,e[2209]=-1,e[2206]=4096,e[2207]=4096,e[2205]=12+p&-16^1431655768,e[2210]=0,e[2198]=0,4096))|0)&(g=0-P|0))>>>0<=d>>>0||(P=e[2197])&&(b=(y=e[2195])+_|0)>>>0<=y>>>0|P>>>0<b>>>0)break r;if(4&H[8792])break o;a:{d:{if(P=e[2093])for(a=8796;;){if((y=e[a>>2])+e[a+4>>2]>>>0>P>>>0&&y>>>0<=P>>>0)break d;if(!(a=e[a+8>>2]))break}if((0|(P=Me(0)))==-1||(u=_,(u=(c=(a=e[2206])+-1|0)&P?(_-P|0)+(P+c&0-a)|0:u)>>>0<=d>>>0|2147483646<u>>>0)||(a=e[2197])&&(g=(c=e[2195])+u|0)>>>0<=c>>>0|a>>>0<g>>>0)break n;if((0|P)!=(0|(a=Me(u))))break a;break s}if(2147483646<(u=g&u-c)>>>0)break n;if((0|(P=Me(u)))==(e[a>>2]+e[a+4>>2]|0))break c;a=P}if(!(d+48>>>0<=u>>>0|2147483646<u>>>0|(0|(P=a))==-1)){if(2147483646<(a=(a=e[2207])+(E-u|0)&0-a)>>>0)break s;if((0|Me(a))!=-1){u=a+u|0;break s}Me(0-u|0);break n}if((0|P)!=-1)break s;break n}E=0;break t}P=0;break e}if((0|P)!=-1)break s}e[2198]=4|e[2198]}if(2147483646<_>>>0||(P=Me(_),(a=Me(0))>>>0<=P>>>0|(0|P)==-1|(0|a)==-1)||(u=a-P|0)>>>0<=d+40>>>0)break i}a=e[2195]+u|0,(e[2195]=a)>>>0>rt[2196]&&(e[2196]=a);s:{o:{n:{if(_=e[2093]){for(a=8796;;){if(((c=e[a>>2])+(E=e[a+4>>2])|0)==(0|P))break n;if(!(a=e[a+8>>2]))break}break o}for((a=e[2091])>>>0<=P>>>0&&a||(e[2091]=P),a=0,e[2200]=u,e[2199]=P,e[2095]=-1,e[2096]=e[2205],e[2202]=0;e[8396+(_=a<<3)>>2]=c=_+8388|0,e[_+8400>>2]=c,(0|(a=a+1|0))!=32;);e[2090]=c=(a=u+-40|0)-(_=P+8&7?-8-P&7:0)|0,e[2093]=_=P+_|0,e[_+4>>2]=1|c,e[4+(a+P|0)>>2]=40,e[2094]=e[2209];break s}if(!(8&H[a+12|0]|P>>>0<=_>>>0|_>>>0<c>>>0)){e[a+4>>2]=E+u,e[2093]=P=(a=_+8&7?-8-_&7:0)+_|0,c=e[2090]+u|0,e[2090]=a=c-a|0,e[P+4>>2]=1|a,e[4+(_+c|0)>>2]=40,e[2094]=e[2209];break s}}P>>>0<(E=e[2091])>>>0&&(e[2091]=P,E=0),c=P+u|0,a=8796;o:{n:{c:{f:{l:{a:{for(;(0|c)!=e[a>>2];)if(!(a=e[a+8>>2]))break a;if(!(8&H[a+12|0]))break l}for(a=8796;;){if((c=e[a>>2])>>>0<=_>>>0&&_>>>0<(E=c+e[a+4>>2]|0)>>>0)break f;a=e[a+8>>2]}}if(e[a>>2]=P,e[a+4>>2]=e[a+4>>2]+u,e[4+(b=(P+8&7?-8-P&7:0)+P|0)>>2]=3|d,a=((P=c+(c+8&7?-8-c&7:0)|0)-b|0)-d|0,g=d+b|0,(0|P)==(0|_)){e[2093]=g,a=e[2090]+a|0,e[2090]=a,e[g+4>>2]=1|a;break n}if(e[2092]==(0|P)){e[2092]=g,a=e[2089]+a|0,e[2089]=a,e[g+4>>2]=1|a,e[a+g>>2]=a;break n}if((3&(_=e[P+4>>2]))==1){S=-8&_;l:if(_>>>0<=255)E=_>>>3,_=e[P+8>>2],(0|(c=e[P+12>>2]))==(0|_)?(R=e[2087]&kr(E),e[2087]=R):(e[_+12>>2]=c,e[c+8>>2]=_);else{if(y=e[P+24>>2],(0|(u=e[P+12>>2]))!=(0|P))_=e[P+8>>2],e[_+12>>2]=u,e[u+8>>2]=_;else if(d=(d=e[(c=P+20|0)>>2])||e[(c=P+16|0)>>2]){for(;_=c,(d=e[(c=(u=d)+20|0)>>2])||(c=u+16|0,d=e[u+16>>2]););e[_>>2]=0}else u=0;if(y){_=e[P+28>>2];a:{if(e[(c=8652+(_<<2)|0)>>2]==(0|P)){if(e[c>>2]=u)break a;R=e[2088]&kr(_),e[2088]=R;break l}if(!(e[y+(e[y+16>>2]==(0|P)?16:20)>>2]=u))break l}e[u+24>>2]=y,(_=e[P+16>>2])&&(e[u+16>>2]=_,e[_+24>>2]=u),(_=e[P+20>>2])&&(e[u+20>>2]=_,e[_+24>>2]=u)}}P=P+S|0,a=a+S|0}if(e[P+4>>2]=-2&e[P+4>>2],e[g+4>>2]=1|a,(e[a+g>>2]=a)>>>0<=255){a=8388+((P=a>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|_,a),e[a+8>>2]=g,e[P+12>>2]=g,e[g+12>>2]=a,e[g+8>>2]=P;break n}if(P=0,(c=a>>>8)&&(P=31,16777215<a>>>0||(P=28+((P=((d=(c<<=E=c+1048320>>>16&8)<<(P=c+520192>>>16&4))<<(c=d+245760>>>16&2)>>>15)-(c|P|E)|0)<<1|a>>>P+21&1)|0)),e[(_=g)+28>>2]=P,e[g+16>>2]=0,_=8652+(P<<2)|(e[g+20>>2]=0),(c=e[2088])&(E=1<<P)){for(c=a<<((0|P)==31?0:25-(P>>>1)|0),P=e[_>>2];;){if((-8&e[(_=P)+4>>2])==(0|a))break c;if(P=c>>>29,c<<=1,!(P=e[16+(E=(4&P)+_|0)>>2]))break}e[E+16>>2]=g}else e[2088]=c|E,e[_>>2]=g;e[g+24>>2]=_,e[g+12>>2]=g,e[g+8>>2]=g;break n}for(e[2090]=g=(a=u+-40|0)-(c=P+8&7?-8-P&7:0)|0,e[2093]=c=P+c|0,e[c+4>>2]=1|g,e[4+(a+P|0)>>2]=40,e[2094]=e[2209],e[(c=(a=(E+(E+-39&7?39-E&7:0)|0)-47|0)>>>0<_+16>>>0?_:a)+4>>2]=27,a=e[2202],e[c+16>>2]=e[2201],e[c+20>>2]=a,a=e[2200],e[c+8>>2]=e[2199],e[c+12>>2]=a,e[2201]=c+8,e[2200]=u,e[2199]=P,a=c+24|(e[2202]=0);e[a+4>>2]=7,P=a+8|0,a=a+4|0,P>>>0<E>>>0;);if((0|_)==(0|c))break s;if(e[c+4>>2]=-2&e[c+4>>2],e[_+4>>2]=1|(E=c-_|0),(e[c>>2]=E)>>>0<=255){a=8388+((P=E>>>3)<<3)|0,P=(c=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|c,a),e[a+8>>2]=_,e[P+12>>2]=_,e[_+12>>2]=a,e[_+8>>2]=P;break s}if(e[_+16>>2]=0,a=e[_+20>>2]=0,(c=E>>>8)&&(a=31,16777215<E>>>0||(a=28+((a=((g=(c<<=u=c+1048320>>>16&8)<<(a=c+520192>>>16&4))<<(c=g+245760>>>16&2)>>>15)-(c|a|u)|0)<<1|E>>>a+21&1)|0)),P=8652+((e[(P=_)+28>>2]=a)<<2)|0,(c=e[2088])&(u=1<<a)){for(a=E<<((0|a)==31?0:25-(a>>>1)|0),P=e[P>>2];;){if((0|E)==(-8&e[(c=P)+4>>2]))break o;if(P=a>>>29,a<<=1,!(P=e[16+(u=c+(4&P)|0)>>2]))break}e[u+16>>2]=_,e[_+24>>2]=c}else e[2088]=c|u,e[P>>2]=_,e[_+24>>2]=P;e[_+12>>2]=_,e[_+8>>2]=_;break s}a=e[_+8>>2],e[a+12>>2]=g,e[_+8>>2]=g,e[g+24>>2]=0,e[g+12>>2]=_,e[g+8>>2]=a}a=b+8|0;break r}a=e[c+8>>2],e[a+12>>2]=_,e[c+8>>2]=_,e[_+24>>2]=0,e[_+12>>2]=c,e[_+8>>2]=a}if(!((a=e[2090])>>>0<=d>>>0)){e[2090]=P=a-d|0,a=e[2093],e[2093]=_=a+d|0,e[_+4>>2]=1|P,e[a+4>>2]=3|d,a=a+8|0;break r}}e[2086]=48,a=0;break r}e:if(g){a=e[E+28>>2];i:{if(e[(c=8652+(a<<2)|0)>>2]==(0|E)){if(e[c>>2]=P)break i;y=kr(a)&y,e[2088]=y;break e}if(!(e[g+(e[g+16>>2]==(0|E)?16:20)>>2]=P))break e}e[P+24>>2]=g,(a=e[E+16>>2])&&(e[P+16>>2]=a,e[a+24>>2]=P),(a=e[E+20>>2])&&(e[P+20>>2]=a,e[a+24>>2]=P)}e:if(_>>>0<=15)e[E+4>>2]=3|(a=_+d|0),e[4+(a=a+E|0)>>2]=1|e[a+4>>2];else if(e[E+4>>2]=3|d,e[4+(c=E+d|0)>>2]=1|_,(e[_+c>>2]=_)>>>0<=255)a=8388+((P=_>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[a+8>>2]:(e[2087]=P|_,a),e[a+8>>2]=c,e[P+12>>2]=c,e[c+12>>2]=a,e[c+8>>2]=P;else{a=0,(d=_>>>8)&&(a=31,16777215<_>>>0||(a=28+((a=((g=(d<<=u=d+1048320>>>16&8)<<(a=d+520192>>>16&4))<<(d=g+245760>>>16&2)>>>15)-(d|a|u)|0)<<1|_>>>a+21&1)|0)),e[(P=c)+28>>2]=a,e[c+16>>2]=0,P=8652+(a<<2)|(e[c+20>>2]=0);i:{if((d=1<<a)&y){for(a=_<<((0|a)==31?0:25-(a>>>1)|0),d=e[P>>2];;){if((-8&e[(P=d)+4>>2])==(0|_))break i;if(d=a>>>29,a<<=1,!(d=e[16+(u=(4&d)+P|0)>>2]))break}e[u+16>>2]=c}else e[2088]=d|y,e[P>>2]=c;e[c+24>>2]=P,e[c+12>>2]=c,e[c+8>>2]=c;break e}a=e[P+8>>2],e[a+12>>2]=c,e[P+8>>2]=c,e[c+24>>2]=0,e[c+12>>2]=P,e[c+8>>2]=a}a=E+8|0;break r}t:if(b){a=e[P+28>>2];e:{if(e[(_=8652+(a<<2)|0)>>2]==(0|P)){if(e[_>>2]=E)break e;R=kr(a)&S,e[2088]=R;break t}if(!(e[b+(e[b+16>>2]==(0|P)?16:20)>>2]=E))break t}e[E+24>>2]=b,(a=e[P+16>>2])&&(e[E+16>>2]=a,e[a+24>>2]=E),(a=e[P+20>>2])&&(e[E+20>>2]=a,e[a+24>>2]=E)}c>>>0<=15?(e[P+4>>2]=3|(a=c+d|0),e[4+(a=a+P|0)>>2]=1|e[a+4>>2]):(e[P+4>>2]=3|d,e[4+(d=P+d|0)>>2]=1|c,e[c+d>>2]=c,y&&(a=8388+((_=y>>>3)<<3)|0,E=e[2092],_=(_=1<<_)&u?e[a+8>>2]:(e[2087]=_|u,a),e[a+8>>2]=E,e[_+12>>2]=E,e[E+12>>2]=a,e[E+8>>2]=_),e[2092]=d,e[2089]=c),a=P+8|0}return K=16+p|0,a}function mr(a,p,P,_,c,E,u){var d,g,y,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0;e[76+(K=y=K-80|0)>>2]=p,g=55+y|0,d=56+y|0,p=0;r:{t:{e:for(;;){(0|tt)<0||(tt=(2147483647-tt|0)<(0|p)?(e[2086]=61,-1):p+tt|0);i:{s:{o:{n:{c:{f:{l:{a:{d:{p:{m:{y:{_:{if(F=e[76+y>>2],R=H[0|(p=F)]){for(;;){v:{x:{h:if(b=255&R){if((0|b)!=37)break x;for(R=p;;){if(H[p+1|0]!=37)break h;if(e[76+y>>2]=b=p+2|0,R=R+1|0,S=H[p+2|0],p=b,(0|S)!=37)break}}else R=p;if(p=R-F|0,a&&Fe(a,F,p),p)continue e;ut=-1,B=!ie(O[e[76+(b=y)>>2]+(R=1)|0]),p=e[76+y>>2],B|H[p+2|0]!=36||(ut=O[p+1|0]+-48|0,mt=1,R=3),e[b+76>>2]=p=R+p|0;h:if(31<(S=(z=O[(R=0)|p])+-32|0)>>>0)b=p;else if(b=p,75913&(S=1<<S))for(;;){if(e[76+y>>2]=b=p+1|0,R|=S,31<(S=(z=O[p+1|0])+-32|0)>>>0)break h;if(p=b,!(75913&(S=1<<S)))break}if((0|z)==42){if(B=y,ie(O[b+1|0])&&(p=e[76+y>>2],H[p+2|0]==36))e[((O[p+1|0]<<2)+c|0)-192>>2]=10,q=e[((O[p+1|0]<<3)+_|0)-384>>2],mt=1,p=p+3|0;else{if(mt)break t;q=mt=0,a&&(p=e[P>>2],e[P>>2]=p+4,q=e[p>>2]),p=e[76+y>>2]+1|0}e[B+76>>2]=p,-1<(0|q)||(q=0-q|0,R|=8192)}else{if((0|(q=xo(76+y|0)))<0)break t;p=e[76+y>>2]}if(S=-1,H[0|p]==46)if(H[p+1|0]==42)if(ie(O[p+2|0])&&(p=e[76+y>>2],H[p+3|0]==36))e[((O[p+2|0]<<2)+c|0)-192>>2]=10,S=e[((O[p+2|0]<<3)+_|0)-384>>2],e[76+y>>2]=p=p+4|0;else{if(mt)break t;S=a?(p=e[P>>2],e[P>>2]=p+4,e[p>>2]):0,p=e[76+y>>2]+2|0,e[76+y>>2]=p}else e[76+y>>2]=p+1,S=xo(76+y|0),p=e[76+y>>2];for(b=0;;){if(Bt=b,V=-1,57<O[0|p]+-65>>>0)break r;if(e[76+y>>2]=z=p+1|0,b=O[0|p],p=z,!((b=H[3295+(b+j(Bt,58)|0)|0])+-1>>>0<8))break}if(!b)break r;h:{u:{g:{if((0|b)==19){if((0|ut)<=-1)break g;break r}if((0|ut)<0)break u;e[(ut<<2)+c>>2]=b,b=e[4+(p=(ut<<3)+_|0)>>2],e[64+y>>2]=e[p>>2],e[68+y>>2]=b}if(p=0,a)break h;continue e}if(!a)break i;ki(64+y|0,b,P,u),z=e[76+y>>2]}if(B=-65537&R,R=8192&R?B:R,ut=3336,b=d,p=O[z+-1|(V=0)],(z=(p=Bt&&(15&p)==3?-33&p:p)+-88|0)>>>0<=32)break v;h:{u:{g:{b:{if(6<(B=p+-65|0)>>>0){if((0|p)!=83)break s;if(!S)break b;b=e[64+y>>2];break u}switch(B-1|0){case 1:break g;case 0:case 2:break s;default:break _}}We(a,32,q,p=0,R);break h}e[12+y>>2]=0,e[8+y>>2]=e[64+y>>2],e[64+y>>2]=8+y,S=-1,b=8+y|0}p=0;u:{for(;;){if(!(F=e[b>>2]))break u;if((B=(0|(F=vo(4+y|0,F)))<0)|S-p>>>0<F>>>0)break;if(b=b+4|0,!((p=p+F|0)>>>0<S>>>0))break u}if(V=-1,B)break r}if(We(a,32,q,p,R),p)for(S=0,b=e[64+y>>2];;){if(!(F=e[b>>2])||(0|p)<(0|(S=(F=vo(4+y|0,F))+S|0)))break h;if(Fe(a,4+y|0,F),b=b+4|0,!(S>>>0<p>>>0))break}else p=0}We(a,32,q,p,8192^R),p=(0|p)<(0|q)?q:p;continue e}e[76+y>>2]=b=p+1|0,R=H[p+1|0],p=b;continue}break}switch(z-1|0){case 28:break c;case 21:break f;case 23:break a;case 22:break d;case 11:case 16:break p;case 10:break m;case 26:break y;case 8:case 12:case 13:case 14:break _;case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 9:case 15:case 17:case 18:case 19:case 20:case 24:case 25:case 27:case 29:case 30:break s;default:break l}}if(V=tt,a)break r;if(!mt)break i;for(p=1;;){if(a=e[(p<<2)+c>>2]){if(ki((p<<3)+_|0,a,P,u),(0|(p=p+(V=1)|0))!=10)continue;break r}break}if(V=1,9<p>>>0||(V=-1,e[(p<<2)+c>>2]))break r;for(;!e[((p=p+1|0)<<2)+c>>2]&&(0|p)!=10;);V=p>>>0<10?-1:1;break r}p=0|L[E](a,ct[64+y>>3],q,S,R,p);continue}b=(p=wo(F=(p=e[64+y>>2])||3346,S))||S+F|0,R=B,S=p?p-F|0:S;break s}O[55+y|0]=e[64+y>>2],S=1,F=g,R=B;break s}if(p=B=e[68+y>>2],F=e[64+y>>2],(0|p)<-1||(0|p)<=-1&&!(4294967295<F>>>0)){p=0-(p+(0<F>>>0)|0)|0,e[64+y>>2]=F=0-F|0,e[68+y>>2]=p,V=1,ut=3336;break n}if(2048&R){V=1,ut=3337;break n}ut=(V=1&R)?3338:3336;break n}if(F=function(Ht,ce,Ae){if(Ht|ce)for(;O[0|(Ae=Ae+-1|0)]=7&Ht|48,(Ht=(7&ce)<<29|Ht>>>3)|(ce>>>=3););return Ae}(e[64+y>>2],e[68+y>>2],d),!(8&R))break o;S=(0|(p=d-F|0))<(0|S)?S:p+1|0;break o}S=8<S>>>0?S:8,R|=8,p=120}if(F=function(Ht,ce,Ae,Ue){if(Ht|ce)for(;O[0|(Ae=Ae+-1|0)]=H[3824+(15&Ht)|0]|Ue,(Ht=(15&ce)<<28|Ht>>>4)|(ce>>>=4););return Ae}(e[64+y>>2],e[68+y>>2],d,32&p),!(8&R)|!(e[64+y>>2]|e[68+y>>2]))break o;ut=3336+(p>>>4)|0,V=2;break o}if(7<(b=255&Bt)>>>(p=0))continue;switch(b-1|0){default:case 0:e[e[64+y>>2]>>2]=tt;continue;case 1:b=e[64+y>>2],e[b>>2]=tt,e[b+4>>2]=tt>>31;continue;case 2:N[e[64+y>>2]>>1]=tt;continue;case 3:O[e[64+y>>2]]=tt;continue;case 5:e[e[64+y>>2]>>2]=tt;continue;case 4:continue;case 6:}b=e[64+y>>2],e[b>>2]=tt,e[b+4>>2]=tt>>31;continue}F=e[64+y>>2],p=e[68+y>>2],ut=3336}F=ye(F,p,d)}R=-1<(0|S)?-65537&R:R,S=!!((B=p=e[68+y>>2])|(z=e[64+y>>2]))|S?(0|(p=!(B|z)+(d-F|0)|0))<(0|S)?S:p:(F=d,0)}We(a,32,p=(0|q)<(0|(b=(S=(0|S)<(0|(B=b-F|0))?B:S)+V|0))?b:q,b,R),Fe(a,ut,V),We(a,48,p,b,65536^R),We(a,48,S,B,0),Fe(a,F,B),We(a,32,p,b,8192^R);continue}break}V=0;break r}V=-1}return K=80+y|0,V}function ur(a){var p,P=0,E=0,c=0,_=0,c=4,E=1439;r:if(P=H[0|a]){for(;!((0|(p=H[0|E]))!=(0|P)||!(c=c+-1|0)|!p);)if(E=E+1|0,P=H[a+1|0],a=a+1|0,!P)break r;_=P}return(255&_)-H[0|E]|0}function Br(a,p,P){var _,c,E=0,u=0,d=0;e[(K=c=K-240|0)>>2]=a,u=1;r:if(!((0|p)<2))for(E=a;;){if(E=(_=E+-4|0)-e[((d=p+-2|0)<<2)+P>>2]|0,0<=(0|L[5](a,E))&&-1<(0|L[5](a,_))||(a=(u<<2)+c|0,0<=(0|L[5](E,_))?(e[a>>2]=E,d=p+-1|0):E=e[a>>2]=_,u=u+1|0,(0|d)<2))break r;a=e[c>>2],p=d}Eo(c,u),K=240+c|0}function hi(a){var p,P,_=0;if(v(0),function(c){var E,u;e[c+428>>2]&&(u=e[c+332>>2],ge(e[c+460>>2],e[c+436>>2],E=u<<2),ge(e[c+464>>2],e[c+440>>2],E),ge(e[c+468>>2],e[c+448>>2],E),H[e[c>>2]+4|0]<4||(ge(e[c+472>>2],e[c+452>>2],E=u<<4),ge(e[c+476>>2],e[c+456>>2],E)))}(a),function(c){var E,u,d,g=0,y=v(0),b=v(0),S=0,R=v(0);if(v(0),v(0),1<=(0|(S=e[c>>2])))for(d=(g=e[c+4>>2])+j(S,52)|0,c=e[c+12>>2];y=I[c>>2],I[g+44>>2]!=(y=(E=e[g+16>>2])?(b=y,y=I[g+4>>2],R=I[g+12>>2],b=v(v(b-y)/R),u=v(Ft(b)),S=v(St(u))<v(2147483648)?~~u:-2147483648,v(y+v(R*v(b-v(0|S))))):(R=I[g+4>>2],b=I[g+8>>2],y<R?R:b<y?b:y))?(I[g+44>>2]=y,e[g+48>>2]=1):e[g+48>>2]=0,E||(I[c>>2]=y),c=c+4|0,(g=g+52|0)>>>0<d>>>0;);}(a+540|0),function(c){var E,u,d,g,y,b,S=0,R=0,F=v(0),B=0,V=v(0),z=(v(0),v(0),0),q=v(0),tt=0,ut=0,mt=0;if(v(0),1<=(0|(B=e[c+540>>2])))for(y=(z=e[c+544>>2])+j(B,52)|0,b=e[c+644>>2];;){r:if(!(e[z>>2]||(0|(B=e[z+32>>2]))<1))if(d=(c=e[z+28>>2])+j(B,28)|0,g=I[z+24>>2],u=I[z+20>>2],E=I[z+44>>2],b)for(;;){q=v(ut=0);t:{e:{i:{if((0|(R=e[c>>2]))<1)S=B=0;else if(tt=e[c+4>>2],V=I[tt>>2],F=v(V-u),(0|R)==1)B=E<v(u+V)^1|F<E^1,S=0;else{if(E<F){B=1,S=0;break e}if(B=0,E<v(u+V))S=0;else{if(S=1,F=I[tt+4>>2],!(E<v(u+F)))for(;;){if((0|R)==(0|(S=S+1|0)))break i;if(V=F,F=I[tt+(S<<2)>>2],E<v(u+F))break}v(F-u)<E||(S=S+-1|0,(F=v(F-V))<g)||(q=v(v(E-V)/F))}}if(B)break e;if(tt=R=1,e[c+16>>2])break t;break e}S=R+-1|0,B=1}tt=(R=(V=I[c+12>>2])!=q)&(q==v(0)|V==v(0))|e[c+8>>2]!=(0|S),ut=B}if(e[c+20>>2]=tt,e[c+24>>2]=R,I[c+12>>2]=q,e[c+16>>2]=ut,e[c+8>>2]=S,!((c=c+28|0)>>>0<d>>>0))break}else{if(!e[z+48>>2]){for(;;)if(e[c+20>>2]=0,!((c=c+28|(e[c+24>>2]=0))>>>0<d>>>0))break r}for(;;){q=v(ut=0);t:{e:{i:{s:if(!(((R=0)|(S=e[(tt=c)>>2]))<1)){if(B=e[c+4>>2],V=I[B>>2],F=v(V-u),(0|S)!=1){if(!(E<F)){if(R=0,E<v(u+V))break s;R=1;o:if(F=I[B+4>>2],!(E<v(u+F))){for(S=S+-1|0;V=F,(0|S)!=(0|R);)if(F=I[B+((R=R+1|0)<<2)>>2],E<v(u+F))break o;B=1;break e}if(B=0,v(F-u)<E){S=R;break i}if(S=R+-1|0,(F=v(F-V))<g)break i;q=v(v(E-V)/F);break i}B=1,S=0;break e}R=E<v(u+V)^1|F<E^1}B=R,S=0}if(!B&&(mt=R=1,e[c+16>>2]))break t}ut=B,mt=(R=(V=I[c+12>>2])!=q)&(q==v(0)|V==v(0))|e[c+8>>2]!=(0|S)}if(e[tt+20>>2]=mt,e[c+24>>2]=R,I[c+12>>2]=q,e[c+16>>2]=ut,e[c+8>>2]=S,!((c=c+28|0)>>>0<d>>>0))break}}if(!((z=z+52|0)>>>0<y>>>0))break}}(a),function(c){var E,u,d,g,y,b=0,S=v(0),R=0,F=0,B=v(0),V=0,z=v(0);if(v(0),!(H[e[c>>2]+4|0]<4||(0|(b=e[c+540>>2]))<1))for(g=(V=e[c+544>>2])+j(b,52)|0,y=e[c+644>>2];;){r:if(e[V>>2]==1&&!((0|(b=e[V+40>>2]))<1))if(u=(c=e[V+36>>2])+j(b,28)|0,E=I[V+44>>2],y)for(;;){z=v(b=0);t:if(!((0|(F=e[c>>2]))<2||(R=e[c+4>>2],E<=(S=I[R>>2])))){b=1;e:if(!(E<(B=I[R+4>>2]))){for(;S=B,(0|F)!=(0|(b=b+1|0));)if(E<(B=I[R+(b<<2)>>2]))break e;b=F+-1|0;break t}z=v(v(E-S)/v(B-S)),b=b+-1|0}if(S=I[c+16>>2],I[c+16>>2]=z,F=e[c+12>>2],e[c+12>>2]=b,e[c+24>>2]=R=S!=z,e[c+20>>2]=R&(z==v(0)|S==v(0))|(0|b)!=(0|F),!((c=c+28|0)>>>0<u>>>0))break}else{if(!e[V+48>>2]){for(;;)if(e[c+20>>2]=0,!((c=c+28|(e[c+24>>2]=0))>>>0<u>>>0))break r}for(;;){z=v(F=0);t:if(!((0|(d=e[c>>2]))<2||(R=e[c+4>>2],E<=(S=I[R>>2])))){if(b=1,!(E<(B=I[R+4>>2])))for(F=d+-1|0;;){if(S=B,(0|b)==(0|F))break t;if(E<(B=I[R+((b=b+1|0)<<2)>>2]))break}z=v(v(E-S)/v(B-S)),F=b+-1|0}if(S=I[c+16>>2],I[c+16>>2]=z,b=e[c+12>>2],e[c+12>>2]=F,e[c+24>>2]=R=S!=z,e[c+20>>2]=R&(z==v(0)|S==v(0))|(0|b)!=(0|F),!((c=c+28|0)>>>0<u>>>0))break}}if(!((V=V+52|0)>>>0<g>>>0))break}}(a),function(c){var E,u,d,g,y,b,S,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=v(0),mt=0,Bt=0,Ht=0,ce=0,Ae=0;if(1<=(0|(F=e[c+564>>2])))for(b=(z=e[c+568>>2])+j(F,36)|0,g=e[c+644>>2];;){r:{if(!(q=((B=V=F=0)|(u=e[z+4>>2]))<1))for(mt=e[z>>2],c=ce=0;;){if(R=e[mt+(c<<2)>>2],e[R+16>>2]){R=1,Ae=0;break r}if(B=B||e[R+24>>2],F=F||e[R+20>>2],V=(I[R+12>>2]!=v(0))+V|0,(0|u)==(0|(c=c+1|0)))break}if(R=0,(ce=g?1:B)|(Ae=g?1:F)&&(e[z+12>>2]=mt=1<<V,(0|V)!=31)){for(F=e[z+20>>2],y=e[z>>2],B=(c=e[z+16>>2])+(tt=mt<<2)|0,B=Ce(c,0,4+((-1^c)+((c=c+4|0)>>>0<B>>>0?B:c)|0)&-4),tt=F+tt|0,c=F;e[c>>2]=1065353216,(c=c+4|0)>>>0<tt>>>0;);if(!q){if(q=0,tt=R=1,V)for(;;){if(V=e[(q<<2)+y>>2],Bt=e[V+8>>2],Ht=j(Bt,R),(ut=I[V+12>>2])!=v(c=0)){for(e[B>>2]=Ht+e[B>>2],I[F>>2]=v(v(1)-ut)*I[F>>2],Bt=j(Bt+(c=1)|0,R);ut=I[V+12>>2],S=e[(d=(E=c<<2)+B|0)>>2],e[d>>2]=S+((d=c&tt)?Bt:Ht),I[(E=F+E|0)>>2]=(d?ut:v(v(1)-ut))*I[E>>2],(0|mt)!=(0|(c=c+1|0)););tt<<=1}else for(;e[(Bt=B+(c<<2)|0)>>2]=Ht+e[Bt>>2],(0|mt)!=(0|(c=c+1|0)););if(R=j(e[V>>2],R),(0|u)==(0|(q=q+1|0)))break}else for(;;){if(V=e[(q<<2)+y>>2],tt=j(e[V+8>>2],R),(ut=I[V+12>>2])!=v(c=0))e[B>>2]=tt+e[B>>2],I[F>>2]=v(v(1)-ut)*I[F>>2];else for(;e[(Ht=B+(c<<2)|0)>>2]=tt+e[Ht>>2],(0|mt)!=(0|(c=c+1|0)););if(R=j(e[V>>2],R),(0|u)==(0|(q=q+1|0)))break}R=0}}}if(e[z+32>>2]=R,e[z+24>>2]=Ae,e[z+28>>2]=ce,!((z=z+36|0)>>>0<b>>>0))break}}(a),function(c){var E,u,d,g,y=v(0),b=0,S=0,R=0,F=0,B=0,V=v(0),z=v(0),q=v(0),tt=0,ut=0,mt=0;if(!(H[e[c>>2]+4|0]<4||(0|(b=e[c+588>>2]))<1))for(g=(R=e[c+592>>2])+j(b,48)|0,E=e[c+644>>2];;){if(c=e[R>>2],(ut=E?1:e[c+20>>2])|(mt=E?1:e[c+24>>2])){r:{t:{B=R,F=e[c+8>>2],b=e[c+12>>2],y=I[c+16>>2],c=(0|F)!=(0|b);e:{if(y!=v(0)){if(c=b+1|0,(0|b)==(0|F)){e[R+8>>2]=ut=1,y=v(v(1)-y),mt=1;break e}c=(0|c)==(0|F)?1:2}if(e[B+8>>2]=c,!mt)break t;c=b}I[R+24>>2]=y,I[R+20>>2]=v(1)-y;break r}mt=0,c=b}ut?(e[R+12>>2]=c,e[R+16>>2]=c+1):ut=0}else ut=mt=0;r:if((0|(u=e[R+36>>2]))<1)q=v(1);else{if(d=e[R+40>>2],c=0,q=v(1),!E)for(;;){t:{e:{if(b=e[(c<<2)+d>>2],S=e[b>>2]){if(!e[S+48>>2]){y=I[b+16>>2];break t}if((0|(F=e[b+12>>2]))<1){y=v(1),I[b+16>>2]=1;break t}if(tt=e[b+8>>2],(0|F)!=1&&(V=I[S+44>>2],B=e[b+4>>2],!(V<=(z=I[B>>2]))))break e;y=I[tt>>2],I[b+16>>2]=y;break t}e[b+16>>2]=1065353216,y=v(1);break t}S=1;e:if(!(V<(y=I[B+4>>2]))){for(;z=y,(0|F)!=(0|(S=S+1|0));)if(V<(y=I[B+(S<<2)>>2]))break e;y=I[(tt+(F<<2)|0)-4>>2],I[b+16>>2]=y;break t}B=b,y=v(v(V-z)/v(y-z)),y=v(v(y*I[(b=tt+(S<<2)|0)>>2])+v(I[b+-4>>2]*v(v(1)-y))),I[B+16>>2]=y}if(q=q<y?q:y,(0|u)==(0|(c=c+1|0)))break r}for(;;){b=e[(c<<2)+d>>2],S=e[b>>2],y=v(1);t:if(S&&(tt=e[b+12>>2],y=v(1),!((0|tt)<1))&&(F=e[b+8>>2],y=I[F>>2],(0|tt)!=1)){e:{if(V=I[S+44>>2],B=e[b+4>>2],V<=(z=I[B>>2])){y=I[F>>2];break t}if(S=1,!(V<(y=I[B+4>>2]))){for(;z=y,(0|tt)!=(0|(S=S+1|0));)if(V<(y=I[B+(S<<2)>>2]))break e;y=I[(F+(tt<<2)|0)-4>>2];break t}}y=v(v(V-z)/v(y-z)),y=v(v(y*I[(S=F+(S<<2)|0)>>2])+v(I[S+-4>>2]*v(v(1)-y)))}if(q=q<(I[b+16>>2]=y)?q:y,(0|u)==(0|(c=c+1|0)))break}}if(e[R+32>>2]=mt,e[R+28>>2]=ut,I[R+44>>2]=q,!((R=R+48|0)>>>0<g>>>0))break}}(a),1<=(0|(p=e[a+4>>2])))for(p=(_=e[a+52>>2])+(p<<2)|0;P=I[_>>2],I[_>>2]=P<v(0)?v(0):v(Mt(P,v(1))),(_=_+4|0)>>>0<p>>>0;);(function(c){var E,u,d,g=0,y=0;if(1<=(0|(y=e[c+4>>2])))for(d=(g=e[c+8>>2])+j(y,12)|0,c=E=e[c+40>>2];y=0,e[g+8>>2]&&(u=e[g+4>>2],!e[(u<<2)+E>>2]&&(0|u)!=-1||(y=!e[e[g>>2]+32>>2])),e[c>>2]=y,c=c+4|0,(g=g+12|0)>>>0<d>>>0;);})(a),function(c){var E,u,d,g,y,b,S,R=0,F=0,B=0,V=0,z=0;if(1<=(0|(u=e[c+4>>2])))for(g=e[c+8>>2],d=e[c>>2],y=e[d+724>>2];;){if(E=e[j(V,12)+g>>2],(e[E+28>>2]||e[E+24>>2])&&(e[(R=V<<2)+e[c+28>>2]>>2]=e[E+12>>2],e[E+24>>2])&&!((0|(B=e[E+12>>2]))<1))for(B=(F=e[E+16>>2])+(B<<2)|0,b=e[R+y>>2],R=e[c+36>>2]+(z<<2)|0,S=e[d+976>>2];e[R>>2]=e[(e[F>>2]+b<<2)+S>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(e[E+28>>2]&&!((0|(R=e[E+12>>2]))<1))for(B=(F=e[E+20>>2])+(R<<2)|0,R=e[c+32>>2]+(z<<2)|0;e[R>>2]=e[F>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(z=e[E+8>>2]+z|0,(0|u)==(0|(V=V+1|0)))break}}(a),L[e[1808]](a+12|0,e[a+36>>2],e[a+44>>2],e[a+40>>2]),function(c){var E,u,d,g,y,b,S=0,R=0,F=0;if(1<=(0|(F=e[c+304>>2])))for(d=(S=e[c+308>>2])+(F<<5)|0,g=e[c+264>>2],y=e[c+144>>2],b=e[c+40>>2],F=u=e[c+312>>2];E=F,R=0,c=R=!e[S+28>>2]||(0|(c=e[S+4>>2]))!=-1&&(R=0,!e[(c<<2)+b>>2])||(0|(c=e[S+8>>2]))!=-1&&(R=0,!e[(c<<2)+u>>2])?R:!e[e[S>>2]+32>>2],e[E>>2]=c,(E=e[S+12>>2])>>>0<=1?E-1?e[(e[S+16>>2]<<2)+y>>2]=c:e[(e[S+16>>2]<<2)+g>>2]=c:Ut(4,1372,0),F=F+4|0,(S=S+32|0)>>>0<d>>>0;);}(a),function(c){var E,u,d,g,y,b,S,R,F,B=0,V=0,z=0,q=0,pe=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,Ae=0,Ue=0,He=0,pe=e[c>>2];if(1<=(0|(mt=e[c+56>>2]))){for(Bt=e[c+60>>2],Ht=e[pe+1052>>2],ce=e[pe+784>>2];;){if(B=e[Bt+j(tt,24)>>2],(e[B+28>>2]||e[B+24>>2])&&(e[(V=tt<<2)+e[c+80>>2]>>2]=e[B+12>>2],e[B+24>>2])&&!((0|(q=e[B+12>>2]))<1))for(Ae=(z=e[B+16>>2])+(q<<2)|0,Ue=e[V+ce>>2],V=(q=ut<<2)+e[c+92>>2]|0,q=q+e[c+88>>2]|0;He=Ue+e[z>>2]<<2,e[V>>2]=Ht+(e[He+e[pe+984>>2]>>2]<<2),e[q>>2]=e[He+e[pe+980>>2]>>2],q=q+4|0,V=V+4|0,(z=z+4|0)>>>0<Ae>>>0;);if(e[B+28>>2]&&!((0|(V=e[B+12>>2]))<1))for(q=(z=e[B+20>>2])+(V<<2)|0,V=e[c+84>>2]+(ut<<2)|0;e[V>>2]=e[z>>2],V=V+4|0,(z=z+4|0)>>>0<q>>>0;);if(ut=e[B+8>>2]+ut|0,(0|mt)==(0|(tt=tt+1|0)))break}pe=e[c>>2]}if(!(H[pe+4|0]<4||(0|(Ue=e[c+56>>2]))<1))for(He=e[pe+792>>2],E=e[c+60>>2],z=ut=0;;){if(tt=e[j(z,24)+E>>2],e[tt+24>>2]&&!((0|(B=e[tt+12>>2]))<1))for(u=(V=e[tt+16>>2])+(B<<2)|0,d=e[He+(z<<2)>>2],q=(B=ut<<2)+e[c+96>>2]|0,mt=B+e[c+100>>2]|0,Bt=B+e[c+104>>2]|0,Ht=B+e[c+108>>2]|0,ce=B+e[c+112>>2]|0,Ae=B+e[c+116>>2]|0,g=e[pe+1308>>2],y=e[pe+1304>>2],b=e[pe+1300>>2],S=e[pe+1296>>2],R=e[pe+1292>>2],F=e[pe+1288>>2];B=e[V>>2]+d<<2,e[q>>2]=e[B+F>>2],e[mt>>2]=e[B+R>>2],e[Bt>>2]=e[B+S>>2],e[Ht>>2]=e[B+b>>2],e[ce>>2]=e[B+y>>2],e[Ae>>2]=e[B+g>>2],Ae=Ae+4|0,ce=ce+4|0,Ht=Ht+4|0,Bt=Bt+4|0,mt=mt+4|0,q=q+4|0,(V=V+4|0)>>>0<u>>>0;);if(ut=e[tt+8>>2]+ut|0,(0|Ue)==(0|(z=z+1|0)))break}}(a),function(c){var E=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,Ae=0,Ue=0,He=e[c+168>>2],pe=e[c>>2];if(1<=(0|(q=e[c+164>>2])))for(ut=e[pe+816>>2];;){if(d=e[j(S,12)+He>>2],(e[d+28>>2]||e[d+24>>2])&&(e[(R=S<<2)+e[c+188>>2]>>2]=e[d+12>>2],e[d+24>>2])){if(u=e[d+16>>2],tt=e[R+ut>>2],1<=(0|(E=e[d+12>>2])))for(mt=u+(E<<2)|0,g=(E=b<<2)+e[c+200>>2]|0,F=E+e[c+204>>2]|0,B=E+e[c+208>>2]|0,V=E+e[c+212>>2]|0,z=E+e[c+196>>2]|0,Bt=e[pe+996>>2],Ht=e[pe+1012>>2],ce=e[pe+1008>>2],Ae=e[pe+1004>>2],Ue=e[pe+1e3>>2],E=u;y=tt+e[E>>2]<<2,e[g>>2]=e[y+Ue>>2],e[F>>2]=e[y+Ae>>2],e[B>>2]=e[y+ce>>2],e[V>>2]=e[y+Ht>>2],e[z>>2]=e[y+Bt>>2],z=z+4|0,V=V+4|0,B=B+4|0,F=F+4|0,g=g+4|0,(E=E+4|0)>>>0<mt>>>0;);E=tt+e[u>>2]<<2,e[R+e[c+288>>2]>>2]=e[E+e[pe+1016>>2]>>2],e[R+e[c+292>>2]>>2]=e[E+e[pe+1020>>2]>>2]}if(e[d+28>>2]&&!((0|(u=e[d+12>>2]))<1))for(u=(E=e[d+20>>2])+(u<<2)|0,g=e[c+192>>2]+(b<<2)|0;e[g>>2]=e[E>>2],g=g+4|0,(E=E+4|0)>>>0<u>>>0;);if(b=e[d+8>>2]+b|0,(0|q)==(0|(S=S+1|0)))break}if(!(H[pe+4|0]<4||(0|(R=e[c+164>>2]))<1))for(tt=e[pe+824>>2],b=d=0;;){if(y=e[j(b,12)+He>>2],e[y+24>>2]&&!((0|(E=e[y+12>>2]))<1))for(q=(g=e[y+16>>2])+(E<<2)|0,ut=e[tt+(b<<2)>>2],F=(u=d<<2)+e[c+216>>2]|0,B=u+e[c+220>>2]|0,V=u+e[c+224>>2]|0,z=u+e[c+228>>2]|0,E=u+e[c+232>>2]|0,S=u+e[c+236>>2]|0,mt=e[pe+1308>>2],Bt=e[pe+1304>>2],Ht=e[pe+1300>>2],ce=e[pe+1296>>2],Ae=e[pe+1292>>2],Ue=e[pe+1288>>2];u=ut+e[g>>2]<<2,e[F>>2]=e[u+Ue>>2],e[B>>2]=e[u+Ae>>2],e[V>>2]=e[u+ce>>2],e[z>>2]=e[u+Ht>>2],e[E>>2]=e[u+Bt>>2],e[S>>2]=e[u+mt>>2],S=S+4|0,E=E+4|0,z=z+4|0,V=V+4|0,B=B+4|0,F=F+4|0,(g=g+4|0)>>>0<q>>>0;);if(d=e[y+8>>2]+d|0,(0|R)==(0|(b=b+1|0)))break}}(a),function(c){var E,F=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=c- -64|0;if(L[e[1807]](F,e[c+88>>2],e[c+148>>2],e[c+144>>2]),L[e[1809]](F,e[c+92>>2],e[c+152>>2],e[e[c>>2]+796>>2],2,e[c+144>>2]),!(H[e[c>>2]+4|0]<4||(L[e[1807]](F,e[c+96>>2],e[c+120>>2],e[c+144>>2]),L[e[1807]](F,e[c+100>>2],e[c+124>>2],e[c+144>>2]),L[e[1807]](F,e[c+104>>2],e[c+128>>2],e[c+144>>2]),L[e[1807]](F,e[c+108>>2],e[c+132>>2],e[c+144>>2]),L[e[1807]](F,e[c+112>>2],e[c+136>>2],e[c+144>>2]),L[e[1807]](F,e[c+116>>2],e[c+140>>2],e[c+144>>2]),(0|(b=e[c+56>>2]))<1))){for(S=e[c+128>>2],R=e[c+124>>2],E=e[c+120>>2],u=e[c+156>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+R>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|b)!=(0|(F=F+1|0)););for(u=e[c+160>>2],y=e[c+140>>2],S=e[c+136>>2],R=e[c+132>>2],F=c=0;e[(g=c<<2)+u>>2]=e[(d=F<<2)+R>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],c=c+4|0,(0|b)!=(0|(F=F+1|0)););}}(a),function(c){var E,F=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=c+172|0;if(L[e[1807]](F,e[c+196>>2],e[c+268>>2],e[c+264>>2]),L[e[1807]](F,e[c+200>>2],e[c+284>>2],e[c+264>>2]),L[e[1807]](F,e[c+204>>2],e[c+276>>2],e[c+264>>2]),L[e[1807]](F,e[c+208>>2],e[c+280>>2],e[c+264>>2]),L[e[1807]](F,e[c+212>>2],e[c+272>>2],e[c+264>>2]),!(H[e[c>>2]+4|0]<4||(L[e[1807]](F,e[c+216>>2],e[c+240>>2],e[c+264>>2]),L[e[1807]](F,e[c+220>>2],e[c+244>>2],e[c+264>>2]),L[e[1807]](F,e[c+224>>2],e[c+248>>2],e[c+264>>2]),L[e[1807]](F,e[c+228>>2],e[c+252>>2],e[c+264>>2]),L[e[1807]](F,e[c+232>>2],e[c+256>>2],e[c+264>>2]),L[e[1807]](F,e[c+236>>2],e[c+260>>2],e[c+264>>2]),(0|(b=e[c+164>>2]))<1))){for(S=e[c+248>>2],R=e[c+244>>2],E=e[c+240>>2],u=e[c+296>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+R>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|b)!=(0|(F=F+1|0)););for(u=e[c+300>>2],y=e[c+260>>2],S=e[c+256>>2],R=e[c+252>>2],F=c=0;e[(g=c<<2)+u>>2]=e[(d=F<<2)+R>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],c=c+4|0,(0|b)!=(0|(F=F+1|0)););}}(a),function(c){var E,u,d,g=0,y=0,b=0;if(1<=(0|(y=e[c+332>>2])))for(E=(g=e[c+336>>2])+j(y,20)|0,u=e[c+312>>2],d=e[c+40>>2],c=e[c+424>>2];y=0,e[g+12>>2]&&(b=e[g+4>>2],e[(b<<2)+d>>2]||(0|b)==-1)&&(b=e[g+8>>2],e[(b<<2)+u>>2]||(0|b)==-1)&&(y=!e[e[g>>2]+32>>2]),e[c>>2]=y,c=c+4|0,(g=g+20|0)>>>0<E>>>0;);}(a),function(c){var E,u,d,g,y,b,S,R,F=0,B=0,V=0,pe=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,Ae=0,Ue=0,He=0,pe=e[c>>2];if(1<=(0|(Bt=e[c+332>>2]))){for(Ht=e[c+336>>2],ce=e[pe+1052>>2],Ae=e[pe+856>>2];;){if(F=e[Ht+j(tt,20)>>2],(e[F+28>>2]||e[F+24>>2])&&(e[(B=tt<<2)+e[c+356>>2]>>2]=e[F+12>>2],e[F+24>>2])&&!((0|(z=e[F+12>>2]))<1))for(Ue=(V=e[F+16>>2])+(z<<2)|0,He=e[B+Ae>>2],B=(q=ut<<2)+e[c+372>>2]|0,z=q+e[c+364>>2]|0,q=q+e[c+368>>2]|0;mt=He+e[V>>2]<<2,e[B>>2]=ce+(e[mt+e[pe+1040>>2]>>2]<<2),e[z>>2]=e[mt+e[pe+1032>>2]>>2],e[q>>2]=e[mt+e[pe+1036>>2]>>2],q=q+4|0,z=z+4|0,B=B+4|0,(V=V+4|0)>>>0<Ue>>>0;);if(e[F+28>>2]&&!((0|(B=e[F+12>>2]))<1))for(z=(V=e[F+20>>2])+(B<<2)|0,B=e[c+360>>2]+(ut<<2)|0;e[B>>2]=e[V>>2],B=B+4|0,(V=V+4|0)>>>0<z>>>0;);if(ut=e[F+8>>2]+ut|0,(0|Bt)==(0|(tt=tt+1|0)))break}pe=e[c>>2]}if(!(H[pe+4|0]<4||(0|(Ae=e[c+332>>2]))<1))for(Ue=e[pe+864>>2],He=e[c+336>>2],V=ut=0;;){if(tt=e[He+j(V,20)>>2],e[tt+24>>2]&&!((0|(F=e[tt+12>>2]))<1))for(E=(B=e[tt+16>>2])+(F<<2)|0,u=e[Ue+(V<<2)>>2],z=(F=ut<<2)+e[c+376>>2]|0,q=F+e[c+380>>2]|0,mt=F+e[c+384>>2]|0,Bt=F+e[c+388>>2]|0,Ht=F+e[c+392>>2]|0,ce=F+e[c+396>>2]|0,d=e[pe+1308>>2],g=e[pe+1304>>2],y=e[pe+1300>>2],b=e[pe+1296>>2],S=e[pe+1292>>2],R=e[pe+1288>>2];F=e[B>>2]+u<<2,e[z>>2]=e[F+R>>2],e[q>>2]=e[F+S>>2],e[mt>>2]=e[F+b>>2],e[Bt>>2]=e[F+y>>2],e[Ht>>2]=e[F+g>>2],e[ce>>2]=e[F+d>>2],ce=ce+4|0,Ht=Ht+4|0,Bt=Bt+4|0,mt=mt+4|0,q=q+4|0,z=z+4|0,(B=B+4|0)>>>0<E>>>0;);if(ut=e[tt+8>>2]+ut|0,(0|Ae)==(0|(V=V+1|0)))break}}(a),function(c){var E,F=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=c+340|0;if(L[e[1807]](F,e[c+364>>2],e[c+448>>2],e[c+424>>2]),L[e[1808]](F,e[c+368>>2],e[c+440>>2],e[c+424>>2]),L[e[1809]](F,e[c+372>>2],e[c+444>>2],e[e[c>>2]+892>>2],2,e[c+424>>2]),!(H[e[c>>2]+4|0]<4||(L[e[1807]](F,e[c+376>>2],e[c+400>>2],e[c+424>>2]),L[e[1807]](F,e[c+380>>2],e[c+404>>2],e[c+424>>2]),L[e[1807]](F,e[c+384>>2],e[c+408>>2],e[c+424>>2]),L[e[1807]](F,e[c+388>>2],e[c+412>>2],e[c+424>>2]),L[e[1807]](F,e[c+392>>2],e[c+416>>2],e[c+424>>2]),L[e[1807]](F,e[c+396>>2],e[c+420>>2],e[c+424>>2]),(0|(b=e[c+332>>2]))<1))){for(S=e[c+408>>2],R=e[c+404>>2],E=e[c+400>>2],u=e[c+452>>2],F=0;e[(d=g<<2)+u>>2]=e[(y=F<<2)+E>>2],e[u+(4|d)>>2]=e[y+R>>2],e[u+(8|d)>>2]=e[y+S>>2],g=g+4|0,(0|b)!=(0|(F=F+1|0)););for(u=e[c+456>>2],y=e[c+420>>2],S=e[c+416>>2],R=e[c+412>>2],F=c=0;e[(g=c<<2)+u>>2]=e[(d=F<<2)+R>>2],e[u+(4|g)>>2]=e[d+S>>2],e[u+(8|g)>>2]=e[d+y>>2],c=c+4|0,(0|b)!=(0|(F=F+1|0)););}}(a),function(c){var E,u,d,g,y,b,S,R=0,F=0,B=0,V=0,z=0;if(1<=(0|(u=e[c+500>>2])))for(g=e[c+504>>2],d=e[c>>2],y=e[d+1252>>2];;){if(E=e[j(V,24)+g>>2],(e[E+28>>2]||e[E+24>>2])&&(e[(R=V<<2)+e[c+524>>2]>>2]=e[E+12>>2],e[E+24>>2])&&!((0|(B=e[E+12>>2]))<1))for(B=(F=e[E+16>>2])+(B<<2)|0,b=e[R+y>>2],R=e[c+532>>2]+(z<<2)|0,S=e[d+1284>>2];e[R>>2]=e[(e[F>>2]+b<<2)+S>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(e[E+28>>2]&&!((0|(R=e[E+12>>2]))<1))for(B=(F=e[E+20>>2])+(R<<2)|0,R=e[c+528>>2]+(z<<2)|0;e[R>>2]=e[F>>2],R=R+4|0,(F=F+4|0)>>>0<B>>>0;);if(z=e[E+8>>2]+z|0,(0|u)==(0|(V=V+1|0)))break}}(a),L[e[1807]](a+508|0,e[a+532>>2],e[a+536>>2],0),function(c){var E,u,d,g,y,b,S=v(0),R=0,F=0,B=0,V=0;if(v(0),K=E=K-16|0,B=e[c>>2],!(H[B+4|0]<5||(0|(V=e[c+596>>2]))<1))for(g=(F=e[c+600>>2])+j(V,12)|0,y=e[c+44>>2],V=e[B+976>>2];;){if(B=(e[F>>2]<<2)+y|0,S=v(e[B>>2]),1<=(0|(R=e[F+4>>2])))for(b=(c=e[F+8>>2])+j(R,48)|0;(R=e[c+8>>2])&&((u=R+-1|0)>>>0<=1?(R=e[c+4>>2],d=I[V+(R+e[c+12>>2]<<2)>>2],S=v(u-1?S+v(I[c+44>>2]*v(d*I[c+20>>2])):S+v(I[c+44>>2]*v(v(d*I[c+20>>2])+v(I[V+(R+e[c+16>>2]<<2)>>2]*I[c+24>>2]))))):(e[E>>2]=R,Ut(4,1024,E))),(c=c+48|0)>>>0<b>>>0;);if(S=(S=v(S+v(.0010000000474974513)))<v(0)?v(0):v(Mt(S,v(1e3))),c=v(St(S))<v(2147483648)?~~S:-2147483648,e[B>>2]=c,!((F=F+12|0)>>>0<g>>>0))break}K=16+E|0}(a),function(c){var E,u,d,g,y,b,S,R,F,B=0,V=0,z=0,q=0,tt=0,ut=v(0);if(K=E=K-16|0,B=e[c>>2],!(H[B+4|0]<4||(Yr(c,e[c+604>>2],e[c+608>>2],e[B+984>>2],e[c+152>>2],e[B+796>>2]),V=e[c>>2],H[V+4|0]<5))){if(z=e[c+608>>2],y=e[V+992>>2],b=e[V+988>>2],1<=(0|(B=e[c+604>>2]))){for(S=j(B,12)+z|0,R=e[c+148>>2],u=e[V+980>>2];;){if(d=(e[z>>2]<<2)+R|0,tt=e[d>>2],1<=(0|(q=e[z+4>>2])))for(F=(B=e[z+8>>2])+j(q,48)|0;(q=e[B+8>>2])&&((g=q+-1|0)>>>0<=1?(q=e[B+4>>2],ut=I[(q+e[B+12>>2]<<2)+u>>2],Qt(v(g-1?v(I[B+44>>2]*v(ut*I[B+20>>2]))+(Yt(0,tt),zt()):v(I[B+44>>2]*v(v(ut*I[B+20>>2])+v(I[(q+e[B+16>>2]<<2)+u>>2]*I[B+24>>2])))+(Yt(0,tt),zt()))),tt=Wt[0]):(e[E>>2]=q,Ut(4,1024,E))),(B=B+48|0)>>>0<F>>>0;);if(Yt(0,tt),ut=zt(),I[d>>2]=ut<v(0)?v(0):v(Mt(ut,v(1))),!((z=z+12|0)>>>0<S>>>0))break}z=e[c+608>>2],B=e[c+604>>2]}te(B,z,b,e[V+1288>>2],e[V+1292>>2],e[V+1296>>2],e[c+156>>2]),te(e[c+604>>2],e[c+608>>2],y,e[V+1300>>2],e[V+1304>>2],e[V+1308>>2],e[c+160>>2])}K=16+E|0}(a),function(c){var E,u=0,d=0,g=0,y=0,b=0,S=v(0),R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0;if(K=E=K-80|0,b=e[c>>2],!(H[b+4|0]<5)){if(q=e[b+1028>>2],tt=e[b+1024>>2],g=d=e[c+616>>2],!((0|(u=e[c+612>>2]))<1)){for(F=j(u,12)+d|0,B=e[c+276>>2],R=e[b+1004>>2];;){if(V=B+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((z=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=I[R+(y+e[u+12>>2]<<2)>>2],Qt(v(z-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[R+(y+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[64+E>>2]=y,Ut(4,1024,64+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(e[V>>2]=g,!((d=d+12|0)>>>0<F>>>0))break}if(g=d=e[c+616>>2],!((0|(u=e[c+612>>2]))<1)){for(F=j(u,12)+d|0,B=e[c+280>>2],R=e[e[c>>2]+1008>>2];;){if(V=B+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((z=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=I[R+(y+e[u+12>>2]<<2)>>2],Qt(v(z-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[R+(y+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[48+E>>2]=y,Ut(4,1024,48+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(e[V>>2]=g,!((d=d+12|0)>>>0<F>>>0))break}if(g=d=e[c+616>>2],!((0|(u=e[c+612>>2]))<1)){for(F=j(u,12)+d|0,B=e[c+268>>2],R=e[e[c>>2]+996>>2];;){if(V=B+(e[d>>2]<<2)|0,g=e[V>>2],1<=(0|(y=e[d+4>>2])))for(ut=(u=e[d+8>>2])+j(y,48)|0;(y=e[u+8>>2])&&((z=y+-1|0)>>>0<=1?(y=e[u+4>>2],S=I[R+(y+e[u+12>>2]<<2)>>2],Qt(v(z-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[R+(y+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[32+E>>2]=y,Ut(4,1024,32+E|0))),(u=u+48|0)>>>0<ut>>>0;);if(Yt(0,g),S=zt(),I[V>>2]=S<v(0)?v(0):v(Mt(S,v(1))),!((d=d+12|0)>>>0<F>>>0))break}u=e[c+612>>2],g=e[c+616>>2]}}}if(te(u,g,tt,e[b+1288>>2],e[b+1292>>2],e[b+1296>>2],e[c+296>>2]),te(e[c+612>>2],e[c+616>>2],q,e[b+1300>>2],e[b+1304>>2],e[b+1308>>2],e[c+300>>2]),!((0|(u=e[c+612>>2]))<1)){for(y=(d=e[c+616>>2])+j(u,12)|0,q=e[c+284>>2],b=e[e[c>>2]+1e3>>2];;){if(tt=q+(e[d>>2]<<2)|0,g=e[tt>>2],1<=(0|(R=e[d+4>>2])))for(F=(u=e[d+8>>2])+j(R,48)|0;(R=e[u+8>>2])&&((B=R+-1|0)>>>0<=1?(R=e[u+4>>2],S=I[b+(R+e[u+12>>2]<<2)>>2],Qt(v(B-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[b+(R+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[16+E>>2]=R,Ut(4,1024,16+E|0))),(u=u+48|0)>>>0<F>>>0;);if(Yt(0,g),S=zt(),I[tt>>2]=S<v(-3600)?v(-3600):v(Mt(S,v(3600))),!((d=d+12|0)>>>0<y>>>0))break}if(!((0|(u=e[c+612>>2]))<1))for(R=(d=e[c+616>>2])+j(u,12)|0,y=e[c+272>>2],c=e[e[c>>2]+1012>>2];;){if(q=y+(e[d>>2]<<2)|0,g=e[q>>2],1<=(0|(b=e[d+4>>2])))for(tt=(u=e[d+8>>2])+j(b,48)|0;(b=e[u+8>>2])&&((F=b+-1|0)>>>0<=1?(b=e[u+4>>2],S=I[c+(b+e[u+12>>2]<<2)>>2],Qt(v(F-1?v(I[u+44>>2]*v(S*I[u+20>>2]))+(Yt(0,g),zt()):v(I[u+44>>2]*v(v(S*I[u+20>>2])+v(I[c+(b+e[u+16>>2]<<2)>>2]*I[u+24>>2])))+(Yt(0,g),zt()))),g=Wt[0]):(e[E>>2]=b,Ut(4,1024,E))),(u=u+48|0)>>>0<tt>>>0;);if(Yt(0,g),S=zt(),I[q>>2]=S<v(9999999747378752e-20)?v(9999999747378752e-20):v(Mt(S,v(100))),!((d=d+12|0)>>>0<R>>>0))break}}}K=80+E|0}(a),function(c){var E,u,d,g,y,b=0,S=0,R=0,F=0,B=v(0),V=0,z=0,q=0,tt=0,ut=0,mt=0;if(v(0),K=E=K-32|0,R=e[c>>2],!(H[R+4|0]<4||(Yr(c,e[c+620>>2],e[c+624>>2],e[R+1040>>2],e[c+444>>2],e[R+892>>2]),V=e[c>>2],H[V+4|0]<5))){if(g=e[V+1048>>2],y=e[V+1044>>2],R=F=e[c+624>>2],!((0|(b=e[c+620>>2]))<1)){for(ut=j(b,12)+F|0,mt=e[c+440>>2],z=e[V+1036>>2];;){if(R=mt+(e[F>>2]<<2)|0,B=v(e[R>>2]),1<=(0|(S=e[F+4>>2])))for(q=(b=e[F+8>>2])+j(S,48)|0;(S=e[b+8>>2])&&((tt=S+-1|0)>>>0<=1?(S=e[b+4>>2],u=I[z+(S+e[b+12>>2]<<2)>>2],B=v(tt-1?B+v(I[b+44>>2]*v(u*I[b+20>>2])):B+v(I[b+44>>2]*v(v(u*I[b+20>>2])+v(I[z+(S+e[b+16>>2]<<2)>>2]*I[b+24>>2]))))):(e[16+E>>2]=S,Ut(4,1024,16+E|0))),(b=b+48|0)>>>0<q>>>0;);if(B=(B=v(B+v(.0010000000474974513)))<v(0)?v(0):v(Mt(B,v(1e3))),b=v(St(B))<v(2147483648)?~~B:-2147483648,e[R>>2]=b,!((F=F+12|0)>>>0<ut>>>0))break}if(R=F=e[c+624>>2],!((0|(b=e[c+620>>2]))<1)){for(ut=j(b,12)+F|0,mt=e[c+448>>2],z=e[e[c>>2]+1032>>2];;){if(q=mt+(e[F>>2]<<2)|0,R=e[q>>2],1<=(0|(S=e[F+4>>2])))for(tt=(b=e[F+8>>2])+j(S,48)|0;(S=e[b+8>>2])&&((d=S+-1|0)>>>0<=1?(S=e[b+4>>2],B=I[z+(S+e[b+12>>2]<<2)>>2],Qt(v(d-1?v(I[b+44>>2]*v(B*I[b+20>>2]))+(Yt(0,R),zt()):v(I[b+44>>2]*v(v(B*I[b+20>>2])+v(I[z+(S+e[b+16>>2]<<2)>>2]*I[b+24>>2])))+(Yt(0,R),zt()))),R=Wt[0]):(e[E>>2]=S,Ut(4,1024,E))),(b=b+48|0)>>>0<tt>>>0;);if(Yt(0,R),B=zt(),I[q>>2]=B<v(0)?v(0):v(Mt(B,v(1))),!((F=F+12|0)>>>0<ut>>>0))break}b=e[c+620>>2],R=e[c+624>>2]}}te(b,R,y,e[V+1288>>2],e[V+1292>>2],e[V+1296>>2],e[c+452>>2]),te(e[c+620>>2],e[c+624>>2],g,e[V+1300>>2],e[V+1304>>2],e[V+1308>>2],e[c+456>>2])}K=32+E|0}(a),function(c){var E,u,d,g,y,b,S=0,R=0,F=0,B=0,V=v(0);if(K=E=K-16|0,R=e[c>>2],!(H[R+4|0]<5||(0|(B=e[c+628>>2]))<1))for(g=(F=e[c+632>>2])+j(B,12)|0,y=e[c+536>>2],B=e[R+1284>>2];;){if(u=(e[F>>2]<<2)+y|0,R=e[u>>2],1<=(0|(S=e[F+4>>2])))for(b=(c=e[F+8>>2])+j(S,48)|0;(S=e[c+8>>2])&&((d=S+-1|0)>>>0<=1?(S=e[c+4>>2],V=I[B+(S+e[c+12>>2]<<2)>>2],Qt(v(d-1?v(I[c+44>>2]*v(V*I[c+20>>2]))+(Yt(0,R),zt()):v(I[c+44>>2]*v(v(V*I[c+20>>2])+v(I[B+(S+e[c+16>>2]<<2)>>2]*I[c+24>>2])))+(Yt(0,R),zt()))),R=Wt[0]):(e[E>>2]=S,Ut(4,1024,E))),(c=c+48|0)>>>0<b>>>0;);if(Yt(0,R),V=zt(),I[u>>2]=V<v(0)?v(0):v(Mt(V,v(1))),!((F=F+12|0)>>>0<g>>>0))break}K=16+E|0}(a),function(c){var E,u,d=0,g=0,y=0,b=v(0),S=0;if(1<=(0|(d=e[c+4>>2])))for(u=(g=e[c+8>>2])+j(d,12)|0,d=e[c+40>>2],y=e[c+52>>2],c=E=e[c+48>>2];e[d>>2]&&(b=I[y>>2],I[c>>2]=b,(0|(S=e[g+4>>2]))!=-1)&&(I[c>>2]=b*I[(S<<2)+E>>2]),c=c+4|0,y=y+4|0,d=d+4|0,(g=g+12|0)>>>0<u>>>0;);}(a),function(c){var E,u=0,d=0,g=0;if(1<=(0|(E=e[c+304>>2])))for(u=e[c+308>>2],d=e[c+312>>2];e[d>>2]&&L[e[u+20>>2]](c,g),d=d+4|0,u=u+32|0,(0|E)!=(0|(g=g+1|0)););}(a),function(c){var E,u,d,g,y,b=0,S=0,R=(v(0),v(0),0),F=0,B=0,V=(v(0),0),z=0,q=0;if(1<=(0|(b=e[c+332>>2])))for(z=(S=e[c+336>>2])+j(b,20)|0,q=e[c+308>>2],V=e[c+316>>2],y=e[c+48>>2],b=e[c+448>>2],R=e[c+444>>2],B=e[c+424>>2];e[B>>2]&&((0|(F=e[S+4>>2]))!=-1&&(I[b>>2]=I[(F<<2)+y>>2]*I[b>>2]),(0|(F=e[S+8>>2]))!=-1)&&(I[b>>2]=I[V+(F<<2)>>2]*I[b>>2],g=e[R>>2],L[e[24+(q+(F<<5)|0)>>2]](c,F,g,g,e[S+16>>2])),R=R+4|0,b=b+4|0,B=B+4|0,(S=S+20|0)>>>0<z>>>0;);if(!(H[e[c>>2]+4|0]<4||(0|(b=e[c+332>>2]))<1))for(F=(R=e[c+336>>2])+j(b,20)|0,z=e[c+328>>2],q=e[c+324>>2],S=e[c+452>>2],b=e[c+456>>2],B=e[c+424>>2];e[B>>2]&&(0|(c=e[R+8>>2]))!=-1&&(c=(V=c<<4)+q|0,E=v(I[S>>2]*I[c>>2]),I[S>>2]=E,u=v(I[S+4>>2]*I[c+4>>2]),I[S+4>>2]=u,d=I[c+8>>2],e[S+12>>2]=1065353216,I[S+4>>2]=u<v(0)?v(0):v(Mt(u,v(1))),I[S>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=v(d*I[S+8>>2]),I[S+8>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=I[b>>2],u=I[(c=z+V|0)>>2],E=v(v(E+u)-v(E*u)),I[b>>2]=E,u=I[b+4>>2],d=I[c+4>>2],u=v(v(u+d)-v(u*d)),I[b+4>>2]=u,d=I[c+8>>2],e[b+12>>2]=1065353216,I[b+4>>2]=u<v(0)?v(0):v(Mt(u,v(1))),I[b>>2]=E<v(0)?v(0):v(Mt(E,v(1))),E=I[b+8>>2],E=v(v(d+E)-v(E*d)),I[b+8>>2]=E<v(0)?v(0):v(Mt(E,v(1)))),b=b+16|0,S=S+16|0,B=B+4|0,(R=R+20|0)>>>0<F>>>0;);}(a),function(c){var E,u,d,g,y,b,S,R,F,B,V,z,q,tt,ut,mt,Bt,Ht,ce,Ae,Ue=0;if(v(0),v(0),v(0),v(0),v(0),v(0),v(0),1<=(0|(R=e[c+500>>2])))for(ce=e[c+536>>2],F=e[c+444>>2],Ae=e[c+504>>2];;){if(c=j(Ue,24)+Ae|0,0<(0|(B=e[c+12>>2])))for(d=I[(Ue<<2)+ce>>2],V=e[c+20>>2],z=e[c+16>>2],q=e[(e[c+4>>2]<<2)+F>>2],tt=e[(e[c+8>>2]<<2)+F>>2],c=0;ut=I[((E=1|c)<<2)+z>>2],u=W[(c<<1)+V>>1]<<3&262136,g=I[(mt=(4|u)+q|0)>>2],E=W[(E<<1)+V>>1]<<3&262136,y=I[(Bt=(4|E)+tt|0)>>2],b=I[(u=u+q|0)>>2],Ht=I[(c<<2)+z>>2],S=I[(E=E+tt|0)>>2],I[u>>2]=b+v(d*v(Ht*v(S-b))),I[mt>>2]=g+v(d*v(Ht*v(y-g))),I[E>>2]=S+v(d*v(ut*v(b-S))),I[Bt>>2]=y+v(d*v(ut*v(g-y))),(0|(c=c+2|0))<(0|B););if(!((0|(Ue=Ue+1|0))<(0|R)))break}}(a),L[e[1810]](a),function(c){var E,u,d,g,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0;if(!((0|(E=e[c+480>>2]))<1)){for(R=(u=e[c+484>>2])+j(E,28)|0,V=e[c+424>>2],z=e[c+40>>2],F=e[c+44>>2],ut=e[c+440>>2],y=u;;){if(1<=(0|(B=e[y+4>>2])))for(tt=y+20|0,q=e[y+12>>2],b=0;d=e[4+(S=q+(b<<4)|0)>>2]<<2,S=e[(g=S)>>2]==1,e[g+12>>2]=e[(e[(S?z:V)+d>>2]?(S?F:ut)+d|0:tt)>>2],(0|(b=b+1|0))<(0|B););if(!((y=y+28|0)>>>0<R>>>0))break}if(!((0|E)<1))for(ut=e[c+436>>2],z=0;;){if(R=j(z,28)+u|0,!(e[(V=R)+24>>2]<1)){for(S=e[c+488>>2],b=0;e[S+(b<<2)>>2]=-1,(0|(b=b+1|0))<(0|(y=e[V+24>>2])););if(!((0|y)<1))for(y=e[c+496>>2],b=0;e[y+(b<<2)>>2]=-1,(0|(b=b+1|0))<e[V+24>>2];);}if(!(e[R+4>>2]<1)){for(F=e[c+492>>2],b=0;e[F+(b<<2)>>2]=-1,(0|(b=b+1|0))<(0|(y=e[R+4>>2])););if(!((0|y)<1))for(B=e[R+12>>2],tt=e[c+496>>2],b=0;q=e[12+(B+(b<<4)|0)>>2]-e[R+20>>2]<<2,y=(0|(y=e[(S=q+tt|0)>>2]))==-1?q+e[c+488>>2]|0:F+(y<<2)|0,e[y>>2]=b,(0|(b=(e[S>>2]=b)+1|0))<e[R+4>>2];);}if(1<=(0|(y=e[V+24>>2])))for(F=e[R+8>>2],tt=e[c+488>>2],B=0;;){if((0|(b=e[tt+(B<<2)>>2]))!=-1){for(q=e[c+492>>2],S=e[R+12>>2];F=(y=e[(y=S+(b<<4)|0)>>2]==1?(y=j(e[y+8>>2],28)+u|0,e[y+8>>2]=F,e[y>>2]):(e[ut+(e[y+4>>2]<<2)>>2]=F,1))+F|0,(0|b)<(0|(y=e[q+(b<<2)>>2]))&&(0|(b=y))!=-1;);y=e[V+24>>2]}if(!((0|(B=B+1|0))<(0|y)))break}if((0|E)==(0|(z=z+1|0)))break}}}(a),function(c){var E=0,u=0,d=0,g=0,y=0,b=v(0),S=0,R=0,F=e[c+332>>2];if(e[c+644>>2]){if(!(((e[c+428>>2]=0)|F)<1))for(;E=126,S=e[c+432>>2]+d|0,!e[(u=d<<2)+e[c+424>>2]>>2]|I[u+e[c+448>>2]>>2]==v(0)||(E=127),O[0|S]=E,(0|F)!=(0|(d=d+1|0)););}else if(e[c+428>>2]){if(E=H[e[c>>2]+4|0],!(((e[c+428>>2]=0)|F)<1))if(4<=E>>>0)for(;b=I[(E=d<<2)+e[c+448>>2]>>2],g=e[E+e[c+424>>2]>>2],u=b!=v(0)&(0|g)!=0,S=e[c+432>>2]+d|0,u=(0|u)==(1&O[0|S])?u:2|u,u=b!=I[E+e[c+468>>2]>>2]?4|u:u,u=e[E+e[c+440>>2]>>2]==e[E+e[c+464>>2]>>2]?u:8|u,E=e[E+e[c+436>>2]>>2]==e[E+e[c+460>>2]>>2]?u:16|u,E=g?32|E:E,g=(u=R<<2)+e[c+452>>2]|0,y=u+e[c+472>>2]|0,(I[g>>2]!=I[y>>2]|I[g+4>>2]!=I[y+4>>2]|(I[g+8>>2]!=I[y+8>>2]|I[g+12>>2]!=I[y+12>>2])||(g=u+e[c+456>>2]|0,u=u+e[c+476>>2]|0,I[g>>2]!=I[u>>2]|I[g+4>>2]!=I[u+4>>2]|I[g+8>>2]!=I[u+8>>2])||I[g+12>>2]!=I[u+12>>2])&&(E|=64),O[0|S]=E,R=R+4|0,(0|F)!=(0|(d=d+1|0)););else for(;b=I[(E=d<<2)+e[c+448>>2]>>2],g=e[E+e[c+424>>2]>>2],u=b!=v(0)&(0|g)!=0,y=e[c+432>>2]+d|0,u=(0|u)==(1&O[0|y])?u:2|u,u=b!=I[E+e[c+468>>2]>>2]?4|u:u,u=e[E+e[c+440>>2]>>2]==e[E+e[c+464>>2]>>2]?u:8|u,E=e[E+e[c+436>>2]>>2]==e[E+e[c+460>>2]>>2]?u:16|u,O[0|y]=g?32|E:E,(0|F)!=(0|(d=d+1|0)););}else if(!((0|F)<1))for(;!e[(E=d<<2)+e[c+424>>2]>>2]|I[E+e[c+448>>2]>>2]==v(0)?(E=e[c+432>>2]+d|0,O[0|E]=254&H[0|E]):(E=e[c+432>>2]+d|0,O[0|E]=1|H[0|E]),(0|F)!=(0|(d=d+1|0)););}(a),e[a+644>>2]=0}function Yr(a,p,P,_,c,E){var u,d,g,y,b,S,R,F=0,B=0,V=0,z=0;if(K=S=K-32|0,1<=(0|p))for(b=j(p,12)+P|0;;){if(!((0|(F=e[P+4>>2]))<1))if(u=(p=e[P+8>>2])+j(F,48)|0,F=e[P>>2]<<2,1<=(0|(R=e[F+E>>2])))for(R<<=1,d=e[e[a>>2]+1052>>2],g=e[c+F>>2];;){r:if(F=e[p+8>>2]){t:{if((B=F+-1|0)>>>0<=1){if(F=(e[p+4>>2]<<2)+_|0,z=(e[F+(e[p+12>>2]<<2)>>2]<<2)+d|0,B-1)break t;for(V=(e[F+(e[p+16>>2]<<2)>>2]<<2)+d|0,F=0;I[(y=(B=F<<2)+g|0)>>2]=I[y>>2]+v(I[p+44>>2]*v(v(I[B+z>>2]*I[p+20>>2])+v(I[B+V>>2]*I[p+24>>2]))),(0|R)!=(0|(F=F+1|0)););break r}e[S>>2]=F,Ut(4,1024,S);break r}for(F=0;I[(V=(B=F<<2)+g|0)>>2]=I[V>>2]+v(I[p+44>>2]*v(I[B+z>>2]*I[p+20>>2])),(0|R)!=(0|(F=F+1|0)););}if(!((p=p+48|0)>>>0<u>>>0))break}else for(;3<=(F=e[p+8>>2])>>>0&&(e[16+S>>2]=F,Ut(4,1024,16+S|0)),(p=p+48|0)>>>0<u>>>0;);if(!((P=P+12|0)>>>0<b>>>0))break}K=32+S|0}function jr(a,p,P){var _;p|=0,P|=0,K=_=K+-64|0;r:{if(a|=0)if(p)if((p+15&-16)!=(0|p))e[52+_>>2]=1522,e[48+_>>2]=2361,Ut(4,1294,48+_|0);else{if(p=function(c,E,u){var d,g=0,y=0,b=0,S=0,R=0,F=0,B=0,V=0,z=0,q=0,tt=0,ut=0,mt=0,Bt=v(0),Ht=0,ce=0,Ae=0,Ue=0,He=0;if(Ce(16+(K=d=K-576|0)|0,0,560),vi(c,16+d|0,12+d|0),(S=e[12+d>>2])>>>0<=u>>>0){if(g=(y=Ce(E,0,S))+e[16+d>>2]|0,e[g+8>>2]=y+e[20+d>>2],e[g+40>>2]=y+e[24+d>>2],e[g+44>>2]=y+e[28+d>>2],e[g+48>>2]=y+e[32+d>>2],e[g+52>>2]=y+e[36+d>>2],e[g+16>>2]=y+e[40+d>>2],e[g+24>>2]=y+e[44+d>>2],e[g+28>>2]=y+e[48+d>>2],e[g+32>>2]=y+e[52+d>>2],e[g+36>>2]=y+e[56+d>>2],E=e[c+704>>2],e[g+308>>2]=y+e[60+d>>2],e[g+312>>2]=y+e[64+d>>2],e[g+316>>2]=y+e[68+d>>2],e[g+320>>2]=y+e[72+d>>2],e[g+324>>2]=y+e[76+d>>2],e[g+328>>2]=y+e[80+d>>2],e[g+60>>2]=y+e[84+d>>2],e[g+144>>2]=y+e[88+d>>2],e[g+148>>2]=y+e[92+d>>2],u=y+e[96+d>>2]|0,e[g+152>>2]=u,!((0|(S=e[E+8>>2]))<1)&&(E=y+e[100+d>>2]|0,e[u>>2]=E,(0|S)!=1))for(u=1;E=(15+(e[e[c+796>>2]+(b<<2)>>2]<<3)&-16)+E|0,e[e[g+152>>2]+(u<<2)>>2]=E,(0|S)!=(0|(u=(b=u)+1|0)););if(e[g+156>>2]=y+e[104+d>>2],e[g+160>>2]=y+e[108+d>>2],e[g+68>>2]=y+e[112+d>>2],e[g+76>>2]=y+e[116+d>>2],e[g+80>>2]=y+e[120+d>>2],e[g+84>>2]=y+e[124+d>>2],e[g+88>>2]=y+e[128+d>>2],e[g+92>>2]=y+e[132+d>>2],e[g+96>>2]=y+e[136+d>>2],e[g+100>>2]=y+e[140+d>>2],e[g+104>>2]=y+e[144+d>>2],e[g+108>>2]=y+e[148+d>>2],e[g+112>>2]=y+e[152+d>>2],e[g+116>>2]=y+e[156+d>>2],e[g+120>>2]=y+e[160+d>>2],e[g+124>>2]=y+e[164+d>>2],e[g+128>>2]=y+e[168+d>>2],e[g+132>>2]=y+e[172+d>>2],e[g+136>>2]=y+e[176+d>>2],e[g+140>>2]=y+e[180+d>>2],e[g+168>>2]=y+e[184+d>>2],e[g+264>>2]=y+e[188+d>>2],e[g+268>>2]=y+e[192+d>>2],e[g+272>>2]=y+e[196+d>>2],e[g+276>>2]=y+e[200+d>>2],e[g+280>>2]=y+e[204+d>>2],e[g+284>>2]=y+e[208+d>>2],e[g+288>>2]=y+e[212+d>>2],e[g+292>>2]=y+e[216+d>>2],e[g+296>>2]=y+e[220+d>>2],e[g+300>>2]=y+e[224+d>>2],e[g+176>>2]=y+e[228+d>>2],e[g+184>>2]=y+e[232+d>>2],e[g+188>>2]=y+e[236+d>>2],e[g+192>>2]=y+e[240+d>>2],e[g+196>>2]=y+e[244+d>>2],e[g+200>>2]=y+e[248+d>>2],e[g+204>>2]=y+e[252+d>>2],e[g+208>>2]=y+e[256+d>>2],e[g+212>>2]=y+e[260+d>>2],e[g+216>>2]=y+e[264+d>>2],e[g+220>>2]=y+e[268+d>>2],e[g+224>>2]=y+e[272+d>>2],e[g+228>>2]=y+e[276+d>>2],e[g+232>>2]=y+e[280+d>>2],e[g+236>>2]=y+e[284+d>>2],e[g+240>>2]=y+e[288+d>>2],e[g+244>>2]=y+e[292+d>>2],e[g+248>>2]=y+e[296+d>>2],e[g+252>>2]=y+e[300+d>>2],e[g+256>>2]=y+e[304+d>>2],e[g+260>>2]=y+e[308+d>>2],E=e[c+704>>2],e[g+336>>2]=y+e[312+d>>2],e[g+424>>2]=y+e[316+d>>2],e[g+432>>2]=y+e[320+d>>2],e[g+436>>2]=y+e[324+d>>2],e[g+440>>2]=y+e[328+d>>2],u=y+e[332+d>>2]|0,e[g+444>>2]=u,!((0|(S=e[E+16>>2]))<1)&&(b=y+e[336+d>>2]|0,e[u>>2]=b,(u=1)!=(0|S)))for(E=0;b=(15+(e[e[c+892>>2]+(E<<2)>>2]<<3)&-16)+b|0,e[e[g+444>>2]+(u<<2)>>2]=b,(0|S)!=(0|(u=(E=u)+1|0)););if(e[g+448>>2]=y+e[340+d>>2],e[g+452>>2]=y+e[344+d>>2],e[g+456>>2]=y+e[348+d>>2],e[g+460>>2]=y+e[352+d>>2],e[g+464>>2]=y+e[356+d>>2],e[g+468>>2]=y+e[360+d>>2],e[g+472>>2]=y+e[364+d>>2],e[g+476>>2]=y+e[368+d>>2],e[g+344>>2]=y+e[372+d>>2],e[g+352>>2]=y+e[376+d>>2],e[g+356>>2]=y+e[380+d>>2],e[g+360>>2]=y+e[384+d>>2],e[g+364>>2]=y+e[388+d>>2],e[g+368>>2]=y+e[392+d>>2],e[g+372>>2]=y+e[396+d>>2],e[g+376>>2]=y+e[400+d>>2],e[g+380>>2]=y+e[404+d>>2],e[g+384>>2]=y+e[408+d>>2],e[g+388>>2]=y+e[412+d>>2],e[g+392>>2]=y+e[416+d>>2],e[g+396>>2]=y+e[420+d>>2],e[g+400>>2]=y+e[424+d>>2],e[g+404>>2]=y+e[428+d>>2],e[g+408>>2]=y+e[432+d>>2],e[g+412>>2]=y+e[436+d>>2],e[g+416>>2]=y+e[440+d>>2],e[g+420>>2]=y+e[444+d>>2],E=e[448+d>>2],u=e[452+d>>2],e[g+552>>2]=y+e[456+d>>2],e[g+548>>2]=u+y,e[g+544>>2]=E+y,e[g+560>>2]=y+e[460+d>>2],E=e[c+704>>2],B=y+e[464+d>>2]|0,e[g+568>>2]=B,1<=(0|(F=e[E+48>>2])))for(b=y+e[468+d>>2]|0,E=y+e[472+d>>2]|0,R=y+e[476+d>>2]|0,V=e[c+1072>>2],u=0;S=B+j(u,36)|0,e[S+20>>2]=R,e[S+16>>2]=E,e[S>>2]=b,b=((S=e[V+(u<<2)>>2])<<2)+b|0,R=(S=1<<S<<2)+R|0,E=E+S|0,(0|F)!=(0|(u=u+1|0)););if(E=e[c+704>>2],S=y+e[516+d>>2]|0,e[g+484>>2]=S,1<=(0|(E=e[E+72>>2])))for(b=y+e[520+d>>2]|0,R=e[c+1212>>2],u=0;e[12+(S+j(u,28)|0)>>2]=b,b=(e[R+(u<<2)>>2]<<4)+b|0,(0|E)!=(0|(u=u+1|0)););e[g+488>>2]=y+e[524+d>>2],e[g+492>>2]=y+e[528+d>>2],e[g+496>>2]=y+e[532+d>>2],e[g+504>>2]=y+e[536+d>>2],e[g+536>>2]=y+e[540+d>>2],e[g+512>>2]=y+e[544+d>>2],e[g+520>>2]=y+e[548+d>>2],e[g+524>>2]=y+e[552+d>>2],e[g+528>>2]=y+e[556+d>>2],e[g+532>>2]=y+e[560+d>>2];t:{if(4<=(F=H[c+4|0])>>>0){if(e[g+576>>2]=y+e[480+d>>2],e[g+584>>2]=y+e[484+d>>2],E=e[c+704>>2],u=e[492+d>>2],S=y+e[488+d>>2]|0,e[g+592>>2]=S,1<=(0|(E=e[E+104>>2])))for(b=u+y|0,R=e[c+1104>>2],u=0;e[40+(S+j(u,48)|0)>>2]=b,b=(e[R+(u<<2)>>2]<<2)+b|0,(0|E)!=(0|(u=u+1|0)););e[g+608>>2]=y+e[500+d>>2],e[g+624>>2]=y+e[508+d>>2]}else{if(E=e[572+d>>2],u=e[568+d>>2],e[g+636>>2]=y+e[564+d>>2],e[g+640>>2]=u+y,e[e[c+704>>2]+20>>2]<1)break t;for(S=E+y|0,B=0;;){e:{if((0|(b=e[(E=B<<2)+e[c+952>>2]>>2]))<=0)E=E+e[g+636>>2]|0;else{for(R=b+(u=e[E+e[c+948>>2]>>2])|0,V=e[c+1060>>2],b=0;b=e[V+(u<<2)>>2]+b|0,(0|(u=u+1|0))<(0|R););if(E=E+e[g+636>>2]|0,u=S,b)break e}u=b=0}if(e[E>>2]=u,S=(b<<2)+S|0,!((0|(B=B+1|0))<e[e[c+704>>2]+20>>2]))break}}F>>>0<5||(e[g+600>>2]=y+e[496+d>>2],e[g+616>>2]=y+e[504+d>>2],e[g+632>>2]=y+e[512+d>>2])}e[g+644>>2]=1,e[g>>2]=c,e[g+648>>2]=1&O[e[c+708>>2]+20|0],y=e[c+704>>2],B=e[y+20>>2];t:if(!((0|(e[g+540>>2]=B))<1)){if(E=B+-1|0,V=e[c+952>>2],z=e[c+940>>2],q=e[c+932>>2],tt=e[c+936>>2],ut=e[c+924>>2],mt=e[c+928>>2],Ht=e[g+552>>2],Ae=e[g+544>>2],F>>>0<4){for(;;)if(u=Ae+j(E,52)|0,b=(S=E<<2)+mt|(e[u>>2]=0),e[u+4>>2]=e[b>>2],e[u+8>>2]=e[(R=S+ut|0)>>2],I[u+12>>2]=I[R>>2]-I[b>>2],e[u+16>>2]=e[S+tt>>2],e[u+44>>2]=e[(b=S+q|0)>>2],Bt=Kr(v(e[S+z>>2])),I[u+20>>2]=Bt,I[u+24>>2]=Bt*v(1.5),ce=e[S+V>>2],R=0,R=(e[u+32>>2]=ce)?e[g+560>>2]+j(e[S+e[c+948>>2]>>2],28)|0:R,e[u+48>>2]=1,e[u+28>>2]=R,e[S+Ht>>2]=e[b>>2],u=0<(0|E),E=E+-1|0,!u)break t}for(ce=e[c+960>>2],He=e[c+944>>2];u=Ae+j(E,52)|0,e[u>>2]=e[(b=E<<2)+He>>2],e[u+4>>2]=e[(S=b+mt|0)>>2],e[u+8>>2]=e[(R=b+ut|0)>>2],I[u+12>>2]=I[R>>2]-I[S>>2],e[u+16>>2]=e[b+tt>>2],e[u+44>>2]=e[(Ue=b+q|0)>>2],Bt=Kr(v(e[b+z>>2])),I[u+20>>2]=Bt,I[u+24>>2]=Bt*v(1.5),R=e[b+V>>2],e[u+32>>2]=R,e[u+28>>2]=R?e[g+560>>2]+j(e[b+e[c+948>>2]>>2],28)|0:0,S=e[b+ce>>2],S=(e[u+40>>2]=S)?e[g+584>>2]+j(e[b+e[c+956>>2]>>2],28)|0:0,e[u+48>>2]=1,e[u+36>>2]=S,e[b+Ht>>2]=e[Ue>>2],u=0<(0|E),E=E+-1|0,u;);}if(4<=F>>>0?(e[g+548>>2]=e[c+944>>2],S=c):(Ce(e[g+548>>2],0,B<<2),S=e[g>>2],y=e[S+704>>2]),b=e[y+52>>2],1<=(0|(e[g+556>>2]=b)))for(u=e[S+1056>>2],R=e[S+1192>>2],B=e[S+1060>>2],F=e[g+560>>2];E=F+j(b=b+-1|0,28)|0,e[E>>2]=e[(V=b<<2)+B>>2],V=e[u+V>>2],e[E+24>>2]=1,e[E+16>>2]=0,e[E+20>>2]=1,e[E+8>>2]=0,e[E+12>>2]=0,e[E+4>>2]=R+(V<<2),0<(0|b););if(b=e[y+48>>2],1<=(0|(e[g+564>>2]=b))){for(;;){if(E=e[g+568>>2]+j(b=b+-1|0,36)|0,R=e[(y=b<<2)+e[S+1072>>2]>>2],1<=(0|(e[E+4>>2]=R)))for(u=0;e[e[E>>2]+(u<<2)>>2]=e[g+560>>2]+j(e[e[S+1064>>2]+(e[y+e[S+1068>>2]>>2]+u<<2)>>2],28),(0|R)!=(0|(u=u+1|0)););if(e[E+24>>2]=1,e[E+28>>2]=1,e[E+8>>2]=1<<R,!(0<(0|b)))break}S=e[g>>2],y=e[S+704>>2]}if(E=e[y>>2],(0|(e[g+4>>2]=E))<1)u=0;else{for(V=e[S+732>>2],z=e[S+736>>2],q=e[S+740>>2],R=e[S+720>>2],tt=e[g+52>>2],B=e[g+568>>2],ut=e[g+8>>2],b=E;F=ut+j(b=b+-1|0,12)|0,e[F>>2]=B+j(e[(u=b<<2)+R>>2],36),e[F+4>>2]=e[u+q>>2],e[F+8>>2]=e[u+z>>2],I[u+tt>>2]=e[u+V>>2]?v(1):v(0),0<(0|b););for(F=e[g+16>>2],u=0;b=e[8+(B+j(e[(V=(E=E+-1|0)<<2)+R>>2],36)|0)>>2],u=u+(e[F+V>>2]=b)|0,0<(0|E););E=e[g+4>>2]}if(e[g+12>>2]=E,e[g+20>>2]=u,E=e[y+4>>2],1<=(0|(e[g+304>>2]=E))){for(;u=e[g+308>>2]+((E=E+-1|0)<<5)|0,e[u>>2]=e[g+568>>2]+j(e[(b=E<<2)+e[S+752>>2]>>2],36),e[u+4>>2]=e[b+e[S+764>>2]>>2],e[u+8>>2]=e[b+e[S+768>>2]>>2],R=e[b+e[S+772>>2]>>2],e[u+12>>2]=R,y=e[b+e[S+776>>2]>>2],e[u+16>>2]=y,e[u+28>>2]=e[b+e[S+760>>2]>>2],R>>>0<=1?R-1?(e[20+(e[g+60>>2]+j(y,24)|0)>>2]=E,e[u+24>>2]=1,e[u+20>>2]=2):(e[8+(e[g+168>>2]+j(y,12)|0)>>2]=E,e[u+24>>2]=3,e[u+20>>2]=4):Ut(4,1179,0),0<(0|E););S=e[g>>2],y=e[S+704>>2]}b=e[y+8>>2];t:if(!((0|(e[g+56>>2]=b))<1)){if(u=b+-1|0,B=e[S+796>>2],F=e[S+804>>2],V=e[S+800>>2],z=e[S+780>>2],q=e[g+568>>2],tt=e[g+60>>2],H[S+4|0]<2){for(;;)if(E=tt+j(u,24)|0,e[E>>2]=q+j(e[(R=u<<2)+z>>2],36),e[E+4>>2]=e[R+V>>2],e[E+8>>2]=e[R+F>>2],R=e[R+B>>2],e[E+12>>2]=0,e[E+16>>2]=R,E=0<(0|u),u=u+-1|0,!E)break t}for(ut=e[S+808>>2];E=tt+j(u,24)|0,e[E>>2]=q+j(e[(R=u<<2)+z>>2],36),e[E+4>>2]=e[R+V>>2],e[E+8>>2]=e[R+F>>2],e[E+16>>2]=e[R+B>>2],e[E+12>>2]=e[R+ut>>2],E=0<(0|u),u=u+-1|0,E;);}if(u=e[y+12>>2],1<=(0|(e[g+164>>2]=u)))for(R=e[S+828>>2],B=e[S+812>>2],F=e[g+568>>2],V=e[g+168>>2],E=u;z=V+j(E=E+-1|0,12)|0,e[z>>2]=F+j(e[(q=E<<2)+B>>2],36),e[z+4>>2]=e[R+q>>2],0<(0|E););if(((E=0)|b)<1)R=0;else{for(B=e[g+68>>2],F=e[g+60>>2],R=0;u=e[e[F+j(b=b+-1|0,24)>>2]+8>>2],R=(e[B+(b<<2)>>2]=u)+R|0,0<(0|b););u=e[g+164>>2],b=e[g+56>>2]}if(e[g+64>>2]=b,e[g+72>>2]=R,b=g,1<=(0|u)){for(B=e[g+176>>2],F=e[g+168>>2];R=e[e[F+j(u=u+-1|0,12)>>2]+8>>2],E=E+(e[B+(u<<2)>>2]=R)|0,0<(0|u););u=e[g+164>>2]}if(e[b+172>>2]=u,e[g+180>>2]=E,R=e[y+16>>2],1<=(0|(e[g+332>>2]=R))){for(V=e[S+872>>2],z=e[S+892>>2],q=e[S+880>>2],tt=e[S+876>>2],B=e[S+852>>2],F=e[g+568>>2],ut=e[g+336>>2],E=R;u=ut+j(E=E+-1|0,20)|0,e[u>>2]=F+j(e[(b=E<<2)+B>>2],36),e[u+4>>2]=e[b+tt>>2],e[u+8>>2]=e[b+q>>2],e[u+16>>2]=e[b+z>>2],e[u+12>>2]=e[b+V>>2],0<(0|E););for(b=e[g+344>>2],u=0;E=e[8+(F+j(e[(V=(R=R+-1|0)<<2)+B>>2],36)|0)>>2],u=(e[b+V>>2]=E)+u|0,0<(0|R););if(e[g+348>>2]=u,R=e[g+332>>2],!((0|(e[g+340>>2]=R))<1))for(u=R<<2,b=e[g+456>>2],B=e[g+452>>2];e[(F=(E=u+-4|0)<<2)+B>>2]=1065353216,e[(V=(u<<=2)-4|0)+B>>2]=1065353216,e[(z=(u=u+-12|0)+B|0)>>2]=1065353216,e[z+4>>2]=1065353216,e[b+F>>2]=0,e[b+V>>2]=1065353216,e[(u=u+b|0)>>2]=0,e[u+4>>2]=0,u=E,0<(0|(R=R+-1|0)););}else e[g+340>>2]=R,e[g+348>>2]=0;if(R=e[y+72>>2],1<=(0|(e[g+480>>2]=R)))for(V=e[S+1208>>2],z=e[S+1224>>2],q=e[S+1220>>2],tt=e[S+1216>>2],ut=e[S+1212>>2],mt=e[g+484>>2],b=0;;){if(E=mt+j(b,28)|0,B=e[(u=b<<2)+ut>>2],e[E+4>>2]=B,e[E>>2]=e[u+tt>>2],F=e[u+q>>2],e[E+16>>2]=F,Ht=e[u+z>>2],e[E+20>>2]=Ht,e[E+8>>2]=0,e[E+24>>2]=1+(F-Ht|0),1<=(0|B))for(Ht=e[u+V>>2],Ae=e[E+12>>2],ce=e[S+1236>>2],He=e[S+1228>>2],Ue=e[S+1232>>2],u=0;e[4+(E=Ae+(u<<4)|0)>>2]=e[(F=u+Ht<<2)+Ue>>2],e[E>>2]=e[F+He>>2],F=e[F+ce>>2],e[E+12>>2]=0,e[E+8>>2]=F,(0|B)!=(0|(u=u+1|0)););if((0|R)==(0|(b=b+1|0)))break}if(u=e[y+80>>2],(0|(e[g+500>>2]=u))<1)b=0;else{for(F=e[S+1280>>2],V=e[S+1268>>2],z=e[S+1276>>2],q=e[S+1272>>2],tt=e[S+1264>>2],ut=e[S+1260>>2],R=e[S+1248>>2],B=e[g+568>>2],mt=e[g+504>>2];E=mt+j(u=u+-1|0,24)|0,e[E>>2]=B+j(e[(b=u<<2)+R>>2],36),e[E+4>>2]=e[b+ut>>2],e[E+8>>2]=e[b+tt>>2],e[E+12>>2]=e[b+q>>2],b=e[b+V>>2],e[E+20>>2]=F+(b<<1),e[E+16>>2]=z+(b<<2),0<(0|u););if((0|(u=e[g+500>>2]))<1)b=0;else{for(F=e[g+512>>2],b=0;E=e[8+(B+j(e[(V=(u=u+-1|0)<<2)+R>>2],36)|0)>>2],b=(e[F+V>>2]=E)+b|0,0<(0|u););u=e[g+500>>2]}}e[g+508>>2]=u,e[g+516>>2]=b;t:if(4<=H[c+4|0]){if(!((R=H[S+4|0])>>>0<4)){if(u=e[y+120>>2],1<=(0|(e[g+572>>2]=u))){for(F=e[S+1172>>2],V=e[g+576>>2];R=(0|(y=e[(E=(u=u+-1|0)<<2)+F>>2]))<0?y=B=b=0:(b=(R=e[E+e[S+1176>>2]>>2]<<2)+e[S+1188>>2]|0,B=e[E+e[S+1180>>2]>>2],y=e[g+544>>2]+j(y,52)|0,R+e[S+1184>>2]|0),E=V+j(u,20)|0,e[E+12>>2]=B,e[E+8>>2]=b,e[E+4>>2]=R,e[E>>2]=y,0<(0|u););if(S=e[g>>2],(R=H[S+4|0])>>>0<4)break t}if(y=e[S+704>>2],b=e[y+100>>2],1<=(0|(e[g+580>>2]=b)))for(B=e[S+1084>>2],F=e[S+1076>>2],V=e[S+1192>>2],z=e[S+1080>>2],q=e[g+584>>2];E=q+j(b=b+-1|0,28)|0,e[E>>2]=e[(u=b<<2)+z>>2],e[E+4>>2]=V+(e[u+F>>2]<<2),u=e[u+B>>2],e[E+20>>2]=1,e[E+24>>2]=1,e[E+12>>2]=0,e[E+16>>2]=0,e[E+8>>2]=u,0<(0|b););if(b=e[y+104>>2],1<=(0|(e[g+588>>2]=b))){for(;;){if(E=e[g+592>>2]+j(b=b+-1|0,48)|0,e[E>>2]=e[g+584>>2]+j(e[(R=b<<2)+e[S+1088>>2]>>2],28),u=e[R+e[S+1092>>2]>>2],e[E+28>>2]=1,e[E+32>>2]=1,e[E+8>>2]=0,e[E+4>>2]=u,y=e[R+e[S+1104>>2]>>2],1<=(0|(e[E+36>>2]=y)))for(u=0;e[e[E+40>>2]+(u<<2)>>2]=e[g+576>>2]+j(e[e[S+1168>>2]+(e[R+e[S+1100>>2]>>2]+u<<2)>>2],20),(0|y)!=(0|(u=u+1|0)););if(!(1<=(0|b)))break}S=e[g>>2],R=H[S+4|0]}if(!(R>>>0<4)){if(R=e[c+704>>2],u=e[R+108>>2],1<=(0|(e[g+604>>2]=u)))for(y=e[c+1124>>2],B=e[c+1128>>2],F=e[c+1120>>2],V=e[g+592>>2],z=e[g+608>>2];E=z+j(u=u+-1|0,12)|0,e[E>>2]=e[(b=u<<2)+F>>2],e[E+4>>2]=e[b+B>>2],e[E+8>>2]=V+j(e[y+b>>2],48),0<(0|u););if(u=e[R+112>>2],1<=(0|(e[g+620>>2]=u)))for(R=e[c+1148>>2],y=e[c+1152>>2],B=e[c+1144>>2],F=e[g+592>>2],V=e[g+624>>2];E=V+j(u=u+-1|0,12)|0,e[E>>2]=e[(b=u<<2)+B>>2],e[E+4>>2]=e[y+b>>2],e[E+8>>2]=F+j(e[b+R>>2],48),0<(0|u););if(b=e[S+1192>>2],E=e[e[S+704>>2]+20>>2],e[g+640>>2]=e[S+972>>2],R=e[S+964>>2],e[g+636>>2]=R,!((0|E)<(u=1))&&(e[R>>2]=b+(e[e[S+968>>2]>>2]<<2),(0|E)!=1))for(;e[(R=u<<2)+e[g+636>>2]>>2]=b+(e[R+e[S+968>>2]>>2]<<2),(0|E)!=(0|(u=u+1|0)););}}}else if(!(e[y+20>>2]<1))for(y=0;;){if(b=e[(B=y<<2)+e[g+636>>2]>>2],1<=((E=0)|(u=e[B+e[S+952>>2]>>2])))for(z=u+(F=e[B+e[S+948>>2]>>2])|0,q=e[S+1060>>2],tt=e[S+1056>>2];;){if(1<=(0|(V=e[(u=F<<2)+q>>2])))for(ut=V+(R=e[u+tt>>2])|0,mt=e[S+1192>>2];;){V=b+(E<<2)|0,Bt=I[mt+(R<<2)>>2],u=b;e:{if(0<(0|E))for(;;){if(I[u>>2]==Bt)break e;if(!((u=u+4|0)>>>0<V>>>0))break}I[V>>2]=Bt,E=E+1|0}if(!((0|(R=R+1|0))<(0|ut)))break}if(!((0|(F=F+1|0))<(0|z)))break}if(function(pe,tr){var Ot,fe,we=0,ke=0,Ne=0;e[8+(K=Ot=K-208|0)>>2]=1,e[12+Ot>>2]=0;e:if(fe=tr<<2){for(e[16+Ot>>2]=4,Ne=tr=e[20+Ot>>2]=4,we=2;tr=(Ne+4|0)+(ke=tr)|0,e[(16+Ot|0)+(we<<2)>>2]=tr,we=we+1|0,Ne=ke,tr>>>0<fe>>>0;);if((ke=(pe+fe|0)-4|0)>>>0<=pe>>>0)tr=we=1;else for(tr=we=1;tr=(3&we)==3?(Br(pe,tr,16+Ot|0),Le(8+Ot|0,2),tr+2|0):(rt[(16+Ot|0)+((Ne=tr+-1|0)<<2)>>2]>=ke-pe>>>0?je(pe,8+Ot|0,tr,0,16+Ot|0):Br(pe,tr,16+Ot|0),(0|tr)==1?(lr(8+Ot|0,1),0):(lr(8+Ot|0,Ne),1)),we=1|e[8+Ot>>2],e[8+Ot>>2]=we,(pe=pe+4|0)>>>0<ke>>>0;);for(je(pe,8+Ot|0,tr,0,16+Ot|0);;){i:{s:{o:{if(!((0|tr)!=1|(0|we)!=1)){if(e[12+Ot>>2])break o;break e}if(1<(0|tr))break s}Le(8+Ot|0,ke=Co(8+Ot|0)),we=e[8+Ot>>2],tr=tr+ke|0;break i}lr(8+Ot|0,2),e[8+Ot>>2]=7^e[8+Ot>>2],Le(8+Ot|0,1),je((Ne=pe+-4|0)-e[(16+Ot|0)+((ke=tr+-2|0)<<2)>>2]|0,8+Ot|0,tr+-1|0,1,16+Ot|0),lr(8+Ot|0,1),we=1|e[8+Ot>>2],e[8+Ot>>2]=we,je(Ne,8+Ot|0,ke,1,16+Ot|0),tr=ke}pe=pe+-4|0}}K=208+Ot|0}(b,E),e[B+e[g+640>>2]>>2]=E,!((0|(y=y+1|0))<e[e[S+704>>2]+20>>2]))break}if(!(H[c+4|0]<5|H[e[g>>2]+4|0]<4)){if(E=e[c+704>>2],u=e[E+128>>2],1<=(0|(e[g+596>>2]=u)))for(R=e[c+1112>>2],y=e[c+1116>>2],B=e[c+1108>>2],F=e[g+592>>2],V=e[g+600>>2];S=V+j(u=u+-1|0,12)|0,e[S>>2]=e[(b=u<<2)+B>>2],e[S+4>>2]=e[y+b>>2],e[S+8>>2]=F+j(e[b+R>>2],48),0<(0|u););if(u=e[E+132>>2],1<=(0|(e[g+612>>2]=u)))for(R=e[c+1136>>2],y=e[c+1140>>2],B=e[c+1132>>2],F=e[g+592>>2],V=e[g+616>>2];S=V+j(u=u+-1|0,12)|0,e[S>>2]=e[(b=u<<2)+B>>2],e[S+4>>2]=e[y+b>>2],e[S+8>>2]=F+j(e[b+R>>2],48),0<(0|u););if(u=e[E+136>>2],!((0|(e[g+628>>2]=u))<1))for(S=e[c+1160>>2],b=e[c+1164>>2],R=e[c+1156>>2],y=e[g+592>>2],B=e[g+632>>2];c=B+j(u=u+-1|0,12)|0,e[c>>2]=e[(E=u<<2)+R>>2],e[c+4>>2]=e[E+b>>2],e[c+8>>2]=y+j(e[E+S>>2],48),0<(0|u););}hi(g)}return K=576+d|0,g}(a,p,P))break r;e[36+_>>2]=2209,e[32+_>>2]=2361,Ut(4,1294,32+_|0)}else e[20+_>>2]=1444,e[16+_>>2]=2361,Ut(4,1294,16+_|0);else e[4+_>>2]=2132,e[_>>2]=2361,Ut(4,1294,_);p=0}return K=64+_|0,0|p}function cr(a){var p;return K=p=K-16|0,a=(a|=0)?function(P){var _;return Ce(16+(K=_=K-576|0)|0,0,560),vi(P,16+_|0,12+_|0),K=576+_|0,e[12+_>>2]}(a):(e[4+p>>2]=2132,e[p>>2]=2343,Ut(4,1294,p),0),K=16+p|0,0|a}function Ji(a){var p=H[a+4|0];vt(e[a+704>>2],4,64),Ee(e[a+708>>2],4),Ee(e[a+708>>2]+4|0,4),Ee(e[a+708>>2]+8|0,4),Ee(e[a+708>>2]+12|0,4),Ee(e[a+708>>2]+16|0,4),Ee(e[a+708>>2]+20|0,1),vt(e[a+720>>2],4,e[e[a+704>>2]>>2]),vt(e[a+724>>2],4,e[e[a+704>>2]>>2]),vt(e[a+728>>2],4,e[e[a+704>>2]>>2]),vt(e[a+732>>2],4,e[e[a+704>>2]>>2]),vt(e[a+736>>2],4,e[e[a+704>>2]>>2]),vt(e[a+740>>2],4,e[e[a+704>>2]>>2]),vt(e[a+752>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+756>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+760>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+764>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+768>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+772>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+776>>2],4,e[e[a+704>>2]+4>>2]),vt(e[a+780>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+784>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+788>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+796>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+800>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+804>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+812>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+816>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+820>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+828>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+852>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+856>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+860>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+868>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+872>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+876>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+880>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+884>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+888>>2],1,e[e[a+704>>2]+16>>2]),vt(e[a+892>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+896>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+900>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+904>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+908>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+912>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+924>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+928>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+932>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+936>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+940>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+948>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+952>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+976>>2],4,e[e[a+704>>2]+24>>2]),vt(e[a+980>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+984>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+996>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1e3>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1004>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1008>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1012>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1016>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1020>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1032>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1036>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1040>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1052>>2],4,e[e[a+704>>2]+40>>2]),vt(e[a+1064>>2],4,e[e[a+704>>2]+44>>2]),vt(e[a+1068>>2],4,e[e[a+704>>2]+48>>2]),vt(e[a+1072>>2],4,e[e[a+704>>2]+48>>2]),vt(e[a+1056>>2],4,e[e[a+704>>2]+52>>2]),vt(e[a+1060>>2],4,e[e[a+704>>2]+52>>2]),vt(e[a+1192>>2],4,e[e[a+704>>2]+56>>2]),vt(e[a+1196>>2],4,e[e[a+704>>2]+60>>2]),vt(e[a+1200>>2],2,e[e[a+704>>2]+64>>2]),vt(e[a+1204>>2],4,e[e[a+704>>2]+68>>2]),vt(e[a+1208>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1212>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1216>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1220>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1224>>2],4,e[e[a+704>>2]+72>>2]),vt(e[a+1228>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1232>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1236>>2],4,e[e[a+704>>2]+76>>2]),vt(e[a+1248>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1252>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1256>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1260>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1264>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1268>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1272>>2],4,e[e[a+704>>2]+80>>2]),vt(e[a+1276>>2],4,e[e[a+704>>2]+84>>2]),vt(e[a+1280>>2],2,e[e[a+704>>2]+84>>2]),vt(e[a+1284>>2],4,e[e[a+704>>2]+88>>2]),p>>>0<2||(vt(e[a+808>>2],4,e[e[a+704>>2]+8>>2]),p>>>0<4)||(vt(e[a+968>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+972>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+792>>2],4,e[e[a+704>>2]+8>>2]),vt(e[a+824>>2],4,e[e[a+704>>2]+12>>2]),vt(e[a+864>>2],4,e[e[a+704>>2]+16>>2]),vt(e[a+1288>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1292>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1296>>2],4,e[e[a+704>>2]+92>>2]),vt(e[a+1300>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+1304>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+1308>>2],4,e[e[a+704>>2]+96>>2]),vt(e[a+944>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+956>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+960>>2],4,e[e[a+704>>2]+20>>2]),vt(e[a+1076>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1080>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1084>>2],4,e[e[a+704>>2]+100>>2]),vt(e[a+1088>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1092>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1096>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1100>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1104>>2],4,e[e[a+704>>2]+104>>2]),vt(e[a+1120>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1124>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1128>>2],4,e[e[a+704>>2]+108>>2]),vt(e[a+1144>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1148>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1152>>2],4,e[e[a+704>>2]+112>>2]),vt(e[a+1168>>2],4,e[e[a+704>>2]+116>>2]),vt(e[a+1172>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1176>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1180>>2],4,e[e[a+704>>2]+120>>2]),vt(e[a+1184>>2],4,e[e[a+704>>2]+124>>2]),vt(e[a+1188>>2],4,e[e[a+704>>2]+124>>2]),(0|p)!=4&&(vt(e[a+988>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+992>>2],4,e[e[a+704>>2]+28>>2]),vt(e[a+1024>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1028>>2],4,e[e[a+704>>2]+32>>2]),vt(e[a+1044>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1048>>2],4,e[e[a+704>>2]+36>>2]),vt(e[a+1108>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1112>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1116>>2],4,e[e[a+704>>2]+128>>2]),vt(e[a+1132>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1136>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1140>>2],4,e[e[a+704>>2]+132>>2]),vt(e[a+1156>>2],4,e[e[a+704>>2]+136>>2]),vt(e[a+1160>>2],4,e[e[a+704>>2]+136>>2]),vt(e[a+1164>>2],4,e[e[a+704>>2]+136>>2])))}function ts(a,p){var P=0,_=0,c=0,E=0,u=0,d=0,g=a+p|0;r:{t:if(!(1&(P=e[a+4>>2]))){if(!(3&P))break r;if(p=(P=e[a>>2])+p|0,(0|(a=a-P|0))!=e[2092])if(P>>>0<=255)c=P>>>3,P=e[a+8>>2],(0|(_=e[a+12>>2]))==(0|P)?(d=e[2087]&kr(c),e[2087]=d):(e[P+12>>2]=_,e[_+8>>2]=P);else{if(u=e[a+24>>2],(0|(P=e[a+12>>2]))!=(0|a))_=e[a+8>>2],e[_+12>>2]=P,e[P+8>>2]=_;else if(c=(c=e[(_=a+20|0)>>2])||e[(_=a+16|0)>>2]){for(;E=_,(c=e[(_=(P=c)+20|0)>>2])||(_=P+16|0,c=e[P+16>>2]););e[E>>2]=0}else P=0;if(u){_=e[a+28>>2];e:{if(e[(c=8652+(_<<2)|0)>>2]==(0|a)){if(e[c>>2]=P)break e;d=e[2088]&kr(_),e[2088]=d;break t}if(!(e[u+(e[u+16>>2]==(0|a)?16:20)>>2]=P))break t}e[P+24>>2]=u,(_=e[a+16>>2])&&(e[P+16>>2]=_,e[_+24>>2]=P),(_=e[a+20>>2])&&(e[P+20>>2]=_,e[_+24>>2]=P)}}else if((3&(P=e[4+g>>2]))==3)return e[2089]=p,e[4+g>>2]=-2&P,e[a+4>>2]=1|p,e[g>>2]=p}t:{if(!(2&(P=e[4+g>>2]))){if(e[2093]==(0|g)){if(e[2093]=a,p=e[2090]+p|0,e[2090]=p,e[a+4>>2]=1|p,e[2092]!=(0|a))break r;return e[2089]=0,e[2092]=0}if(e[2092]==(0|g))return e[2092]=a,p=e[2089]+p|0,e[2089]=p,e[a+4>>2]=1|p,e[a+p>>2]=p;p=(-8&P)+p|0;e:if(P>>>0<=255)c=P>>>3,P=e[8+g>>2],(0|(_=e[12+g>>2]))==(0|P)?(d=e[2087]&kr(c),e[2087]=d):(e[P+12>>2]=_,e[_+8>>2]=P);else{if(u=e[24+g>>2],(0|g)!=(0|(P=e[12+g>>2])))_=e[8+g>>2],e[_+12>>2]=P,e[P+8>>2]=_;else if(c=(c=e[(_=20+g|0)>>2])||e[(_=16+g|0)>>2]){for(;E=_,(c=e[(_=(P=c)+20|0)>>2])||(_=P+16|0,c=e[P+16>>2]););e[E>>2]=0}else P=0;if(u){_=e[28+g>>2];i:{if(e[(c=8652+(_<<2)|0)>>2]==(0|g)){if(e[c>>2]=P)break i;d=e[2088]&kr(_),e[2088]=d;break e}if(!(e[u+(e[u+16>>2]==(0|g)?16:20)>>2]=P))break e}e[P+24>>2]=u,(_=e[16+g>>2])&&(e[P+16>>2]=_,e[_+24>>2]=P),(_=e[20+g>>2])&&(e[P+20>>2]=_,e[_+24>>2]=P)}}if(e[a+4>>2]=1|p,e[a+p>>2]=p,e[2092]!=(0|a))break t;return e[2089]=p}e[4+g>>2]=-2&P,e[a+4>>2]=1|p,e[a+p>>2]=p}if(p>>>0<=255)return p=8388+((P=p>>>3)<<3)|0,P=(_=e[2087])&(P=1<<P)?e[p+8>>2]:(e[2087]=P|_,p),e[p+8>>2]=a,e[P+12>>2]=a,e[a+12>>2]=p,e[a+8>>2]=P;e[a+16>>2]=0,P=e[a+20>>2]=0,(c=p>>>8)&&(P=31,16777215<p>>>0||(P=28+((P=((g=(c<<=E=c+1048320>>>16&8)<<(P=c+520192>>>16&4))<<(c=245760+g>>>16&2)>>>15)-(c|P|E)|0)<<1|p>>>P+21&1)|0)),c=8652+((e[(_=a)+28>>2]=P)<<2)|0;t:{if((_=e[2088])&(E=1<<P)){for(_=p<<((0|P)==31?0:25-(P>>>1)|0),P=e[c>>2];;){if((-8&e[(c=P)+4>>2])==(0|p))break t;if(P=_>>>29,_<<=1,!(P=e[16+(E=c+(4&P)|0)>>2]))break}e[E+16>>2]=a}else e[2088]=_|E,e[c>>2]=a;return e[a+24>>2]=c,e[a+12>>2]=a,e[a+8>>2]=a}p=e[c+8>>2],e[p+12>>2]=a,e[c+8>>2]=a,e[a+24>>2]=0,e[a+12>>2]=c,e[a+8>>2]=p}}function Kr(a){var p,P,_,c,E,u,d,g,y=v(0),b=(v(0),0),S=0,R=(v(0),v(0),v(0),v(0),0);v(0),v(0);r:{t:{if(Qt(a),S=2147483647&(b=Wt[0])){if(!(S>>>0<2139095041))return v(v(.10000000149011612)+a);if((0|S)==1065353216)return v(-1<(0|b)?.10000000149011612:10);if((0|S)==2139095040)return v(-1<(0|b)?0:-a);if((0|b)==1073741824)return v(.010000000707805157);if((0|b)==1056964608)return v(.3162277638912201);if(1291845633<=S>>>0)return v((0|b)<0?Nt:0);if(p=I[1701],g=v(v(1.600000023841858)-p),P=v(v(1)/v(p+v(1.600000023841858))),Yt(0,-4096&(Qt(d=v(g*P)),Wt[0])),y=zt(),_=v(y*y),E=I[1705],p=v(P*v(v(g-v((c=y)*v(3.099609375)))-v(y*v(v(1.600000023841858)-v(v(3.099609375)-p))))),P=v(v(d+y)*p),y=v(d*d),g=v(P+v(v(y*y)*v(v(y*v(v(y*v(v(y*v(v(y*v(v(y*v(.20697501301765442))+v(.23066075146198273)))+v(.2727281153202057)))+v(.3333333432674408)))+v(.4285714328289032)))+v(.6000000238418579)))),Yt(0,-4096&(Qt(v(v(_+v(3))+g)),Wt[0])),y=zt(),P=v(c*y),d=v(v(p*y)+v(d*v(g-v(v(y+v(-3))-_)))),Yt(0,-4096&(Qt(v(P+d)),Wt[0])),y=zt(),p=v(y*v(.9619140625)),_=v(I[1703]+v(v(v(d-v(y-P))*v(.9617967009544373))+v(y*v(-.00011736857413779944)))),Yt(0,-4096&(Qt(v(v(E+v(p+_))+v(-4))),Wt[0])),d=zt(),Yt(0,-4096&b),g=zt(),y=v(d*g),a=v(v(v(_-v(v(v(d-v(-4))-E)-p))*a)+v(v(a-g)*d)),Qt(d=v(y+a)),1124073473<=(0|(b=Wt[0])))break t;e:{if((S=1124073472)==(0|b)){if(v(a+v(4299566569443414e-23))>v(d-y))break t}else{if(S=2147483647&b,!(a<=v(d-y)^1|(0|b)!=-1021968384)|1125515265<=S>>>0)break r;if(S>>>0<1056964609)break e}R=(8388607&(S=(8388608>>>(S>>>23)-126)+b|0)|8388608)>>>150-(u=S>>>23&255),R=(0|b)<0?0-R|0:R,y=v(y-(Yt(0,S&-8388608>>u-127),zt())),Qt(v(a+y)),b=Wt[0]}Yt(0,-32768&b),d=zt(),p=v(d*v(.693145751953125)),d=v(v(d*v(14286065379565116e-22))+v(v(a-v(d-y))*v(.6931471824645996))),a=v(p+d),y=v(a*a),y=v(a-v(y*v(v(y*v(v(y*v(v(y*v(v(y*v(4138136944220605e-23))+v(-16533901998627698e-22)))+v(661375597701408e-19)))+v(-.0027777778450399637)))+v(.1666666716337204)))),c=v(v(a*y)/v(y+v(-2))),y=v(d-v(a-p)),a=(0|(b=0|(Qt(a=v(v(a-v(c-v(y+v(a*y))))+v(1))),Wt[0]+(R<<23))))<=8388607?function(F,B){var V=0;return 128<=(0|B)?(F=v(F*v(17014118346046923e22)),B=(0|(V=B+-127|0))<128?V:(F=v(F*v(17014118346046923e22)),((0|B)<381?B:381)+-254|0)):-127<(0|B)||(F=v(F*v(11754943508222875e-54)),B=-127<(0|(V=B+126|0))?V:(F=v(F*v(11754943508222875e-54)),(-378<(0|B)?B:-378)+252|0)),v(F*(Yt(0,1065353216+(B<<23)|0),zt()))}(a,R):(Yt(0,b),zt()),a=v(v(1)*a)}else a=v(1);return a}return v(Nt)}return v(0)}function Bi(a,p){var P,_,c,E=0,u=0,d=v(0);if(Qt(p),!((c=2147483647&(_=Wt[0]))>>>0<=2139095040&&(Qt(a),(E=2147483647&(u=Wt[0]))>>>0<2139095041)))return v(a+p);if((0|_)==1065353216)return li(a);_=(P=_>>>30&2)|u>>>31;r:{t:{e:{i:{if(!E){switch(_-2|0){case 0:break i;case 1:break;default:break e}return v(-3.1415927410125732)}if((0|c)!=2139095040){if(!c|!(E>>>0<=218103808+c>>>0&&(0|E)!=2139095040))break r;if(a=d=E+218103808>>>0<c>>>0&&(d=v(0),P)?d:li(v(St(v(a/p)))),_>>>0<=2){switch(_-1|0){case 0:return v(-a);case 1:break;default:break e}return v(v(3.1415927410125732)-v(a+v(8742277657347586e-23)))}return v(v(a+v(8742277657347586e-23))+v(-3.1415927410125732))}if((0|E)==2139095040)break t;return I[6784+(_<<2)>>2]}a=v(3.1415927410125732)}return a}return I[6768+(_<<2)>>2]}return v((0|u)<0?-1.5707963705062866:1.5707963705062866)}function li(a){v(0);var p,P,_,c,E,u=0;v(0),v(0),Qt(a);r:{if(1283457024<=(c=2147483647&(E=Wt[0]))>>>0){if(2139095040<c>>>0)break r;return v((0|E)<0?-1.570796251296997:1.570796251296997)}t:{if(c>>>0<=1054867455){if(u=-1,964689920<=c>>>0)break t;break r}a=v(St(a)),u=c>>>0<=1066926079?c>>>0<=1060110335?(a=v(v(v(a+a)+v(-1))/v(a+v(2))),0):(a=v(v(a+v(-1))/v(a+v(1))),1):c>>>0<=1075576831?(a=v(v(a+v(-1.5))/v(v(a*v(1.5))+v(1))),2):(a=v(v(-1)/a),3)}if(c=u,P=v(a*a),p=v(P*P),_=v(p*v(v(p*v(-.106480173766613))+v(-.19999158382415771))),p=v(P*v(v(p*v(v(p*v(.06168760731816292))+v(.14253635704517365)))+v(.333333283662796))),(0|c)<=-1)return v(a-v(a*v(_+p)));a=v(I[6736+(c<<=2)>>2]-v(v(v(a*v(_+p))-I[6752+c>>2])-a)),a=(0|E)<0?v(-a):a}return a}function Qe(a,p){var P,_,c,E=0,u=0;return K=_=K-16|0,Qt(a),(E=2147483647&(c=Wt[0]))>>>0<=1305022426?(ct[p>>3]=(P=+a)+-1.5707963109016418*(u=.6366197723675814*P+6755399441055744-6755399441055744)+-15893254773528196e-24*u,E=St(u)<2147483648?~~u:-2147483648):2139095040<=E>>>0?(ct[p>>3]=v(a-a),E=0):(P=E,ct[8+_>>3]=(Yt(0,P-((E=(E>>>23)-150|0)<<23)|0),zt()),E=function(d,g,y){var b,S,R,F,B,V,z=0,q=0,tt=0,ut=0,mt=0,Bt=0,Ht=0,ce=0,Ae=0,Ue=0,He=0;if(K=b=K-560|0,Ht=(q=y)+j(R=0<(0|(y=(y+-3|0)/24|0))?y:0,-24)|0,0<=(0|(S=e[972])))for(q=S+1|0,y=R;ct[(320+b|0)+(tt<<3)>>3]=(0|y)<0?0:+e[3904+(y<<2)>>2],y=y+1|0,(0|q)!=(0|(tt=tt+1|0)););for(mt=Ht+-24|0,q=0;;){for(z=y=0;z+=ct[(y<<3)+d>>3]*ct[(320+b|0)+(q-y<<3)>>3],(0|(y=y+1|0))!=1;);if(ct[(q<<3)+b>>3]=z,y=(0|q)<(0|S),q=q+1|0,!y)break}V=23-mt|0,F=24-mt|0,q=S;r:{for(;;){if(z=ct[(q<<3)+b>>3],!(Ae=((y=0)|(tt=q))<1))for(;Bt=(480+b|0)+(y<<2)|0,ce=z,ut=St(z*=5960464477539063e-23)<2147483648?~~z:-2147483648,ut=St(ce+=-16777216*(z=0|ut))<2147483648?~~ce:-2147483648,e[Bt>>2]=ut,z=ct[((tt=tt+-1|0)<<3)+b>>3]+z,(0|q)!=(0|(y=y+1|0)););z=Be(z,mt),z=(z+=-8*Ft(.125*z))-(0|(Bt=St(z)<2147483648?~~z:-2147483648));t:{e:{i:{if(He=(0|mt)<1){if(mt)break i;ut=e[476+((q<<2)+b|0)>>2]>>23}else ut=e[476+(tt=(q<<2)+b|0)>>2],Ue=tt,tt=ut-((y=ut>>F)<<F)|0,Bt=y+Bt|0,ut=(e[Ue+476>>2]=tt)>>V;if((0|ut)<1)break t;break e}if(ut=2,!(.5<=z)){ut=0;break t}}if(tt=y=0,!Ae)for(;;){Ae=e[(B=(480+b|0)+(y<<2)|0)>>2],Ue=16777215;e:{i:{if(!tt){if(!Ae)break i;Ue=16777216,tt=1}e[B>>2]=Ue-Ae;break e}tt=0}if((0|q)==(0|(y=y+1|0)))break}He||1<(y=mt+-1|0)>>>0||(e[476+(y=(q<<2)+b|0)>>2]=y-1?8388607&e[y+476>>2]:4194303&e[y+476>>2]),Bt=Bt+1|0,(0|ut)==2&&(z=1-z,ut=2,tt)&&(z-=Be(1,mt))}if(z!=0)break;if(!(((tt=0)|(y=q))<=(0|S))){for(;tt=e[(480+b|0)+((y=y+-1|0)<<2)>>2]|tt,(0|S)<(0|y););if(tt){for(Ht=mt;Ht=Ht+-24|0,!e[(480+b|0)+((q=q+-1|0)<<2)>>2];);break r}}for(y=1;y=(tt=y)+1|0,!e[(480+b|0)+(S-tt<<2)>>2];);for(tt=q+tt|0;;){for(q=Bt=q+1|0,ct[(320+b|0)+(Bt<<3)>>3]=e[3904+(R+q<<2)>>2],z=y=0;z+=ct[(y<<3)+d>>3]*ct[(320+b|0)+(Bt-y<<3)>>3],(0|(y=y+1|0))!=1;);if(ct[(q<<3)+b>>3]=z,!((0|q)<(0|tt)))break}q=tt}16777216<=(z=Be(z,0-mt|0))?(d=(480+b|0)+(q<<2)|0,ce=z,y=St(z*=5960464477539063e-23)<2147483648?~~z:-2147483648,tt=St(z=ce+-16777216*(0|y))<2147483648?~~z:-2147483648,e[d>>2]=tt,q=q+1|0):(y=St(z)<2147483648?~~z:-2147483648,Ht=mt),e[(480+b|0)+(q<<2)>>2]=y}if(z=Be(1,Ht),!((0|q)<=-1)){for(y=q;ct[(y<<3)+b>>3]=z*+e[(480+b|0)+(y<<2)>>2],z*=5960464477539063e-23,d=0<(0|y),y=y+-1|0,d;);if(!((0|q)<=-1))for(y=q;;){for(mt=q-(d=y)|0,y=z=0;z+=ct[6672+(y<<3)>>3]*ct[(d+y<<3)+b>>3],!((0|S)<=(0|y))&&(Ht=y>>>0<mt>>>0,y=y+1|0,Ht););if(ct[(160+b|0)+(mt<<3)>>3]=z,y=d+-1|0,!(0<(0|d)))break}}if(0<=(q|(z=0)))for(;z+=ct[(160+b|0)+(q<<3)>>3],d=0<(0|q),q=q+-1|0,d;);return ct[g>>3]=ut?-z:z,K=560+b|0,7&Bt}(8+_|0,_,E),u=ct[_>>3],(0|c)<=-1?(ct[p>>3]=-u,E=0-E|0):ct[p>>3]=u),K=16+_|0,E}function vo(a,p){return a?function(P,_){r:{if(P){if(_>>>0<=127)break r;if(e[e[1789]>>2]){if(_>>>0<=2047)return O[P+1|0]=63&_|128,O[0|P]=_>>>6|192,2;if(!((-8192&_)!=57344&&55296<=_>>>0))return O[P+2|0]=63&_|128,O[0|P]=_>>>12|224,O[P+1|0]=_>>>6&63|128,3;if(_+-65536>>>0<=1048575)return O[P+3|0]=63&_|128,O[0|P]=_>>>18|240,O[P+2|0]=_>>>6&63|128,O[P+1|0]=_>>>12&63|128,4}else if((-128&_)==57216)break r;e[2086]=25,P=-1}else P=1;return P}return O[0|P]=_,1}(a,p):0}function vi(a,p,P){var _,c,E=0,u=0,d=0,g=0,y=0,b=0,S=0,R=0,F=0,B=H[a+4|0];if(e[p>>2]=652,u=e[a+704>>2],1<=(0|(g=e[u>>2]))){for(y=e[a+720>>2],S=e[a+1072>>2];d=(1<<e[S+(e[y+(E<<2)>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+4>>2]=j(g,12),e[p+8>>2]=e[u>>2]<<2,e[p+12>>2]=e[u>>2]<<2,e[p+16>>2]=e[u>>2]<<2,e[p+20>>2]=e[u>>2]<<2,d=e[u>>2],e[p+28>>2]=E,e[p+24>>2]=d<<2,d=e[u>>2],e[p+40>>2]=E,e[p+36>>2]=E,e[p+32>>2]=d<<2,e[p+44>>2]=e[u+4>>2]<<5,e[p+48>>2]=e[u+4>>2]<<2,e[p+52>>2]=e[u+4>>2]<<2,e[p+56>>2]=e[u+4>>2]<<2,e[p+60>>2]=e[u+4>>2]<<4,e[p+64>>2]=e[u+4>>2]<<4,1<=((E=0)|(g=e[u+8>>2]))){for(y=e[a+780>>2],S=e[a+1072>>2],F=e[a+796>>2],d=0;b=(15+(e[(R=E<<2)+F>>2]<<3)&-16)+b|0,d=(1<<e[S+(e[y+R>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+68>>2]=j(g,24),e[p+72>>2]=e[u+8>>2]<<2,e[p+76>>2]=e[u+8>>2]<<2,d=e[u+8>>2],e[p+84>>2]=b,e[p+80>>2]=d<<2,e[p+88>>2]=e[u+8>>2]<<4,e[p+92>>2]=e[u+8>>2]<<4,d=e[u+8>>2],e[p+100>>2]=E,e[p+96>>2]=d<<2,d=e[u+8>>2],e[p+140>>2]=E,e[p+136>>2]=E,e[p+132>>2]=E,e[p+128>>2]=E,e[p+124>>2]=E,e[p+120>>2]=E,e[p+116>>2]=E,e[p+112>>2]=E,e[p+108>>2]=E,e[p+104>>2]=d<<2,e[p+144>>2]=e[u+8>>2]<<2,e[p+148>>2]=e[u+8>>2]<<2,e[p+152>>2]=e[u+8>>2]<<2,e[p+156>>2]=e[u+8>>2]<<2,e[p+160>>2]=e[u+8>>2]<<2,e[p+164>>2]=e[u+8>>2]<<2,1<=((E=b=0)|(g=e[u+12>>2]))){for(y=e[a+812>>2],S=e[a+1072>>2],d=0;d=(1<<e[S+(e[y+(E<<2)>>2]<<2)>>2])+d|0,(0|g)!=(0|(E=E+1|0)););E=d<<2}if(e[p+168>>2]=j(g,12),e[p+172>>2]=e[u+12>>2]<<2,e[p+176>>2]=e[u+12>>2]<<2,e[p+180>>2]=e[u+12>>2]<<2,e[p+184>>2]=e[u+12>>2]<<2,e[p+188>>2]=e[u+12>>2]<<2,e[p+192>>2]=e[u+12>>2]<<2,e[p+196>>2]=e[u+12>>2]<<2,e[p+200>>2]=e[u+12>>2]<<2,e[p+204>>2]=e[u+12>>2]<<4,e[p+208>>2]=e[u+12>>2]<<4,d=e[u+12>>2],e[p+216>>2]=E,e[p+212>>2]=d<<2,d=e[u+12>>2],e[p+268>>2]=E,e[p+264>>2]=E,e[p+260>>2]=E,e[p+256>>2]=E,e[p+252>>2]=E,e[p+248>>2]=E,e[p+244>>2]=E,e[p+240>>2]=E,e[p+236>>2]=E,e[p+232>>2]=E,e[p+228>>2]=E,e[p+224>>2]=E,e[p+220>>2]=d<<2,e[p+272>>2]=e[u+12>>2]<<2,e[p+276>>2]=e[u+12>>2]<<2,e[p+280>>2]=e[u+12>>2]<<2,e[p+284>>2]=e[u+12>>2]<<2,e[p+288>>2]=e[u+12>>2]<<2,e[p+292>>2]=e[u+12>>2]<<2,1<=((E=0)|(d=e[u+16>>2]))){for(y=e[a+852>>2],S=e[a+1072>>2],F=e[a+892>>2],g=0;b=(15+(e[(R=E<<2)+F>>2]<<3)&-16)+b|0,g=(1<<e[S+(e[y+R>>2]<<2)>>2])+g|0,(0|d)!=(0|(E=E+1|0)););E=g<<2}if(e[p+296>>2]=j(d,20),e[p+300>>2]=e[u+16>>2]<<2,e[p+304>>2]=e[u+16>>2],e[p+308>>2]=e[u+16>>2]<<2,e[p+312>>2]=e[u+16>>2]<<2,d=e[u+16>>2],e[p+320>>2]=b,e[p+316>>2]=d<<2,e[p+324>>2]=e[u+16>>2]<<2,e[p+328>>2]=e[u+16>>2]<<4,e[p+332>>2]=e[u+16>>2]<<4,e[p+336>>2]=e[u+16>>2]<<2,e[p+340>>2]=e[u+16>>2]<<2,e[p+344>>2]=e[u+16>>2]<<2,e[p+348>>2]=e[u+16>>2]<<4,e[p+352>>2]=e[u+16>>2]<<4,d=e[u+16>>2],e[p+360>>2]=E,e[p+356>>2]=d<<2,d=e[u+16>>2],e[p+404>>2]=E,e[p+400>>2]=E,e[p+396>>2]=E,e[p+392>>2]=E,e[p+388>>2]=E,e[p+384>>2]=E,e[p+380>>2]=E,e[p+376>>2]=E,e[p+372>>2]=E,e[p+368>>2]=E,e[p+364>>2]=d<<2,e[p+408>>2]=e[u+16>>2]<<2,e[p+412>>2]=e[u+16>>2]<<2,e[p+416>>2]=e[u+16>>2]<<2,e[p+420>>2]=e[u+16>>2]<<2,e[p+424>>2]=e[u+16>>2]<<2,e[p+428>>2]=e[u+16>>2]<<2,y=e[a+704>>2],e[p+432>>2]=j(e[y+20>>2],52),e[p+436>>2]=B>>>(E=g=0)<=3?e[y+20>>2]<<2:0,e[p+440>>2]=e[y+20>>2]<<2,e[p+444>>2]=j(e[y+52>>2],28),1<=(0|(u=e[y+48>>2]))){for(d=e[a+1072>>2],b=0;b=(S=e[d+(E<<2)>>2])+b|0,g=(1<<S)+g|0,(0|u)!=(0|(E=E+1|0)););E=g<<2,g=b<<2}if(e[p+460>>2]=E,e[p+456>>2]=E,e[p+452>>2]=g,e[p+448>>2]=j(u,36),e[p+500>>2]=j(e[y+72>>2],28),1<=((b=E=d=0)|(S=e[y+72>>2]))){for(F=e[a+1224>>2],R=e[a+1220>>2],c=e[a+1212>>2],g=0;g=(0|(_=e[(u=b<<2)+R>>2]-e[u+F>>2]|0))<(0|g)?g:1+_|0,E=(0|E)<(0|(u=e[u+c>>2]))?u:E,(0|S)!=(0|(b=b+1|0)););b=E<<2,E=g<<2}if(u=e[y+76>>2],e[p+516>>2]=E,e[p+512>>2]=b,e[p+508>>2]=E,e[p+504>>2]=u<<4,1<=(0|(u=e[y+80>>2]))){for(d=e[a+1248>>2],b=e[a+1072>>2],g=E=0;g=(1<<e[b+(e[d+(E<<2)>>2]<<2)>>2])+g|0,(0|u)!=(0|(E=E+1|0)););d=g<<2}if(e[p+520>>2]=j(u,24),e[p+524>>2]=e[y+80>>2]<<2,u=e[y+80>>2],e[p+532>>2]=d,e[p+528>>2]=u<<2,u=e[y+80>>2],e[p+544>>2]=d,e[p+540>>2]=d,e[p+536>>2]=u<<2,u=p,4<=B>>>0){if(e[p+464>>2]=j(e[y+120>>2],20),e[p+468>>2]=j(e[y+100>>2],28),d=p,1<=((E=b=0)|(S=e[y+104>>2]))){for(a=e[a+1104>>2],g=0;g=e[a+(E<<2)>>2]+g|0,(0|S)!=(0|(E=E+1|0)););a=g<<2}else a=0;e[d+476>>2]=a,e[p+472>>2]=j(S,48),e[p+484>>2]=j(e[y+108>>2],12),a=e[y+112>>2],e[p+552>>2]=0,e[p+492>>2]=j(a,12),a=0}else{if((0|(b=e[y+20>>2]))<1)g=0;else for(S=e[a+1060>>2],F=e[a+952>>2],a=e[a+948>>2],d=g=0;;){if(1<=(0|(R=e[(E=d<<2)+F>>2])))for(R=(E=S+(e[a+E>>2]<<2)|0)+(R<<2)|0;g=e[E>>2]+g|0,(E=E+4|0)>>>0<R>>>0;);if((0|b)==(0|(d=d+1|0)))break}e[p+552>>2]=b<<2,b=e[y+20>>2]<<2,a=g<<2}for(e[u+556>>2]=a,e[p+548>>2]=b,4<B>>>0&&(e[p+480>>2]=j(e[y+128>>2],12),e[p+488>>2]=j(e[y+132>>2],12),e[p+496>>2]=j(e[y+136>>2],12)),E=g=0;E=((u=e[(a=(g<<2)+p|0)>>2])+15&-16)+(e[a>>2]=E)|0,(0|(g=g+1|0))!=140;);e[P>>2]=E}function ki(a,p,P,_){r:{if(!(20<p>>>0||9<(p=p+-9|0)>>>0)){switch(p-1|0){default:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=e[p>>2];case 0:return p=e[P>>2],e[P>>2]=p+4,p=e[p>>2],e[a>>2]=p,e[a+4>>2]=p>>31;case 1:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=e[p>>2],e[a+4>>2]=0;case 3:return p=e[P>>2],e[P>>2]=p+4,p=N[p>>1],e[a>>2]=p,e[a+4>>2]=p>>31;case 4:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=W[p>>1],e[a+4>>2]=0;case 5:return p=e[P>>2],e[P>>2]=p+4,p=O[0|p],e[a>>2]=p,e[a+4>>2]=p>>31;case 6:return p=e[P>>2],e[P>>2]=p+4,e[a>>2]=H[0|p],e[a+4>>2]=0;case 2:case 7:break r;case 8:}L[_](a,P)}return}p=e[P>>2]+7&-8,e[P>>2]=p+8,P=e[p+4>>2],e[a>>2]=e[p>>2],e[a+4>>2]=P}function xo(a){var p,P,_=0;if(ie(O[e[a>>2]]))for(;p=e[a>>2],P=O[0|p],e[a>>2]=p+1,_=(j(_,10)+P|0)-48|0,ie(O[p+1|0]););return _}function bo(a,p,P,_,c){var E,u;e[204+(K=u=K-208|0)>>2]=P,Ce(160+u|(P=0),0,40),e[200+u>>2]=e[204+u>>2],(0|mr(0,p,200+u|0,80+u|0,160+u|0,_,c))<0||(P=0<=e[a+76>>2]?1:P,P=e[a>>2],O[a+74|0]<=0&&(e[a>>2]=-33&P),E=32&P,e[a+48>>2]?mr(a,p,200+u|0,80+u|0,160+u|0,_,c):(e[a+48>>2]=80,e[a+16>>2]=80+u,e[a+28>>2]=u,e[a+20>>2]=u,P=e[a+44>>2],mr(a,p,200+(e[a+44>>2]=u)|0,80+u|0,160+u|0,_,c),P&&(L[e[a+36>>2]](a,0,0),e[a+48>>2]=0,e[a+44>>2]=P,e[a+28>>2]=0,e[a+16>>2]=0,e[a+20>>2]=0)),e[a>>2]=e[a>>2]|E),K=208+u|0}function Ao(a,p,P){var _,c;ge(8+(K=c=K-160|0)|0,3192,144),e[52+c>>2]=a,e[28+c>>2]=a,e[56+c>>2]=_=(_=-2-a|0)>>>0<256?_:256,e[36+c>>2]=a=a+_|0,e[24+c>>2]=a,bo(8+c|0,p,P,11,12),_&&(a=e[28+c>>2],O[a-((0|a)==e[24+c>>2])|0]=0),K=160+c|0}function wo(a,p){var P,_,c=0,c=(0|p)!=0;r:{t:{e:{i:if(!(!p|!(3&a)))for(;;){if(!H[0|a])break e;if(a=a+1|0,c=(0|(p=p+-1|0))!=0,!p)break i;if(!(3&a))break}if(!c)break t}if(!H[0|a])break r;e:{if(4<=p>>>0){for(c=(c=p+-4|0)-(P=-4&c)|0,P=4+(a+P|0)|0;;){if((-1^(_=e[a>>2]))&_+-16843009&-2139062144)break e;if(a=a+4|0,!(3<(p=p+-4|0)>>>0))break}p=c,a=P}if(!p)break t}for(;;){if(!H[0|a])break r;if(a=a+1|0,!(p=p+-1|0))break}}return 0}return a}function To(a){var p,P=0;if(!a)return 32;if(!(1&a))for(;P=P+1|0,p=2&a,a>>>=1,!p;);return P}function Eo(a,p){var P,_,c,E,u=0,d=0,d=4;K=E=K-256|0;r:if(!((0|p)<2))for(u=e[(c=(p<<2)+a|0)>>2]=E;;){for(ge(u,e[a>>2],P=d>>>0<256?d:256),u=0;ge(e[(_=(u<<2)+a|0)>>2],e[((u=u+1|0)<<2)+a>>2],P),e[_>>2]=e[_>>2]+P,(0|p)!=(0|u););if(!(d=d-P|0))break r;u=e[c>>2]}K=256+E|0}function Co(a){return To(e[a>>2]+-1|0)||((a=To(e[a+4>>2]))?a+32|0:0)}function Is(a,p){p|=0,Wt[0]=a|=0,Wt[1]=p}function So(a,p,P){return function(_,c,E){var u,d,g,y,b=j(d=E>>>16,g=_>>>16);return _=(65535&(g=((u=j(y=65535&E,_&=65535))>>>16)+j(g,y)|0))+j(_,d)|0,Vt=((b+j(c,E)|0)+(g>>>16)|0)+(_>>>16)|0,65535&u|_<<16}(a,p,P)}function Po(a,p,P){return function(_,c,E){var u,d,g=0,y=0,b=0,S=0,R=0,F=0,B=0;r:{t:{e:{i:{s:{if(!(y=c))return Is((c=_)-j(_=(_>>>0)/(E>>>0)|0,E)|0,0),Vt=0,_;if(g=E){if(!((S=g+-1|0)&g))break s;R=0-(S=(yt(g)+33|0)-yt(y)|0)|0;break e}if(!_)return Is(0,y-j(_=(y>>>0)/0|0,0)|0),Vt=0,_;if((g=32-yt(y)|0)>>>0<31)break i;break t}if(Is(_&S,0),(0|g)==1)break r;return E=31&(g=g?31-yt(g+-1^g)|0:32),_=32<=(63&g)>>>0?(y=0,c>>>E):(y=c>>>E,((1<<E)-1&c)<<32-E|_>>>E),Vt=y,_}S=g+1|0,R=63-g|0}if(g=c,b=31&(y=63&S),b=32<=y>>>0?(y=0,g>>>b):(y=g>>>b,((1<<b)-1&g)<<32-b|_>>>b),g=31&(R&=63),32<=R>>>0?(c=_<<g,_=0):(c=(1<<g)-1&_>>>32-g|c<<g,_<<=g),S)for((R=E+(g=-1)|0)>>>0<4294967295&&(g=0);b=(d=F=b<<1|c>>>31)-(u=E&(F=g-((y=y<<1|b>>>31)+(R>>>0<F>>>0)|0)>>31))|0,y=y-(d>>>0<u>>>0)|0,c=c<<1|_>>>31,_=B|_<<1,B=F&=1,S=S+-1|0;);return Is(b,y),Vt=c<<1|_>>>31,F|_<<1}Is(_,c),c=_=0}return Vt=c,_}(a,p,P)}function kr(a){var p;return(-1>>>(p=31&a)&-2)<<p|(-1<<(a=0-a&31)&-2)>>>a}function $o(){return w.byteLength/65536|0}}(Pt,It,pt)}}D=null,x.wasmBinary&&(Rt=x.wasmBinary);var wt={},Rt=[];typeof wt!="object"&&et("no native wasm support detected");var It,pt=new function(Tt){var $t=Array(16);return $t.grow=function(){17<=$t.length&&Jt("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."),$t.push(null)},$t.set=function(at,lt){$t[at]=lt},$t.get=function(at){return $t[at]},$t},xt=!1;function Ct(Tt,$t){Tt||Jt("Assertion failed: "+$t)}var Gt,st,nt,Y,gt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ot(Tt,$t,at){var lt=$t+at;for(at=$t;Tt[at]&&!(lt<=at);)++at;if(16<at-$t&&Tt.subarray&&gt)return gt.decode(Tt.subarray($t,at));for(lt="";$t<at;){var Wt,be,de=Tt[$t++];128&de?(Wt=63&Tt[$t++],(224&de)==192?lt+=String.fromCharCode((31&de)<<6|Wt):(be=63&Tt[$t++],(de=(240&de)==224?(15&de)<<12|Wt<<6|be:(7&de)<<18|Wt<<12|be<<6|63&Tt[$t++])<65536?lt+=String.fromCharCode(de):(de-=65536,lt+=String.fromCharCode(55296|de>>10,56320|1023&de)))):lt+=String.fromCharCode(de)}return lt}function ht(Tt,$t){return Tt?ot(nt,Tt,$t):""}function dt(Tt){return 0<Tt%65536&&(Tt+=65536-Tt%65536),Tt}function At(Tt){Gt=Tt,x.HEAP8=st=new Int8Array(Tt),x.HEAP16=new Int16Array(Tt),x.HEAP32=Y=new Int32Array(Tt),x.HEAPU8=nt=new Uint8Array(Tt),x.HEAPU16=new Uint16Array(Tt),x.HEAPU32=new Uint32Array(Tt),x.HEAPF32=new Float32Array(Tt),x.HEAPF64=new Float64Array(Tt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");var Et=x.TOTAL_MEMORY||16777216;function Dt(Tt){for(;0<Tt.length;){var $t,at=Tt.shift();typeof at=="function"?at():typeof($t=at.ea)=="number"?at.da===void 0?x.dynCall_v($t):x.dynCall_vi($t,at.da):$t(at.da===void 0?null:at.da)}}(It=x.wasmMemory||new function(){return{buffer:new ArrayBuffer(Et/65536*65536),grow:function(Tt){return hr(Tt)}}})&&(Gt=It.buffer),Gt.byteLength,At(Gt),Y[2216]=5251936;var oe,kt=[],se=[],Kt=[],Xt=[],_e=(Math.imul&&Math.imul(4294967295,5)===-5||(Math.imul=function(Tt,$t){var at=65535&Tt,lt=65535&$t;return at*lt+((Tt>>>16)*lt+at*($t>>>16)<<16)|0}),Math.fround||(oe=new Float32Array(1),Math.fround=function(Tt){return oe[0]=Tt,oe[0]}),Math.clz32||(Math.clz32=function(Tt){var $t=32,at=Tt>>16;return at&&($t-=16,Tt=at),(at=Tt>>8)&&($t-=8,Tt=at),(at=Tt>>4)&&($t-=4,Tt=at),(at=Tt>>2)&&($t-=2,Tt=at),Tt>>1?$t-2:$t-Tt}),Math.trunc||(Math.trunc=function(Tt){return Tt<0?Math.ceil(Tt):Math.floor(Tt)}),0),$e=null;function Jt(Tt){throw x.onAbort&&x.onAbort(Tt),_t(Tt),et(Tt),xt=!0,"abort("+Tt+"). Build with -s ASSERTIONS=1 for more info."}x.preloadedImages={},x.preloadedAudios={};var De="data:application/octet-stream;base64,";function xe(Tt){return String.prototype.startsWith?Tt.startsWith(De):Tt.indexOf(De)===0}var ae="_em_module.wasm";function Lr(){try{if(Rt)return new Uint8Array(Rt);var Tt=Wr(ae);if(Tt)return Tt;if(X)return X(ae);throw"both async and sync fetching of the wasm failed"}catch($t){Jt($t)}}xe(ae)||(Q=ae,ae=x.locateFile?x.locateFile(Q,Ar):Ar+Q),se.push({ea:function(){Hr()}});var vr=[null,[],[]];function Fi(Tt){for(var $t=[],at=0;at<Tt.length;at++){var lt=Tt[at];255<lt&&(lt&=255),$t.push(String.fromCharCode(lt))}return $t.join("")}var sr=typeof atob=="function"?atob:function(Tt){var $t="",at=0;Tt=Tt.replace(/[^A-Za-z0-9\+\/=]/g,"");do var be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(Tt.charAt(at++)),be=be<<2|de>>4,de=(15&de)<<4|lt>>2,Yt=(3&lt)<<6|Wt;while($t+=String.fromCharCode(be),lt!==64&&($t+=String.fromCharCode(de)),Wt!==64&&($t+=String.fromCharCode(Yt)),at<Tt.length);return $t};function Wr(Tt){if(xe(Tt)){if(Tt=Tt.slice(De.length),typeof it=="boolean"&&it){try{var $t=Buffer.from(Tt,"base64")}catch{$t=new Buffer(Tt,"base64")}var at=new Uint8Array($t.buffer,$t.byteOffset,$t.byteLength)}else try{for(var lt=sr(Tt),Wt=new Uint8Array(lt.length),$t=0;$t<lt.length;++$t)Wt[$t]=lt.charCodeAt($t);at=Wt}catch{throw Error("Converting base64 string to bytes failed.")}return at}}var fr,Pt={a:function(Tt,$t,at){nt.set(nt.subarray($t,$t+at),Tt)},b:function(Tt){if(2147418112<Tt)return!1;for(var $t=Math.max(st.length,16777216);$t<Tt;)$t=$t<=536870912?dt(2*$t):Math.min(dt((3*$t+2147483648)/4),2147418112);r:{try{It.grow($t-Gt.byteLength+65535>>16),At(It.buffer);var at=1;break r}catch{}at=void 0}return!!at},c:function(Tt,$t,at,lt){try{for(var Wt=0,be=0;be<at;be++){for(var de=Y[$t+8*be>>2],Yt=Y[$t+(8*be+4)>>2],ze=0;ze<Yt;ze++){var Ye=nt[de+ze],Qt=vr[Tt];Ye===0||Ye===10?((Tt===1?_t:et)(ot(Qt,0)),Qt.length=0):Qt.push(Ye)}Wt+=Yt}return Y[lt>>2]=Wt,0}catch(zt){return typeof FS<"u"&&zt instanceof FS.fa||Jt(zt),zt.ga}},memory:It,table:pt},Ar=function(){function Tt(Wt){x.asm=Wt.exports,_e--,x.monitorRunDependencies&&x.monitorRunDependencies(_e),_e==0&&$e&&(Wt=$e,$e=null,Wt())}function $t(Wt){Tt(Wt.instance)}function at(Wt){(Rt||!J&&!Z||typeof fetch!="function"?new Promise(function(be){be(Lr())}):fetch(ae,{credentials:"same-origin"}).then(function(be){if(be.ok)return be.arrayBuffer();throw"failed to load wasm binary file at '"+ae+"'"}).catch(Lr)).then(function(){return{then:function(be){be({instance:new ft})}}}).then(Wt,function(be){et("failed to asynchronously prepare wasm: "+be),Jt(be)})}var lt={env:Pt,wasi_unstable:Pt};if(_e++,x.monitorRunDependencies&&x.monitorRunDependencies(_e),x.instantiateWasm)try{return x.instantiateWasm(lt,Tt)}catch(Wt){return et("Module.instantiateWasm callback failed with error: "+Wt),!1}return Rt||typeof wt.instantiateStreaming!="function"||xe(ae)||typeof fetch!="function"?at($t):fetch(ae,{credentials:"same-origin"}).then(function(Wt){return wt.instantiateStreaming(Wt,lt).then($t,function(be){et("wasm streaming compile failed: "+be),et("falling back to ArrayBuffer instantiation"),at($t)})}),{}}(),Hr=(x.asm=Ar,x.___wasm_call_ctors=function(){return x.asm.d.apply(null,arguments)}),Xe=(x._csmGetLogFunction=function(){return x.asm.e.apply(null,arguments)},x._csmGetVersion=function(){return x.asm.f.apply(null,arguments)},x._csmGetLatestMocVersion=function(){return x.asm.g.apply(null,arguments)},x._csmGetMocVersion=function(){return x.asm.h.apply(null,arguments)},x._csmHasMocConsistency=function(){return x.asm.i.apply(null,arguments)},x._csmSetLogFunction=function(){return x.asm.j.apply(null,arguments)},x._csmReviveMocInPlace=function(){return x.asm.k.apply(null,arguments)},x._csmReadCanvasInfo=function(){return x.asm.l.apply(null,arguments)},x._csmGetSizeofModel=function(){return x.asm.m.apply(null,arguments)},x._csmInitializeModelInPlace=function(){return x.asm.n.apply(null,arguments)},x._csmUpdateModel=function(){return x.asm.o.apply(null,arguments)},x._csmGetParameterCount=function(){return x.asm.p.apply(null,arguments)},x._csmGetParameterIds=function(){return x.asm.q.apply(null,arguments)},x._csmGetParameterTypes=function(){return x.asm.r.apply(null,arguments)},x._csmGetParameterMinimumValues=function(){return x.asm.s.apply(null,arguments)},x._csmGetParameterMaximumValues=function(){return x.asm.t.apply(null,arguments)},x._csmGetParameterDefaultValues=function(){return x.asm.u.apply(null,arguments)},x._csmGetParameterValues=function(){return x.asm.v.apply(null,arguments)},x._csmGetPartCount=function(){return x.asm.w.apply(null,arguments)},x._csmGetPartIds=function(){return x.asm.x.apply(null,arguments)},x._csmGetPartOpacities=function(){return x.asm.y.apply(null,arguments)},x._csmGetPartParentPartIndices=function(){return x.asm.z.apply(null,arguments)},x._csmGetDrawableCount=function(){return x.asm.A.apply(null,arguments)},x._csmGetDrawableIds=function(){return x.asm.B.apply(null,arguments)},x._csmGetDrawableConstantFlags=function(){return x.asm.C.apply(null,arguments)},x._csmGetDrawableDynamicFlags=function(){return x.asm.D.apply(null,arguments)},x._csmGetDrawableTextureIndices=function(){return x.asm.E.apply(null,arguments)},x._csmGetDrawableDrawOrders=function(){return x.asm.F.apply(null,arguments)},x._csmGetDrawableRenderOrders=function(){return x.asm.G.apply(null,arguments)},x._csmGetDrawableOpacities=function(){return x.asm.H.apply(null,arguments)},x._csmGetDrawableMaskCounts=function(){return x.asm.I.apply(null,arguments)},x._csmGetDrawableMasks=function(){return x.asm.J.apply(null,arguments)},x._csmGetDrawableVertexCounts=function(){return x.asm.K.apply(null,arguments)},x._csmGetDrawableVertexPositions=function(){return x.asm.L.apply(null,arguments)},x._csmGetDrawableVertexUvs=function(){return x.asm.M.apply(null,arguments)},x._csmGetDrawableIndexCounts=function(){return x.asm.N.apply(null,arguments)},x._csmGetDrawableIndices=function(){return x.asm.O.apply(null,arguments)},x._csmGetDrawableMultiplyColors=function(){return x.asm.P.apply(null,arguments)},x._csmGetDrawableScreenColors=function(){return x.asm.Q.apply(null,arguments)},x._csmGetDrawableParentPartIndices=function(){return x.asm.R.apply(null,arguments)},x._csmResetDrawableDynamicFlags=function(){return x.asm.S.apply(null,arguments)},x._csmGetParameterKeyCounts=function(){return x.asm.T.apply(null,arguments)},x._csmGetParameterKeyValues=function(){return x.asm.U.apply(null,arguments)},x._csmMallocMoc=function(){return x.asm.V.apply(null,arguments)},x._csmMallocModelAndInitialize=function(){return x.asm.W.apply(null,arguments)},x._csmMalloc=function(){return x.asm.X.apply(null,arguments)},x._csmFree=function(){return x.asm.Y.apply(null,arguments)},x._csmInitializeAmountOfMemory=function(){return x.asm.Z.apply(null,arguments)},x.stackSave=function(){return x.asm._.apply(null,arguments)}),Li=x.stackAlloc=function(){return x.asm.$.apply(null,arguments)},Rs=x.stackRestore=function(){return x.asm.aa.apply(null,arguments)},hr=x.__growWasmMemory=function(){return x.asm.ba.apply(null,arguments)};function Qr(){function Tt(){if(!fr&&(fr=!0,!xt)){if(Dt(se),Dt(Kt),x.onRuntimeInitialized&&x.onRuntimeInitialized(),x.postRun)for(typeof x.postRun=="function"&&(x.postRun=[x.postRun]);x.postRun.length;){var $t=x.postRun.shift();Xt.unshift($t)}Dt(Xt)}}if(!(0<_e)){if(x.preRun)for(typeof x.preRun=="function"&&(x.preRun=[x.preRun]);x.preRun.length;)(function(){var $t=x.preRun.shift();kt.unshift($t)})();Dt(kt),0<_e||(x.setStatus?(x.setStatus("Running..."),setTimeout(function(){setTimeout(function(){x.setStatus("")},1),Tt()},1)):Tt())}}if(x.dynCall_vi=function(){return x.asm.ca.apply(null,arguments)},x.asm=Ar,x.ccall=function(Tt,$t,at,lt){var Wt={string:function(Ye){var Qt=0;if(Ye!=null&&Ye!==0){var zt=1+(Ye.length<<2),l=Qt=Li(zt),w=nt;if(0<zt){for(var zt=l+zt-1,$=0;$<Ye.length;++$){var L=Ye.charCodeAt($);if((L=55296<=L&&L<=57343?65536+((1023&L)<<10)|1023&Ye.charCodeAt(++$):L)<=127){if(zt<=l)break;w[l++]=L}else{if(L<=2047){if(zt<=l+1)break;w[l++]=192|L>>6}else{if(L<=65535){if(zt<=l+2)break;w[l++]=224|L>>12}else{if(zt<=l+3)break;w[l++]=240|L>>18,w[l++]=128|L>>12&63}w[l++]=128|L>>6&63}w[l++]=128|63&L}}w[l]=0}}return Qt},array:function(Ye){var Qt=Li(Ye.length);return st.set(Ye,Qt),Qt}},be=function(Ye){var Qt=x["_"+Ye];return Ct(Qt,"Cannot call unknown function "+Ye+", make sure it is exported"),Qt}(Tt),de=[];if(Tt=0,lt)for(var Yt=0;Yt<lt.length;Yt++){var ze=Wt[at[Yt]];ze?(Tt===0&&(Tt=Xe()),de[Yt]=ze(lt[Yt])):de[Yt]=lt[Yt]}return at=function(Ye){return $t==="string"?ht(Ye):$t==="boolean"?!!Ye:Ye}(at=be.apply(null,de)),Tt!==0&&Rs(Tt),at},x.UTF8ToString=ht,x.addFunction=function(Tt,$t){var at=pt.length;try{pt.grow(1)}catch(lt){throw!lt instanceof RangeError?lt:"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{pt.set(at,Tt)}catch(lt){if(!lt instanceof TypeError)throw lt;Ct($t!==void 0,"Missing signature argument to addFunction"),pt.set(at,Tt)}return at},x.then=function(Tt){var $t;return fr?Tt(x):($t=x.onRuntimeInitialized,x.onRuntimeInitialized=function(){$t&&$t(),Tt(x)}),x},$e=function Tt(){fr||Qr(),fr||($e=Tt)},x.run=Qr,x.preInit)for(typeof x.preInit=="function"&&(x.preInit=[x.preInit]);0<x.preInit.length;)x.preInit.pop()();return Qr(),C}),T=(typeof qr=="object"&&typeof module=="object"?module.exports=A:typeof define=="function"&&define.amd?define([],function(){return A}):typeof qr=="object"&&(qr._em_module=A),A())})(Ds=Ds||{}),window.Live2DCubismCore=Ds;var ys=(s=>(s[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s))(ys||{}),Ha=(s=>(s[s.UNKNOWN=0]="UNKNOWN",s[s.WEBGL=1]="WEBGL",s[s.CANVAS=2]="CANVAS",s))(Ha||{}),Lo=(s=>(s[s.COLOR=16384]="COLOR",s[s.DEPTH=256]="DEPTH",s[s.STENCIL=1024]="STENCIL",s))(Lo||{}),Re=(s=>(s[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",s))(Re||{}),Ai=(s=>(s[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",s))(Ai||{}),qt=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(qt||{}),Fs=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(Fs||{}),Pe=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(Pe||{}),le=(s=>(s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s))(le||{}),Gi=(s=>(s[s.NEAREST=0]="NEAREST",s[s.LINEAR=1]="LINEAR",s))(Gi||{}),Vi=(s=>(s[s.CLAMP=33071]="CLAMP",s[s.REPEAT=10497]="REPEAT",s[s.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",s))(Vi||{}),wi=(s=>(s[s.OFF=0]="OFF",s[s.POW2=1]="POW2",s[s.ON=2]="ON",s[s.ON_MANUAL=3]="ON_MANUAL",s))(wi||{}),Vr=(s=>(s[s.NPM=0]="NPM",s[s.UNPACK=1]="UNPACK",s[s.PMA=2]="PMA",s[s.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",s[s.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",s[s.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",s))(Vr||{}),Ti=(s=>(s[s.NO=0]="NO",s[s.YES=1]="YES",s[s.AUTO=2]="AUTO",s[s.BLEND=0]="BLEND",s[s.CLEAR=1]="CLEAR",s[s.BLIT=2]="BLIT",s))(Ti||{}),Bo=(s=>(s[s.AUTO=0]="AUTO",s[s.MANUAL=1]="MANUAL",s))(Bo||{}),ri=(s=>(s.LOW="lowp",s.MEDIUM="mediump",s.HIGH="highp",s))(ri||{}),xr=(s=>(s[s.NONE=0]="NONE",s[s.SCISSOR=1]="SCISSOR",s[s.STENCIL=2]="STENCIL",s[s.SPRITE=3]="SPRITE",s[s.COLOR=4]="COLOR",s))(xr||{}),Du=(s=>(s[s.RED=1]="RED",s[s.GREEN=2]="GREEN",s[s.BLUE=4]="BLUE",s[s.ALPHA=8]="ALPHA",s))(Du||{}),yr=(s=>(s[s.NONE=0]="NONE",s[s.LOW=2]="LOW",s[s.MEDIUM=4]="MEDIUM",s[s.HIGH=8]="HIGH",s))(yr||{}),Ei=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(Ei||{});const Fu={createCanvas:(s,t)=>{const r=document.createElement("canvas");return r.width=s,r.height=t,r},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")},ue={ADAPTER:Fu,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Ya=/iPhone/i,Lu=/iPod/i,Bu=/iPad/i,ku=/\biOS-universal(?:.+)Mac\b/i,ja=/\bAndroid(?:.+)Mobile\b/i,Ou=/Android/i,Ks=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ko=/Silk/i,ss=/Windows Phone/i,Nu=/\bWindows(?:.+)ARM\b/i,Uu=/BlackBerry/i,Gu=/BB10/i,Vu=/Opera Mini/i,zu=/\b(CriOS|Chrome)(?:.+)Mobile/i,Xu=/Mobile(?:.+)Firefox\b/i,Wu=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function v2(s){return function(t){return t.test(s)}}function Hu(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var r=t.userAgent,i=r.split("[FBAN");typeof i[1]<"u"&&(r=i[0]),i=r.split("Twitter"),typeof i[1]<"u"&&(r=i[0]);var n=v2(r),o={apple:{phone:n(Ya)&&!n(ss),ipod:n(Lu),tablet:!n(Ya)&&(n(Bu)||Wu(t))&&!n(ss),universal:n(ku),device:(n(Ya)||n(Lu)||n(Bu)||n(ku)||Wu(t))&&!n(ss)},amazon:{phone:n(Ks),tablet:!n(Ks)&&n(ko),device:n(Ks)||n(ko)},android:{phone:!n(ss)&&n(Ks)||!n(ss)&&n(ja),tablet:!n(ss)&&!n(Ks)&&!n(ja)&&(n(ko)||n(Ou)),device:!n(ss)&&(n(Ks)||n(ko)||n(ja)||n(Ou))||n(/\bokhttp\b/i)},windows:{phone:n(ss),tablet:n(Nu),device:n(ss)||n(Nu)},other:{blackberry:n(Uu),blackberry10:n(Gu),opera:n(Vu),firefox:n(Xu),chrome:n(zu),device:n(Uu)||n(Gu)||n(Vu)||n(Xu)||n(zu)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}const x2=Hu.default??Hu,Ci=x2(globalThis.navigator);ue.RETINA_PREFIX=/@([0-9\.]+)x/,ue.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var qa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yu(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function b2(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var r=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var n=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return s[i]}})}),r}var Za={exports:{}},ju;function A2(){return ju||(ju=1,function(s){var t=Object.prototype.hasOwnProperty,r="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function n(A,T,C){this.fn=A,this.context=T,this.once=C||!1}function o(A,T,C,x,M){if(typeof C!="function")throw new TypeError("The listener must be a function");var D=new n(C,x||A,M),k=r?r+T:T;return A._events[k]?A._events[k].fn?A._events[k]=[A._events[k],D]:A._events[k].push(D):(A._events[k]=D,A._eventsCount++),A}function h(A,T){--A._eventsCount===0?A._events=new i:delete A._events[T]}function f(){this._events=new i,this._eventsCount=0}f.prototype.eventNames=function(){var T=[],C,x;if(this._eventsCount===0)return T;for(x in C=this._events)t.call(C,x)&&T.push(r?x.slice(1):x);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(C)):T},f.prototype.listeners=function(T){var C=r?r+T:T,x=this._events[C];if(!x)return[];if(x.fn)return[x.fn];for(var M=0,D=x.length,k=new Array(D);M<D;M++)k[M]=x[M].fn;return k},f.prototype.listenerCount=function(T){var C=r?r+T:T,x=this._events[C];return x?x.fn?1:x.length:0},f.prototype.emit=function(T,C,x,M,D,k){var U=r?r+T:T;if(!this._events[U])return!1;var G=this._events[U],X=arguments.length,J,Z;if(G.fn){switch(G.once&&this.removeListener(T,G.fn,void 0,!0),X){case 1:return G.fn.call(G.context),!0;case 2:return G.fn.call(G.context,C),!0;case 3:return G.fn.call(G.context,C,x),!0;case 4:return G.fn.call(G.context,C,x,M),!0;case 5:return G.fn.call(G.context,C,x,M,D),!0;case 6:return G.fn.call(G.context,C,x,M,D,k),!0}for(Z=1,J=new Array(X-1);Z<X;Z++)J[Z-1]=arguments[Z];G.fn.apply(G.context,J)}else{var it=G.length,Q;for(Z=0;Z<it;Z++)switch(G[Z].once&&this.removeListener(T,G[Z].fn,void 0,!0),X){case 1:G[Z].fn.call(G[Z].context);break;case 2:G[Z].fn.call(G[Z].context,C);break;case 3:G[Z].fn.call(G[Z].context,C,x);break;case 4:G[Z].fn.call(G[Z].context,C,x,M);break;default:if(!J)for(Q=1,J=new Array(X-1);Q<X;Q++)J[Q-1]=arguments[Q];G[Z].fn.apply(G[Z].context,J)}}return!0},f.prototype.on=function(T,C,x){return o(this,T,C,x,!1)},f.prototype.once=function(T,C,x){return o(this,T,C,x,!0)},f.prototype.removeListener=function(T,C,x,M){var D=r?r+T:T;if(!this._events[D])return this;if(!C)return h(this,D),this;var k=this._events[D];if(k.fn)k.fn===C&&(!M||k.once)&&(!x||k.context===x)&&h(this,D);else{for(var U=0,G=[],X=k.length;U<X;U++)(k[U].fn!==C||M&&!k[U].once||x&&k[U].context!==x)&&G.push(k[U]);G.length?this._events[D]=G.length===1?G[0]:G:h(this,D)}return this},f.prototype.removeAllListeners=function(T){var C;return T?(C=r?r+T:T,this._events[C]&&h(this,C)):(this._events=new i,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=r,f.EventEmitter=f,s.exports=f}(Za)),Za.exports}var w2=A2();const ns=Yu(w2);var Oo={exports:{}},qu;function T2(){if(qu)return Oo.exports;qu=1,Oo.exports=s,Oo.exports.default=s;function s(st,nt,Y){Y=Y||2;var gt=nt&&nt.length,ot=gt?nt[0]*Y:st.length,ht=t(st,0,ot,Y,!0),dt=[];if(!ht||ht.next===ht.prev)return dt;var At,Et,Dt,oe,kt,se,Kt;if(gt&&(ht=A(st,nt,ht,Y)),st.length>80*Y){At=Dt=st[0],Et=oe=st[1];for(var Xt=Y;Xt<ot;Xt+=Y)kt=st[Xt],se=st[Xt+1],kt<At&&(At=kt),se<Et&&(Et=se),kt>Dt&&(Dt=kt),se>oe&&(oe=se);Kt=Math.max(Dt-At,oe-Et),Kt=Kt!==0?32767/Kt:0}return i(ht,dt,Y,At,Et,Kt,0),dt}function t(st,nt,Y,gt,ot){var ht,dt;if(ot===Gt(st,nt,Y,gt)>0)for(ht=nt;ht<Y;ht+=gt)dt=pt(ht,st[ht],st[ht+1],dt);else for(ht=Y-gt;ht>=nt;ht-=gt)dt=pt(ht,st[ht],st[ht+1],dt);return dt&&it(dt,dt.next)&&(xt(dt),dt=dt.next),dt}function r(st,nt){if(!st)return st;nt||(nt=st);var Y=st,gt;do if(gt=!1,!Y.steiner&&(it(Y,Y.next)||Z(Y.prev,Y,Y.next)===0)){if(xt(Y),Y=nt=Y.prev,Y===Y.next)break;gt=!0}else Y=Y.next;while(gt||Y!==nt);return nt}function i(st,nt,Y,gt,ot,ht,dt){if(st){!dt&&ht&&D(st,gt,ot,ht);for(var At=st,Et,Dt;st.prev!==st.next;){if(Et=st.prev,Dt=st.next,ht?o(st,gt,ot,ht):n(st)){nt.push(Et.i/Y|0),nt.push(st.i/Y|0),nt.push(Dt.i/Y|0),xt(st),st=Dt.next,At=Dt.next;continue}if(st=Dt,st===At){dt?dt===1?(st=h(r(st),nt,Y),i(st,nt,Y,gt,ot,ht,2)):dt===2&&f(st,nt,Y,gt,ot,ht):i(r(st),nt,Y,gt,ot,ht,1);break}}}}function n(st){var nt=st.prev,Y=st,gt=st.next;if(Z(nt,Y,gt)>=0)return!1;for(var ot=nt.x,ht=Y.x,dt=gt.x,At=nt.y,Et=Y.y,Dt=gt.y,oe=ot<ht?ot<dt?ot:dt:ht<dt?ht:dt,kt=At<Et?At<Dt?At:Dt:Et<Dt?Et:Dt,se=ot>ht?ot>dt?ot:dt:ht>dt?ht:dt,Kt=At>Et?At>Dt?At:Dt:Et>Dt?Et:Dt,Xt=gt.next;Xt!==nt;){if(Xt.x>=oe&&Xt.x<=se&&Xt.y>=kt&&Xt.y<=Kt&&X(ot,At,ht,Et,dt,Dt,Xt.x,Xt.y)&&Z(Xt.prev,Xt,Xt.next)>=0)return!1;Xt=Xt.next}return!0}function o(st,nt,Y,gt){var ot=st.prev,ht=st,dt=st.next;if(Z(ot,ht,dt)>=0)return!1;for(var At=ot.x,Et=ht.x,Dt=dt.x,oe=ot.y,kt=ht.y,se=dt.y,Kt=At<Et?At<Dt?At:Dt:Et<Dt?Et:Dt,Xt=oe<kt?oe<se?oe:se:kt<se?kt:se,_e=At>Et?At>Dt?At:Dt:Et>Dt?Et:Dt,$e=oe>kt?oe>se?oe:se:kt>se?kt:se,Jt=U(Kt,Xt,nt,Y,gt),De=U(_e,$e,nt,Y,gt),xe=st.prevZ,ae=st.nextZ;xe&&xe.z>=Jt&&ae&&ae.z<=De;){if(xe.x>=Kt&&xe.x<=_e&&xe.y>=Xt&&xe.y<=$e&&xe!==ot&&xe!==dt&&X(At,oe,Et,kt,Dt,se,xe.x,xe.y)&&Z(xe.prev,xe,xe.next)>=0||(xe=xe.prevZ,ae.x>=Kt&&ae.x<=_e&&ae.y>=Xt&&ae.y<=$e&&ae!==ot&&ae!==dt&&X(At,oe,Et,kt,Dt,se,ae.x,ae.y)&&Z(ae.prev,ae,ae.next)>=0))return!1;ae=ae.nextZ}for(;xe&&xe.z>=Jt;){if(xe.x>=Kt&&xe.x<=_e&&xe.y>=Xt&&xe.y<=$e&&xe!==ot&&xe!==dt&&X(At,oe,Et,kt,Dt,se,xe.x,xe.y)&&Z(xe.prev,xe,xe.next)>=0)return!1;xe=xe.prevZ}for(;ae&&ae.z<=De;){if(ae.x>=Kt&&ae.x<=_e&&ae.y>=Xt&&ae.y<=$e&&ae!==ot&&ae!==dt&&X(At,oe,Et,kt,Dt,se,ae.x,ae.y)&&Z(ae.prev,ae,ae.next)>=0)return!1;ae=ae.nextZ}return!0}function h(st,nt,Y){var gt=st;do{var ot=gt.prev,ht=gt.next.next;!it(ot,ht)&&Q(ot,gt,gt.next,ht)&&wt(ot,ht)&&wt(ht,ot)&&(nt.push(ot.i/Y|0),nt.push(gt.i/Y|0),nt.push(ht.i/Y|0),xt(gt),xt(gt.next),gt=st=ht),gt=gt.next}while(gt!==st);return r(gt)}function f(st,nt,Y,gt,ot,ht){var dt=st;do{for(var At=dt.next.next;At!==dt.prev;){if(dt.i!==At.i&&J(dt,At)){var Et=It(dt,At);dt=r(dt,dt.next),Et=r(Et,Et.next),i(dt,nt,Y,gt,ot,ht,0),i(Et,nt,Y,gt,ot,ht,0);return}At=At.next}dt=dt.next}while(dt!==st)}function A(st,nt,Y,gt){var ot=[],ht,dt,At,Et,Dt;for(ht=0,dt=nt.length;ht<dt;ht++)At=nt[ht]*gt,Et=ht<dt-1?nt[ht+1]*gt:st.length,Dt=t(st,At,Et,gt,!1),Dt===Dt.next&&(Dt.steiner=!0),ot.push(G(Dt));for(ot.sort(T),ht=0;ht<ot.length;ht++)Y=C(ot[ht],Y);return Y}function T(st,nt){return st.x-nt.x}function C(st,nt){var Y=x(st,nt);if(!Y)return nt;var gt=It(Y,st);return r(gt,gt.next),r(Y,Y.next)}function x(st,nt){var Y=nt,gt=st.x,ot=st.y,ht=-1/0,dt;do{if(ot<=Y.y&&ot>=Y.next.y&&Y.next.y!==Y.y){var At=Y.x+(ot-Y.y)*(Y.next.x-Y.x)/(Y.next.y-Y.y);if(At<=gt&&At>ht&&(ht=At,dt=Y.x<Y.next.x?Y:Y.next,At===gt))return dt}Y=Y.next}while(Y!==nt);if(!dt)return null;var Et=dt,Dt=dt.x,oe=dt.y,kt=1/0,se;Y=dt;do gt>=Y.x&&Y.x>=Dt&&gt!==Y.x&&X(ot<oe?gt:ht,ot,Dt,oe,ot<oe?ht:gt,ot,Y.x,Y.y)&&(se=Math.abs(ot-Y.y)/(gt-Y.x),wt(Y,st)&&(se<kt||se===kt&&(Y.x>dt.x||Y.x===dt.x&&M(dt,Y)))&&(dt=Y,kt=se)),Y=Y.next;while(Y!==Et);return dt}function M(st,nt){return Z(st.prev,st,nt.prev)<0&&Z(nt.next,st,st.next)<0}function D(st,nt,Y,gt){var ot=st;do ot.z===0&&(ot.z=U(ot.x,ot.y,nt,Y,gt)),ot.prevZ=ot.prev,ot.nextZ=ot.next,ot=ot.next;while(ot!==st);ot.prevZ.nextZ=null,ot.prevZ=null,k(ot)}function k(st){var nt,Y,gt,ot,ht,dt,At,Et,Dt=1;do{for(Y=st,st=null,ht=null,dt=0;Y;){for(dt++,gt=Y,At=0,nt=0;nt<Dt&&(At++,gt=gt.nextZ,!!gt);nt++);for(Et=Dt;At>0||Et>0&&gt;)At!==0&&(Et===0||!gt||Y.z<=gt.z)?(ot=Y,Y=Y.nextZ,At--):(ot=gt,gt=gt.nextZ,Et--),ht?ht.nextZ=ot:st=ot,ot.prevZ=ht,ht=ot;Y=gt}ht.nextZ=null,Dt*=2}while(dt>1);return st}function U(st,nt,Y,gt,ot){return st=(st-Y)*ot|0,nt=(nt-gt)*ot|0,st=(st|st<<8)&16711935,st=(st|st<<4)&252645135,st=(st|st<<2)&858993459,st=(st|st<<1)&1431655765,nt=(nt|nt<<8)&16711935,nt=(nt|nt<<4)&252645135,nt=(nt|nt<<2)&858993459,nt=(nt|nt<<1)&1431655765,st|nt<<1}function G(st){var nt=st,Y=st;do(nt.x<Y.x||nt.x===Y.x&&nt.y<Y.y)&&(Y=nt),nt=nt.next;while(nt!==st);return Y}function X(st,nt,Y,gt,ot,ht,dt,At){return(ot-dt)*(nt-At)>=(st-dt)*(ht-At)&&(st-dt)*(gt-At)>=(Y-dt)*(nt-At)&&(Y-dt)*(ht-At)>=(ot-dt)*(gt-At)}function J(st,nt){return st.next.i!==nt.i&&st.prev.i!==nt.i&&!ft(st,nt)&&(wt(st,nt)&&wt(nt,st)&&Rt(st,nt)&&(Z(st.prev,st,nt.prev)||Z(st,nt.prev,nt))||it(st,nt)&&Z(st.prev,st,st.next)>0&&Z(nt.prev,nt,nt.next)>0)}function Z(st,nt,Y){return(nt.y-st.y)*(Y.x-nt.x)-(nt.x-st.x)*(Y.y-nt.y)}function it(st,nt){return st.x===nt.x&&st.y===nt.y}function Q(st,nt,Y,gt){var ot=et(Z(st,nt,Y)),ht=et(Z(st,nt,gt)),dt=et(Z(Y,gt,st)),At=et(Z(Y,gt,nt));return!!(ot!==ht&&dt!==At||ot===0&&_t(st,Y,nt)||ht===0&&_t(st,gt,nt)||dt===0&&_t(Y,st,gt)||At===0&&_t(Y,nt,gt))}function _t(st,nt,Y){return nt.x<=Math.max(st.x,Y.x)&&nt.x>=Math.min(st.x,Y.x)&&nt.y<=Math.max(st.y,Y.y)&&nt.y>=Math.min(st.y,Y.y)}function et(st){return st>0?1:st<0?-1:0}function ft(st,nt){var Y=st;do{if(Y.i!==st.i&&Y.next.i!==st.i&&Y.i!==nt.i&&Y.next.i!==nt.i&&Q(Y,Y.next,st,nt))return!0;Y=Y.next}while(Y!==st);return!1}function wt(st,nt){return Z(st.prev,st,st.next)<0?Z(st,nt,st.next)>=0&&Z(st,st.prev,nt)>=0:Z(st,nt,st.prev)<0||Z(st,st.next,nt)<0}function Rt(st,nt){var Y=st,gt=!1,ot=(st.x+nt.x)/2,ht=(st.y+nt.y)/2;do Y.y>ht!=Y.next.y>ht&&Y.next.y!==Y.y&&ot<(Y.next.x-Y.x)*(ht-Y.y)/(Y.next.y-Y.y)+Y.x&&(gt=!gt),Y=Y.next;while(Y!==st);return gt}function It(st,nt){var Y=new Ct(st.i,st.x,st.y),gt=new Ct(nt.i,nt.x,nt.y),ot=st.next,ht=nt.prev;return st.next=nt,nt.prev=st,Y.next=ot,ot.prev=Y,gt.next=Y,Y.prev=gt,ht.next=gt,gt.prev=ht,gt}function pt(st,nt,Y,gt){var ot=new Ct(st,nt,Y);return gt?(ot.next=gt.next,ot.prev=gt,gt.next.prev=ot,gt.next=ot):(ot.prev=ot,ot.next=ot),ot}function xt(st){st.next.prev=st.prev,st.prev.next=st.next,st.prevZ&&(st.prevZ.nextZ=st.nextZ),st.nextZ&&(st.nextZ.prevZ=st.prevZ)}function Ct(st,nt,Y){this.i=st,this.x=nt,this.y=Y,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}s.deviation=function(st,nt,Y,gt){var ot=nt&&nt.length,ht=ot?nt[0]*Y:st.length,dt=Math.abs(Gt(st,0,ht,Y));if(ot)for(var At=0,Et=nt.length;At<Et;At++){var Dt=nt[At]*Y,oe=At<Et-1?nt[At+1]*Y:st.length;dt-=Math.abs(Gt(st,Dt,oe,Y))}var kt=0;for(At=0;At<gt.length;At+=3){var se=gt[At]*Y,Kt=gt[At+1]*Y,Xt=gt[At+2]*Y;kt+=Math.abs((st[se]-st[Xt])*(st[Kt+1]-st[se+1])-(st[se]-st[Kt])*(st[Xt+1]-st[se+1]))}return dt===0&&kt===0?0:Math.abs((kt-dt)/dt)};function Gt(st,nt,Y,gt){for(var ot=0,ht=nt,dt=Y-gt;ht<Y;ht+=gt)ot+=(st[dt]-st[ht])*(st[ht+1]+st[dt+1]),dt=ht;return ot}return s.flatten=function(st){for(var nt=st[0][0].length,Y={vertices:[],holes:[],dimensions:nt},gt=0,ot=0;ot<st.length;ot++){for(var ht=0;ht<st[ot].length;ht++)for(var dt=0;dt<nt;dt++)Y.vertices.push(st[ot][ht][dt]);ot>0&&(gt+=st[ot-1].length,Y.holes.push(gt))}return Y},Oo.exports}var E2=T2();const Zu=Yu(E2);var Ls={},Sn={exports:{}};var C2=Sn.exports,Qu;function S2(){return Qu||(Qu=1,function(s,t){(function(r){var i=t&&!t.nodeType&&t,n=s&&!s.nodeType&&s,o=typeof qa=="object"&&qa;(o.global===o||o.window===o||o.self===o)&&(r=o);var h,f=2147483647,A=36,T=1,C=26,x=38,M=700,D=72,k=128,U="-",G=/^xn--/,X=/[^\x20-\x7E]/,J=/[\x2E\u3002\uFF0E\uFF61]/g,Z={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},it=A-T,Q=Math.floor,_t=String.fromCharCode,et;function ft(ot){throw new RangeError(Z[ot])}function wt(ot,ht){for(var dt=ot.length,At=[];dt--;)At[dt]=ht(ot[dt]);return At}function Rt(ot,ht){var dt=ot.split("@"),At="";dt.length>1&&(At=dt[0]+"@",ot=dt[1]),ot=ot.replace(J,".");var Et=ot.split("."),Dt=wt(Et,ht).join(".");return At+Dt}function It(ot){for(var ht=[],dt=0,At=ot.length,Et,Dt;dt<At;)Et=ot.charCodeAt(dt++),Et>=55296&&Et<=56319&&dt<At?(Dt=ot.charCodeAt(dt++),(Dt&64512)==56320?ht.push(((Et&1023)<<10)+(Dt&1023)+65536):(ht.push(Et),dt--)):ht.push(Et);return ht}function pt(ot){return wt(ot,function(ht){var dt="";return ht>65535&&(ht-=65536,dt+=_t(ht>>>10&1023|55296),ht=56320|ht&1023),dt+=_t(ht),dt}).join("")}function xt(ot){return ot-48<10?ot-22:ot-65<26?ot-65:ot-97<26?ot-97:A}function Ct(ot,ht){return ot+22+75*(ot<26)-((ht!=0)<<5)}function Gt(ot,ht,dt){var At=0;for(ot=dt?Q(ot/M):ot>>1,ot+=Q(ot/ht);ot>it*C>>1;At+=A)ot=Q(ot/it);return Q(At+(it+1)*ot/(ot+x))}function st(ot){var ht=[],dt=ot.length,At,Et=0,Dt=k,oe=D,kt,se,Kt,Xt,_e,$e,Jt,De,xe;for(kt=ot.lastIndexOf(U),kt<0&&(kt=0),se=0;se<kt;++se)ot.charCodeAt(se)>=128&&ft("not-basic"),ht.push(ot.charCodeAt(se));for(Kt=kt>0?kt+1:0;Kt<dt;){for(Xt=Et,_e=1,$e=A;Kt>=dt&&ft("invalid-input"),Jt=xt(ot.charCodeAt(Kt++)),(Jt>=A||Jt>Q((f-Et)/_e))&&ft("overflow"),Et+=Jt*_e,De=$e<=oe?T:$e>=oe+C?C:$e-oe,!(Jt<De);$e+=A)xe=A-De,_e>Q(f/xe)&&ft("overflow"),_e*=xe;At=ht.length+1,oe=Gt(Et-Xt,At,Xt==0),Q(Et/At)>f-Dt&&ft("overflow"),Dt+=Q(Et/At),Et%=At,ht.splice(Et++,0,Dt)}return pt(ht)}function nt(ot){var ht,dt,At,Et,Dt,oe,kt,se,Kt,Xt,_e,$e=[],Jt,De,xe,ae;for(ot=It(ot),Jt=ot.length,ht=k,dt=0,Dt=D,oe=0;oe<Jt;++oe)_e=ot[oe],_e<128&&$e.push(_t(_e));for(At=Et=$e.length,Et&&$e.push(U);At<Jt;){for(kt=f,oe=0;oe<Jt;++oe)_e=ot[oe],_e>=ht&&_e<kt&&(kt=_e);for(De=At+1,kt-ht>Q((f-dt)/De)&&ft("overflow"),dt+=(kt-ht)*De,ht=kt,oe=0;oe<Jt;++oe)if(_e=ot[oe],_e<ht&&++dt>f&&ft("overflow"),_e==ht){for(se=dt,Kt=A;Xt=Kt<=Dt?T:Kt>=Dt+C?C:Kt-Dt,!(se<Xt);Kt+=A)ae=se-Xt,xe=A-Xt,$e.push(_t(Ct(Xt+ae%xe,0))),se=Q(ae/xe);$e.push(_t(Ct(se,0))),Dt=Gt(dt,De,At==Et),dt=0,++At}++dt,++ht}return $e.join("")}function Y(ot){return Rt(ot,function(ht){return G.test(ht)?st(ht.slice(4).toLowerCase()):ht})}function gt(ot){return Rt(ot,function(ht){return X.test(ht)?"xn--"+nt(ht):ht})}if(h={version:"1.4.1",ucs2:{decode:It,encode:pt},decode:st,encode:nt,toASCII:gt,toUnicode:Y},i&&n)if(s.exports==i)n.exports=h;else for(et in h)h.hasOwnProperty(et)&&(i[et]=h[et]);else r.punycode=h})(C2)}(Sn,Sn.exports)),Sn.exports}var Qa,Ku;function P2(){return Ku||(Ku=1,Qa=Error),Qa}var Ka,Ju;function $2(){return Ju||(Ju=1,Ka=EvalError),Ka}var Ja,t0;function M2(){return t0||(t0=1,Ja=RangeError),Ja}var th,e0;function R2(){return e0||(e0=1,th=ReferenceError),th}var eh,r0;function i0(){return r0||(r0=1,eh=SyntaxError),eh}var rh,s0;function Pn(){return s0||(s0=1,rh=TypeError),rh}var ih,n0;function I2(){return n0||(n0=1,ih=URIError),ih}var sh,o0;function D2(){return o0||(o0=1,sh=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var n=42;t[r]=n;for(r in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var h=Object.getOwnPropertyDescriptor(t,r);if(h.value!==n||h.enumerable!==!0)return!1}return!0}),sh}var nh,a0;function F2(){if(a0)return nh;a0=1;var s=typeof Symbol<"u"&&Symbol,t=D2();return nh=function(){return typeof s!="function"||typeof Symbol!="function"||typeof s("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},nh}var oh,h0;function L2(){if(h0)return oh;h0=1;var s={__proto__:null,foo:{}},t=Object;return oh=function(){return{__proto__:s}.foo===s.foo&&!(s instanceof t)},oh}var ah,l0;function B2(){if(l0)return ah;l0=1;var s="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,i="[object Function]",n=function(A,T){for(var C=[],x=0;x<A.length;x+=1)C[x]=A[x];for(var M=0;M<T.length;M+=1)C[M+A.length]=T[M];return C},o=function(A,T){for(var C=[],x=T,M=0;x<A.length;x+=1,M+=1)C[M]=A[x];return C},h=function(f,A){for(var T="",C=0;C<f.length;C+=1)T+=f[C],C+1<f.length&&(T+=A);return T};return ah=function(A){var T=this;if(typeof T!="function"||t.apply(T)!==i)throw new TypeError(s+T);for(var C=o(arguments,1),x,M=function(){if(this instanceof x){var X=T.apply(this,n(C,arguments));return Object(X)===X?X:this}return T.apply(A,n(C,arguments))},D=r(0,T.length-C.length),k=[],U=0;U<D;U++)k[U]="$"+U;if(x=Function("binder","return function ("+h(k,",")+"){ return binder.apply(this,arguments); }")(M),T.prototype){var G=function(){};G.prototype=T.prototype,x.prototype=new G,G.prototype=null}return x},ah}var hh,u0;function lh(){if(u0)return hh;u0=1;var s=B2();return hh=Function.prototype.bind||s,hh}var uh,c0;function k2(){if(c0)return uh;c0=1;var s=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=lh();return uh=r.call(s,t),uh}var ch,f0;function Js(){if(f0)return ch;f0=1;var s,t=P2(),r=$2(),i=M2(),n=R2(),o=i0(),h=Pn(),f=I2(),A=Function,T=function(nt){try{return A('"use strict"; return ('+nt+").constructor;")()}catch{}},C=Object.getOwnPropertyDescriptor;if(C)try{C({},"")}catch{C=null}var x=function(){throw new h},M=C?function(){try{return arguments.callee,x}catch{try{return C(arguments,"callee").get}catch{return x}}}():x,D=F2()(),k=L2()(),U=Object.getPrototypeOf||(k?function(nt){return nt.__proto__}:null),G={},X=typeof Uint8Array>"u"||!U?s:U(Uint8Array),J={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?s:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?s:ArrayBuffer,"%ArrayIteratorPrototype%":D&&U?U([][Symbol.iterator]()):s,"%AsyncFromSyncIteratorPrototype%":s,"%AsyncFunction%":G,"%AsyncGenerator%":G,"%AsyncGeneratorFunction%":G,"%AsyncIteratorPrototype%":G,"%Atomics%":typeof Atomics>"u"?s:Atomics,"%BigInt%":typeof BigInt>"u"?s:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?s:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?s:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?s:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":r,"%Float32Array%":typeof Float32Array>"u"?s:Float32Array,"%Float64Array%":typeof Float64Array>"u"?s:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?s:FinalizationRegistry,"%Function%":A,"%GeneratorFunction%":G,"%Int8Array%":typeof Int8Array>"u"?s:Int8Array,"%Int16Array%":typeof Int16Array>"u"?s:Int16Array,"%Int32Array%":typeof Int32Array>"u"?s:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":D&&U?U(U([][Symbol.iterator]())):s,"%JSON%":typeof JSON=="object"?JSON:s,"%Map%":typeof Map>"u"?s:Map,"%MapIteratorPrototype%":typeof Map>"u"||!D||!U?s:U(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?s:Promise,"%Proxy%":typeof Proxy>"u"?s:Proxy,"%RangeError%":i,"%ReferenceError%":n,"%Reflect%":typeof Reflect>"u"?s:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?s:Set,"%SetIteratorPrototype%":typeof Set>"u"||!D||!U?s:U(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?s:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":D&&U?U(""[Symbol.iterator]()):s,"%Symbol%":D?Symbol:s,"%SyntaxError%":o,"%ThrowTypeError%":M,"%TypedArray%":X,"%TypeError%":h,"%Uint8Array%":typeof Uint8Array>"u"?s:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?s:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?s:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?s:Uint32Array,"%URIError%":f,"%WeakMap%":typeof WeakMap>"u"?s:WeakMap,"%WeakRef%":typeof WeakRef>"u"?s:WeakRef,"%WeakSet%":typeof WeakSet>"u"?s:WeakSet};if(U)try{null.error}catch(nt){var Z=U(U(nt));J["%Error.prototype%"]=Z}var it=function nt(Y){var gt;if(Y==="%AsyncFunction%")gt=T("async function () {}");else if(Y==="%GeneratorFunction%")gt=T("function* () {}");else if(Y==="%AsyncGeneratorFunction%")gt=T("async function* () {}");else if(Y==="%AsyncGenerator%"){var ot=nt("%AsyncGeneratorFunction%");ot&&(gt=ot.prototype)}else if(Y==="%AsyncIteratorPrototype%"){var ht=nt("%AsyncGenerator%");ht&&U&&(gt=U(ht.prototype))}return J[Y]=gt,gt},Q={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},_t=lh(),et=k2(),ft=_t.call(Function.call,Array.prototype.concat),wt=_t.call(Function.apply,Array.prototype.splice),Rt=_t.call(Function.call,String.prototype.replace),It=_t.call(Function.call,String.prototype.slice),pt=_t.call(Function.call,RegExp.prototype.exec),xt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ct=/\\(\\)?/g,Gt=function(Y){var gt=It(Y,0,1),ot=It(Y,-1);if(gt==="%"&&ot!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(ot==="%"&&gt!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var ht=[];return Rt(Y,xt,function(dt,At,Et,Dt){ht[ht.length]=Et?Rt(Dt,Ct,"$1"):At||dt}),ht},st=function(Y,gt){var ot=Y,ht;if(et(Q,ot)&&(ht=Q[ot],ot="%"+ht[0]+"%"),et(J,ot)){var dt=J[ot];if(dt===G&&(dt=it(ot)),typeof dt>"u"&&!gt)throw new h("intrinsic "+Y+" exists, but is not available. Please file an issue!");return{alias:ht,name:ot,value:dt}}throw new o("intrinsic "+Y+" does not exist!")};return ch=function(Y,gt){if(typeof Y!="string"||Y.length===0)throw new h("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof gt!="boolean")throw new h('"allowMissing" argument must be a boolean');if(pt(/^%?[^%]*%?$/,Y)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var ot=Gt(Y),ht=ot.length>0?ot[0]:"",dt=st("%"+ht+"%",gt),At=dt.name,Et=dt.value,Dt=!1,oe=dt.alias;oe&&(ht=oe[0],wt(ot,ft([0,1],oe)));for(var kt=1,se=!0;kt<ot.length;kt+=1){var Kt=ot[kt],Xt=It(Kt,0,1),_e=It(Kt,-1);if((Xt==='"'||Xt==="'"||Xt==="`"||_e==='"'||_e==="'"||_e==="`")&&Xt!==_e)throw new o("property names with quotes must have matching quotes");if((Kt==="constructor"||!se)&&(Dt=!0),ht+="."+Kt,At="%"+ht+"%",et(J,At))Et=J[At];else if(Et!=null){if(!(Kt in Et)){if(!gt)throw new h("base intrinsic for "+Y+" exists, but the property is not available.");return}if(C&&kt+1>=ot.length){var $e=C(Et,Kt);se=!!$e,se&&"get"in $e&&!("originalValue"in $e.get)?Et=$e.get:Et=Et[Kt]}else se=et(Et,Kt),Et=Et[Kt];se&&!Dt&&(J[At]=Et)}}return Et},ch}var fh={exports:{}},dh,d0;function ph(){if(d0)return dh;d0=1;var s=Js(),t=s("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return dh=t,dh}var _h,p0;function _0(){if(p0)return _h;p0=1;var s=Js(),t=s("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch{t=null}return _h=t,_h}var gh,g0;function O2(){if(g0)return gh;g0=1;var s=ph(),t=i0(),r=Pn(),i=_0();return gh=function(o,h,f){if(!o||typeof o!="object"&&typeof o!="function")throw new r("`obj` must be an object or a function`");if(typeof h!="string"&&typeof h!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var A=arguments.length>3?arguments[3]:null,T=arguments.length>4?arguments[4]:null,C=arguments.length>5?arguments[5]:null,x=arguments.length>6?arguments[6]:!1,M=!!i&&i(o,h);if(s)s(o,h,{configurable:C===null&&M?M.configurable:!C,enumerable:A===null&&M?M.enumerable:!A,value:f,writable:T===null&&M?M.writable:!T});else if(x||!A&&!T&&!C)o[h]=f;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},gh}var mh,m0;function N2(){if(m0)return mh;m0=1;var s=ph(),t=function(){return!!s};return t.hasArrayLengthDefineBug=function(){if(!s)return null;try{return s([],"length",{value:1}).length!==1}catch{return!0}},mh=t,mh}var yh,y0;function U2(){if(y0)return yh;y0=1;var s=Js(),t=O2(),r=N2()(),i=_0(),n=Pn(),o=s("%Math.floor%");return yh=function(f,A){if(typeof f!="function")throw new n("`fn` is not a function");if(typeof A!="number"||A<0||A>4294967295||o(A)!==A)throw new n("`length` must be a positive 32-bit integer");var T=arguments.length>2&&!!arguments[2],C=!0,x=!0;if("length"in f&&i){var M=i(f,"length");M&&!M.configurable&&(C=!1),M&&!M.writable&&(x=!1)}return(C||x||!T)&&(r?t(f,"length",A,!0,!0):t(f,"length",A)),f},yh}var v0;function G2(){return v0||(v0=1,function(s){var t=lh(),r=Js(),i=U2(),n=Pn(),o=r("%Function.prototype.apply%"),h=r("%Function.prototype.call%"),f=r("%Reflect.apply%",!0)||t.call(h,o),A=ph(),T=r("%Math.max%");s.exports=function(M){if(typeof M!="function")throw new n("a function is required");var D=f(t,h,arguments);return i(D,1+T(0,M.length-(arguments.length-1)),!0)};var C=function(){return f(t,o,arguments)};A?A(s.exports,"apply",{value:C}):s.exports.apply=C}(fh)),fh.exports}var vh,x0;function V2(){if(x0)return vh;x0=1;var s=Js(),t=G2(),r=t(s("String.prototype.indexOf"));return vh=function(n,o){var h=s(n,!!o);return typeof h=="function"&&r(n,".prototype.")>-1?t(h):h},vh}const z2=b2(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var xh,b0;function X2(){if(b0)return xh;b0=1;var s=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&s?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=s&&t&&typeof t.get=="function"?t.get:null,i=s&&Map.prototype.forEach,n=typeof Set=="function"&&Set.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,h=n&&o&&typeof o.get=="function"?o.get:null,f=n&&Set.prototype.forEach,A=typeof WeakMap=="function"&&WeakMap.prototype,T=A?WeakMap.prototype.has:null,C=typeof WeakSet=="function"&&WeakSet.prototype,x=C?WeakSet.prototype.has:null,M=typeof WeakRef=="function"&&WeakRef.prototype,D=M?WeakRef.prototype.deref:null,k=Boolean.prototype.valueOf,U=Object.prototype.toString,G=Function.prototype.toString,X=String.prototype.match,J=String.prototype.slice,Z=String.prototype.replace,it=String.prototype.toUpperCase,Q=String.prototype.toLowerCase,_t=RegExp.prototype.test,et=Array.prototype.concat,ft=Array.prototype.join,wt=Array.prototype.slice,Rt=Math.floor,It=typeof BigInt=="function"?BigInt.prototype.valueOf:null,pt=Object.getOwnPropertySymbols,xt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ct=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Gt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ct||!0)?Symbol.toStringTag:null,st=Object.prototype.propertyIsEnumerable,nt=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(at){return at.__proto__}:null);function Y(at,lt){if(at===1/0||at===-1/0||at!==at||at&&at>-1e3&&at<1e3||_t.call(/e/,lt))return lt;var Wt=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof at=="number"){var be=at<0?-Rt(-at):Rt(at);if(be!==at){var de=String(be),Yt=J.call(lt,de.length+1);return Z.call(de,Wt,"$&_")+"."+Z.call(Z.call(Yt,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Z.call(lt,Wt,"$&_")}var gt=z2,ot=gt.custom,ht=_e(ot)?ot:null;xh=function at(lt,Wt,be,de){var Yt=Wt||{};if(De(Yt,"quoteStyle")&&Yt.quoteStyle!=="single"&&Yt.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(De(Yt,"maxStringLength")&&(typeof Yt.maxStringLength=="number"?Yt.maxStringLength<0&&Yt.maxStringLength!==1/0:Yt.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var ze=De(Yt,"customInspect")?Yt.customInspect:!0;if(typeof ze!="boolean"&&ze!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(De(Yt,"indent")&&Yt.indent!==null&&Yt.indent!==" "&&!(parseInt(Yt.indent,10)===Yt.indent&&Yt.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(De(Yt,"numericSeparator")&&typeof Yt.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Ye=Yt.numericSeparator;if(typeof lt>"u")return"undefined";if(lt===null)return"null";if(typeof lt=="boolean")return lt?"true":"false";if(typeof lt=="string")return Ar(lt,Yt);if(typeof lt=="number"){if(lt===0)return 1/0/lt>0?"0":"-0";var Qt=String(lt);return Ye?Y(lt,Qt):Qt}if(typeof lt=="bigint"){var zt=String(lt)+"n";return Ye?Y(lt,zt):zt}var l=typeof Yt.depth>"u"?5:Yt.depth;if(typeof be>"u"&&(be=0),be>=l&&l>0&&typeof lt=="object")return Et(lt)?"[Array]":"[Object]";var w=Qr(Yt,be);if(typeof de>"u")de=[];else if(Lr(de,lt)>=0)return"[Circular]";function $(Lt,re,Zt){if(re&&(de=wt.call(de),de.push(re)),Zt){var K={depth:Yt.depth};return De(Yt,"quoteStyle")&&(K.quoteStyle=Yt.quoteStyle),at(Lt,K,be+1,de)}return at(Lt,Yt,be+1,de)}if(typeof lt=="function"&&!oe(lt)){var L=ae(lt),O=$t(lt,$);return"[Function"+(L?": "+L:" (anonymous)")+"]"+(O.length>0?" { "+ft.call(O,", ")+" }":"")}if(_e(lt)){var N=Ct?Z.call(String(lt),/^(Symbol\(.*\))_[^)]*$/,"$1"):xt.call(lt);return typeof lt=="object"&&!Ct?Xe(N):N}if(Pt(lt)){for(var e="<"+Q.call(String(lt.nodeName)),H=lt.attributes||[],W=0;W<H.length;W++)e+=" "+H[W].name+"="+dt(At(H[W].value),"double",Yt);return e+=">",lt.childNodes&&lt.childNodes.length&&(e+="..."),e+="</"+Q.call(String(lt.nodeName))+">",e}if(Et(lt)){if(lt.length===0)return"[]";var rt=$t(lt,$);return w&&!hr(rt)?"["+Tt(rt,w)+"]":"[ "+ft.call(rt,", ")+" ]"}if(kt(lt)){var I=$t(lt,$);return!("cause"in Error.prototype)&&"cause"in lt&&!st.call(lt,"cause")?"{ ["+String(lt)+"] "+ft.call(et.call("[cause]: "+$(lt.cause),I),", ")+" }":I.length===0?"["+String(lt)+"]":"{ ["+String(lt)+"] "+ft.call(I,", ")+" }"}if(typeof lt=="object"&&ze){if(ht&&typeof lt[ht]=="function"&&gt)return gt(lt,{depth:l-be});if(ze!=="symbol"&&typeof lt.inspect=="function")return lt.inspect()}if(vr(lt)){var ct=[];return i&&i.call(lt,function(Lt,re){ct.push($(re,lt,!0)+" => "+$(Lt,lt))}),Rs("Map",r.call(lt),ct,w)}if(Wr(lt)){var j=[];return f&&f.call(lt,function(Lt){j.push($(Lt,lt))}),Rs("Set",h.call(lt),j,w)}if(Fi(lt))return Li("WeakMap");if(fr(lt))return Li("WeakSet");if(sr(lt))return Li("WeakRef");if(Kt(lt))return Xe($(Number(lt)));if($e(lt))return Xe($(It.call(lt)));if(Xt(lt))return Xe(k.call(lt));if(se(lt))return Xe($(String(lt)));if(typeof window<"u"&&lt===window)return"{ [object Window] }";if(lt===qa)return"{ [object globalThis] }";if(!Dt(lt)&&!oe(lt)){var v=$t(lt,$),St=nt?nt(lt)===Object.prototype:lt instanceof Object||lt.constructor===Object,yt=lt instanceof Object?"":"null prototype",Mt=!St&&Gt&&Object(lt)===lt&&Gt in lt?J.call(xe(lt),8,-1):yt?"Object":"",Ft=St||typeof lt.constructor!="function"?"":lt.constructor.name?lt.constructor.name+" ":"",Nt=Ft+(Mt||yt?"["+ft.call(et.call([],Mt||[],yt||[]),": ")+"] ":"");return v.length===0?Nt+"{}":w?Nt+"{"+Tt(v,w)+"}":Nt+"{ "+ft.call(v,", ")+" }"}return String(lt)};function dt(at,lt,Wt){var be=(Wt.quoteStyle||lt)==="double"?'"':"'";return be+at+be}function At(at){return Z.call(String(at),/"/g,"&quot;")}function Et(at){return xe(at)==="[object Array]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Dt(at){return xe(at)==="[object Date]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function oe(at){return xe(at)==="[object RegExp]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function kt(at){return xe(at)==="[object Error]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function se(at){return xe(at)==="[object String]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Kt(at){return xe(at)==="[object Number]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function Xt(at){return xe(at)==="[object Boolean]"&&(!Gt||!(typeof at=="object"&&Gt in at))}function _e(at){if(Ct)return at&&typeof at=="object"&&at instanceof Symbol;if(typeof at=="symbol")return!0;if(!at||typeof at!="object"||!xt)return!1;try{return xt.call(at),!0}catch{}return!1}function $e(at){if(!at||typeof at!="object"||!It)return!1;try{return It.call(at),!0}catch{}return!1}var Jt=Object.prototype.hasOwnProperty||function(at){return at in this};function De(at,lt){return Jt.call(at,lt)}function xe(at){return U.call(at)}function ae(at){if(at.name)return at.name;var lt=X.call(G.call(at),/^function\s*([\w$]+)/);return lt?lt[1]:null}function Lr(at,lt){if(at.indexOf)return at.indexOf(lt);for(var Wt=0,be=at.length;Wt<be;Wt++)if(at[Wt]===lt)return Wt;return-1}function vr(at){if(!r||!at||typeof at!="object")return!1;try{r.call(at);try{h.call(at)}catch{return!0}return at instanceof Map}catch{}return!1}function Fi(at){if(!T||!at||typeof at!="object")return!1;try{T.call(at,T);try{x.call(at,x)}catch{return!0}return at instanceof WeakMap}catch{}return!1}function sr(at){if(!D||!at||typeof at!="object")return!1;try{return D.call(at),!0}catch{}return!1}function Wr(at){if(!h||!at||typeof at!="object")return!1;try{h.call(at);try{r.call(at)}catch{return!0}return at instanceof Set}catch{}return!1}function fr(at){if(!x||!at||typeof at!="object")return!1;try{x.call(at,x);try{T.call(at,T)}catch{return!0}return at instanceof WeakSet}catch{}return!1}function Pt(at){return!at||typeof at!="object"?!1:typeof HTMLElement<"u"&&at instanceof HTMLElement?!0:typeof at.nodeName=="string"&&typeof at.getAttribute=="function"}function Ar(at,lt){if(at.length>lt.maxStringLength){var Wt=at.length-lt.maxStringLength,be="... "+Wt+" more character"+(Wt>1?"s":"");return Ar(J.call(at,0,lt.maxStringLength),lt)+be}var de=Z.call(Z.call(at,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Hr);return dt(de,"single",lt)}function Hr(at){var lt=at.charCodeAt(0),Wt={8:"b",9:"t",10:"n",12:"f",13:"r"}[lt];return Wt?"\\"+Wt:"\\x"+(lt<16?"0":"")+it.call(lt.toString(16))}function Xe(at){return"Object("+at+")"}function Li(at){return at+" { ? }"}function Rs(at,lt,Wt,be){var de=be?Tt(Wt,be):ft.call(Wt,", ");return at+" ("+lt+") {"+de+"}"}function hr(at){for(var lt=0;lt<at.length;lt++)if(Lr(at[lt],`
44
44
  `)>=0)return!1;return!0}function Qr(at,lt){var Wt;if(at.indent===" ")Wt=" ";else if(typeof at.indent=="number"&&at.indent>0)Wt=ft.call(Array(at.indent+1)," ");else return null;return{base:Wt,prev:ft.call(Array(lt+1),Wt)}}function Tt(at,lt){if(at.length===0)return"";var Wt=`
45
45
  `+lt.prev+lt.base;return Wt+ft.call(at,","+Wt)+`
46
- `+lt.prev}function $t(at,lt){var Wt=Et(at),Ae=[];if(Wt){Ae.length=at.length;for(var de=0;de<at.length;de++)Ae[de]=De(at,de)?lt(at[de],at):""}var Yt=typeof pt=="function"?pt(at):[],ze;if(Ct){ze={};for(var Ye=0;Ye<Yt.length;Ye++)ze["$"+Yt[Ye]]=Yt[Ye]}for(var Qt in at)De(at,Qt)&&(Wt&&String(Number(Qt))===Qt&&Qt<at.length||Ct&&ze["$"+Qt]instanceof Symbol||(_t.call(/[^\w$]/,Qt)?Ae.push(lt(Qt,at)+": "+lt(at[Qt],at)):Ae.push(Qt+": "+lt(at[Qt],at))));if(typeof pt=="function")for(var zt=0;zt<Yt.length;zt++)st.call(at,Yt[zt])&&Ae.push("["+lt(Yt[zt])+"]: "+lt(at[Yt[zt]],at));return Ae}return bh}var Ah,w0;function W2(){if(w0)return Ah;w0=1;var s=Js(),t=V2(),r=X2(),i=Pn(),n=s("%WeakMap%",!0),o=s("%Map%",!0),h=t("WeakMap.prototype.get",!0),f=t("WeakMap.prototype.set",!0),A=t("WeakMap.prototype.has",!0),T=t("Map.prototype.get",!0),C=t("Map.prototype.set",!0),x=t("Map.prototype.has",!0),M=function(G,X){for(var J=G,Z;(Z=J.next)!==null;J=Z)if(Z.key===X)return J.next=Z.next,Z.next=G.next,G.next=Z,Z},D=function(G,X){var J=M(G,X);return J&&J.value},k=function(G,X,J){var Z=M(G,X);Z?Z.value=J:G.next={key:X,next:G.next,value:J}},U=function(G,X){return!!M(G,X)};return Ah=function(){var X,J,Z,it={assert:function(Q){if(!it.has(Q))throw new i("Side channel does not contain "+r(Q))},get:function(Q){if(n&&Q&&(typeof Q=="object"||typeof Q=="function")){if(X)return h(X,Q)}else if(o){if(J)return T(J,Q)}else if(Z)return D(Z,Q)},has:function(Q){if(n&&Q&&(typeof Q=="object"||typeof Q=="function")){if(X)return A(X,Q)}else if(o){if(J)return x(J,Q)}else if(Z)return U(Z,Q);return!1},set:function(Q,_t){n&&Q&&(typeof Q=="object"||typeof Q=="function")?(X||(X=new n),f(X,Q,_t)):o?(J||(J=new o),C(J,Q,_t)):(Z||(Z={key:{},next:null}),k(Z,Q,_t))}};return it},Ah}var wh,T0;function Th(){if(T0)return wh;T0=1;var s=String.prototype.replace,t=/%20/g,r={RFC1738:"RFC1738",RFC3986:"RFC3986"};return wh={default:r.RFC3986,formatters:{RFC1738:function(i){return s.call(i,t,"+")},RFC3986:function(i){return String(i)}},RFC1738:r.RFC1738,RFC3986:r.RFC3986},wh}var Eh,E0;function C0(){if(E0)return Eh;E0=1;var s=Th(),t=Object.prototype.hasOwnProperty,r=Array.isArray,i=function(){for(var G=[],X=0;X<256;++X)G.push("%"+((X<16?"0":"")+X.toString(16)).toUpperCase());return G}(),n=function(X){for(;X.length>1;){var J=X.pop(),Z=J.obj[J.prop];if(r(Z)){for(var it=[],Q=0;Q<Z.length;++Q)typeof Z[Q]<"u"&&it.push(Z[Q]);J.obj[J.prop]=it}}},o=function(X,J){for(var Z=J&&J.plainObjects?Object.create(null):{},it=0;it<X.length;++it)typeof X[it]<"u"&&(Z[it]=X[it]);return Z},h=function G(X,J,Z){if(!J)return X;if(typeof J!="object"){if(r(X))X.push(J);else if(X&&typeof X=="object")(Z&&(Z.plainObjects||Z.allowPrototypes)||!t.call(Object.prototype,J))&&(X[J]=!0);else return[X,J];return X}if(!X||typeof X!="object")return[X].concat(J);var it=X;return r(X)&&!r(J)&&(it=o(X,Z)),r(X)&&r(J)?(J.forEach(function(Q,_t){if(t.call(X,_t)){var et=X[_t];et&&typeof et=="object"&&Q&&typeof Q=="object"?X[_t]=G(et,Q,Z):X.push(Q)}else X[_t]=Q}),X):Object.keys(J).reduce(function(Q,_t){var et=J[_t];return t.call(Q,_t)?Q[_t]=G(Q[_t],et,Z):Q[_t]=et,Q},it)},f=function(X,J){return Object.keys(J).reduce(function(Z,it){return Z[it]=J[it],Z},X)},A=function(G,X,J){var Z=G.replace(/\+/g," ");if(J==="iso-8859-1")return Z.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(Z)}catch{return Z}},T=1024,C=function(X,J,Z,it,Q){if(X.length===0)return X;var _t=X;if(typeof X=="symbol"?_t=Symbol.prototype.toString.call(X):typeof X!="string"&&(_t=String(X)),Z==="iso-8859-1")return escape(_t).replace(/%u[0-9a-f]{4}/gi,function(xt){return"%26%23"+parseInt(xt.slice(2),16)+"%3B"});for(var et="",ft=0;ft<_t.length;ft+=T){for(var wt=_t.length>=T?_t.slice(ft,ft+T):_t,Rt=[],It=0;It<wt.length;++It){var pt=wt.charCodeAt(It);if(pt===45||pt===46||pt===95||pt===126||pt>=48&&pt<=57||pt>=65&&pt<=90||pt>=97&&pt<=122||Q===s.RFC1738&&(pt===40||pt===41)){Rt[Rt.length]=wt.charAt(It);continue}if(pt<128){Rt[Rt.length]=i[pt];continue}if(pt<2048){Rt[Rt.length]=i[192|pt>>6]+i[128|pt&63];continue}if(pt<55296||pt>=57344){Rt[Rt.length]=i[224|pt>>12]+i[128|pt>>6&63]+i[128|pt&63];continue}It+=1,pt=65536+((pt&1023)<<10|wt.charCodeAt(It)&1023),Rt[Rt.length]=i[240|pt>>18]+i[128|pt>>12&63]+i[128|pt>>6&63]+i[128|pt&63]}et+=Rt.join("")}return et},x=function(X){for(var J=[{obj:{o:X},prop:"o"}],Z=[],it=0;it<J.length;++it)for(var Q=J[it],_t=Q.obj[Q.prop],et=Object.keys(_t),ft=0;ft<et.length;++ft){var wt=et[ft],Rt=_t[wt];typeof Rt=="object"&&Rt!==null&&Z.indexOf(Rt)===-1&&(J.push({obj:_t,prop:wt}),Z.push(Rt))}return n(J),X},M=function(X){return Object.prototype.toString.call(X)==="[object RegExp]"},D=function(X){return!X||typeof X!="object"?!1:!!(X.constructor&&X.constructor.isBuffer&&X.constructor.isBuffer(X))},k=function(X,J){return[].concat(X,J)},U=function(X,J){if(r(X)){for(var Z=[],it=0;it<X.length;it+=1)Z.push(J(X[it]));return Z}return J(X)};return Eh={arrayToObject:o,assign:f,combine:k,compact:x,decode:A,encode:C,isBuffer:D,isRegExp:M,maybeMap:U,merge:h},Eh}var Ch,S0;function H2(){if(S0)return Ch;S0=1;var s=W2(),t=C0(),r=Th(),i=Object.prototype.hasOwnProperty,n={brackets:function(G){return G+"[]"},comma:"comma",indices:function(G,X){return G+"["+X+"]"},repeat:function(G){return G}},o=Array.isArray,h=Array.prototype.push,f=function(U,G){h.apply(U,o(G)?G:[G])},A=Date.prototype.toISOString,T=r.default,C={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,format:T,formatter:r.formatters[T],indices:!1,serializeDate:function(G){return A.call(G)},skipNulls:!1,strictNullHandling:!1},x=function(G){return typeof G=="string"||typeof G=="number"||typeof G=="boolean"||typeof G=="symbol"||typeof G=="bigint"},M={},D=function U(G,X,J,Z,it,Q,_t,et,ft,wt,Rt,It,pt,xt,Ct,Gt,st,nt){for(var Y=G,gt=nt,ot=0,ht=!1;(gt=gt.get(M))!==void 0&&!ht;){var dt=gt.get(G);if(ot+=1,typeof dt<"u"){if(dt===ot)throw new RangeError("Cyclic object value");ht=!0}typeof gt.get(M)>"u"&&(ot=0)}if(typeof wt=="function"?Y=wt(X,Y):Y instanceof Date?Y=pt(Y):J==="comma"&&o(Y)&&(Y=t.maybeMap(Y,function(xe){return xe instanceof Date?pt(xe):xe})),Y===null){if(Q)return ft&&!Gt?ft(X,C.encoder,st,"key",xt):X;Y=""}if(x(Y)||t.isBuffer(Y)){if(ft){var At=Gt?X:ft(X,C.encoder,st,"key",xt);return[Ct(At)+"="+Ct(ft(Y,C.encoder,st,"value",xt))]}return[Ct(X)+"="+Ct(String(Y))]}var Et=[];if(typeof Y>"u")return Et;var Dt;if(J==="comma"&&o(Y))Gt&&ft&&(Y=t.maybeMap(Y,ft)),Dt=[{value:Y.length>0?Y.join(",")||null:void 0}];else if(o(wt))Dt=wt;else{var oe=Object.keys(Y);Dt=Rt?oe.sort(Rt):oe}var kt=et?X.replace(/\./g,"%2E"):X,se=Z&&o(Y)&&Y.length===1?kt+"[]":kt;if(it&&o(Y)&&Y.length===0)return se+"[]";for(var Kt=0;Kt<Dt.length;++Kt){var Xt=Dt[Kt],_e=typeof Xt=="object"&&typeof Xt.value<"u"?Xt.value:Y[Xt];if(!(_t&&_e===null)){var $e=It&&et?Xt.replace(/\./g,"%2E"):Xt,Jt=o(Y)?typeof J=="function"?J(se,$e):se:se+(It?"."+$e:"["+$e+"]");nt.set(G,ot);var De=s();De.set(M,nt),f(Et,U(_e,Jt,J,Z,it,Q,_t,et,J==="comma"&&Gt&&o(Y)?null:ft,wt,Rt,It,pt,xt,Ct,Gt,st,De))}}return Et},k=function(G){if(!G)return C;if(typeof G.allowEmptyArrays<"u"&&typeof G.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof G.encodeDotInKeys<"u"&&typeof G.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(G.encoder!==null&&typeof G.encoder<"u"&&typeof G.encoder!="function")throw new TypeError("Encoder has to be a function.");var X=G.charset||C.charset;if(typeof G.charset<"u"&&G.charset!=="utf-8"&&G.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var J=r.default;if(typeof G.format<"u"){if(!i.call(r.formatters,G.format))throw new TypeError("Unknown format option provided.");J=G.format}var Z=r.formatters[J],it=C.filter;(typeof G.filter=="function"||o(G.filter))&&(it=G.filter);var Q;if(G.arrayFormat in n?Q=G.arrayFormat:"indices"in G?Q=G.indices?"indices":"repeat":Q=C.arrayFormat,"commaRoundTrip"in G&&typeof G.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var _t=typeof G.allowDots>"u"?G.encodeDotInKeys===!0?!0:C.allowDots:!!G.allowDots;return{addQueryPrefix:typeof G.addQueryPrefix=="boolean"?G.addQueryPrefix:C.addQueryPrefix,allowDots:_t,allowEmptyArrays:typeof G.allowEmptyArrays=="boolean"?!!G.allowEmptyArrays:C.allowEmptyArrays,arrayFormat:Q,charset:X,charsetSentinel:typeof G.charsetSentinel=="boolean"?G.charsetSentinel:C.charsetSentinel,commaRoundTrip:G.commaRoundTrip,delimiter:typeof G.delimiter>"u"?C.delimiter:G.delimiter,encode:typeof G.encode=="boolean"?G.encode:C.encode,encodeDotInKeys:typeof G.encodeDotInKeys=="boolean"?G.encodeDotInKeys:C.encodeDotInKeys,encoder:typeof G.encoder=="function"?G.encoder:C.encoder,encodeValuesOnly:typeof G.encodeValuesOnly=="boolean"?G.encodeValuesOnly:C.encodeValuesOnly,filter:it,format:J,formatter:Z,serializeDate:typeof G.serializeDate=="function"?G.serializeDate:C.serializeDate,skipNulls:typeof G.skipNulls=="boolean"?G.skipNulls:C.skipNulls,sort:typeof G.sort=="function"?G.sort:null,strictNullHandling:typeof G.strictNullHandling=="boolean"?G.strictNullHandling:C.strictNullHandling}};return Ch=function(U,G){var X=U,J=k(G),Z,it;typeof J.filter=="function"?(it=J.filter,X=it("",X)):o(J.filter)&&(it=J.filter,Z=it);var Q=[];if(typeof X!="object"||X===null)return"";var _t=n[J.arrayFormat],et=_t==="comma"&&J.commaRoundTrip;Z||(Z=Object.keys(X)),J.sort&&Z.sort(J.sort);for(var ft=s(),wt=0;wt<Z.length;++wt){var Rt=Z[wt];J.skipNulls&&X[Rt]===null||f(Q,D(X[Rt],Rt,_t,et,J.allowEmptyArrays,J.strictNullHandling,J.skipNulls,J.encodeDotInKeys,J.encode?J.encoder:null,J.filter,J.sort,J.allowDots,J.serializeDate,J.format,J.formatter,J.encodeValuesOnly,J.charset,ft))}var It=Q.join(J.delimiter),pt=J.addQueryPrefix===!0?"?":"";return J.charsetSentinel&&(J.charset==="iso-8859-1"?pt+="utf8=%26%2310003%3B&":pt+="utf8=%E2%9C%93&"),It.length>0?pt+It:""},Ch}var Sh,P0;function Y2(){if(P0)return Sh;P0=1;var s=C0(),t=Object.prototype.hasOwnProperty,r=Array.isArray,i={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:s.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},n=function(M){return M.replace(/&#(\d+);/g,function(D,k){return String.fromCharCode(parseInt(k,10))})},o=function(M,D){return M&&typeof M=="string"&&D.comma&&M.indexOf(",")>-1?M.split(","):M},h="utf8=%26%2310003%3B",f="utf8=%E2%9C%93",A=function(D,k){var U={__proto__:null},G=k.ignoreQueryPrefix?D.replace(/^\?/,""):D;G=G.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var X=k.parameterLimit===1/0?void 0:k.parameterLimit,J=G.split(k.delimiter,X),Z=-1,it,Q=k.charset;if(k.charsetSentinel)for(it=0;it<J.length;++it)J[it].indexOf("utf8=")===0&&(J[it]===f?Q="utf-8":J[it]===h&&(Q="iso-8859-1"),Z=it,it=J.length);for(it=0;it<J.length;++it)if(it!==Z){var _t=J[it],et=_t.indexOf("]="),ft=et===-1?_t.indexOf("="):et+1,wt,Rt;ft===-1?(wt=k.decoder(_t,i.decoder,Q,"key"),Rt=k.strictNullHandling?null:""):(wt=k.decoder(_t.slice(0,ft),i.decoder,Q,"key"),Rt=s.maybeMap(o(_t.slice(ft+1),k),function(pt){return k.decoder(pt,i.decoder,Q,"value")})),Rt&&k.interpretNumericEntities&&Q==="iso-8859-1"&&(Rt=n(Rt)),_t.indexOf("[]=")>-1&&(Rt=r(Rt)?[Rt]:Rt);var It=t.call(U,wt);It&&k.duplicates==="combine"?U[wt]=s.combine(U[wt],Rt):(!It||k.duplicates==="last")&&(U[wt]=Rt)}return U},T=function(M,D,k,U){for(var G=U?D:o(D,k),X=M.length-1;X>=0;--X){var J,Z=M[X];if(Z==="[]"&&k.parseArrays)J=k.allowEmptyArrays&&(G===""||k.strictNullHandling&&G===null)?[]:[].concat(G);else{J=k.plainObjects?Object.create(null):{};var it=Z.charAt(0)==="["&&Z.charAt(Z.length-1)==="]"?Z.slice(1,-1):Z,Q=k.decodeDotInKeys?it.replace(/%2E/g,"."):it,_t=parseInt(Q,10);!k.parseArrays&&Q===""?J={0:G}:!isNaN(_t)&&Z!==Q&&String(_t)===Q&&_t>=0&&k.parseArrays&&_t<=k.arrayLimit?(J=[],J[_t]=G):Q!=="__proto__"&&(J[Q]=G)}G=J}return G},C=function(D,k,U,G){if(D){var X=U.allowDots?D.replace(/\.([^.[]+)/g,"[$1]"):D,J=/(\[[^[\]]*])/,Z=/(\[[^[\]]*])/g,it=U.depth>0&&J.exec(X),Q=it?X.slice(0,it.index):X,_t=[];if(Q){if(!U.plainObjects&&t.call(Object.prototype,Q)&&!U.allowPrototypes)return;_t.push(Q)}for(var et=0;U.depth>0&&(it=Z.exec(X))!==null&&et<U.depth;){if(et+=1,!U.plainObjects&&t.call(Object.prototype,it[1].slice(1,-1))&&!U.allowPrototypes)return;_t.push(it[1])}if(it){if(U.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+U.depth+" and strictDepth is true");_t.push("["+X.slice(it.index)+"]")}return T(_t,k,U,G)}},x=function(D){if(!D)return i;if(typeof D.allowEmptyArrays<"u"&&typeof D.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof D.decodeDotInKeys<"u"&&typeof D.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(D.decoder!==null&&typeof D.decoder<"u"&&typeof D.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof D.charset<"u"&&D.charset!=="utf-8"&&D.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var k=typeof D.charset>"u"?i.charset:D.charset,U=typeof D.duplicates>"u"?i.duplicates:D.duplicates;if(U!=="combine"&&U!=="first"&&U!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var G=typeof D.allowDots>"u"?D.decodeDotInKeys===!0?!0:i.allowDots:!!D.allowDots;return{allowDots:G,allowEmptyArrays:typeof D.allowEmptyArrays=="boolean"?!!D.allowEmptyArrays:i.allowEmptyArrays,allowPrototypes:typeof D.allowPrototypes=="boolean"?D.allowPrototypes:i.allowPrototypes,allowSparse:typeof D.allowSparse=="boolean"?D.allowSparse:i.allowSparse,arrayLimit:typeof D.arrayLimit=="number"?D.arrayLimit:i.arrayLimit,charset:k,charsetSentinel:typeof D.charsetSentinel=="boolean"?D.charsetSentinel:i.charsetSentinel,comma:typeof D.comma=="boolean"?D.comma:i.comma,decodeDotInKeys:typeof D.decodeDotInKeys=="boolean"?D.decodeDotInKeys:i.decodeDotInKeys,decoder:typeof D.decoder=="function"?D.decoder:i.decoder,delimiter:typeof D.delimiter=="string"||s.isRegExp(D.delimiter)?D.delimiter:i.delimiter,depth:typeof D.depth=="number"||D.depth===!1?+D.depth:i.depth,duplicates:U,ignoreQueryPrefix:D.ignoreQueryPrefix===!0,interpretNumericEntities:typeof D.interpretNumericEntities=="boolean"?D.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof D.parameterLimit=="number"?D.parameterLimit:i.parameterLimit,parseArrays:D.parseArrays!==!1,plainObjects:typeof D.plainObjects=="boolean"?D.plainObjects:i.plainObjects,strictDepth:typeof D.strictDepth=="boolean"?!!D.strictDepth:i.strictDepth,strictNullHandling:typeof D.strictNullHandling=="boolean"?D.strictNullHandling:i.strictNullHandling}};return Sh=function(M,D){var k=x(D);if(M===""||M===null||typeof M>"u")return k.plainObjects?Object.create(null):{};for(var U=typeof M=="string"?A(M,k):M,G=k.plainObjects?Object.create(null):{},X=Object.keys(U),J=0;J<X.length;++J){var Z=X[J],it=C(Z,U[Z],k,typeof M=="string");G=s.merge(G,it,k)}return k.allowSparse===!0?G:s.compact(G)},Sh}var Ph,$0;function j2(){if($0)return Ph;$0=1;var s=H2(),t=Y2(),r=Th();return Ph={formats:r,parse:t,stringify:s},Ph}var M0;function q2(){if(M0)return Ls;M0=1;var s=S2();function t(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var r=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,n=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,o=["<",">",'"',"`"," ","\r",`
47
- `," "],h=["{","}","|","\\","^","`"].concat(o),f=["'"].concat(h),A=["%","/","?",";","#"].concat(f),T=["/","?","#"],C=255,x=/^[+a-z0-9A-Z_-]{0,63}$/,M=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,D={javascript:!0,"javascript:":!0},k={javascript:!0,"javascript:":!0},U={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},G=j2();function X(Q,_t,et){if(Q&&typeof Q=="object"&&Q instanceof t)return Q;var ft=new t;return ft.parse(Q,_t,et),ft}t.prototype.parse=function(Q,_t,et){if(typeof Q!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof Q);var ft=Q.indexOf("?"),wt=ft!==-1&&ft<Q.indexOf("#")?"?":"#",Rt=Q.split(wt),It=/\\/g;Rt[0]=Rt[0].replace(It,"/"),Q=Rt.join(wt);var pt=Q;if(pt=pt.trim(),!et&&Q.split("#").length===1){var xt=n.exec(pt);if(xt)return this.path=pt,this.href=pt,this.pathname=xt[1],xt[2]?(this.search=xt[2],_t?this.query=G.parse(this.search.substr(1)):this.query=this.search.substr(1)):_t&&(this.search="",this.query={}),this}var Ct=r.exec(pt);if(Ct){Ct=Ct[0];var Gt=Ct.toLowerCase();this.protocol=Gt,pt=pt.substr(Ct.length)}if(et||Ct||pt.match(/^\/\/[^@/]+@[^@/]+/)){var st=pt.substr(0,2)==="//";st&&!(Ct&&k[Ct])&&(pt=pt.substr(2),this.slashes=!0)}if(!k[Ct]&&(st||Ct&&!U[Ct])){for(var nt=-1,Y=0;Y<T.length;Y++){var gt=pt.indexOf(T[Y]);gt!==-1&&(nt===-1||gt<nt)&&(nt=gt)}var ot,ht;nt===-1?ht=pt.lastIndexOf("@"):ht=pt.lastIndexOf("@",nt),ht!==-1&&(ot=pt.slice(0,ht),pt=pt.slice(ht+1),this.auth=decodeURIComponent(ot)),nt=-1;for(var Y=0;Y<A.length;Y++){var gt=pt.indexOf(A[Y]);gt!==-1&&(nt===-1||gt<nt)&&(nt=gt)}nt===-1&&(nt=pt.length),this.host=pt.slice(0,nt),pt=pt.slice(nt),this.parseHost(),this.hostname=this.hostname||"";var dt=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!dt)for(var At=this.hostname.split(/\./),Y=0,Et=At.length;Y<Et;Y++){var Dt=At[Y];if(Dt&&!Dt.match(x)){for(var oe="",kt=0,se=Dt.length;kt<se;kt++)Dt.charCodeAt(kt)>127?oe+="x":oe+=Dt[kt];if(!oe.match(x)){var Kt=At.slice(0,Y),Xt=At.slice(Y+1),_e=Dt.match(M);_e&&(Kt.push(_e[1]),Xt.unshift(_e[2])),Xt.length&&(pt="/"+Xt.join(".")+pt),this.hostname=Kt.join(".");break}}}this.hostname.length>C?this.hostname="":this.hostname=this.hostname.toLowerCase(),dt||(this.hostname=s.toASCII(this.hostname));var $e=this.port?":"+this.port:"",Jt=this.hostname||"";this.host=Jt+$e,this.href+=this.host,dt&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),pt[0]!=="/"&&(pt="/"+pt))}if(!D[Gt])for(var Y=0,Et=f.length;Y<Et;Y++){var De=f[Y];if(pt.indexOf(De)!==-1){var xe=encodeURIComponent(De);xe===De&&(xe=escape(De)),pt=pt.split(De).join(xe)}}var ae=pt.indexOf("#");ae!==-1&&(this.hash=pt.substr(ae),pt=pt.slice(0,ae));var Lr=pt.indexOf("?");if(Lr!==-1?(this.search=pt.substr(Lr),this.query=pt.substr(Lr+1),_t&&(this.query=G.parse(this.query)),pt=pt.slice(0,Lr)):_t&&(this.search="",this.query={}),pt&&(this.pathname=pt),U[Gt]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var $e=this.pathname||"",vr=this.search||"";this.path=$e+vr}return this.href=this.format(),this};function J(Q){return typeof Q=="string"&&(Q=X(Q)),Q instanceof t?Q.format():t.prototype.format.call(Q)}t.prototype.format=function(){var Q=this.auth||"";Q&&(Q=encodeURIComponent(Q),Q=Q.replace(/%3A/i,":"),Q+="@");var _t=this.protocol||"",et=this.pathname||"",ft=this.hash||"",wt=!1,Rt="";this.host?wt=Q+this.host:this.hostname&&(wt=Q+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(wt+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(Rt=G.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var It=this.search||Rt&&"?"+Rt||"";return _t&&_t.substr(-1)!==":"&&(_t+=":"),this.slashes||(!_t||U[_t])&&wt!==!1?(wt="//"+(wt||""),et&&et.charAt(0)!=="/"&&(et="/"+et)):wt||(wt=""),ft&&ft.charAt(0)!=="#"&&(ft="#"+ft),It&&It.charAt(0)!=="?"&&(It="?"+It),et=et.replace(/[?#]/g,function(pt){return encodeURIComponent(pt)}),It=It.replace("#","%23"),_t+wt+et+It+ft};function Z(Q,_t){return X(Q,!1,!0).resolve(_t)}t.prototype.resolve=function(Q){return this.resolveObject(X(Q,!1,!0)).format()};function it(Q,_t){return Q?X(Q,!1,!0).resolveObject(_t):_t}return t.prototype.resolveObject=function(Q){if(typeof Q=="string"){var _t=new t;_t.parse(Q,!1,!0),Q=_t}for(var et=new t,ft=Object.keys(this),wt=0;wt<ft.length;wt++){var Rt=ft[wt];et[Rt]=this[Rt]}if(et.hash=Q.hash,Q.href==="")return et.href=et.format(),et;if(Q.slashes&&!Q.protocol){for(var It=Object.keys(Q),pt=0;pt<It.length;pt++){var xt=It[pt];xt!=="protocol"&&(et[xt]=Q[xt])}return U[et.protocol]&&et.hostname&&!et.pathname&&(et.pathname="/",et.path=et.pathname),et.href=et.format(),et}if(Q.protocol&&Q.protocol!==et.protocol){if(!U[Q.protocol]){for(var Ct=Object.keys(Q),Gt=0;Gt<Ct.length;Gt++){var st=Ct[Gt];et[st]=Q[st]}return et.href=et.format(),et}if(et.protocol=Q.protocol,!Q.host&&!k[Q.protocol]){for(var Et=(Q.pathname||"").split("/");Et.length&&!(Q.host=Et.shift()););Q.host||(Q.host=""),Q.hostname||(Q.hostname=""),Et[0]!==""&&Et.unshift(""),Et.length<2&&Et.unshift(""),et.pathname=Et.join("/")}else et.pathname=Q.pathname;if(et.search=Q.search,et.query=Q.query,et.host=Q.host||"",et.auth=Q.auth,et.hostname=Q.hostname||Q.host,et.port=Q.port,et.pathname||et.search){var nt=et.pathname||"",Y=et.search||"";et.path=nt+Y}return et.slashes=et.slashes||Q.slashes,et.href=et.format(),et}var gt=et.pathname&&et.pathname.charAt(0)==="/",ot=Q.host||Q.pathname&&Q.pathname.charAt(0)==="/",ht=ot||gt||et.host&&Q.pathname,dt=ht,At=et.pathname&&et.pathname.split("/")||[],Et=Q.pathname&&Q.pathname.split("/")||[],Dt=et.protocol&&!U[et.protocol];if(Dt&&(et.hostname="",et.port=null,et.host&&(At[0]===""?At[0]=et.host:At.unshift(et.host)),et.host="",Q.protocol&&(Q.hostname=null,Q.port=null,Q.host&&(Et[0]===""?Et[0]=Q.host:Et.unshift(Q.host)),Q.host=null),ht=ht&&(Et[0]===""||At[0]==="")),ot)et.host=Q.host||Q.host===""?Q.host:et.host,et.hostname=Q.hostname||Q.hostname===""?Q.hostname:et.hostname,et.search=Q.search,et.query=Q.query,At=Et;else if(Et.length)At||(At=[]),At.pop(),At=At.concat(Et),et.search=Q.search,et.query=Q.query;else if(Q.search!=null){if(Dt){et.host=At.shift(),et.hostname=et.host;var oe=et.host&&et.host.indexOf("@")>0?et.host.split("@"):!1;oe&&(et.auth=oe.shift(),et.hostname=oe.shift(),et.host=et.hostname)}return et.search=Q.search,et.query=Q.query,(et.pathname!==null||et.search!==null)&&(et.path=(et.pathname?et.pathname:"")+(et.search?et.search:"")),et.href=et.format(),et}if(!At.length)return et.pathname=null,et.search?et.path="/"+et.search:et.path=null,et.href=et.format(),et;for(var kt=At.slice(-1)[0],se=(et.host||Q.host||At.length>1)&&(kt==="."||kt==="..")||kt==="",Kt=0,Xt=At.length;Xt>=0;Xt--)kt=At[Xt],kt==="."?At.splice(Xt,1):kt===".."?(At.splice(Xt,1),Kt++):Kt&&(At.splice(Xt,1),Kt--);if(!ht&&!dt)for(;Kt--;Kt)At.unshift("..");ht&&At[0]!==""&&(!At[0]||At[0].charAt(0)!=="/")&&At.unshift(""),se&&At.join("/").substr(-1)!=="/"&&At.push("");var _e=At[0]===""||At[0]&&At[0].charAt(0)==="/";if(Dt){et.hostname=_e?"":At.length?At.shift():"",et.host=et.hostname;var oe=et.host&&et.host.indexOf("@")>0?et.host.split("@"):!1;oe&&(et.auth=oe.shift(),et.hostname=oe.shift(),et.host=et.hostname)}return ht=ht||et.host&&At.length,ht&&!_e&&At.unshift(""),At.length>0?et.pathname=At.join("/"):(et.pathname=null,et.path=null),(et.pathname!==null||et.search!==null)&&(et.path=(et.pathname?et.pathname:"")+(et.search?et.search:"")),et.auth=Q.auth||et.auth,et.slashes=et.slashes||Q.slashes,et.href=et.format(),et},t.prototype.parseHost=function(){var Q=this.host,_t=i.exec(Q);_t&&(_t=_t[0],_t!==":"&&(this.port=_t.substr(1)),Q=Q.substr(0,Q.length-_t.length)),Q&&(this.hostname=Q)},Ls.parse=X,Ls.resolve=Z,Ls.resolveObject=it,Ls.format=J,Ls.Url=t,Ls}var $h=q2();const R0={};function Oe(s,t,r=3){if(R0[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
46
+ `+lt.prev}function $t(at,lt){var Wt=Et(at),be=[];if(Wt){be.length=at.length;for(var de=0;de<at.length;de++)be[de]=De(at,de)?lt(at[de],at):""}var Yt=typeof pt=="function"?pt(at):[],ze;if(Ct){ze={};for(var Ye=0;Ye<Yt.length;Ye++)ze["$"+Yt[Ye]]=Yt[Ye]}for(var Qt in at)De(at,Qt)&&(Wt&&String(Number(Qt))===Qt&&Qt<at.length||Ct&&ze["$"+Qt]instanceof Symbol||(_t.call(/[^\w$]/,Qt)?be.push(lt(Qt,at)+": "+lt(at[Qt],at)):be.push(Qt+": "+lt(at[Qt],at))));if(typeof pt=="function")for(var zt=0;zt<Yt.length;zt++)st.call(at,Yt[zt])&&be.push("["+lt(Yt[zt])+"]: "+lt(at[Yt[zt]],at));return be}return xh}var bh,A0;function W2(){if(A0)return bh;A0=1;var s=Js(),t=V2(),r=X2(),i=Pn(),n=s("%WeakMap%",!0),o=s("%Map%",!0),h=t("WeakMap.prototype.get",!0),f=t("WeakMap.prototype.set",!0),A=t("WeakMap.prototype.has",!0),T=t("Map.prototype.get",!0),C=t("Map.prototype.set",!0),x=t("Map.prototype.has",!0),M=function(G,X){for(var J=G,Z;(Z=J.next)!==null;J=Z)if(Z.key===X)return J.next=Z.next,Z.next=G.next,G.next=Z,Z},D=function(G,X){var J=M(G,X);return J&&J.value},k=function(G,X,J){var Z=M(G,X);Z?Z.value=J:G.next={key:X,next:G.next,value:J}},U=function(G,X){return!!M(G,X)};return bh=function(){var X,J,Z,it={assert:function(Q){if(!it.has(Q))throw new i("Side channel does not contain "+r(Q))},get:function(Q){if(n&&Q&&(typeof Q=="object"||typeof Q=="function")){if(X)return h(X,Q)}else if(o){if(J)return T(J,Q)}else if(Z)return D(Z,Q)},has:function(Q){if(n&&Q&&(typeof Q=="object"||typeof Q=="function")){if(X)return A(X,Q)}else if(o){if(J)return x(J,Q)}else if(Z)return U(Z,Q);return!1},set:function(Q,_t){n&&Q&&(typeof Q=="object"||typeof Q=="function")?(X||(X=new n),f(X,Q,_t)):o?(J||(J=new o),C(J,Q,_t)):(Z||(Z={key:{},next:null}),k(Z,Q,_t))}};return it},bh}var Ah,w0;function wh(){if(w0)return Ah;w0=1;var s=String.prototype.replace,t=/%20/g,r={RFC1738:"RFC1738",RFC3986:"RFC3986"};return Ah={default:r.RFC3986,formatters:{RFC1738:function(i){return s.call(i,t,"+")},RFC3986:function(i){return String(i)}},RFC1738:r.RFC1738,RFC3986:r.RFC3986},Ah}var Th,T0;function E0(){if(T0)return Th;T0=1;var s=wh(),t=Object.prototype.hasOwnProperty,r=Array.isArray,i=function(){for(var G=[],X=0;X<256;++X)G.push("%"+((X<16?"0":"")+X.toString(16)).toUpperCase());return G}(),n=function(X){for(;X.length>1;){var J=X.pop(),Z=J.obj[J.prop];if(r(Z)){for(var it=[],Q=0;Q<Z.length;++Q)typeof Z[Q]<"u"&&it.push(Z[Q]);J.obj[J.prop]=it}}},o=function(X,J){for(var Z=J&&J.plainObjects?Object.create(null):{},it=0;it<X.length;++it)typeof X[it]<"u"&&(Z[it]=X[it]);return Z},h=function G(X,J,Z){if(!J)return X;if(typeof J!="object"){if(r(X))X.push(J);else if(X&&typeof X=="object")(Z&&(Z.plainObjects||Z.allowPrototypes)||!t.call(Object.prototype,J))&&(X[J]=!0);else return[X,J];return X}if(!X||typeof X!="object")return[X].concat(J);var it=X;return r(X)&&!r(J)&&(it=o(X,Z)),r(X)&&r(J)?(J.forEach(function(Q,_t){if(t.call(X,_t)){var et=X[_t];et&&typeof et=="object"&&Q&&typeof Q=="object"?X[_t]=G(et,Q,Z):X.push(Q)}else X[_t]=Q}),X):Object.keys(J).reduce(function(Q,_t){var et=J[_t];return t.call(Q,_t)?Q[_t]=G(Q[_t],et,Z):Q[_t]=et,Q},it)},f=function(X,J){return Object.keys(J).reduce(function(Z,it){return Z[it]=J[it],Z},X)},A=function(G,X,J){var Z=G.replace(/\+/g," ");if(J==="iso-8859-1")return Z.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(Z)}catch{return Z}},T=1024,C=function(X,J,Z,it,Q){if(X.length===0)return X;var _t=X;if(typeof X=="symbol"?_t=Symbol.prototype.toString.call(X):typeof X!="string"&&(_t=String(X)),Z==="iso-8859-1")return escape(_t).replace(/%u[0-9a-f]{4}/gi,function(xt){return"%26%23"+parseInt(xt.slice(2),16)+"%3B"});for(var et="",ft=0;ft<_t.length;ft+=T){for(var wt=_t.length>=T?_t.slice(ft,ft+T):_t,Rt=[],It=0;It<wt.length;++It){var pt=wt.charCodeAt(It);if(pt===45||pt===46||pt===95||pt===126||pt>=48&&pt<=57||pt>=65&&pt<=90||pt>=97&&pt<=122||Q===s.RFC1738&&(pt===40||pt===41)){Rt[Rt.length]=wt.charAt(It);continue}if(pt<128){Rt[Rt.length]=i[pt];continue}if(pt<2048){Rt[Rt.length]=i[192|pt>>6]+i[128|pt&63];continue}if(pt<55296||pt>=57344){Rt[Rt.length]=i[224|pt>>12]+i[128|pt>>6&63]+i[128|pt&63];continue}It+=1,pt=65536+((pt&1023)<<10|wt.charCodeAt(It)&1023),Rt[Rt.length]=i[240|pt>>18]+i[128|pt>>12&63]+i[128|pt>>6&63]+i[128|pt&63]}et+=Rt.join("")}return et},x=function(X){for(var J=[{obj:{o:X},prop:"o"}],Z=[],it=0;it<J.length;++it)for(var Q=J[it],_t=Q.obj[Q.prop],et=Object.keys(_t),ft=0;ft<et.length;++ft){var wt=et[ft],Rt=_t[wt];typeof Rt=="object"&&Rt!==null&&Z.indexOf(Rt)===-1&&(J.push({obj:_t,prop:wt}),Z.push(Rt))}return n(J),X},M=function(X){return Object.prototype.toString.call(X)==="[object RegExp]"},D=function(X){return!X||typeof X!="object"?!1:!!(X.constructor&&X.constructor.isBuffer&&X.constructor.isBuffer(X))},k=function(X,J){return[].concat(X,J)},U=function(X,J){if(r(X)){for(var Z=[],it=0;it<X.length;it+=1)Z.push(J(X[it]));return Z}return J(X)};return Th={arrayToObject:o,assign:f,combine:k,compact:x,decode:A,encode:C,isBuffer:D,isRegExp:M,maybeMap:U,merge:h},Th}var Eh,C0;function H2(){if(C0)return Eh;C0=1;var s=W2(),t=E0(),r=wh(),i=Object.prototype.hasOwnProperty,n={brackets:function(G){return G+"[]"},comma:"comma",indices:function(G,X){return G+"["+X+"]"},repeat:function(G){return G}},o=Array.isArray,h=Array.prototype.push,f=function(U,G){h.apply(U,o(G)?G:[G])},A=Date.prototype.toISOString,T=r.default,C={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,format:T,formatter:r.formatters[T],indices:!1,serializeDate:function(G){return A.call(G)},skipNulls:!1,strictNullHandling:!1},x=function(G){return typeof G=="string"||typeof G=="number"||typeof G=="boolean"||typeof G=="symbol"||typeof G=="bigint"},M={},D=function U(G,X,J,Z,it,Q,_t,et,ft,wt,Rt,It,pt,xt,Ct,Gt,st,nt){for(var Y=G,gt=nt,ot=0,ht=!1;(gt=gt.get(M))!==void 0&&!ht;){var dt=gt.get(G);if(ot+=1,typeof dt<"u"){if(dt===ot)throw new RangeError("Cyclic object value");ht=!0}typeof gt.get(M)>"u"&&(ot=0)}if(typeof wt=="function"?Y=wt(X,Y):Y instanceof Date?Y=pt(Y):J==="comma"&&o(Y)&&(Y=t.maybeMap(Y,function(xe){return xe instanceof Date?pt(xe):xe})),Y===null){if(Q)return ft&&!Gt?ft(X,C.encoder,st,"key",xt):X;Y=""}if(x(Y)||t.isBuffer(Y)){if(ft){var At=Gt?X:ft(X,C.encoder,st,"key",xt);return[Ct(At)+"="+Ct(ft(Y,C.encoder,st,"value",xt))]}return[Ct(X)+"="+Ct(String(Y))]}var Et=[];if(typeof Y>"u")return Et;var Dt;if(J==="comma"&&o(Y))Gt&&ft&&(Y=t.maybeMap(Y,ft)),Dt=[{value:Y.length>0?Y.join(",")||null:void 0}];else if(o(wt))Dt=wt;else{var oe=Object.keys(Y);Dt=Rt?oe.sort(Rt):oe}var kt=et?X.replace(/\./g,"%2E"):X,se=Z&&o(Y)&&Y.length===1?kt+"[]":kt;if(it&&o(Y)&&Y.length===0)return se+"[]";for(var Kt=0;Kt<Dt.length;++Kt){var Xt=Dt[Kt],_e=typeof Xt=="object"&&typeof Xt.value<"u"?Xt.value:Y[Xt];if(!(_t&&_e===null)){var $e=It&&et?Xt.replace(/\./g,"%2E"):Xt,Jt=o(Y)?typeof J=="function"?J(se,$e):se:se+(It?"."+$e:"["+$e+"]");nt.set(G,ot);var De=s();De.set(M,nt),f(Et,U(_e,Jt,J,Z,it,Q,_t,et,J==="comma"&&Gt&&o(Y)?null:ft,wt,Rt,It,pt,xt,Ct,Gt,st,De))}}return Et},k=function(G){if(!G)return C;if(typeof G.allowEmptyArrays<"u"&&typeof G.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof G.encodeDotInKeys<"u"&&typeof G.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(G.encoder!==null&&typeof G.encoder<"u"&&typeof G.encoder!="function")throw new TypeError("Encoder has to be a function.");var X=G.charset||C.charset;if(typeof G.charset<"u"&&G.charset!=="utf-8"&&G.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var J=r.default;if(typeof G.format<"u"){if(!i.call(r.formatters,G.format))throw new TypeError("Unknown format option provided.");J=G.format}var Z=r.formatters[J],it=C.filter;(typeof G.filter=="function"||o(G.filter))&&(it=G.filter);var Q;if(G.arrayFormat in n?Q=G.arrayFormat:"indices"in G?Q=G.indices?"indices":"repeat":Q=C.arrayFormat,"commaRoundTrip"in G&&typeof G.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var _t=typeof G.allowDots>"u"?G.encodeDotInKeys===!0?!0:C.allowDots:!!G.allowDots;return{addQueryPrefix:typeof G.addQueryPrefix=="boolean"?G.addQueryPrefix:C.addQueryPrefix,allowDots:_t,allowEmptyArrays:typeof G.allowEmptyArrays=="boolean"?!!G.allowEmptyArrays:C.allowEmptyArrays,arrayFormat:Q,charset:X,charsetSentinel:typeof G.charsetSentinel=="boolean"?G.charsetSentinel:C.charsetSentinel,commaRoundTrip:G.commaRoundTrip,delimiter:typeof G.delimiter>"u"?C.delimiter:G.delimiter,encode:typeof G.encode=="boolean"?G.encode:C.encode,encodeDotInKeys:typeof G.encodeDotInKeys=="boolean"?G.encodeDotInKeys:C.encodeDotInKeys,encoder:typeof G.encoder=="function"?G.encoder:C.encoder,encodeValuesOnly:typeof G.encodeValuesOnly=="boolean"?G.encodeValuesOnly:C.encodeValuesOnly,filter:it,format:J,formatter:Z,serializeDate:typeof G.serializeDate=="function"?G.serializeDate:C.serializeDate,skipNulls:typeof G.skipNulls=="boolean"?G.skipNulls:C.skipNulls,sort:typeof G.sort=="function"?G.sort:null,strictNullHandling:typeof G.strictNullHandling=="boolean"?G.strictNullHandling:C.strictNullHandling}};return Eh=function(U,G){var X=U,J=k(G),Z,it;typeof J.filter=="function"?(it=J.filter,X=it("",X)):o(J.filter)&&(it=J.filter,Z=it);var Q=[];if(typeof X!="object"||X===null)return"";var _t=n[J.arrayFormat],et=_t==="comma"&&J.commaRoundTrip;Z||(Z=Object.keys(X)),J.sort&&Z.sort(J.sort);for(var ft=s(),wt=0;wt<Z.length;++wt){var Rt=Z[wt];J.skipNulls&&X[Rt]===null||f(Q,D(X[Rt],Rt,_t,et,J.allowEmptyArrays,J.strictNullHandling,J.skipNulls,J.encodeDotInKeys,J.encode?J.encoder:null,J.filter,J.sort,J.allowDots,J.serializeDate,J.format,J.formatter,J.encodeValuesOnly,J.charset,ft))}var It=Q.join(J.delimiter),pt=J.addQueryPrefix===!0?"?":"";return J.charsetSentinel&&(J.charset==="iso-8859-1"?pt+="utf8=%26%2310003%3B&":pt+="utf8=%E2%9C%93&"),It.length>0?pt+It:""},Eh}var Ch,S0;function Y2(){if(S0)return Ch;S0=1;var s=E0(),t=Object.prototype.hasOwnProperty,r=Array.isArray,i={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:s.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},n=function(M){return M.replace(/&#(\d+);/g,function(D,k){return String.fromCharCode(parseInt(k,10))})},o=function(M,D){return M&&typeof M=="string"&&D.comma&&M.indexOf(",")>-1?M.split(","):M},h="utf8=%26%2310003%3B",f="utf8=%E2%9C%93",A=function(D,k){var U={__proto__:null},G=k.ignoreQueryPrefix?D.replace(/^\?/,""):D;G=G.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var X=k.parameterLimit===1/0?void 0:k.parameterLimit,J=G.split(k.delimiter,X),Z=-1,it,Q=k.charset;if(k.charsetSentinel)for(it=0;it<J.length;++it)J[it].indexOf("utf8=")===0&&(J[it]===f?Q="utf-8":J[it]===h&&(Q="iso-8859-1"),Z=it,it=J.length);for(it=0;it<J.length;++it)if(it!==Z){var _t=J[it],et=_t.indexOf("]="),ft=et===-1?_t.indexOf("="):et+1,wt,Rt;ft===-1?(wt=k.decoder(_t,i.decoder,Q,"key"),Rt=k.strictNullHandling?null:""):(wt=k.decoder(_t.slice(0,ft),i.decoder,Q,"key"),Rt=s.maybeMap(o(_t.slice(ft+1),k),function(pt){return k.decoder(pt,i.decoder,Q,"value")})),Rt&&k.interpretNumericEntities&&Q==="iso-8859-1"&&(Rt=n(Rt)),_t.indexOf("[]=")>-1&&(Rt=r(Rt)?[Rt]:Rt);var It=t.call(U,wt);It&&k.duplicates==="combine"?U[wt]=s.combine(U[wt],Rt):(!It||k.duplicates==="last")&&(U[wt]=Rt)}return U},T=function(M,D,k,U){for(var G=U?D:o(D,k),X=M.length-1;X>=0;--X){var J,Z=M[X];if(Z==="[]"&&k.parseArrays)J=k.allowEmptyArrays&&(G===""||k.strictNullHandling&&G===null)?[]:[].concat(G);else{J=k.plainObjects?Object.create(null):{};var it=Z.charAt(0)==="["&&Z.charAt(Z.length-1)==="]"?Z.slice(1,-1):Z,Q=k.decodeDotInKeys?it.replace(/%2E/g,"."):it,_t=parseInt(Q,10);!k.parseArrays&&Q===""?J={0:G}:!isNaN(_t)&&Z!==Q&&String(_t)===Q&&_t>=0&&k.parseArrays&&_t<=k.arrayLimit?(J=[],J[_t]=G):Q!=="__proto__"&&(J[Q]=G)}G=J}return G},C=function(D,k,U,G){if(D){var X=U.allowDots?D.replace(/\.([^.[]+)/g,"[$1]"):D,J=/(\[[^[\]]*])/,Z=/(\[[^[\]]*])/g,it=U.depth>0&&J.exec(X),Q=it?X.slice(0,it.index):X,_t=[];if(Q){if(!U.plainObjects&&t.call(Object.prototype,Q)&&!U.allowPrototypes)return;_t.push(Q)}for(var et=0;U.depth>0&&(it=Z.exec(X))!==null&&et<U.depth;){if(et+=1,!U.plainObjects&&t.call(Object.prototype,it[1].slice(1,-1))&&!U.allowPrototypes)return;_t.push(it[1])}if(it){if(U.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+U.depth+" and strictDepth is true");_t.push("["+X.slice(it.index)+"]")}return T(_t,k,U,G)}},x=function(D){if(!D)return i;if(typeof D.allowEmptyArrays<"u"&&typeof D.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof D.decodeDotInKeys<"u"&&typeof D.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(D.decoder!==null&&typeof D.decoder<"u"&&typeof D.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof D.charset<"u"&&D.charset!=="utf-8"&&D.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var k=typeof D.charset>"u"?i.charset:D.charset,U=typeof D.duplicates>"u"?i.duplicates:D.duplicates;if(U!=="combine"&&U!=="first"&&U!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var G=typeof D.allowDots>"u"?D.decodeDotInKeys===!0?!0:i.allowDots:!!D.allowDots;return{allowDots:G,allowEmptyArrays:typeof D.allowEmptyArrays=="boolean"?!!D.allowEmptyArrays:i.allowEmptyArrays,allowPrototypes:typeof D.allowPrototypes=="boolean"?D.allowPrototypes:i.allowPrototypes,allowSparse:typeof D.allowSparse=="boolean"?D.allowSparse:i.allowSparse,arrayLimit:typeof D.arrayLimit=="number"?D.arrayLimit:i.arrayLimit,charset:k,charsetSentinel:typeof D.charsetSentinel=="boolean"?D.charsetSentinel:i.charsetSentinel,comma:typeof D.comma=="boolean"?D.comma:i.comma,decodeDotInKeys:typeof D.decodeDotInKeys=="boolean"?D.decodeDotInKeys:i.decodeDotInKeys,decoder:typeof D.decoder=="function"?D.decoder:i.decoder,delimiter:typeof D.delimiter=="string"||s.isRegExp(D.delimiter)?D.delimiter:i.delimiter,depth:typeof D.depth=="number"||D.depth===!1?+D.depth:i.depth,duplicates:U,ignoreQueryPrefix:D.ignoreQueryPrefix===!0,interpretNumericEntities:typeof D.interpretNumericEntities=="boolean"?D.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof D.parameterLimit=="number"?D.parameterLimit:i.parameterLimit,parseArrays:D.parseArrays!==!1,plainObjects:typeof D.plainObjects=="boolean"?D.plainObjects:i.plainObjects,strictDepth:typeof D.strictDepth=="boolean"?!!D.strictDepth:i.strictDepth,strictNullHandling:typeof D.strictNullHandling=="boolean"?D.strictNullHandling:i.strictNullHandling}};return Ch=function(M,D){var k=x(D);if(M===""||M===null||typeof M>"u")return k.plainObjects?Object.create(null):{};for(var U=typeof M=="string"?A(M,k):M,G=k.plainObjects?Object.create(null):{},X=Object.keys(U),J=0;J<X.length;++J){var Z=X[J],it=C(Z,U[Z],k,typeof M=="string");G=s.merge(G,it,k)}return k.allowSparse===!0?G:s.compact(G)},Ch}var Sh,P0;function j2(){if(P0)return Sh;P0=1;var s=H2(),t=Y2(),r=wh();return Sh={formats:r,parse:t,stringify:s},Sh}var $0;function q2(){if($0)return Ls;$0=1;var s=S2();function t(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var r=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,n=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,o=["<",">",'"',"`"," ","\r",`
47
+ `," "],h=["{","}","|","\\","^","`"].concat(o),f=["'"].concat(h),A=["%","/","?",";","#"].concat(f),T=["/","?","#"],C=255,x=/^[+a-z0-9A-Z_-]{0,63}$/,M=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,D={javascript:!0,"javascript:":!0},k={javascript:!0,"javascript:":!0},U={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},G=j2();function X(Q,_t,et){if(Q&&typeof Q=="object"&&Q instanceof t)return Q;var ft=new t;return ft.parse(Q,_t,et),ft}t.prototype.parse=function(Q,_t,et){if(typeof Q!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof Q);var ft=Q.indexOf("?"),wt=ft!==-1&&ft<Q.indexOf("#")?"?":"#",Rt=Q.split(wt),It=/\\/g;Rt[0]=Rt[0].replace(It,"/"),Q=Rt.join(wt);var pt=Q;if(pt=pt.trim(),!et&&Q.split("#").length===1){var xt=n.exec(pt);if(xt)return this.path=pt,this.href=pt,this.pathname=xt[1],xt[2]?(this.search=xt[2],_t?this.query=G.parse(this.search.substr(1)):this.query=this.search.substr(1)):_t&&(this.search="",this.query={}),this}var Ct=r.exec(pt);if(Ct){Ct=Ct[0];var Gt=Ct.toLowerCase();this.protocol=Gt,pt=pt.substr(Ct.length)}if(et||Ct||pt.match(/^\/\/[^@/]+@[^@/]+/)){var st=pt.substr(0,2)==="//";st&&!(Ct&&k[Ct])&&(pt=pt.substr(2),this.slashes=!0)}if(!k[Ct]&&(st||Ct&&!U[Ct])){for(var nt=-1,Y=0;Y<T.length;Y++){var gt=pt.indexOf(T[Y]);gt!==-1&&(nt===-1||gt<nt)&&(nt=gt)}var ot,ht;nt===-1?ht=pt.lastIndexOf("@"):ht=pt.lastIndexOf("@",nt),ht!==-1&&(ot=pt.slice(0,ht),pt=pt.slice(ht+1),this.auth=decodeURIComponent(ot)),nt=-1;for(var Y=0;Y<A.length;Y++){var gt=pt.indexOf(A[Y]);gt!==-1&&(nt===-1||gt<nt)&&(nt=gt)}nt===-1&&(nt=pt.length),this.host=pt.slice(0,nt),pt=pt.slice(nt),this.parseHost(),this.hostname=this.hostname||"";var dt=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!dt)for(var At=this.hostname.split(/\./),Y=0,Et=At.length;Y<Et;Y++){var Dt=At[Y];if(Dt&&!Dt.match(x)){for(var oe="",kt=0,se=Dt.length;kt<se;kt++)Dt.charCodeAt(kt)>127?oe+="x":oe+=Dt[kt];if(!oe.match(x)){var Kt=At.slice(0,Y),Xt=At.slice(Y+1),_e=Dt.match(M);_e&&(Kt.push(_e[1]),Xt.unshift(_e[2])),Xt.length&&(pt="/"+Xt.join(".")+pt),this.hostname=Kt.join(".");break}}}this.hostname.length>C?this.hostname="":this.hostname=this.hostname.toLowerCase(),dt||(this.hostname=s.toASCII(this.hostname));var $e=this.port?":"+this.port:"",Jt=this.hostname||"";this.host=Jt+$e,this.href+=this.host,dt&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),pt[0]!=="/"&&(pt="/"+pt))}if(!D[Gt])for(var Y=0,Et=f.length;Y<Et;Y++){var De=f[Y];if(pt.indexOf(De)!==-1){var xe=encodeURIComponent(De);xe===De&&(xe=escape(De)),pt=pt.split(De).join(xe)}}var ae=pt.indexOf("#");ae!==-1&&(this.hash=pt.substr(ae),pt=pt.slice(0,ae));var Lr=pt.indexOf("?");if(Lr!==-1?(this.search=pt.substr(Lr),this.query=pt.substr(Lr+1),_t&&(this.query=G.parse(this.query)),pt=pt.slice(0,Lr)):_t&&(this.search="",this.query={}),pt&&(this.pathname=pt),U[Gt]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var $e=this.pathname||"",vr=this.search||"";this.path=$e+vr}return this.href=this.format(),this};function J(Q){return typeof Q=="string"&&(Q=X(Q)),Q instanceof t?Q.format():t.prototype.format.call(Q)}t.prototype.format=function(){var Q=this.auth||"";Q&&(Q=encodeURIComponent(Q),Q=Q.replace(/%3A/i,":"),Q+="@");var _t=this.protocol||"",et=this.pathname||"",ft=this.hash||"",wt=!1,Rt="";this.host?wt=Q+this.host:this.hostname&&(wt=Q+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(wt+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(Rt=G.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var It=this.search||Rt&&"?"+Rt||"";return _t&&_t.substr(-1)!==":"&&(_t+=":"),this.slashes||(!_t||U[_t])&&wt!==!1?(wt="//"+(wt||""),et&&et.charAt(0)!=="/"&&(et="/"+et)):wt||(wt=""),ft&&ft.charAt(0)!=="#"&&(ft="#"+ft),It&&It.charAt(0)!=="?"&&(It="?"+It),et=et.replace(/[?#]/g,function(pt){return encodeURIComponent(pt)}),It=It.replace("#","%23"),_t+wt+et+It+ft};function Z(Q,_t){return X(Q,!1,!0).resolve(_t)}t.prototype.resolve=function(Q){return this.resolveObject(X(Q,!1,!0)).format()};function it(Q,_t){return Q?X(Q,!1,!0).resolveObject(_t):_t}return t.prototype.resolveObject=function(Q){if(typeof Q=="string"){var _t=new t;_t.parse(Q,!1,!0),Q=_t}for(var et=new t,ft=Object.keys(this),wt=0;wt<ft.length;wt++){var Rt=ft[wt];et[Rt]=this[Rt]}if(et.hash=Q.hash,Q.href==="")return et.href=et.format(),et;if(Q.slashes&&!Q.protocol){for(var It=Object.keys(Q),pt=0;pt<It.length;pt++){var xt=It[pt];xt!=="protocol"&&(et[xt]=Q[xt])}return U[et.protocol]&&et.hostname&&!et.pathname&&(et.pathname="/",et.path=et.pathname),et.href=et.format(),et}if(Q.protocol&&Q.protocol!==et.protocol){if(!U[Q.protocol]){for(var Ct=Object.keys(Q),Gt=0;Gt<Ct.length;Gt++){var st=Ct[Gt];et[st]=Q[st]}return et.href=et.format(),et}if(et.protocol=Q.protocol,!Q.host&&!k[Q.protocol]){for(var Et=(Q.pathname||"").split("/");Et.length&&!(Q.host=Et.shift()););Q.host||(Q.host=""),Q.hostname||(Q.hostname=""),Et[0]!==""&&Et.unshift(""),Et.length<2&&Et.unshift(""),et.pathname=Et.join("/")}else et.pathname=Q.pathname;if(et.search=Q.search,et.query=Q.query,et.host=Q.host||"",et.auth=Q.auth,et.hostname=Q.hostname||Q.host,et.port=Q.port,et.pathname||et.search){var nt=et.pathname||"",Y=et.search||"";et.path=nt+Y}return et.slashes=et.slashes||Q.slashes,et.href=et.format(),et}var gt=et.pathname&&et.pathname.charAt(0)==="/",ot=Q.host||Q.pathname&&Q.pathname.charAt(0)==="/",ht=ot||gt||et.host&&Q.pathname,dt=ht,At=et.pathname&&et.pathname.split("/")||[],Et=Q.pathname&&Q.pathname.split("/")||[],Dt=et.protocol&&!U[et.protocol];if(Dt&&(et.hostname="",et.port=null,et.host&&(At[0]===""?At[0]=et.host:At.unshift(et.host)),et.host="",Q.protocol&&(Q.hostname=null,Q.port=null,Q.host&&(Et[0]===""?Et[0]=Q.host:Et.unshift(Q.host)),Q.host=null),ht=ht&&(Et[0]===""||At[0]==="")),ot)et.host=Q.host||Q.host===""?Q.host:et.host,et.hostname=Q.hostname||Q.hostname===""?Q.hostname:et.hostname,et.search=Q.search,et.query=Q.query,At=Et;else if(Et.length)At||(At=[]),At.pop(),At=At.concat(Et),et.search=Q.search,et.query=Q.query;else if(Q.search!=null){if(Dt){et.host=At.shift(),et.hostname=et.host;var oe=et.host&&et.host.indexOf("@")>0?et.host.split("@"):!1;oe&&(et.auth=oe.shift(),et.hostname=oe.shift(),et.host=et.hostname)}return et.search=Q.search,et.query=Q.query,(et.pathname!==null||et.search!==null)&&(et.path=(et.pathname?et.pathname:"")+(et.search?et.search:"")),et.href=et.format(),et}if(!At.length)return et.pathname=null,et.search?et.path="/"+et.search:et.path=null,et.href=et.format(),et;for(var kt=At.slice(-1)[0],se=(et.host||Q.host||At.length>1)&&(kt==="."||kt==="..")||kt==="",Kt=0,Xt=At.length;Xt>=0;Xt--)kt=At[Xt],kt==="."?At.splice(Xt,1):kt===".."?(At.splice(Xt,1),Kt++):Kt&&(At.splice(Xt,1),Kt--);if(!ht&&!dt)for(;Kt--;Kt)At.unshift("..");ht&&At[0]!==""&&(!At[0]||At[0].charAt(0)!=="/")&&At.unshift(""),se&&At.join("/").substr(-1)!=="/"&&At.push("");var _e=At[0]===""||At[0]&&At[0].charAt(0)==="/";if(Dt){et.hostname=_e?"":At.length?At.shift():"",et.host=et.hostname;var oe=et.host&&et.host.indexOf("@")>0?et.host.split("@"):!1;oe&&(et.auth=oe.shift(),et.hostname=oe.shift(),et.host=et.hostname)}return ht=ht||et.host&&At.length,ht&&!_e&&At.unshift(""),At.length>0?et.pathname=At.join("/"):(et.pathname=null,et.path=null),(et.pathname!==null||et.search!==null)&&(et.path=(et.pathname?et.pathname:"")+(et.search?et.search:"")),et.auth=Q.auth||et.auth,et.slashes=et.slashes||Q.slashes,et.href=et.format(),et},t.prototype.parseHost=function(){var Q=this.host,_t=i.exec(Q);_t&&(_t=_t[0],_t!==":"&&(this.port=_t.substr(1)),Q=Q.substr(0,Q.length-_t.length)),Q&&(this.hostname=Q)},Ls.parse=X,Ls.resolve=Z,Ls.resolveObject=it,Ls.format=J,Ls.Url=t,Ls}var Ph=q2();const M0={};function Oe(s,t,r=3){if(M0[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
48
48
  Deprecated since v${s}`):(i=i.split(`
49
49
  `).splice(r).join(`
50
50
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
51
51
  Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
52
- Deprecated since v${s}`),console.warn(i))),R0[t]=!0}const No={get parse(){return Oe("7.3.0","utils.url.parse is deprecated, use native URL API instead."),$h.parse},get format(){return Oe("7.3.0","utils.url.format is deprecated, use native URL API instead."),$h.format},get resolve(){return Oe("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),$h.resolve}};function Si(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function $n(s){return s.split("?")[0].split("#")[0]}function Z2(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q2(s,t,r){return s.replace(new RegExp(Z2(t),"g"),r)}function K2(s,t){let r="",i=0,n=-1,o=0,h=-1;for(let f=0;f<=s.length;++f){if(f<s.length)h=s.charCodeAt(f);else{if(h===47)break;h=47}if(h===47){if(!(n===f-1||o===1))if(n!==f-1&&o===2){if(r.length<2||i!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){const A=r.lastIndexOf("/");if(A!==r.length-1){A===-1?(r="",i=0):(r=r.slice(0,A),i=r.length-1-r.lastIndexOf("/")),n=f,o=0;continue}}else if(r.length===2||r.length===1){r="",i=0,n=f,o=0;continue}}}else r.length>0?r+=`/${s.slice(n+1,f)}`:r=s.slice(n+1,f),i=f-n-1;n=f,o=0}else h===46&&o!==-1?++o:o=-1}return r}const Pr={toPosix(s){return Q2(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Si(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const r=/^[^/:]+:\/{0,2}/.exec(s);return r?r[0]:""},toAbsolute(s,t,r){if(Si(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=$n(this.toPosix(t??ue.ADAPTER.getBaseUrl())),n=$n(this.toPosix(r??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Pr.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Si(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const r=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=K2(s),s.length>0&&i&&(s+="/"),r?`/${s}`:t+s},isAbsolute(s){return Si(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let r=0;r<s.length;++r){const i=s[r];if(Si(i),i.length>0)if(t===void 0)t=i;else{const n=s[r-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Si(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const r=t===47;let i=-1,n=!0;const o=this.getProtocol(s),h=s;s=s.slice(o.length);for(let f=s.length-1;f>=1;--f)if(t=s.charCodeAt(f),t===47){if(!n){i=f;break}}else n=!1;return i===-1?r?"/":this.isUrl(h)?o+s:o:r&&i===1?"//":o+s.slice(0,i)},rootname(s){Si(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const r=s.indexOf("/",t.length);r!==-1?t=s.slice(0,r):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){Si(s),t&&Si(t),s=$n(this.toPosix(s));let r=0,i=-1,n=!0,o;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let h=t.length-1,f=-1;for(o=s.length-1;o>=0;--o){const A=s.charCodeAt(o);if(A===47){if(!n){r=o+1;break}}else f===-1&&(n=!1,f=o+1),h>=0&&(A===t.charCodeAt(h)?--h===-1&&(i=o):(h=-1,i=f))}return r===i?i=f:i===-1&&(i=s.length),s.slice(r,i)}for(o=s.length-1;o>=0;--o)if(s.charCodeAt(o)===47){if(!n){r=o+1;break}}else i===-1&&(n=!1,i=o+1);return i===-1?"":s.slice(r,i)},extname(s){Si(s),s=$n(this.toPosix(s));let t=-1,r=0,i=-1,n=!0,o=0;for(let h=s.length-1;h>=0;--h){const f=s.charCodeAt(h);if(f===47){if(!n){r=h+1;break}continue}i===-1&&(n=!1,i=h+1),f===46?t===-1?t=h:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===r+1?"":s.slice(t,i)},parse(s){Si(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=$n(this.toPosix(s));let r=s.charCodeAt(0);const i=this.isAbsolute(s);let n;t.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let o=-1,h=0,f=-1,A=!0,T=s.length-1,C=0;for(;T>=n;--T){if(r=s.charCodeAt(T),r===47){if(!A){h=T+1;break}continue}f===-1&&(A=!1,f=T+1),r===46?o===-1?o=T:C!==1&&(C=1):o!==-1&&(C=-1)}return o===-1||f===-1||C===0||C===1&&o===f-1&&o===h+1?f!==-1&&(h===0&&i?t.base=t.name=s.slice(1,f):t.base=t.name=s.slice(h,f)):(h===0&&i?(t.name=s.slice(1,o),t.base=s.slice(1,f)):(t.name=s.slice(h,o),t.base=s.slice(h,f)),t.ext=s.slice(o,f)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Mh;async function I0(){return Mh??(Mh=(async()=>{var o;const s=document.createElement("canvas").getContext("webgl");if(!s)return Vr.UNPACK;const t=await new Promise(h=>{const f=document.createElement("video");f.onloadeddata=()=>h(f),f.onerror=()=>h(null),f.autoplay=!1,f.crossOrigin="anonymous",f.preload="auto",f.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",f.load()});if(!t)return Vr.UNPACK;const r=s.createTexture();s.bindTexture(s.TEXTURE_2D,r);const i=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,i),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,n),s.deleteFramebuffer(i),s.deleteTexture(r),(o=s.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?Vr.PMA:Vr.UNPACK})()),Mh}function J2(){Oe("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function tp(){Oe("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let Rh;function D0(){return typeof Rh>"u"&&(Rh=function(){var t;const s={stencil:!0,failIfMajorPerformanceCaveat:ue.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!ue.ADAPTER.getWebGLRenderingContext())return!1;const r=ue.ADAPTER.createCanvas();let i=r.getContext("webgl",s)||r.getContext("experimental-webgl",s);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const o=i.getExtension("WEBGL_lose_context");o&&o.loseContext()}return i=null,n}catch{return!1}}()),Rh}var ep={grad:.9,turn:360,rad:360/(2*Math.PI)},os=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Ir=function(s,t,r){return t===void 0&&(t=0),r===void 0&&(r=Math.pow(10,t)),Math.round(r*s)/r+0},ci=function(s,t,r){return t===void 0&&(t=0),r===void 0&&(r=1),s>r?r:s>t?s:t},F0=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},L0=function(s){return{r:ci(s.r,0,255),g:ci(s.g,0,255),b:ci(s.b,0,255),a:ci(s.a)}},Ih=function(s){return{r:Ir(s.r),g:Ir(s.g),b:Ir(s.b),a:Ir(s.a,3)}},rp=/^#([0-9a-f]{3,8})$/i,Uo=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},B0=function(s){var t=s.r,r=s.g,i=s.b,n=s.a,o=Math.max(t,r,i),h=o-Math.min(t,r,i),f=h?o===t?(r-i)/h:o===r?2+(i-t)/h:4+(t-r)/h:0;return{h:60*(f<0?f+6:f),s:o?h/o*100:0,v:o/255*100,a:n}},k0=function(s){var t=s.h,r=s.s,i=s.v,n=s.a;t=t/360*6,r/=100,i/=100;var o=Math.floor(t),h=i*(1-r),f=i*(1-(t-o)*r),A=i*(1-(1-t+o)*r),T=o%6;return{r:255*[i,f,h,h,A,i][T],g:255*[A,i,i,f,h,h][T],b:255*[h,h,A,i,i,f][T],a:n}},O0=function(s){return{h:F0(s.h),s:ci(s.s,0,100),l:ci(s.l,0,100),a:ci(s.a)}},N0=function(s){return{h:Ir(s.h),s:Ir(s.s),l:Ir(s.l),a:Ir(s.a,3)}},U0=function(s){return k0((r=(t=s).s,{h:t.h,s:(r*=((i=t.l)<50?i:100-i)/100)>0?2*r/(i+r)*100:0,v:i+r,a:t.a}));var t,r,i},Mn=function(s){return{h:(t=B0(s)).h,s:(n=(200-(r=t.s))*(i=t.v)/100)>0&&n<200?r*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,r,i,n},ip=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sp=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,np=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,op=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Dh={string:[[function(s){var t=rp.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Ir(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Ir(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=np.exec(s)||op.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:L0({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=ip.exec(s)||sp.exec(s);if(!t)return null;var r,i,n=O0({h:(r=t[1],i=t[2],i===void 0&&(i="deg"),Number(r)*(ep[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return U0(n)},"hsl"]],object:[[function(s){var t=s.r,r=s.g,i=s.b,n=s.a,o=n===void 0?1:n;return os(t)&&os(r)&&os(i)?L0({r:Number(t),g:Number(r),b:Number(i),a:Number(o)}):null},"rgb"],[function(s){var t=s.h,r=s.s,i=s.l,n=s.a,o=n===void 0?1:n;if(!os(t)||!os(r)||!os(i))return null;var h=O0({h:Number(t),s:Number(r),l:Number(i),a:Number(o)});return U0(h)},"hsl"],[function(s){var t=s.h,r=s.s,i=s.v,n=s.a,o=n===void 0?1:n;if(!os(t)||!os(r)||!os(i))return null;var h=function(f){return{h:F0(f.h),s:ci(f.s,0,100),v:ci(f.v,0,100),a:ci(f.a)}}({h:Number(t),s:Number(r),v:Number(i),a:Number(o)});return k0(h)},"hsv"]]},G0=function(s,t){for(var r=0;r<t.length;r++){var i=t[r][0](s);if(i)return[i,t[r][1]]}return[null,void 0]},ap=function(s){return typeof s=="string"?G0(s.trim(),Dh.string):typeof s=="object"&&s!==null?G0(s,Dh.object):[null,void 0]},Fh=function(s,t){var r=Mn(s);return{h:r.h,s:ci(r.s+100*t,0,100),l:r.l,a:r.a}},Lh=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},V0=function(s,t){var r=Mn(s);return{h:r.h,s:r.s,l:ci(r.l+100*t,0,100),a:r.a}},Bh=function(){function s(t){this.parsed=ap(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Ir(Lh(this.rgba),2)},s.prototype.isDark=function(){return Lh(this.rgba)<.5},s.prototype.isLight=function(){return Lh(this.rgba)>=.5},s.prototype.toHex=function(){return t=Ih(this.rgba),r=t.r,i=t.g,n=t.b,h=(o=t.a)<1?Uo(Ir(255*o)):"","#"+Uo(r)+Uo(i)+Uo(n)+h;var t,r,i,n,o,h},s.prototype.toRgb=function(){return Ih(this.rgba)},s.prototype.toRgbString=function(){return t=Ih(this.rgba),r=t.r,i=t.g,n=t.b,(o=t.a)<1?"rgba("+r+", "+i+", "+n+", "+o+")":"rgb("+r+", "+i+", "+n+")";var t,r,i,n,o},s.prototype.toHsl=function(){return N0(Mn(this.rgba))},s.prototype.toHslString=function(){return t=N0(Mn(this.rgba)),r=t.h,i=t.s,n=t.l,(o=t.a)<1?"hsla("+r+", "+i+"%, "+n+"%, "+o+")":"hsl("+r+", "+i+"%, "+n+"%)";var t,r,i,n,o},s.prototype.toHsv=function(){return t=B0(this.rgba),{h:Ir(t.h),s:Ir(t.s),v:Ir(t.v),a:Ir(t.a,3)};var t},s.prototype.invert=function(){return zi({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),zi(Fh(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),zi(Fh(this.rgba,-t))},s.prototype.grayscale=function(){return zi(Fh(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),zi(V0(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),zi(V0(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?zi({r:(r=this.rgba).r,g:r.g,b:r.b,a:t}):Ir(this.rgba.a,3);var r},s.prototype.hue=function(t){var r=Mn(this.rgba);return typeof t=="number"?zi({h:t,s:r.s,l:r.l,a:r.a}):Ir(r.h)},s.prototype.isEqual=function(t){return this.toHex()===zi(t).toHex()},s}(),zi=function(s){return s instanceof Bh?s:new Bh(s)},z0=[],hp=function(s){s.forEach(function(t){z0.indexOf(t)<0&&(t(Bh,Dh),z0.push(t))})};function lp(s,t){var r={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in r)i[r[n]]=n;var o={};s.prototype.toName=function(h){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var f,A,T=i[this.toHex()];if(T)return T;if(h!=null&&h.closest){var C=this.toRgb(),x=1/0,M="black";if(!o.length)for(var D in r)o[D]=new s(r[D]).toRgb();for(var k in r){var U=(f=C,A=o[k],Math.pow(f.r-A.r,2)+Math.pow(f.g-A.g,2)+Math.pow(f.b-A.b,2));U<x&&(x=U,M=k)}return M}},t.string.push([function(h){var f=h.toLowerCase(),A=f==="transparent"?"#0000":r[f];return A?new s(A).toRgb():null},"name"])}hp([lp]);const tn=class Ua{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Ua)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,r){const i=typeof t;if(i!==typeof r)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===r;if(Array.isArray(t)&&Array.isArray(r)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(r))return t.length!==r.length?!1:t.every((n,o)=>n===r[o]);if(t!==null&&r!==null){const n=Object.keys(t),o=Object.keys(r);return n.length!==o.length?!1:n.every(h=>t[h]===r[h])}return t===r}toRgba(){const[t,r,i,n]=this._components;return{r:t,g:r,b:i,a:n}}toRgb(){const[t,r,i]=this._components;return{r:t,g:r,b:i}}toRgbaString(){const[t,r,i]=this.toUint8RgbArray();return`rgba(${t},${r},${i},${this.alpha})`}toUint8RgbArray(t){const[r,i,n]=this._components;return t=t??[],t[0]=Math.round(r*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toRgbArray(t){t=t??[];const[r,i,n]=this._components;return t[0]=r,t[1]=i,t[2]=n,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[r,i,n,o]=Ua.temp.setValue(t)._components;return this._components[0]*=r,this._components[1]*=i,this._components[2]*=n,this._components[3]*=o,this.refreshInt(),this._value=null,this}premultiply(t,r=!0){return r&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,r=!0){if(t===1)return(255<<24)+this._int;if(t===0)return r?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,o=this._int&255;return r&&(i=i*t+.5|0,n=n*t+.5|0,o=o*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+o}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[r,i,n]=this._components;return this._components[0]=Math.round(r*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(n*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[r,i,n,o]=this._components;return t[0]=r,t[1]=i,t[2]=n,t[3]=o,t}normalize(t){let r,i,n,o;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const h=t;r=(h>>16&255)/255,i=(h>>8&255)/255,n=(h&255)/255,o=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[r,i,n,o=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[r,i,n,o=255]=t,r/=255,i/=255,n/=255,o/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const f=Ua.HEX_PATTERN.exec(t);f&&(t=`#${f[2]}`)}const h=zi(t);h.isValid()&&({r,g:i,b:n,a:o}=h.rgba,r/=255,i/=255,n/=255)}if(r!==void 0)this._components[0]=r,this._components[1]=i,this._components[2]=n,this._components[3]=o,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,r,i]=this._components;this._int=(t*255<<16)+(r*255<<8)+(i*255|0)}_clamp(t,r=0,i=1){return typeof t=="number"?Math.min(Math.max(t,r),i):(t.forEach((n,o)=>{t[o]=Math.min(Math.max(n,r),i)}),t)}};tn.shared=new tn,tn.temp=new tn,tn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rr=tn;function up(s,t=[]){return Oe("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),rr.shared.setValue(s).toRgbArray(t)}function X0(s){return Oe("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),rr.shared.setValue(s).toHex()}function cp(s){return Oe("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),rr.shared.setValue(s).toNumber()}function W0(s){return Oe("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),rr.shared.setValue(s).toNumber()}function fp(){const s=[],t=[];for(let i=0;i<32;i++)s[i]=i,t[i]=i;s[Re.NORMAL_NPM]=Re.NORMAL,s[Re.ADD_NPM]=Re.ADD,s[Re.SCREEN_NPM]=Re.SCREEN,t[Re.NORMAL]=Re.NORMAL_NPM,t[Re.ADD]=Re.ADD_NPM,t[Re.SCREEN]=Re.SCREEN_NPM;const r=[];return r.push(t),r.push(s),r}const kh=fp();function Oh(s,t){return kh[t?1:0][s]}function dp(s,t,r,i=!0){return Oe("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),rr.shared.setValue(s).premultiply(t,i).toArray(r??new Float32Array(4))}function pp(s,t){return Oe("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),rr.shared.setValue(s).toPremultiplied(t)}function _p(s,t,r,i=!0){return Oe("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),rr.shared.setValue(s).premultiply(t,i).toArray(r??new Float32Array(4))}const H0=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Y0(s,t=null){const r=s*6;if(t=t||new Uint16Array(r),t.length!==r)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${r}`);for(let i=0,n=0;i<r;i+=6,n+=4)t[i+0]=n+0,t[i+1]=n+1,t[i+2]=n+2,t[i+3]=n+0,t[i+4]=n+2,t[i+5]=n+3;return t}function Go(s){if(s.BYTES_PER_ELEMENT===4)return s instanceof Float32Array?"Float32Array":s instanceof Uint32Array?"Uint32Array":"Int32Array";if(s.BYTES_PER_ELEMENT===2){if(s instanceof Uint16Array)return"Uint16Array"}else if(s.BYTES_PER_ELEMENT===1&&s instanceof Uint8Array)return"Uint8Array";return null}const gp={Float32Array,Uint32Array,Int32Array,Uint8Array};function mp(s,t){let r=0,i=0;const n={};for(let A=0;A<s.length;A++)i+=t[A],r+=s[A].length;const o=new ArrayBuffer(r*4);let h=null,f=0;for(let A=0;A<s.length;A++){const T=t[A],C=s[A],x=Go(C);n[x]||(n[x]=new gp[x](o)),h=n[x];for(let M=0;M<C.length;M++){const D=(M/T|0)*i+f,k=M%T;h[D+k]=C[M]}f+=T}return new Float32Array(o)}function Rn(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Nh(s){return!(s&s-1)&&!!s}function Uh(s){let t=(s>65535?1:0)<<4;s>>>=t;let r=(s>255?1:0)<<3;return s>>>=r,t|=r,r=(s>15?1:0)<<2,s>>>=r,t|=r,r=(s>3?1:0)<<1,s>>>=r,t|=r,t|s>>1}function Bs(s,t,r){const i=s.length;let n;if(t>=i||r===0)return;r=t+r>i?i-t:r;const o=i-r;for(n=t;n<o;++n)s[n]=s[n+r];s.length=o}function as(s){return s===0?0:s<0?-1:1}let yp=0;function vs(){return++yp}const Gh=class{constructor(s,t,r,i){this.left=s,this.top=t,this.right=r,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Gh.EMPTY=new Gh(0,0,0,0);let Vh=Gh;const zh={},zr=Object.create(null),ii=Object.create(null);function vp(){let s;for(s in zr)zr[s].destroy();for(s in ii)ii[s].destroy()}function xp(){let s;for(s in zr)delete zr[s];for(s in ii)delete ii[s]}class j0{constructor(t,r,i){this._canvas=ue.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||ue.RESOLUTION,this.resize(t,r)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,r){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(r*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function q0(s,t,r){for(let i=0,n=4*r*t;i<t;++i,n+=4)if(s[n+3]!==0)return!1;return!0}function Z0(s,t,r,i,n){const o=4*t;for(let h=i,f=i*o+4*r;h<=n;++h,f+=o)if(s[f+3]!==0)return!1;return!0}function Q0(s){const{width:t,height:r}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const n=i.getImageData(0,0,t,r).data;let o=0,h=0,f=t-1,A=r-1;for(;h<r&&q0(n,t,h);)++h;if(h===r)return Vh.EMPTY;for(;q0(n,t,A);)--A;for(;Z0(n,t,o,h,A);)++o;for(;Z0(n,t,f,h,A);)--f;return++f,++A,new Vh(o,h,f,A)}function K0(s){const t=Q0(s),{width:r,height:i}=t;let n=null;if(!t.isEmpty()){const o=s.getContext("2d");if(o===null)throw new TypeError("Failed to get canvas 2D context");n=o.getImageData(t.left,t.top,r,i)}return{width:r,height:i,data:n}}function bp(s){const t=H0.exec(s);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function J0(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const r=new URL(s,document.baseURI);return r.hostname!==t.hostname||r.port!==t.port||r.protocol!==t.protocol?"anonymous":""}function Xi(s,t=1){var i;const r=(i=ue.RETINA_PREFIX)==null?void 0:i.exec(s);return r?parseFloat(r[1]):t}const Ap=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:ii,BoundingBox:Vh,CanvasRenderTarget:j0,DATA_URI:H0,EventEmitter:ns,ProgramCache:zh,TextureCache:zr,clearTextureCache:xp,correctBlendMode:Oh,createIndicesForQuads:Y0,decomposeDataUri:bp,deprecation:Oe,destroyTextureCache:vp,detectVideoAlphaMode:I0,determineCrossOrigin:J0,earcut:Qu,getBufferType:Go,getCanvasBoundingBox:Q0,getResolutionOfUrl:Xi,hex2rgb:up,hex2string:X0,interleaveTypedArrays:mp,isMobile:Ci,isPow2:Nh,isWebGLSupported:D0,log2:Uh,nextPow2:Rn,path:Pr,premultiplyBlendMode:kh,premultiplyRgba:dp,premultiplyTint:pp,premultiplyTintToRgba:_p,removeItems:Bs,rgb2hex:W0,sayHello:tp,sign:as,skipHello:J2,string2hex:cp,trimCanvas:K0,uid:vs,url:No},Symbol.toStringTag,{value:"Module"}));var ee=(s=>(s.Renderer="renderer",s.Application="application",s.RendererSystem="renderer-webgl-system",s.RendererPlugin="renderer-webgl-plugin",s.CanvasRendererSystem="renderer-canvas-system",s.CanvasRendererPlugin="renderer-canvas-plugin",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s))(ee||{});const Xh=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},tc=(s,t)=>Xh(s).priority??t,be={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Xh).forEach(t=>{t.type.forEach(r=>{var i,n;return(n=(i=this._removeHandlers)[r])==null?void 0:n.call(i,t)})}),this},add(...s){return s.map(Xh).forEach(t=>{t.type.forEach(r=>{var o,h;const i=this._addHandlers,n=this._queue;i[r]?(o=i[r])==null||o.call(i,t):(n[r]=n[r]||[],(h=n[r])==null||h.push(t))})}),this},handle(s,t,r){var h;const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,n[s]=r;const o=this._queue;return o[s]&&((h=o[s])==null||h.forEach(f=>t(f)),delete o[s]),this},handleByMap(s,t){return this.handle(s,r=>{r.name&&(t[r.name]=r.ref)},r=>{r.name&&delete t[r.name]})},handleByList(s,t,r=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,o)=>tc(o,r)-tc(n,r)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}};class Vo{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const wp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
52
+ Deprecated since v${s}`),console.warn(i))),M0[t]=!0}const No={get parse(){return Oe("7.3.0","utils.url.parse is deprecated, use native URL API instead."),Ph.parse},get format(){return Oe("7.3.0","utils.url.format is deprecated, use native URL API instead."),Ph.format},get resolve(){return Oe("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),Ph.resolve}};function Si(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function $n(s){return s.split("?")[0].split("#")[0]}function Z2(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q2(s,t,r){return s.replace(new RegExp(Z2(t),"g"),r)}function K2(s,t){let r="",i=0,n=-1,o=0,h=-1;for(let f=0;f<=s.length;++f){if(f<s.length)h=s.charCodeAt(f);else{if(h===47)break;h=47}if(h===47){if(!(n===f-1||o===1))if(n!==f-1&&o===2){if(r.length<2||i!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){const A=r.lastIndexOf("/");if(A!==r.length-1){A===-1?(r="",i=0):(r=r.slice(0,A),i=r.length-1-r.lastIndexOf("/")),n=f,o=0;continue}}else if(r.length===2||r.length===1){r="",i=0,n=f,o=0;continue}}}else r.length>0?r+=`/${s.slice(n+1,f)}`:r=s.slice(n+1,f),i=f-n-1;n=f,o=0}else h===46&&o!==-1?++o:o=-1}return r}const Pr={toPosix(s){return Q2(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Si(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const r=/^[^/:]+:\/{0,2}/.exec(s);return r?r[0]:""},toAbsolute(s,t,r){if(Si(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=$n(this.toPosix(t??ue.ADAPTER.getBaseUrl())),n=$n(this.toPosix(r??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Pr.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Si(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const r=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=K2(s),s.length>0&&i&&(s+="/"),r?`/${s}`:t+s},isAbsolute(s){return Si(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let r=0;r<s.length;++r){const i=s[r];if(Si(i),i.length>0)if(t===void 0)t=i;else{const n=s[r-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Si(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const r=t===47;let i=-1,n=!0;const o=this.getProtocol(s),h=s;s=s.slice(o.length);for(let f=s.length-1;f>=1;--f)if(t=s.charCodeAt(f),t===47){if(!n){i=f;break}}else n=!1;return i===-1?r?"/":this.isUrl(h)?o+s:o:r&&i===1?"//":o+s.slice(0,i)},rootname(s){Si(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const r=s.indexOf("/",t.length);r!==-1?t=s.slice(0,r):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){Si(s),t&&Si(t),s=$n(this.toPosix(s));let r=0,i=-1,n=!0,o;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let h=t.length-1,f=-1;for(o=s.length-1;o>=0;--o){const A=s.charCodeAt(o);if(A===47){if(!n){r=o+1;break}}else f===-1&&(n=!1,f=o+1),h>=0&&(A===t.charCodeAt(h)?--h===-1&&(i=o):(h=-1,i=f))}return r===i?i=f:i===-1&&(i=s.length),s.slice(r,i)}for(o=s.length-1;o>=0;--o)if(s.charCodeAt(o)===47){if(!n){r=o+1;break}}else i===-1&&(n=!1,i=o+1);return i===-1?"":s.slice(r,i)},extname(s){Si(s),s=$n(this.toPosix(s));let t=-1,r=0,i=-1,n=!0,o=0;for(let h=s.length-1;h>=0;--h){const f=s.charCodeAt(h);if(f===47){if(!n){r=h+1;break}continue}i===-1&&(n=!1,i=h+1),f===46?t===-1?t=h:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===r+1?"":s.slice(t,i)},parse(s){Si(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=$n(this.toPosix(s));let r=s.charCodeAt(0);const i=this.isAbsolute(s);let n;t.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let o=-1,h=0,f=-1,A=!0,T=s.length-1,C=0;for(;T>=n;--T){if(r=s.charCodeAt(T),r===47){if(!A){h=T+1;break}continue}f===-1&&(A=!1,f=T+1),r===46?o===-1?o=T:C!==1&&(C=1):o!==-1&&(C=-1)}return o===-1||f===-1||C===0||C===1&&o===f-1&&o===h+1?f!==-1&&(h===0&&i?t.base=t.name=s.slice(1,f):t.base=t.name=s.slice(h,f)):(h===0&&i?(t.name=s.slice(1,o),t.base=s.slice(1,f)):(t.name=s.slice(h,o),t.base=s.slice(h,f)),t.ext=s.slice(o,f)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let $h;async function R0(){return $h??($h=(async()=>{var o;const s=document.createElement("canvas").getContext("webgl");if(!s)return Vr.UNPACK;const t=await new Promise(h=>{const f=document.createElement("video");f.onloadeddata=()=>h(f),f.onerror=()=>h(null),f.autoplay=!1,f.crossOrigin="anonymous",f.preload="auto",f.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",f.load()});if(!t)return Vr.UNPACK;const r=s.createTexture();s.bindTexture(s.TEXTURE_2D,r);const i=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,i),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,n),s.deleteFramebuffer(i),s.deleteTexture(r),(o=s.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?Vr.PMA:Vr.UNPACK})()),$h}function J2(){Oe("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function tp(){Oe("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let Mh;function I0(){return typeof Mh>"u"&&(Mh=function(){var t;const s={stencil:!0,failIfMajorPerformanceCaveat:ue.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!ue.ADAPTER.getWebGLRenderingContext())return!1;const r=ue.ADAPTER.createCanvas();let i=r.getContext("webgl",s)||r.getContext("experimental-webgl",s);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const o=i.getExtension("WEBGL_lose_context");o&&o.loseContext()}return i=null,n}catch{return!1}}()),Mh}var ep={grad:.9,turn:360,rad:360/(2*Math.PI)},os=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Ir=function(s,t,r){return t===void 0&&(t=0),r===void 0&&(r=Math.pow(10,t)),Math.round(r*s)/r+0},ci=function(s,t,r){return t===void 0&&(t=0),r===void 0&&(r=1),s>r?r:s>t?s:t},D0=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},F0=function(s){return{r:ci(s.r,0,255),g:ci(s.g,0,255),b:ci(s.b,0,255),a:ci(s.a)}},Rh=function(s){return{r:Ir(s.r),g:Ir(s.g),b:Ir(s.b),a:Ir(s.a,3)}},rp=/^#([0-9a-f]{3,8})$/i,Uo=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},L0=function(s){var t=s.r,r=s.g,i=s.b,n=s.a,o=Math.max(t,r,i),h=o-Math.min(t,r,i),f=h?o===t?(r-i)/h:o===r?2+(i-t)/h:4+(t-r)/h:0;return{h:60*(f<0?f+6:f),s:o?h/o*100:0,v:o/255*100,a:n}},B0=function(s){var t=s.h,r=s.s,i=s.v,n=s.a;t=t/360*6,r/=100,i/=100;var o=Math.floor(t),h=i*(1-r),f=i*(1-(t-o)*r),A=i*(1-(1-t+o)*r),T=o%6;return{r:255*[i,f,h,h,A,i][T],g:255*[A,i,i,f,h,h][T],b:255*[h,h,A,i,i,f][T],a:n}},k0=function(s){return{h:D0(s.h),s:ci(s.s,0,100),l:ci(s.l,0,100),a:ci(s.a)}},O0=function(s){return{h:Ir(s.h),s:Ir(s.s),l:Ir(s.l),a:Ir(s.a,3)}},N0=function(s){return B0((r=(t=s).s,{h:t.h,s:(r*=((i=t.l)<50?i:100-i)/100)>0?2*r/(i+r)*100:0,v:i+r,a:t.a}));var t,r,i},Mn=function(s){return{h:(t=L0(s)).h,s:(n=(200-(r=t.s))*(i=t.v)/100)>0&&n<200?r*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,r,i,n},ip=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sp=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,np=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,op=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ih={string:[[function(s){var t=rp.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Ir(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Ir(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=np.exec(s)||op.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:F0({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=ip.exec(s)||sp.exec(s);if(!t)return null;var r,i,n=k0({h:(r=t[1],i=t[2],i===void 0&&(i="deg"),Number(r)*(ep[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return N0(n)},"hsl"]],object:[[function(s){var t=s.r,r=s.g,i=s.b,n=s.a,o=n===void 0?1:n;return os(t)&&os(r)&&os(i)?F0({r:Number(t),g:Number(r),b:Number(i),a:Number(o)}):null},"rgb"],[function(s){var t=s.h,r=s.s,i=s.l,n=s.a,o=n===void 0?1:n;if(!os(t)||!os(r)||!os(i))return null;var h=k0({h:Number(t),s:Number(r),l:Number(i),a:Number(o)});return N0(h)},"hsl"],[function(s){var t=s.h,r=s.s,i=s.v,n=s.a,o=n===void 0?1:n;if(!os(t)||!os(r)||!os(i))return null;var h=function(f){return{h:D0(f.h),s:ci(f.s,0,100),v:ci(f.v,0,100),a:ci(f.a)}}({h:Number(t),s:Number(r),v:Number(i),a:Number(o)});return B0(h)},"hsv"]]},U0=function(s,t){for(var r=0;r<t.length;r++){var i=t[r][0](s);if(i)return[i,t[r][1]]}return[null,void 0]},ap=function(s){return typeof s=="string"?U0(s.trim(),Ih.string):typeof s=="object"&&s!==null?U0(s,Ih.object):[null,void 0]},Dh=function(s,t){var r=Mn(s);return{h:r.h,s:ci(r.s+100*t,0,100),l:r.l,a:r.a}},Fh=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},G0=function(s,t){var r=Mn(s);return{h:r.h,s:r.s,l:ci(r.l+100*t,0,100),a:r.a}},Lh=function(){function s(t){this.parsed=ap(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Ir(Fh(this.rgba),2)},s.prototype.isDark=function(){return Fh(this.rgba)<.5},s.prototype.isLight=function(){return Fh(this.rgba)>=.5},s.prototype.toHex=function(){return t=Rh(this.rgba),r=t.r,i=t.g,n=t.b,h=(o=t.a)<1?Uo(Ir(255*o)):"","#"+Uo(r)+Uo(i)+Uo(n)+h;var t,r,i,n,o,h},s.prototype.toRgb=function(){return Rh(this.rgba)},s.prototype.toRgbString=function(){return t=Rh(this.rgba),r=t.r,i=t.g,n=t.b,(o=t.a)<1?"rgba("+r+", "+i+", "+n+", "+o+")":"rgb("+r+", "+i+", "+n+")";var t,r,i,n,o},s.prototype.toHsl=function(){return O0(Mn(this.rgba))},s.prototype.toHslString=function(){return t=O0(Mn(this.rgba)),r=t.h,i=t.s,n=t.l,(o=t.a)<1?"hsla("+r+", "+i+"%, "+n+"%, "+o+")":"hsl("+r+", "+i+"%, "+n+"%)";var t,r,i,n,o},s.prototype.toHsv=function(){return t=L0(this.rgba),{h:Ir(t.h),s:Ir(t.s),v:Ir(t.v),a:Ir(t.a,3)};var t},s.prototype.invert=function(){return zi({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),zi(Dh(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),zi(Dh(this.rgba,-t))},s.prototype.grayscale=function(){return zi(Dh(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),zi(G0(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),zi(G0(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?zi({r:(r=this.rgba).r,g:r.g,b:r.b,a:t}):Ir(this.rgba.a,3);var r},s.prototype.hue=function(t){var r=Mn(this.rgba);return typeof t=="number"?zi({h:t,s:r.s,l:r.l,a:r.a}):Ir(r.h)},s.prototype.isEqual=function(t){return this.toHex()===zi(t).toHex()},s}(),zi=function(s){return s instanceof Lh?s:new Lh(s)},V0=[],hp=function(s){s.forEach(function(t){V0.indexOf(t)<0&&(t(Lh,Ih),V0.push(t))})};function lp(s,t){var r={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in r)i[r[n]]=n;var o={};s.prototype.toName=function(h){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var f,A,T=i[this.toHex()];if(T)return T;if(h!=null&&h.closest){var C=this.toRgb(),x=1/0,M="black";if(!o.length)for(var D in r)o[D]=new s(r[D]).toRgb();for(var k in r){var U=(f=C,A=o[k],Math.pow(f.r-A.r,2)+Math.pow(f.g-A.g,2)+Math.pow(f.b-A.b,2));U<x&&(x=U,M=k)}return M}},t.string.push([function(h){var f=h.toLowerCase(),A=f==="transparent"?"#0000":r[f];return A?new s(A).toRgb():null},"name"])}hp([lp]);const tn=class Na{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Na)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,r){const i=typeof t;if(i!==typeof r)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===r;if(Array.isArray(t)&&Array.isArray(r)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(r))return t.length!==r.length?!1:t.every((n,o)=>n===r[o]);if(t!==null&&r!==null){const n=Object.keys(t),o=Object.keys(r);return n.length!==o.length?!1:n.every(h=>t[h]===r[h])}return t===r}toRgba(){const[t,r,i,n]=this._components;return{r:t,g:r,b:i,a:n}}toRgb(){const[t,r,i]=this._components;return{r:t,g:r,b:i}}toRgbaString(){const[t,r,i]=this.toUint8RgbArray();return`rgba(${t},${r},${i},${this.alpha})`}toUint8RgbArray(t){const[r,i,n]=this._components;return t=t??[],t[0]=Math.round(r*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toRgbArray(t){t=t??[];const[r,i,n]=this._components;return t[0]=r,t[1]=i,t[2]=n,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[r,i,n,o]=Na.temp.setValue(t)._components;return this._components[0]*=r,this._components[1]*=i,this._components[2]*=n,this._components[3]*=o,this.refreshInt(),this._value=null,this}premultiply(t,r=!0){return r&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,r=!0){if(t===1)return(255<<24)+this._int;if(t===0)return r?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,o=this._int&255;return r&&(i=i*t+.5|0,n=n*t+.5|0,o=o*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+o}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[r,i,n]=this._components;return this._components[0]=Math.round(r*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(n*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[r,i,n,o]=this._components;return t[0]=r,t[1]=i,t[2]=n,t[3]=o,t}normalize(t){let r,i,n,o;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const h=t;r=(h>>16&255)/255,i=(h>>8&255)/255,n=(h&255)/255,o=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[r,i,n,o=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[r,i,n,o=255]=t,r/=255,i/=255,n/=255,o/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const f=Na.HEX_PATTERN.exec(t);f&&(t=`#${f[2]}`)}const h=zi(t);h.isValid()&&({r,g:i,b:n,a:o}=h.rgba,r/=255,i/=255,n/=255)}if(r!==void 0)this._components[0]=r,this._components[1]=i,this._components[2]=n,this._components[3]=o,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,r,i]=this._components;this._int=(t*255<<16)+(r*255<<8)+(i*255|0)}_clamp(t,r=0,i=1){return typeof t=="number"?Math.min(Math.max(t,r),i):(t.forEach((n,o)=>{t[o]=Math.min(Math.max(n,r),i)}),t)}};tn.shared=new tn,tn.temp=new tn,tn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rr=tn;function up(s,t=[]){return Oe("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),rr.shared.setValue(s).toRgbArray(t)}function z0(s){return Oe("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),rr.shared.setValue(s).toHex()}function cp(s){return Oe("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),rr.shared.setValue(s).toNumber()}function X0(s){return Oe("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),rr.shared.setValue(s).toNumber()}function fp(){const s=[],t=[];for(let i=0;i<32;i++)s[i]=i,t[i]=i;s[Re.NORMAL_NPM]=Re.NORMAL,s[Re.ADD_NPM]=Re.ADD,s[Re.SCREEN_NPM]=Re.SCREEN,t[Re.NORMAL]=Re.NORMAL_NPM,t[Re.ADD]=Re.ADD_NPM,t[Re.SCREEN]=Re.SCREEN_NPM;const r=[];return r.push(t),r.push(s),r}const Bh=fp();function kh(s,t){return Bh[t?1:0][s]}function dp(s,t,r,i=!0){return Oe("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),rr.shared.setValue(s).premultiply(t,i).toArray(r??new Float32Array(4))}function pp(s,t){return Oe("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),rr.shared.setValue(s).toPremultiplied(t)}function _p(s,t,r,i=!0){return Oe("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),rr.shared.setValue(s).premultiply(t,i).toArray(r??new Float32Array(4))}const W0=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function H0(s,t=null){const r=s*6;if(t=t||new Uint16Array(r),t.length!==r)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${r}`);for(let i=0,n=0;i<r;i+=6,n+=4)t[i+0]=n+0,t[i+1]=n+1,t[i+2]=n+2,t[i+3]=n+0,t[i+4]=n+2,t[i+5]=n+3;return t}function Go(s){if(s.BYTES_PER_ELEMENT===4)return s instanceof Float32Array?"Float32Array":s instanceof Uint32Array?"Uint32Array":"Int32Array";if(s.BYTES_PER_ELEMENT===2){if(s instanceof Uint16Array)return"Uint16Array"}else if(s.BYTES_PER_ELEMENT===1&&s instanceof Uint8Array)return"Uint8Array";return null}const gp={Float32Array,Uint32Array,Int32Array,Uint8Array};function mp(s,t){let r=0,i=0;const n={};for(let A=0;A<s.length;A++)i+=t[A],r+=s[A].length;const o=new ArrayBuffer(r*4);let h=null,f=0;for(let A=0;A<s.length;A++){const T=t[A],C=s[A],x=Go(C);n[x]||(n[x]=new gp[x](o)),h=n[x];for(let M=0;M<C.length;M++){const D=(M/T|0)*i+f,k=M%T;h[D+k]=C[M]}f+=T}return new Float32Array(o)}function Rn(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Oh(s){return!(s&s-1)&&!!s}function Nh(s){let t=(s>65535?1:0)<<4;s>>>=t;let r=(s>255?1:0)<<3;return s>>>=r,t|=r,r=(s>15?1:0)<<2,s>>>=r,t|=r,r=(s>3?1:0)<<1,s>>>=r,t|=r,t|s>>1}function Bs(s,t,r){const i=s.length;let n;if(t>=i||r===0)return;r=t+r>i?i-t:r;const o=i-r;for(n=t;n<o;++n)s[n]=s[n+r];s.length=o}function as(s){return s===0?0:s<0?-1:1}let yp=0;function vs(){return++yp}const Uh=class{constructor(s,t,r,i){this.left=s,this.top=t,this.right=r,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Uh.EMPTY=new Uh(0,0,0,0);let Gh=Uh;const Vh={},zr=Object.create(null),ii=Object.create(null);function vp(){let s;for(s in zr)zr[s].destroy();for(s in ii)ii[s].destroy()}function xp(){let s;for(s in zr)delete zr[s];for(s in ii)delete ii[s]}class Y0{constructor(t,r,i){this._canvas=ue.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||ue.RESOLUTION,this.resize(t,r)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,r){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(r*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function j0(s,t,r){for(let i=0,n=4*r*t;i<t;++i,n+=4)if(s[n+3]!==0)return!1;return!0}function q0(s,t,r,i,n){const o=4*t;for(let h=i,f=i*o+4*r;h<=n;++h,f+=o)if(s[f+3]!==0)return!1;return!0}function Z0(s){const{width:t,height:r}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const n=i.getImageData(0,0,t,r).data;let o=0,h=0,f=t-1,A=r-1;for(;h<r&&j0(n,t,h);)++h;if(h===r)return Gh.EMPTY;for(;j0(n,t,A);)--A;for(;q0(n,t,o,h,A);)++o;for(;q0(n,t,f,h,A);)--f;return++f,++A,new Gh(o,h,f,A)}function Q0(s){const t=Z0(s),{width:r,height:i}=t;let n=null;if(!t.isEmpty()){const o=s.getContext("2d");if(o===null)throw new TypeError("Failed to get canvas 2D context");n=o.getImageData(t.left,t.top,r,i)}return{width:r,height:i,data:n}}function bp(s){const t=W0.exec(s);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function K0(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const r=new URL(s,document.baseURI);return r.hostname!==t.hostname||r.port!==t.port||r.protocol!==t.protocol?"anonymous":""}function Xi(s,t=1){var i;const r=(i=ue.RETINA_PREFIX)==null?void 0:i.exec(s);return r?parseFloat(r[1]):t}const Ap=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:ii,BoundingBox:Gh,CanvasRenderTarget:Y0,DATA_URI:W0,EventEmitter:ns,ProgramCache:Vh,TextureCache:zr,clearTextureCache:xp,correctBlendMode:kh,createIndicesForQuads:H0,decomposeDataUri:bp,deprecation:Oe,destroyTextureCache:vp,detectVideoAlphaMode:R0,determineCrossOrigin:K0,earcut:Zu,getBufferType:Go,getCanvasBoundingBox:Z0,getResolutionOfUrl:Xi,hex2rgb:up,hex2string:z0,interleaveTypedArrays:mp,isMobile:Ci,isPow2:Oh,isWebGLSupported:I0,log2:Nh,nextPow2:Rn,path:Pr,premultiplyBlendMode:Bh,premultiplyRgba:dp,premultiplyTint:pp,premultiplyTintToRgba:_p,removeItems:Bs,rgb2hex:X0,sayHello:tp,sign:as,skipHello:J2,string2hex:cp,trimCanvas:Q0,uid:vs,url:No},Symbol.toStringTag,{value:"Module"}));var ee=(s=>(s.Renderer="renderer",s.Application="application",s.RendererSystem="renderer-webgl-system",s.RendererPlugin="renderer-webgl-plugin",s.CanvasRendererSystem="renderer-canvas-system",s.CanvasRendererPlugin="renderer-canvas-plugin",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s))(ee||{});const zh=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},J0=(s,t)=>zh(s).priority??t,Te={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(zh).forEach(t=>{t.type.forEach(r=>{var i,n;return(n=(i=this._removeHandlers)[r])==null?void 0:n.call(i,t)})}),this},add(...s){return s.map(zh).forEach(t=>{t.type.forEach(r=>{var o,h;const i=this._addHandlers,n=this._queue;i[r]?(o=i[r])==null||o.call(i,t):(n[r]=n[r]||[],(h=n[r])==null||h.push(t))})}),this},handle(s,t,r){var h;const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,n[s]=r;const o=this._queue;return o[s]&&((h=o[s])==null||h.forEach(f=>t(f)),delete o[s]),this},handleByMap(s,t){return this.handle(s,r=>{r.name&&(t[r.name]=r.ref)},r=>{r.name&&delete t[r.name]})},handleByList(s,t,r=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,o)=>J0(o,r)-J0(n,r)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}};class Vo{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const wp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
53
53
  `);function Tp(s){let t="";for(let r=0;r<s;++r)r>0&&(t+=`
54
- else `),r<s-1&&(t+=`if(test == ${r}.0){}`);return t}function ec(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const r=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=wp.replace(/%forloop%/gi,Tp(s));if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))s=s/2|0;else break}return s}const Wh=0,Hh=1,Yh=2,jh=3,qh=4,Zh=5;class Pi{constructor(){this.data=0,this.blendMode=Re.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Wh)}set blend(t){!!(this.data&1<<Wh)!==t&&(this.data^=1<<Wh)}get offsets(){return!!(this.data&1<<Hh)}set offsets(t){!!(this.data&1<<Hh)!==t&&(this.data^=1<<Hh)}get culling(){return!!(this.data&1<<Yh)}set culling(t){!!(this.data&1<<Yh)!==t&&(this.data^=1<<Yh)}get depthTest(){return!!(this.data&1<<jh)}set depthTest(t){!!(this.data&1<<jh)!==t&&(this.data^=1<<jh)}get depthMask(){return!!(this.data&1<<Zh)}set depthMask(t){!!(this.data&1<<Zh)!==t&&(this.data^=1<<Zh)}get clockwiseFrontFace(){return!!(this.data&1<<qh)}set clockwiseFrontFace(t){!!(this.data&1<<qh)!==t&&(this.data^=1<<qh)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Re.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Pi;return t.depthTest=!1,t.blend=!0,t}}Pi.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const zo=[];function Qh(s,t){if(!s)return null;let r="";if(typeof s=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(s);i&&(r=i[1].toLowerCase())}for(let i=zo.length-1;i>=0;--i){const n=zo[i];if(n.test&&n.test(s,r))return new n(s,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class si{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,r,i,n,o,h,f,A){if(arguments.length>8)throw new Error("max arguments reached");const{name:T,items:C}=this;this._aliasCount++;for(let x=0,M=C.length;x<M;x++)C[x][T](t,r,i,n,o,h,f,A);return C===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const r=this.items.indexOf(t);return r!==-1&&(this.ensureNonAliasedItems(),this.items.splice(r,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(si.prototype,{dispatch:{value:si.prototype.emit},run:{value:si.prototype.emit}});class en{constructor(t=0,r=0){this._width=t,this._height=r,this.destroyed=!1,this.internal=!1,this.onResize=new si("setRealSize"),this.onUpdate=new si("update"),this.onError=new si("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,r){(t!==this._width||r!==this._height)&&(this._width=t,this._height=r,this.onResize.emit(t,r))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,r,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,r){return!1}}class In extends en{constructor(t,r){const{width:i,height:n}=r||{};if(!i||!n)throw new Error("BufferResource width or height invalid");super(i,n),this.data=t,this.unpackAlignment=r.unpackAlignment??4}upload(t,r,i){const n=t.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,this.unpackAlignment),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Vr.UNPACK);const o=r.realWidth,h=r.realHeight;return i.width===o&&i.height===h?n.texSubImage2D(r.target,0,0,0,o,h,r.format,i.type,this.data):(i.width=o,i.height=h,n.texImage2D(r.target,0,i.internalFormat,o,h,0,r.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Ep={scaleMode:Gi.NEAREST,alphaMode:Vr.NPM},Kh=class An extends ns{constructor(t=null,r=null){super(),r=Object.assign({},An.defaultOptions,r);const{alphaMode:i,mipmap:n,anisotropicLevel:o,scaleMode:h,width:f,height:A,wrapMode:T,format:C,type:x,target:M,resolution:D,resourceOptions:k}=r;t&&!(t instanceof en)&&(t=Qh(t,k),t.internal=!0),this.resolution=D||ue.RESOLUTION,this.width=Math.round((f||0)*this.resolution)/this.resolution,this.height=Math.round((A||0)*this.resolution)/this.resolution,this._mipmap=n,this.anisotropicLevel=o,this._wrapMode=T,this._scaleMode=h,this.format=C,this.type=x,this.target=M,this.alphaMode=i,this.uid=vs(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=f>0&&A>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,r){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),r!==void 0&&r!==this.mipmap&&(this.mipmap=r,i=!0),i&&this.dirtyStyleId++,this}setSize(t,r,i){return i=i||this.resolution,this.setRealSize(t*i,r*i,i)}setRealSize(t,r,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(r)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Nh(this.realWidth)&&Nh(this.realHeight)}setResolution(t){const r=this.resolution;return r===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*r)/t,this.height=Math.round(this.height*r)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete ii[this.cacheId],delete zr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),An.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,r,i=ue.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let o=null;if(n)o=t;else{if(!t._pixiId){const f=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t._pixiId=`${f}_${vs()}`}o=t._pixiId}let h=ii[o];if(n&&i&&!h)throw new Error(`The cacheId "${o}" does not exist in BaseTextureCache.`);return h||(h=new An(t,r),h.cacheId=o,An.addToCache(h,o)),h}static fromBuffer(t,r,i,n){t=t||new Float32Array(r*i*4);const o=new In(t,{width:r,height:i,...n==null?void 0:n.resourceOptions});let h,f;return t instanceof Float32Array?(h=qt.RGBA,f=Pe.FLOAT):t instanceof Int32Array?(h=qt.RGBA_INTEGER,f=Pe.INT):t instanceof Uint32Array?(h=qt.RGBA_INTEGER,f=Pe.UNSIGNED_INT):t instanceof Int16Array?(h=qt.RGBA_INTEGER,f=Pe.SHORT):t instanceof Uint16Array?(h=qt.RGBA_INTEGER,f=Pe.UNSIGNED_SHORT):t instanceof Int8Array?(h=qt.RGBA,f=Pe.BYTE):(h=qt.RGBA,f=Pe.UNSIGNED_BYTE),o.internal=!0,new An(o,Object.assign({},Ep,{type:f,format:h},n))}static addToCache(t,r){r&&(t.textureCacheIds.includes(r)||t.textureCacheIds.push(r),ii[r]&&ii[r]!==t&&console.warn(`BaseTexture added to the cache with an id [${r}] that already had an entry`),ii[r]=t)}static removeFromCache(t){if(typeof t=="string"){const r=ii[t];if(r){const i=r.textureCacheIds.indexOf(t);return i>-1&&r.textureCacheIds.splice(i,1),delete ii[t],r}}else if(t!=null&&t.textureCacheIds){for(let r=0;r<t.textureCacheIds.length;++r)delete ii[t.textureCacheIds[r]];return t.textureCacheIds.length=0,t}return null}};Kh.defaultOptions={mipmap:wi.POW2,anisotropicLevel:0,scaleMode:Gi.LINEAR,wrapMode:Vi.CLAMP,alphaMode:Vr.UNPACK,target:Fs.TEXTURE_2D,format:qt.RGBA,type:Pe.UNSIGNED_BYTE},Kh._globalBatch=0;let Ge=Kh;class Xo{constructor(){this.texArray=null,this.blend=0,this.type=Ai.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Cp=0,br=class p2{constructor(t,r=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=r,this.id=Cp++,this.disposeRunner=new si("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Ei.ELEMENT_ARRAY_BUFFER:Ei.ARRAY_BUFFER}get index(){return this.type===Ei.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new p2(t)}};class Dn{constructor(t,r=0,i=!1,n=Pe.FLOAT,o,h,f,A=1){this.buffer=t,this.size=r,this.normalized=i,this.type=n,this.stride=o,this.start=h,this.instance=f,this.divisor=A}destroy(){this.buffer=null}static from(t,r,i,n,o){return new Dn(t,r,i,n,o)}}const Sp={Float32Array,Uint32Array,Int32Array,Uint8Array};function Pp(s,t){let r=0,i=0;const n={};for(let A=0;A<s.length;A++)i+=t[A],r+=s[A].length;const o=new ArrayBuffer(r*4);let h=null,f=0;for(let A=0;A<s.length;A++){const T=t[A],C=s[A],x=Go(C);n[x]||(n[x]=new Sp[x](o)),h=n[x];for(let M=0;M<C.length;M++){const D=(M/T|0)*i+f,k=M%T;h[D+k]=C[M]}f+=T}return new Float32Array(o)}const rc={5126:4,5123:2,5121:1};let $p=0;const Mp={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class hs{constructor(t=[],r={}){this.buffers=t,this.indexBuffer=null,this.attributes=r,this.glVertexArrayObjects={},this.id=$p++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new si("disposeGeometry"),this.refCount=0}addAttribute(t,r,i=0,n=!1,o,h,f,A=!1){if(!r)throw new Error("You must pass a buffer when creating an attribute");r instanceof br||(r instanceof Array&&(r=new Float32Array(r)),r=new br(r));const T=t.split("|");if(T.length>1){for(let x=0;x<T.length;x++)this.addAttribute(T[x],r,i,n,o);return this}let C=this.buffers.indexOf(r);return C===-1&&(this.buffers.push(r),C=this.buffers.length-1),this.attributes[t]=new Dn(C,i,n,o,h,f,A),this.instanced=this.instanced||A,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof br||(t instanceof Array&&(t=new Uint16Array(t)),t=new br(t)),t.type=Ei.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],r=[],i=new br;let n;for(n in this.attributes){const o=this.attributes[n],h=this.buffers[o.buffer];t.push(h.data),r.push(o.size*rc[o.type]/4),o.buffer=0}for(i.data=Pp(t,r),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const r=this.attributes[t];return this.buffers[r.buffer].data.length/(r.stride/4||r.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new hs;for(let r=0;r<this.buffers.length;r++)t.buffers[r]=new br(this.buffers[r].data.slice(0));for(const r in this.attributes){const i=this.attributes[r];t.attributes[r]=new Dn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Ei.ELEMENT_ARRAY_BUFFER),t}static merge(t){const r=new hs,i=[],n=[],o=[];let h;for(let f=0;f<t.length;f++){h=t[f];for(let A=0;A<h.buffers.length;A++)n[A]=n[A]||0,n[A]+=h.buffers[A].data.length,o[A]=0}for(let f=0;f<h.buffers.length;f++)i[f]=new Mp[Go(h.buffers[f].data)](n[f]),r.buffers[f]=new br(i[f]);for(let f=0;f<t.length;f++){h=t[f];for(let A=0;A<h.buffers.length;A++)i[A].set(h.buffers[A].data,o[A]),o[A]+=h.buffers[A].data.length}if(r.attributes=h.attributes,h.indexBuffer){r.indexBuffer=r.buffers[h.buffers.indexOf(h.indexBuffer)],r.indexBuffer.type=Ei.ELEMENT_ARRAY_BUFFER;let f=0,A=0,T=0,C=0;for(let x=0;x<h.buffers.length;x++)if(h.buffers[x]!==h.indexBuffer){C=x;break}for(const x in h.attributes){const M=h.attributes[x];(M.buffer|0)===C&&(A+=M.size*rc[M.type]/4)}for(let x=0;x<t.length;x++){const M=t[x].indexBuffer.data;for(let D=0;D<M.length;D++)r.indexBuffer.data[D+T]+=f;f+=t[x].buffers[C].data.length/A,T+=M.length}}return r}}class Jh extends hs{constructor(t=!1){super(),this._buffer=new br(null,t,!1),this._indexBuffer=new br(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Pe.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Pe.FLOAT).addAttribute("aColor",this._buffer,4,!0,Pe.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Pe.FLOAT).addIndex(this._indexBuffer)}}const Fn=Math.PI*2,ic=180/Math.PI,sc=Math.PI/180;var Dr=(s=>(s[s.POLY=0]="POLY",s[s.RECT=1]="RECT",s[s.CIRC=2]="CIRC",s[s.ELIP=3]="ELIP",s[s.RREC=4]="RREC",s))(Dr||{});class Ze{constructor(t=0,r=0){this.x=0,this.y=0,this.x=t,this.y=r}clone(){return new Ze(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,r=t){return this.x=t,this.y=r,this}}Ze.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Wo=[new Ze,new Ze,new Ze,new Ze];class Ve{constructor(t=0,r=0,i=0,n=0){this.x=Number(t),this.y=Number(r),this.width=Number(i),this.height=Number(n),this.type=Dr.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Ve(0,0,0,0)}clone(){return new Ve(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,r){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&r>=this.y&&r<this.y+this.height}intersects(t,r){if(!r){const ft=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=ft)return!1;const wt=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>wt}const i=this.left,n=this.right,o=this.top,h=this.bottom;if(n<=i||h<=o)return!1;const f=Wo[0].set(t.left,t.top),A=Wo[1].set(t.left,t.bottom),T=Wo[2].set(t.right,t.top),C=Wo[3].set(t.right,t.bottom);if(T.x<=f.x||A.y<=f.y)return!1;const x=Math.sign(r.a*r.d-r.b*r.c);if(x===0||(r.apply(f,f),r.apply(A,A),r.apply(T,T),r.apply(C,C),Math.max(f.x,A.x,T.x,C.x)<=i||Math.min(f.x,A.x,T.x,C.x)>=n||Math.max(f.y,A.y,T.y,C.y)<=o||Math.min(f.y,A.y,T.y,C.y)>=h))return!1;const M=x*(A.y-f.y),D=x*(f.x-A.x),k=M*i+D*o,U=M*n+D*o,G=M*i+D*h,X=M*n+D*h;if(Math.max(k,U,G,X)<=M*f.x+D*f.y||Math.min(k,U,G,X)>=M*C.x+D*C.y)return!1;const J=x*(f.y-T.y),Z=x*(T.x-f.x),it=J*i+Z*o,Q=J*n+Z*o,_t=J*i+Z*h,et=J*n+Z*h;return!(Math.max(it,Q,_t,et)<=J*f.x+Z*f.y||Math.min(it,Q,_t,et)>=J*C.x+Z*C.y)}pad(t=0,r=t){return this.x-=t,this.y-=r,this.width+=t*2,this.height+=r*2,this}fit(t){const r=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),o=Math.min(this.y+this.height,t.y+t.height);return this.x=r,this.width=Math.max(i-r,0),this.y=n,this.height=Math.max(o-n,0),this}ceil(t=1,r=.001){const i=Math.ceil((this.x+this.width-r)*t)/t,n=Math.ceil((this.y+this.height-r)*t)/t;return this.x=Math.floor((this.x+r)*t)/t,this.y=Math.floor((this.y+r)*t)/t,this.width=i-this.x,this.height=n-this.y,this}enlarge(t){const r=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),o=Math.max(this.y+this.height,t.y+t.height);return this.x=r,this.width=i-r,this.y=n,this.height=o-n,this}}Ve.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ln{constructor(t=0,r=0,i=0){this.x=t,this.y=r,this.radius=i,this.type=Dr.CIRC}clone(){return new Ln(this.x,this.y,this.radius)}contains(t,r){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,o=this.y-r;return n*=n,o*=o,n+o<=i}getBounds(){return new Ve(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ln.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Bn{constructor(t=0,r=0,i=0,n=0){this.x=t,this.y=r,this.width=i,this.height=n,this.type=Dr.ELIP}clone(){return new Bn(this.x,this.y,this.width,this.height)}contains(t,r){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,n=(r-this.y)/this.height;return i*=i,n*=n,i+n<=1}getBounds(){return new Ve(this.x-this.width,this.y-this.height,this.width,this.height)}}Bn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class xs{constructor(...t){let r=Array.isArray(t[0])?t[0]:t;if(typeof r[0]!="number"){const i=[];for(let n=0,o=r.length;n<o;n++)i.push(r[n].x,r[n].y);r=i}this.points=r,this.type=Dr.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),r=new xs(t);return r.closeStroke=this.closeStroke,r}contains(t,r){let i=!1;const n=this.points.length/2;for(let o=0,h=n-1;o<n;h=o++){const f=this.points[o*2],A=this.points[o*2+1],T=this.points[h*2],C=this.points[h*2+1];A>r!=C>r&&t<(T-f)*((r-A)/(C-A))+f&&(i=!i)}return i}}xs.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((s,t)=>`${s}, ${t}`,"")}]`};class kn{constructor(t=0,r=0,i=0,n=0,o=20){this.x=t,this.y=r,this.width=i,this.height=n,this.radius=o,this.type=Dr.RREC}clone(){return new kn(this.x,this.y,this.width,this.height,this.radius)}contains(t,r){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&r>=this.y&&r<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(r>=this.y+i&&r<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),o=r-(this.y+i);const h=i*i;if(n*n+o*o<=h||(n=t-(this.x+this.width-i),n*n+o*o<=h)||(o=r-(this.y+this.height-i),n*n+o*o<=h)||(n=t-(this.x+i),n*n+o*o<=h))return!0}return!1}}kn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class nr{constructor(t=1,r=0,i=0,n=1,o=0,h=0){this.array=null,this.a=t,this.b=r,this.c=i,this.d=n,this.tx=o,this.ty=h}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,r,i,n,o,h){return this.a=t,this.b=r,this.c=i,this.d=n,this.tx=o,this.ty=h,this}toArray(t,r){this.array||(this.array=new Float32Array(9));const i=r||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,r){r=r||new Ze;const i=t.x,n=t.y;return r.x=this.a*i+this.c*n+this.tx,r.y=this.b*i+this.d*n+this.ty,r}applyInverse(t,r){r=r||new Ze;const i=1/(this.a*this.d+this.c*-this.b),n=t.x,o=t.y;return r.x=this.d*i*n+-this.c*i*o+(this.ty*this.c-this.tx*this.d)*i,r.y=this.a*i*o+-this.b*i*n+(-this.ty*this.a+this.tx*this.b)*i,r}translate(t,r){return this.tx+=t,this.ty+=r,this}scale(t,r){return this.a*=t,this.d*=r,this.c*=t,this.b*=r,this.tx*=t,this.ty*=r,this}rotate(t){const r=Math.cos(t),i=Math.sin(t),n=this.a,o=this.c,h=this.tx;return this.a=n*r-this.b*i,this.b=n*i+this.b*r,this.c=o*r-this.d*i,this.d=o*i+this.d*r,this.tx=h*r-this.ty*i,this.ty=h*i+this.ty*r,this}append(t){const r=this.a,i=this.b,n=this.c,o=this.d;return this.a=t.a*r+t.b*n,this.b=t.a*i+t.b*o,this.c=t.c*r+t.d*n,this.d=t.c*i+t.d*o,this.tx=t.tx*r+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*o+this.ty,this}setTransform(t,r,i,n,o,h,f,A,T){return this.a=Math.cos(f+T)*o,this.b=Math.sin(f+T)*o,this.c=-Math.sin(f-A)*h,this.d=Math.cos(f-A)*h,this.tx=t-(i*this.a+n*this.c),this.ty=r-(i*this.b+n*this.d),this}prepend(t){const r=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=r*t.a+this.ty*t.c+t.tx,this.ty=r*t.b+this.ty*t.d+t.ty,this}decompose(t){const r=this.a,i=this.b,n=this.c,o=this.d,h=t.pivot,f=-Math.atan2(-n,o),A=Math.atan2(i,r),T=Math.abs(f+A);return T<1e-5||Math.abs(Fn-T)<1e-5?(t.rotation=A,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=f,t.skew.y=A),t.scale.x=Math.sqrt(r*r+i*i),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=this.tx+(h.x*r+h.y*n),t.position.y=this.ty+(h.x*i+h.y*o),t}invert(){const t=this.a,r=this.b,i=this.c,n=this.d,o=this.tx,h=t*n-r*i;return this.a=n/h,this.b=-r/h,this.c=-i/h,this.d=t/h,this.tx=(i*this.ty-n*o)/h,this.ty=-(t*this.ty-r*o)/h,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new nr;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new nr}static get TEMP_MATRIX(){return new nr}}nr.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const ks=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Os=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ns=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Us=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],tl=[],nc=[],Ho=Math.sign;function Rp(){for(let s=0;s<16;s++){const t=[];tl.push(t);for(let r=0;r<16;r++){const i=Ho(ks[s]*ks[r]+Ns[s]*Os[r]),n=Ho(Os[s]*ks[r]+Us[s]*Os[r]),o=Ho(ks[s]*Ns[r]+Ns[s]*Us[r]),h=Ho(Os[s]*Ns[r]+Us[s]*Us[r]);for(let f=0;f<16;f++)if(ks[f]===i&&Os[f]===n&&Ns[f]===o&&Us[f]===h){t.push(f);break}}}for(let s=0;s<16;s++){const t=new nr;t.set(ks[s],Os[s],Ns[s],Us[s],0,0),nc.push(t)}}Rp();const dr={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>ks[s],uY:s=>Os[s],vX:s=>Ns[s],vY:s=>Us[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>tl[s][t],sub:(s,t)=>tl[s][dr.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?dr.S:dr.N:Math.abs(t)*2<=Math.abs(s)?s>0?dr.E:dr.W:t>0?s>0?dr.SE:dr.SW:s>0?dr.NE:dr.NW,matrixAppendRotationInv:(s,t,r=0,i=0)=>{const n=nc[dr.inv(t)];n.tx=r,n.ty=i,s.append(n)}};class $i{constructor(t,r,i=0,n=0){this._x=i,this._y=n,this.cb=t,this.scope=r}clone(t=this.cb,r=this.scope){return new $i(t,r,this._x,this._y)}set(t=0,r=t){return(this._x!==t||this._y!==r)&&(this._x=t,this._y=r,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}$i.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const el=class{constructor(){this.worldTransform=new nr,this.localTransform=new nr,this.position=new $i(this.onChange,this,0,0),this.scale=new $i(this.onChange,this,1,1),this.pivot=new $i(this.onChange,this,0,0),this.skew=new $i(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const s=this.localTransform;this._localID!==this._currentLocalID&&(s.a=this._cx*this.scale.x,s.b=this._sx*this.scale.x,s.c=this._cy*this.scale.y,s.d=this._sy*this.scale.y,s.tx=this.position.x-(this.pivot.x*s.a+this.pivot.y*s.c),s.ty=this.position.y-(this.pivot.x*s.b+this.pivot.y*s.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(s){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==s._worldID){const r=s.worldTransform,i=this.worldTransform;i.a=t.a*r.a+t.b*r.c,i.b=t.a*r.b+t.b*r.d,i.c=t.c*r.a+t.d*r.c,i.d=t.c*r.b+t.d*r.d,i.tx=t.tx*r.a+t.ty*r.c+r.tx,i.ty=t.tx*r.b+t.ty*r.d+r.ty,this._parentID=s._worldID,this._worldID++}}setFromMatrix(s){s.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(s){this._rotation!==s&&(this._rotation=s,this.updateSkew())}};el.IDENTITY=new el;let rn=el;rn.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Ip=`varying vec2 vTextureCoord;
54
+ else `),r<s-1&&(t+=`if(test == ${r}.0){}`);return t}function tc(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const r=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=wp.replace(/%forloop%/gi,Tp(s));if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))s=s/2|0;else break}return s}const Xh=0,Wh=1,Hh=2,Yh=3,jh=4,qh=5;class Pi{constructor(){this.data=0,this.blendMode=Re.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Xh)}set blend(t){!!(this.data&1<<Xh)!==t&&(this.data^=1<<Xh)}get offsets(){return!!(this.data&1<<Wh)}set offsets(t){!!(this.data&1<<Wh)!==t&&(this.data^=1<<Wh)}get culling(){return!!(this.data&1<<Hh)}set culling(t){!!(this.data&1<<Hh)!==t&&(this.data^=1<<Hh)}get depthTest(){return!!(this.data&1<<Yh)}set depthTest(t){!!(this.data&1<<Yh)!==t&&(this.data^=1<<Yh)}get depthMask(){return!!(this.data&1<<qh)}set depthMask(t){!!(this.data&1<<qh)!==t&&(this.data^=1<<qh)}get clockwiseFrontFace(){return!!(this.data&1<<jh)}set clockwiseFrontFace(t){!!(this.data&1<<jh)!==t&&(this.data^=1<<jh)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Re.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Pi;return t.depthTest=!1,t.blend=!0,t}}Pi.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const zo=[];function Zh(s,t){if(!s)return null;let r="";if(typeof s=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(s);i&&(r=i[1].toLowerCase())}for(let i=zo.length-1;i>=0;--i){const n=zo[i];if(n.test&&n.test(s,r))return new n(s,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class si{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,r,i,n,o,h,f,A){if(arguments.length>8)throw new Error("max arguments reached");const{name:T,items:C}=this;this._aliasCount++;for(let x=0,M=C.length;x<M;x++)C[x][T](t,r,i,n,o,h,f,A);return C===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const r=this.items.indexOf(t);return r!==-1&&(this.ensureNonAliasedItems(),this.items.splice(r,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(si.prototype,{dispatch:{value:si.prototype.emit},run:{value:si.prototype.emit}});class en{constructor(t=0,r=0){this._width=t,this._height=r,this.destroyed=!1,this.internal=!1,this.onResize=new si("setRealSize"),this.onUpdate=new si("update"),this.onError=new si("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,r){(t!==this._width||r!==this._height)&&(this._width=t,this._height=r,this.onResize.emit(t,r))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,r,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,r){return!1}}class In extends en{constructor(t,r){const{width:i,height:n}=r||{};if(!i||!n)throw new Error("BufferResource width or height invalid");super(i,n),this.data=t,this.unpackAlignment=r.unpackAlignment??4}upload(t,r,i){const n=t.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,this.unpackAlignment),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Vr.UNPACK);const o=r.realWidth,h=r.realHeight;return i.width===o&&i.height===h?n.texSubImage2D(r.target,0,0,0,o,h,r.format,i.type,this.data):(i.width=o,i.height=h,n.texImage2D(r.target,0,i.internalFormat,o,h,0,r.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Ep={scaleMode:Gi.NEAREST,alphaMode:Vr.NPM},Qh=class An extends ns{constructor(t=null,r=null){super(),r=Object.assign({},An.defaultOptions,r);const{alphaMode:i,mipmap:n,anisotropicLevel:o,scaleMode:h,width:f,height:A,wrapMode:T,format:C,type:x,target:M,resolution:D,resourceOptions:k}=r;t&&!(t instanceof en)&&(t=Zh(t,k),t.internal=!0),this.resolution=D||ue.RESOLUTION,this.width=Math.round((f||0)*this.resolution)/this.resolution,this.height=Math.round((A||0)*this.resolution)/this.resolution,this._mipmap=n,this.anisotropicLevel=o,this._wrapMode=T,this._scaleMode=h,this.format=C,this.type=x,this.target=M,this.alphaMode=i,this.uid=vs(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=f>0&&A>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,r){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),r!==void 0&&r!==this.mipmap&&(this.mipmap=r,i=!0),i&&this.dirtyStyleId++,this}setSize(t,r,i){return i=i||this.resolution,this.setRealSize(t*i,r*i,i)}setRealSize(t,r,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(r)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Oh(this.realWidth)&&Oh(this.realHeight)}setResolution(t){const r=this.resolution;return r===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*r)/t,this.height=Math.round(this.height*r)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete ii[this.cacheId],delete zr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),An.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,r,i=ue.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let o=null;if(n)o=t;else{if(!t._pixiId){const f=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t._pixiId=`${f}_${vs()}`}o=t._pixiId}let h=ii[o];if(n&&i&&!h)throw new Error(`The cacheId "${o}" does not exist in BaseTextureCache.`);return h||(h=new An(t,r),h.cacheId=o,An.addToCache(h,o)),h}static fromBuffer(t,r,i,n){t=t||new Float32Array(r*i*4);const o=new In(t,{width:r,height:i,...n==null?void 0:n.resourceOptions});let h,f;return t instanceof Float32Array?(h=qt.RGBA,f=Pe.FLOAT):t instanceof Int32Array?(h=qt.RGBA_INTEGER,f=Pe.INT):t instanceof Uint32Array?(h=qt.RGBA_INTEGER,f=Pe.UNSIGNED_INT):t instanceof Int16Array?(h=qt.RGBA_INTEGER,f=Pe.SHORT):t instanceof Uint16Array?(h=qt.RGBA_INTEGER,f=Pe.UNSIGNED_SHORT):t instanceof Int8Array?(h=qt.RGBA,f=Pe.BYTE):(h=qt.RGBA,f=Pe.UNSIGNED_BYTE),o.internal=!0,new An(o,Object.assign({},Ep,{type:f,format:h},n))}static addToCache(t,r){r&&(t.textureCacheIds.includes(r)||t.textureCacheIds.push(r),ii[r]&&ii[r]!==t&&console.warn(`BaseTexture added to the cache with an id [${r}] that already had an entry`),ii[r]=t)}static removeFromCache(t){if(typeof t=="string"){const r=ii[t];if(r){const i=r.textureCacheIds.indexOf(t);return i>-1&&r.textureCacheIds.splice(i,1),delete ii[t],r}}else if(t!=null&&t.textureCacheIds){for(let r=0;r<t.textureCacheIds.length;++r)delete ii[t.textureCacheIds[r]];return t.textureCacheIds.length=0,t}return null}};Qh.defaultOptions={mipmap:wi.POW2,anisotropicLevel:0,scaleMode:Gi.LINEAR,wrapMode:Vi.CLAMP,alphaMode:Vr.UNPACK,target:Fs.TEXTURE_2D,format:qt.RGBA,type:Pe.UNSIGNED_BYTE},Qh._globalBatch=0;let Ge=Qh;class Xo{constructor(){this.texArray=null,this.blend=0,this.type=Ai.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Cp=0,br=class p2{constructor(t,r=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=r,this.id=Cp++,this.disposeRunner=new si("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Ei.ELEMENT_ARRAY_BUFFER:Ei.ARRAY_BUFFER}get index(){return this.type===Ei.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new p2(t)}};class Dn{constructor(t,r=0,i=!1,n=Pe.FLOAT,o,h,f,A=1){this.buffer=t,this.size=r,this.normalized=i,this.type=n,this.stride=o,this.start=h,this.instance=f,this.divisor=A}destroy(){this.buffer=null}static from(t,r,i,n,o){return new Dn(t,r,i,n,o)}}const Sp={Float32Array,Uint32Array,Int32Array,Uint8Array};function Pp(s,t){let r=0,i=0;const n={};for(let A=0;A<s.length;A++)i+=t[A],r+=s[A].length;const o=new ArrayBuffer(r*4);let h=null,f=0;for(let A=0;A<s.length;A++){const T=t[A],C=s[A],x=Go(C);n[x]||(n[x]=new Sp[x](o)),h=n[x];for(let M=0;M<C.length;M++){const D=(M/T|0)*i+f,k=M%T;h[D+k]=C[M]}f+=T}return new Float32Array(o)}const ec={5126:4,5123:2,5121:1};let $p=0;const Mp={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class hs{constructor(t=[],r={}){this.buffers=t,this.indexBuffer=null,this.attributes=r,this.glVertexArrayObjects={},this.id=$p++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new si("disposeGeometry"),this.refCount=0}addAttribute(t,r,i=0,n=!1,o,h,f,A=!1){if(!r)throw new Error("You must pass a buffer when creating an attribute");r instanceof br||(r instanceof Array&&(r=new Float32Array(r)),r=new br(r));const T=t.split("|");if(T.length>1){for(let x=0;x<T.length;x++)this.addAttribute(T[x],r,i,n,o);return this}let C=this.buffers.indexOf(r);return C===-1&&(this.buffers.push(r),C=this.buffers.length-1),this.attributes[t]=new Dn(C,i,n,o,h,f,A),this.instanced=this.instanced||A,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof br||(t instanceof Array&&(t=new Uint16Array(t)),t=new br(t)),t.type=Ei.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],r=[],i=new br;let n;for(n in this.attributes){const o=this.attributes[n],h=this.buffers[o.buffer];t.push(h.data),r.push(o.size*ec[o.type]/4),o.buffer=0}for(i.data=Pp(t,r),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const r=this.attributes[t];return this.buffers[r.buffer].data.length/(r.stride/4||r.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new hs;for(let r=0;r<this.buffers.length;r++)t.buffers[r]=new br(this.buffers[r].data.slice(0));for(const r in this.attributes){const i=this.attributes[r];t.attributes[r]=new Dn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Ei.ELEMENT_ARRAY_BUFFER),t}static merge(t){const r=new hs,i=[],n=[],o=[];let h;for(let f=0;f<t.length;f++){h=t[f];for(let A=0;A<h.buffers.length;A++)n[A]=n[A]||0,n[A]+=h.buffers[A].data.length,o[A]=0}for(let f=0;f<h.buffers.length;f++)i[f]=new Mp[Go(h.buffers[f].data)](n[f]),r.buffers[f]=new br(i[f]);for(let f=0;f<t.length;f++){h=t[f];for(let A=0;A<h.buffers.length;A++)i[A].set(h.buffers[A].data,o[A]),o[A]+=h.buffers[A].data.length}if(r.attributes=h.attributes,h.indexBuffer){r.indexBuffer=r.buffers[h.buffers.indexOf(h.indexBuffer)],r.indexBuffer.type=Ei.ELEMENT_ARRAY_BUFFER;let f=0,A=0,T=0,C=0;for(let x=0;x<h.buffers.length;x++)if(h.buffers[x]!==h.indexBuffer){C=x;break}for(const x in h.attributes){const M=h.attributes[x];(M.buffer|0)===C&&(A+=M.size*ec[M.type]/4)}for(let x=0;x<t.length;x++){const M=t[x].indexBuffer.data;for(let D=0;D<M.length;D++)r.indexBuffer.data[D+T]+=f;f+=t[x].buffers[C].data.length/A,T+=M.length}}return r}}class Kh extends hs{constructor(t=!1){super(),this._buffer=new br(null,t,!1),this._indexBuffer=new br(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Pe.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Pe.FLOAT).addAttribute("aColor",this._buffer,4,!0,Pe.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Pe.FLOAT).addIndex(this._indexBuffer)}}const Fn=Math.PI*2,rc=180/Math.PI,ic=Math.PI/180;var Dr=(s=>(s[s.POLY=0]="POLY",s[s.RECT=1]="RECT",s[s.CIRC=2]="CIRC",s[s.ELIP=3]="ELIP",s[s.RREC=4]="RREC",s))(Dr||{});class Ze{constructor(t=0,r=0){this.x=0,this.y=0,this.x=t,this.y=r}clone(){return new Ze(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,r=t){return this.x=t,this.y=r,this}}Ze.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Wo=[new Ze,new Ze,new Ze,new Ze];class Ve{constructor(t=0,r=0,i=0,n=0){this.x=Number(t),this.y=Number(r),this.width=Number(i),this.height=Number(n),this.type=Dr.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Ve(0,0,0,0)}clone(){return new Ve(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,r){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&r>=this.y&&r<this.y+this.height}intersects(t,r){if(!r){const ft=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=ft)return!1;const wt=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>wt}const i=this.left,n=this.right,o=this.top,h=this.bottom;if(n<=i||h<=o)return!1;const f=Wo[0].set(t.left,t.top),A=Wo[1].set(t.left,t.bottom),T=Wo[2].set(t.right,t.top),C=Wo[3].set(t.right,t.bottom);if(T.x<=f.x||A.y<=f.y)return!1;const x=Math.sign(r.a*r.d-r.b*r.c);if(x===0||(r.apply(f,f),r.apply(A,A),r.apply(T,T),r.apply(C,C),Math.max(f.x,A.x,T.x,C.x)<=i||Math.min(f.x,A.x,T.x,C.x)>=n||Math.max(f.y,A.y,T.y,C.y)<=o||Math.min(f.y,A.y,T.y,C.y)>=h))return!1;const M=x*(A.y-f.y),D=x*(f.x-A.x),k=M*i+D*o,U=M*n+D*o,G=M*i+D*h,X=M*n+D*h;if(Math.max(k,U,G,X)<=M*f.x+D*f.y||Math.min(k,U,G,X)>=M*C.x+D*C.y)return!1;const J=x*(f.y-T.y),Z=x*(T.x-f.x),it=J*i+Z*o,Q=J*n+Z*o,_t=J*i+Z*h,et=J*n+Z*h;return!(Math.max(it,Q,_t,et)<=J*f.x+Z*f.y||Math.min(it,Q,_t,et)>=J*C.x+Z*C.y)}pad(t=0,r=t){return this.x-=t,this.y-=r,this.width+=t*2,this.height+=r*2,this}fit(t){const r=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),o=Math.min(this.y+this.height,t.y+t.height);return this.x=r,this.width=Math.max(i-r,0),this.y=n,this.height=Math.max(o-n,0),this}ceil(t=1,r=.001){const i=Math.ceil((this.x+this.width-r)*t)/t,n=Math.ceil((this.y+this.height-r)*t)/t;return this.x=Math.floor((this.x+r)*t)/t,this.y=Math.floor((this.y+r)*t)/t,this.width=i-this.x,this.height=n-this.y,this}enlarge(t){const r=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),o=Math.max(this.y+this.height,t.y+t.height);return this.x=r,this.width=i-r,this.y=n,this.height=o-n,this}}Ve.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ln{constructor(t=0,r=0,i=0){this.x=t,this.y=r,this.radius=i,this.type=Dr.CIRC}clone(){return new Ln(this.x,this.y,this.radius)}contains(t,r){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,o=this.y-r;return n*=n,o*=o,n+o<=i}getBounds(){return new Ve(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ln.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Bn{constructor(t=0,r=0,i=0,n=0){this.x=t,this.y=r,this.width=i,this.height=n,this.type=Dr.ELIP}clone(){return new Bn(this.x,this.y,this.width,this.height)}contains(t,r){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,n=(r-this.y)/this.height;return i*=i,n*=n,i+n<=1}getBounds(){return new Ve(this.x-this.width,this.y-this.height,this.width,this.height)}}Bn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class xs{constructor(...t){let r=Array.isArray(t[0])?t[0]:t;if(typeof r[0]!="number"){const i=[];for(let n=0,o=r.length;n<o;n++)i.push(r[n].x,r[n].y);r=i}this.points=r,this.type=Dr.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),r=new xs(t);return r.closeStroke=this.closeStroke,r}contains(t,r){let i=!1;const n=this.points.length/2;for(let o=0,h=n-1;o<n;h=o++){const f=this.points[o*2],A=this.points[o*2+1],T=this.points[h*2],C=this.points[h*2+1];A>r!=C>r&&t<(T-f)*((r-A)/(C-A))+f&&(i=!i)}return i}}xs.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((s,t)=>`${s}, ${t}`,"")}]`};class kn{constructor(t=0,r=0,i=0,n=0,o=20){this.x=t,this.y=r,this.width=i,this.height=n,this.radius=o,this.type=Dr.RREC}clone(){return new kn(this.x,this.y,this.width,this.height,this.radius)}contains(t,r){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&r>=this.y&&r<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(r>=this.y+i&&r<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let n=t-(this.x+i),o=r-(this.y+i);const h=i*i;if(n*n+o*o<=h||(n=t-(this.x+this.width-i),n*n+o*o<=h)||(o=r-(this.y+this.height-i),n*n+o*o<=h)||(n=t-(this.x+i),n*n+o*o<=h))return!0}return!1}}kn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class nr{constructor(t=1,r=0,i=0,n=1,o=0,h=0){this.array=null,this.a=t,this.b=r,this.c=i,this.d=n,this.tx=o,this.ty=h}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,r,i,n,o,h){return this.a=t,this.b=r,this.c=i,this.d=n,this.tx=o,this.ty=h,this}toArray(t,r){this.array||(this.array=new Float32Array(9));const i=r||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,r){r=r||new Ze;const i=t.x,n=t.y;return r.x=this.a*i+this.c*n+this.tx,r.y=this.b*i+this.d*n+this.ty,r}applyInverse(t,r){r=r||new Ze;const i=1/(this.a*this.d+this.c*-this.b),n=t.x,o=t.y;return r.x=this.d*i*n+-this.c*i*o+(this.ty*this.c-this.tx*this.d)*i,r.y=this.a*i*o+-this.b*i*n+(-this.ty*this.a+this.tx*this.b)*i,r}translate(t,r){return this.tx+=t,this.ty+=r,this}scale(t,r){return this.a*=t,this.d*=r,this.c*=t,this.b*=r,this.tx*=t,this.ty*=r,this}rotate(t){const r=Math.cos(t),i=Math.sin(t),n=this.a,o=this.c,h=this.tx;return this.a=n*r-this.b*i,this.b=n*i+this.b*r,this.c=o*r-this.d*i,this.d=o*i+this.d*r,this.tx=h*r-this.ty*i,this.ty=h*i+this.ty*r,this}append(t){const r=this.a,i=this.b,n=this.c,o=this.d;return this.a=t.a*r+t.b*n,this.b=t.a*i+t.b*o,this.c=t.c*r+t.d*n,this.d=t.c*i+t.d*o,this.tx=t.tx*r+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*o+this.ty,this}setTransform(t,r,i,n,o,h,f,A,T){return this.a=Math.cos(f+T)*o,this.b=Math.sin(f+T)*o,this.c=-Math.sin(f-A)*h,this.d=Math.cos(f-A)*h,this.tx=t-(i*this.a+n*this.c),this.ty=r-(i*this.b+n*this.d),this}prepend(t){const r=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=r*t.a+this.ty*t.c+t.tx,this.ty=r*t.b+this.ty*t.d+t.ty,this}decompose(t){const r=this.a,i=this.b,n=this.c,o=this.d,h=t.pivot,f=-Math.atan2(-n,o),A=Math.atan2(i,r),T=Math.abs(f+A);return T<1e-5||Math.abs(Fn-T)<1e-5?(t.rotation=A,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=f,t.skew.y=A),t.scale.x=Math.sqrt(r*r+i*i),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=this.tx+(h.x*r+h.y*n),t.position.y=this.ty+(h.x*i+h.y*o),t}invert(){const t=this.a,r=this.b,i=this.c,n=this.d,o=this.tx,h=t*n-r*i;return this.a=n/h,this.b=-r/h,this.c=-i/h,this.d=t/h,this.tx=(i*this.ty-n*o)/h,this.ty=-(t*this.ty-r*o)/h,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new nr;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new nr}static get TEMP_MATRIX(){return new nr}}nr.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const ks=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Os=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ns=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Us=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Jh=[],sc=[],Ho=Math.sign;function Rp(){for(let s=0;s<16;s++){const t=[];Jh.push(t);for(let r=0;r<16;r++){const i=Ho(ks[s]*ks[r]+Ns[s]*Os[r]),n=Ho(Os[s]*ks[r]+Us[s]*Os[r]),o=Ho(ks[s]*Ns[r]+Ns[s]*Us[r]),h=Ho(Os[s]*Ns[r]+Us[s]*Us[r]);for(let f=0;f<16;f++)if(ks[f]===i&&Os[f]===n&&Ns[f]===o&&Us[f]===h){t.push(f);break}}}for(let s=0;s<16;s++){const t=new nr;t.set(ks[s],Os[s],Ns[s],Us[s],0,0),sc.push(t)}}Rp();const dr={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>ks[s],uY:s=>Os[s],vX:s=>Ns[s],vY:s=>Us[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Jh[s][t],sub:(s,t)=>Jh[s][dr.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?dr.S:dr.N:Math.abs(t)*2<=Math.abs(s)?s>0?dr.E:dr.W:t>0?s>0?dr.SE:dr.SW:s>0?dr.NE:dr.NW,matrixAppendRotationInv:(s,t,r=0,i=0)=>{const n=sc[dr.inv(t)];n.tx=r,n.ty=i,s.append(n)}};class $i{constructor(t,r,i=0,n=0){this._x=i,this._y=n,this.cb=t,this.scope=r}clone(t=this.cb,r=this.scope){return new $i(t,r,this._x,this._y)}set(t=0,r=t){return(this._x!==t||this._y!==r)&&(this._x=t,this._y=r,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}$i.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const tl=class{constructor(){this.worldTransform=new nr,this.localTransform=new nr,this.position=new $i(this.onChange,this,0,0),this.scale=new $i(this.onChange,this,1,1),this.pivot=new $i(this.onChange,this,0,0),this.skew=new $i(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const s=this.localTransform;this._localID!==this._currentLocalID&&(s.a=this._cx*this.scale.x,s.b=this._sx*this.scale.x,s.c=this._cy*this.scale.y,s.d=this._sy*this.scale.y,s.tx=this.position.x-(this.pivot.x*s.a+this.pivot.y*s.c),s.ty=this.position.y-(this.pivot.x*s.b+this.pivot.y*s.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(s){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==s._worldID){const r=s.worldTransform,i=this.worldTransform;i.a=t.a*r.a+t.b*r.c,i.b=t.a*r.b+t.b*r.d,i.c=t.c*r.a+t.d*r.c,i.d=t.c*r.b+t.d*r.d,i.tx=t.tx*r.a+t.ty*r.c+r.tx,i.ty=t.tx*r.b+t.ty*r.d+r.ty,this._parentID=s._worldID,this._worldID++}}setFromMatrix(s){s.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(s){this._rotation!==s&&(this._rotation=s,this.updateSkew())}};tl.IDENTITY=new tl;let rn=tl;rn.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Ip=`varying vec2 vTextureCoord;
55
55
 
56
56
  uniform sampler2D uSampler;
57
57
 
@@ -68,7 +68,7 @@ void main(void){
68
68
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
69
69
  vTextureCoord = aTextureCoord;
70
70
  }
71
- `;function oc(s,t,r){const i=s.createShader(t);return s.shaderSource(i,r),s.compileShader(i),i}function rl(s){const t=new Array(s);for(let r=0;r<t.length;r++)t[r]=!1;return t}function ac(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return rl(2*t);case"bvec3":return rl(3*t);case"bvec4":return rl(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Gs=[{test:s=>s.type==="float"&&s.size===1&&!s.isArray,code:s=>`
71
+ `;function nc(s,t,r){const i=s.createShader(t);return s.shaderSource(i,r),s.compileShader(i),i}function el(s){const t=new Array(s);for(let r=0;r<t.length;r++)t[r]=!1;return t}function oc(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return el(2*t);case"bvec3":return el(3*t);case"bvec4":return el(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Gs=[{test:s=>s.type==="float"&&s.size===1&&!s.isArray,code:s=>`
72
72
  if(uv["${s}"] !== ud["${s}"].value)
73
73
  {
74
74
  ud["${s}"].value = uv["${s}"]
@@ -339,13 +339,13 @@ void main(void){
339
339
  cv = cu.value;
340
340
  v = uv["${n}"];
341
341
  ${A};`)}}return new Function("ud","uv","renderer","syncData",r.join(`
342
- `))}const hc={};let sn=hc;function lc(){if(sn===hc||sn!=null&&sn.isContextLost()){const s=ue.ADAPTER.createCanvas();let t;ue.PREFER_ENV>=ys.WEBGL2&&(t=s.getContext("webgl2",{})),t||(t=s.getContext("webgl",{})||s.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),sn=t}return sn}let Yo;function kp(){if(!Yo){Yo=ri.MEDIUM;const s=lc();if(s&&s.getShaderPrecisionFormat){const t=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);t&&(Yo=t.precision?ri.HIGH:ri.MEDIUM)}}return Yo}function uc(s,t){const r=s.getShaderSource(t).split(`
342
+ `))}const ac={};let sn=ac;function hc(){if(sn===ac||sn!=null&&sn.isContextLost()){const s=ue.ADAPTER.createCanvas();let t;ue.PREFER_ENV>=ys.WEBGL2&&(t=s.getContext("webgl2",{})),t||(t=s.getContext("webgl",{})||s.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),sn=t}return sn}let Yo;function kp(){if(!Yo){Yo=ri.MEDIUM;const s=hc();if(s&&s.getShaderPrecisionFormat){const t=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);t&&(Yo=t.precision?ri.HIGH:ri.MEDIUM)}}return Yo}function lc(s,t){const r=s.getShaderSource(t).split(`
343
343
  `).map((T,C)=>`${C}: ${T}`),i=s.getShaderInfoLog(t),n=i.split(`
344
344
  `),o={},h=n.map(T=>parseFloat(T.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(T=>T&&!o[T]?(o[T]=!0,!0):!1),f=[""];h.forEach(T=>{r[T-1]=`%c${r[T-1]}%c`,f.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const A=r.join(`
345
- `);f[0]=A,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...f),console.groupEnd()}function Op(s,t,r,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(r,s.COMPILE_STATUS)||uc(s,r),s.getShaderParameter(i,s.COMPILE_STATUS)||uc(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}const Np={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function cc(s){return Np[s]}let jo=null;const fc={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function dc(s,t){if(!jo){const r=Object.keys(fc);jo={};for(let i=0;i<r.length;++i){const n=r[i];jo[s[n]]=fc[n]}}return jo[t]}function pc(s,t,r){if(s.substring(0,9)!=="precision"){let i=t;return t===ri.HIGH&&r!==ri.HIGH&&(i=ri.MEDIUM),`precision ${i} float;
346
- ${s}`}else if(r!==ri.HIGH&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}let On;function _c(){if(typeof On=="boolean")return On;try{On=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{On=!1}return On}let Up=0;const qo={},il=class wn{constructor(t,r,i="pixi-shader",n={}){this.extra={},this.id=Up++,this.vertexSrc=t||wn.defaultVertexSrc,this.fragmentSrc=r||wn.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=n,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),qo[i]?(qo[i]++,i+=`-${qo[i]}`):qo[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
345
+ `);f[0]=A,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...f),console.groupEnd()}function Op(s,t,r,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(r,s.COMPILE_STATUS)||lc(s,r),s.getShaderParameter(i,s.COMPILE_STATUS)||lc(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}const Np={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function uc(s){return Np[s]}let jo=null;const cc={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function fc(s,t){if(!jo){const r=Object.keys(cc);jo={};for(let i=0;i<r.length;++i){const n=r[i];jo[s[n]]=cc[n]}}return jo[t]}function dc(s,t,r){if(s.substring(0,9)!=="precision"){let i=t;return t===ri.HIGH&&r!==ri.HIGH&&(i=ri.MEDIUM),`precision ${i} float;
346
+ ${s}`}else if(r!==ri.HIGH&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}let On;function pc(){if(typeof On=="boolean")return On;try{On=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{On=!1}return On}let Up=0;const qo={},rl=class wn{constructor(t,r,i="pixi-shader",n={}){this.extra={},this.id=Up++,this.vertexSrc=t||wn.defaultVertexSrc,this.fragmentSrc=r||wn.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=n,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),qo[i]?(qo[i]++,i+=`-${qo[i]}`):qo[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
347
347
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
348
- ${this.fragmentSrc}`,this.vertexSrc=pc(this.vertexSrc,wn.defaultVertexPrecision,ri.HIGH),this.fragmentSrc=pc(this.fragmentSrc,wn.defaultFragmentPrecision,kp())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Dp}static get defaultFragmentSrc(){return Ip}static from(t,r,i){const n=t+r;let o=zh[n];return o||(zh[n]=o=new wn(t,r,i)),o}};il.defaultVertexPrecision=ri.HIGH,il.defaultFragmentPrecision=Ci.apple.device?ri.HIGH:ri.MEDIUM;let Wi=il,Gp=0;class fi{constructor(t,r,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Gp++,this.static=!!r,this.ubo=!!i,t instanceof br?(this.buffer=t,this.buffer.type=Ei.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new br(new Float32Array(1)),this.buffer.type=Ei.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,r,i){if(!this.ubo)this.uniforms[t]=new fi(r,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,r,i){return new fi(t,r,i)}static uboFrom(t,r){return new fi(t,r??!0,!0)}}class Mi{constructor(t,r){this.uniformBindCount=0,this.program=t,r?r instanceof fi?this.uniformGroup=r:this.uniformGroup=new fi(r):this.uniformGroup=new fi({}),this.disposeRunner=new si("disposeShader")}checkUniformExists(t,r){if(r.uniforms[t])return!0;for(const i in r.uniforms){const n=r.uniforms[i];if(n.group===!0&&this.checkUniformExists(t,n))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,r,i){const n=Wi.from(t,r);return new Mi(n,i)}}class gc{constructor(t,r){if(this.vertexSrc=t,this.fragTemplate=r,this.programCache={},this.defaultGroupCache={},!r.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!r.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let o=0;o<t;o++)i[o]=o;this.defaultGroupCache[t]=fi.from({uSamplers:i},!0);let n=this.fragTemplate;n=n.replace(/%count%/gi,`${t}`),n=n.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Wi(this.vertexSrc,n)}const r={tint:new Float32Array([1,1,1,1]),translationMatrix:new nr,default:this.defaultGroupCache[t]};return new Mi(this.programCache[t],r)}generateSampleSrc(t){let r="";r+=`
348
+ ${this.fragmentSrc}`,this.vertexSrc=dc(this.vertexSrc,wn.defaultVertexPrecision,ri.HIGH),this.fragmentSrc=dc(this.fragmentSrc,wn.defaultFragmentPrecision,kp())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Dp}static get defaultFragmentSrc(){return Ip}static from(t,r,i){const n=t+r;let o=Vh[n];return o||(Vh[n]=o=new wn(t,r,i)),o}};rl.defaultVertexPrecision=ri.HIGH,rl.defaultFragmentPrecision=Ci.apple.device?ri.HIGH:ri.MEDIUM;let Wi=rl,Gp=0;class fi{constructor(t,r,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Gp++,this.static=!!r,this.ubo=!!i,t instanceof br?(this.buffer=t,this.buffer.type=Ei.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new br(new Float32Array(1)),this.buffer.type=Ei.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,r,i){if(!this.ubo)this.uniforms[t]=new fi(r,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,r,i){return new fi(t,r,i)}static uboFrom(t,r){return new fi(t,r??!0,!0)}}class Mi{constructor(t,r){this.uniformBindCount=0,this.program=t,r?r instanceof fi?this.uniformGroup=r:this.uniformGroup=new fi(r):this.uniformGroup=new fi({}),this.disposeRunner=new si("disposeShader")}checkUniformExists(t,r){if(r.uniforms[t])return!0;for(const i in r.uniforms){const n=r.uniforms[i];if(n.group===!0&&this.checkUniformExists(t,n))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,r,i){const n=Wi.from(t,r);return new Mi(n,i)}}class _c{constructor(t,r){if(this.vertexSrc=t,this.fragTemplate=r,this.programCache={},this.defaultGroupCache={},!r.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!r.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let o=0;o<t;o++)i[o]=o;this.defaultGroupCache[t]=fi.from({uSamplers:i},!0);let n=this.fragTemplate;n=n.replace(/%count%/gi,`${t}`),n=n.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Wi(this.vertexSrc,n)}const r={tint:new Float32Array([1,1,1,1]),translationMatrix:new nr,default:this.defaultGroupCache[t]};return new Mi(this.programCache[t],r)}generateSampleSrc(t){let r="";r+=`
349
349
  `,r+=`
350
350
  `;for(let i=0;i<t;i++)i>0&&(r+=`
351
351
  else `),i<t-1&&(r+=`if(vTextureId < ${i}.5)`),r+=`
@@ -384,7 +384,7 @@ void main(void){
384
384
  vTextureId = aTextureId;
385
385
  vColor = aColor * tint;
386
386
  }
387
- `;const Un=class Ui extends Nn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Jh,this.vertexSize=6,this.state=Pi.for2d(),this.size=Ui.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??zp(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Vp(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return Oe("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Wp}static get defaultFragmentTemplate(){return Xp}setShaderGenerator({vertex:t=Ui.defaultVertexSrc,fragment:r=Ui.defaultFragmentTemplate}={}){this.shaderGenerator=new gc(t,r)}contextChange(){const t=this.renderer.gl;ue.PREFER_ENV===ys.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ui.defaultMaxTextures),this.maxTextures=ec(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let r=0;r<this._packedGeometryPoolSize;r++)this._packedGeometries[r]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:r}=Ui,i=this.size/4,n=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Xo);for(;r.length<n;)r.push(new Zo);for(let o=0;o<this.maxTextures;o++)this._tempBoundTextures[o]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:r}=this,i=Ui._textureArrayPool,n=this.renderer.batch,o=this._tempBoundTextures,h=this.renderer.textureGC.count;let f=++Ge._globalBatch,A=0,T=i[0],C=0;n.copyBoundTextures(o,r);for(let x=0;x<this._bufferSize;++x){const M=t[x];t[x]=null,M._batchEnabled!==f&&(T.count>=r&&(n.boundArray(T,o,f,r),this.buildDrawCalls(T,C,x),C=x,T=i[++A],++f),M._batchEnabled=f,M.touched=h,T.elements[T.count++]=M)}T.count>0&&(n.boundArray(T,o,f,r),this.buildDrawCalls(T,C,this._bufferSize),++A,++f);for(let x=0;x<o.length;x++)o[x]=null;Ge._globalBatch=f}buildDrawCalls(t,r,i){const{_bufferedElements:n,_attributeBuffer:o,_indexBuffer:h,vertexSize:f}=this,A=Ui._drawCallPool;let T=this._dcIndex,C=this._aIndex,x=this._iIndex,M=A[T];M.start=this._iIndex,M.texArray=t;for(let D=r;D<i;++D){const k=n[D],U=k._texture.baseTexture,G=kh[U.alphaMode?1:0][k.blendMode];n[D]=null,r<D&&M.blend!==G&&(M.size=x-M.start,r=D,M=A[++T],M.texArray=t,M.start=x),this.packInterleavedGeometry(k,o,h,C,x),C+=k.vertexData.length/2*f,x+=k.indices.length,M.blend=G}r<i&&(M.size=x-M.start,++T),this._dcIndex=T,this._aIndex=C,this._iIndex=x}bindAndClearTexArray(t){const r=this.renderer.texture;for(let i=0;i<t.count;i++)r.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:r,_indexBuffer:i}=this;Ui.canUploadSameBuffer?(t[this._flushId]._buffer.update(r.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(r.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:r,state:i}=this.renderer,n=Ui._drawCallPool;let o=null;for(let h=0;h<t;h++){const{texArray:f,type:A,size:T,start:C,blend:x}=n[h];o!==f&&(o=f,this.bindAndClearTexArray(f)),this.state.blendMode=x,i.set(this.state),r.drawElements(A,T,r.UNSIGNED_SHORT,C*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Ui.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const r=Rn(Math.ceil(t/8)),i=Uh(r),n=r*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let o=this._aBuffers[n];return o||(this._aBuffers[n]=o=new Vo(n*this.vertexSize*4)),o}getIndexBuffer(t){const r=Rn(Math.ceil(t/12)),i=Uh(r),n=r*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let o=this._iBuffers[i];return o||(this._iBuffers[i]=o=new Uint16Array(n)),o}packInterleavedGeometry(t,r,i,n,o){const{uint32View:h,float32View:f}=r,A=n/this.vertexSize,T=t.uvs,C=t.indices,x=t.vertexData,M=t._texture.baseTexture._batchLocation,D=Math.min(t.worldAlpha,1),k=rr.shared.setValue(t._tintRGB).toPremultiplied(D,t._texture.baseTexture.alphaMode>0);for(let U=0;U<x.length;U+=2)f[n++]=x[U],f[n++]=x[U+1],f[n++]=T[U],f[n++]=T[U+1],h[n++]=k,f[n++]=M;for(let U=0;U<C.length;U++)i[o++]=A+C[U]}};Un.defaultBatchSize=4096,Un.extension={name:"batch",type:ee.RendererPlugin},Un._drawCallPool=[],Un._textureArrayPool=[];let bs=Un;be.add(bs);var Hp=`varying vec2 vTextureCoord;
387
+ `;const Un=class Ui extends Nn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Kh,this.vertexSize=6,this.state=Pi.for2d(),this.size=Ui.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??zp(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Vp(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return Oe("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Wp}static get defaultFragmentTemplate(){return Xp}setShaderGenerator({vertex:t=Ui.defaultVertexSrc,fragment:r=Ui.defaultFragmentTemplate}={}){this.shaderGenerator=new _c(t,r)}contextChange(){const t=this.renderer.gl;ue.PREFER_ENV===ys.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ui.defaultMaxTextures),this.maxTextures=tc(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let r=0;r<this._packedGeometryPoolSize;r++)this._packedGeometries[r]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:r}=Ui,i=this.size/4,n=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Xo);for(;r.length<n;)r.push(new Zo);for(let o=0;o<this.maxTextures;o++)this._tempBoundTextures[o]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:r}=this,i=Ui._textureArrayPool,n=this.renderer.batch,o=this._tempBoundTextures,h=this.renderer.textureGC.count;let f=++Ge._globalBatch,A=0,T=i[0],C=0;n.copyBoundTextures(o,r);for(let x=0;x<this._bufferSize;++x){const M=t[x];t[x]=null,M._batchEnabled!==f&&(T.count>=r&&(n.boundArray(T,o,f,r),this.buildDrawCalls(T,C,x),C=x,T=i[++A],++f),M._batchEnabled=f,M.touched=h,T.elements[T.count++]=M)}T.count>0&&(n.boundArray(T,o,f,r),this.buildDrawCalls(T,C,this._bufferSize),++A,++f);for(let x=0;x<o.length;x++)o[x]=null;Ge._globalBatch=f}buildDrawCalls(t,r,i){const{_bufferedElements:n,_attributeBuffer:o,_indexBuffer:h,vertexSize:f}=this,A=Ui._drawCallPool;let T=this._dcIndex,C=this._aIndex,x=this._iIndex,M=A[T];M.start=this._iIndex,M.texArray=t;for(let D=r;D<i;++D){const k=n[D],U=k._texture.baseTexture,G=Bh[U.alphaMode?1:0][k.blendMode];n[D]=null,r<D&&M.blend!==G&&(M.size=x-M.start,r=D,M=A[++T],M.texArray=t,M.start=x),this.packInterleavedGeometry(k,o,h,C,x),C+=k.vertexData.length/2*f,x+=k.indices.length,M.blend=G}r<i&&(M.size=x-M.start,++T),this._dcIndex=T,this._aIndex=C,this._iIndex=x}bindAndClearTexArray(t){const r=this.renderer.texture;for(let i=0;i<t.count;i++)r.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:r,_indexBuffer:i}=this;Ui.canUploadSameBuffer?(t[this._flushId]._buffer.update(r.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(r.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:r,state:i}=this.renderer,n=Ui._drawCallPool;let o=null;for(let h=0;h<t;h++){const{texArray:f,type:A,size:T,start:C,blend:x}=n[h];o!==f&&(o=f,this.bindAndClearTexArray(f)),this.state.blendMode=x,i.set(this.state),r.drawElements(A,T,r.UNSIGNED_SHORT,C*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Ui.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const r=Rn(Math.ceil(t/8)),i=Nh(r),n=r*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let o=this._aBuffers[n];return o||(this._aBuffers[n]=o=new Vo(n*this.vertexSize*4)),o}getIndexBuffer(t){const r=Rn(Math.ceil(t/12)),i=Nh(r),n=r*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let o=this._iBuffers[i];return o||(this._iBuffers[i]=o=new Uint16Array(n)),o}packInterleavedGeometry(t,r,i,n,o){const{uint32View:h,float32View:f}=r,A=n/this.vertexSize,T=t.uvs,C=t.indices,x=t.vertexData,M=t._texture.baseTexture._batchLocation,D=Math.min(t.worldAlpha,1),k=rr.shared.setValue(t._tintRGB).toPremultiplied(D,t._texture.baseTexture.alphaMode>0);for(let U=0;U<x.length;U+=2)f[n++]=x[U],f[n++]=x[U+1],f[n++]=T[U],f[n++]=T[U+1],h[n++]=k,f[n++]=M;for(let U=0;U<C.length;U++)i[o++]=A+C[U]}};Un.defaultBatchSize=4096,Un.extension={name:"batch",type:ee.RendererPlugin},Un._drawCallPool=[],Un._textureArrayPool=[];let bs=Un;Te.add(bs);var Hp=`varying vec2 vTextureCoord;
388
388
 
389
389
  uniform sampler2D uSampler;
390
390
 
@@ -417,7 +417,7 @@ void main(void)
417
417
  gl_Position = filterVertexPosition();
418
418
  vTextureCoord = filterTextureCoord();
419
419
  }
420
- `;const sl=class Mo extends Mi{constructor(t,r,i){const n=Wi.from(t||Mo.defaultVertexSrc,r||Mo.defaultFragmentSrc);super(n,i),this.padding=0,this.resolution=Mo.defaultResolution,this.multisample=Mo.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Pi}apply(t,r,i,n,o){t.applyFilter(this,r,i,n)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Yp}static get defaultFragmentSrc(){return Hp}};sl.defaultResolution=1,sl.defaultMultisample=yr.NONE;let Gr=sl;class Gn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new rr(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:r,background:i,backgroundAlpha:n}=t,o=i??r;o!==void 0&&(this.color=o),this.alpha=n}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Gn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Gn.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"background"},be.add(Gn);class nl{constructor(t){this.renderer=t,this.emptyRenderer=new Nn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,r){const{boundTextures:i}=this.renderer.texture;for(let n=r-1;n>=0;--n)t[n]=i[n]||null,t[n]&&(t[n]._batchLocation=n)}boundArray(t,r,i,n){const{elements:o,ids:h,count:f}=t;let A=0;for(let T=0;T<f;T++){const C=o[T],x=C._batchLocation;if(x>=0&&x<n&&r[x]===C){h[T]=x;continue}for(;A<n;){const M=r[A];if(M&&M._batchEnabled===i&&M._batchLocation===A){A++;continue}h[T]=A,C._batchLocation=A,r[A]=C;break}}}destroy(){this.renderer=null}}nl.extension={type:ee.RendererSystem,name:"batch"},be.add(nl);let mc=0;class Vn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=mc++}init(t){if(t.context)this.initFromContext(t.context);else{const r=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:r,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=mc++,this.renderer.runners.contextChange.emit(t);const r=this.renderer.view;r.addEventListener!==void 0&&(r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const r=this.createContext(this.renderer.view,t);this.initFromContext(r)}createContext(t,r){let i;if(ue.PREFER_ENV>=ys.WEBGL2&&(i=t.getContext("webgl2",r)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",r)||t.getContext("experimental-webgl",r),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,r={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,r,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,r,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const r=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),r&&!r.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Vn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Vn.extension={type:ee.RendererSystem,name:"context"},be.add(Vn);class Qo{constructor(t,r){if(this.width=Math.round(t),this.height=Math.round(r),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new si("disposeFramebuffer"),this.multisample=yr.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,r){return this.colorTextures[t]=r||new Ge(null,{scaleMode:Gi.NEAREST,resolution:1,mipmap:wi.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new Ge(null,{scaleMode:Gi.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:wi.OFF,format:qt.DEPTH_COMPONENT,type:Pe.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,r){if(t=Math.round(t),r=Math.round(r),!t||!r)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&r===this.height)){this.width=t,this.height=r,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const n=this.colorTextures[i],o=n.resolution;n.setSize(t/o,r/o)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,r/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class ol extends Ge{constructor(t={}){if(typeof t=="number"){const r=arguments[0],i=arguments[1],n=arguments[2],o=arguments[3];t={width:r,height:i,scaleMode:n,resolution:o}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=yr.NONE),super(null,t),this.mipmap=wi.OFF,this.valid=!0,this._clear=new rr([0,0,0,0]),this.framebuffer=new Qo(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,r){this.framebuffer.resize(t*this.resolution,r*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Hi extends en{constructor(t){const r=t,i=r.naturalWidth||r.videoWidth||r.displayWidth||r.width,n=r.naturalHeight||r.videoHeight||r.displayHeight||r.height;super(i,n),this.source=t,this.noSubImage=!1}static crossOrigin(t,r,i){i===void 0&&!r.startsWith("data:")?t.crossOrigin=J0(r):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,r,i,n){const o=t.gl,h=r.realWidth,f=r.realHeight;if(n=n||this.source,typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement){if(!n.complete||n.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement&&n.readyState<=1)return!1;return o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Vr.UNPACK),!this.noSubImage&&r.target===o.TEXTURE_2D&&i.width===h&&i.height===f?o.texSubImage2D(o.TEXTURE_2D,0,0,0,r.format,i.type,n):(i.width=h,i.height=f,o.texImage2D(r.target,0,i.internalFormat,r.format,i.type,n)),!0}update(){if(this.destroyed)return;const t=this.source,r=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(r,i),super.update()}dispose(){this.source=null}}class al extends Hi{constructor(t,r){if(r=r||{},typeof t=="string"){const i=new Image;Hi.crossOrigin(i,t,r.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(r.createBitmap??ue.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,this.bitmap=null,this._load=null,r.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((r,i)=>{const n=this.source;this.url=n.src;const o=()=>{this.destroyed||(n.onload=null,n.onerror=null,this.update(),this._load=null,this.createBitmap?r(this.process()):r(this))};n.complete&&n.src?o():(n.onload=o,n.onerror=h=>{i(h),this.onError.emit(h)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const r=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(n=>n.blob()).then(n=>r(n,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Vr.UNPACK?"premultiply":"none"})).then(n=>this.destroyed?Promise.reject():(this.bitmap=n,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,r,i){if(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,r,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,r,i,this.bitmap),!this.preserveBitmap){let n=!0;const o=r._glTextures;for(const h in o){const f=o[h];if(f!==i&&f.dirtyId!==r.dirtyId){n=!1;break}}n&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ko{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,r,i){const n=r.width,o=r.height;if(i){const h=t.width/2/n,f=t.height/2/o,A=t.x/n+h,T=t.y/o+f;i=dr.add(i,dr.NW),this.x0=A+h*dr.uX(i),this.y0=T+f*dr.uY(i),i=dr.add(i,2),this.x1=A+h*dr.uX(i),this.y1=T+f*dr.uY(i),i=dr.add(i,2),this.x2=A+h*dr.uX(i),this.y2=T+f*dr.uY(i),i=dr.add(i,2),this.x3=A+h*dr.uX(i),this.y3=T+f*dr.uY(i)}else this.x0=t.x/n,this.y0=t.y/o,this.x1=(t.x+t.width)/n,this.y1=t.y/o,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/o,this.x3=t.x/n,this.y3=(t.y+t.height)/o;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Ko.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const yc=new Ko;function Jo(s){s.destroy=function(){},s.on=function(){},s.once=function(){},s.emit=function(){}}class ne extends ns{constructor(t,r,i,n,o,h,f){if(super(),this.noFrame=!1,r||(this.noFrame=!0,r=new Ve(0,0,1,1)),t instanceof ne&&(t=t.baseTexture),this.baseTexture=t,this._frame=r,this.trim=n,this.valid=!1,this.destroyed=!1,this._uvs=yc,this.uvMatrix=null,this.orig=i||r,this._rotate=Number(o||0),o===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=h?new Ze(h.x,h.y):new Ze(0,0),this.defaultBorders=f,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=r:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:r}=this.baseTexture;r!=null&&r.url&&zr[r.url]&&ne.removeFromCache(r.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,ne.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var n;const t=this._frame.clone(),r=this._frame===this.orig?t:this.orig.clone(),i=new ne(this.baseTexture,!this.noFrame&&t,r,(n=this.trim)==null?void 0:n.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===yc&&(this._uvs=new Ko),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,r={},i=ue.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let o=null;if(n)o=t;else if(t instanceof Ge){if(!t.cacheId){const f=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t.cacheId=`${f}-${vs()}`,Ge.addToCache(t,t.cacheId)}o=t.cacheId}else{if(!t._pixiId){const f=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t._pixiId=`${f}_${vs()}`}o=t._pixiId}let h=zr[o];if(n&&i&&!h)throw new Error(`The cacheId "${o}" does not exist in TextureCache.`);return!h&&!(t instanceof Ge)?(r.resolution||(r.resolution=Xi(t)),h=new ne(new Ge(t,r)),h.baseTexture.cacheId=o,Ge.addToCache(h.baseTexture,o),ne.addToCache(h,o)):!h&&t instanceof Ge&&(h=new ne(t),ne.addToCache(h,o)),h}static fromURL(t,r){const i=Object.assign({autoLoad:!1},r==null?void 0:r.resourceOptions),n=ne.from(t,Object.assign({resourceOptions:i},r),!1),o=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):o.load().then(()=>Promise.resolve(n))}static fromBuffer(t,r,i,n){return new ne(Ge.fromBuffer(t,r,i,n))}static fromLoader(t,r,i,n){const o=new Ge(t,Object.assign({scaleMode:Ge.defaultOptions.scaleMode,resolution:Xi(r)},n)),{resource:h}=o;h instanceof al&&(h.url=r);const f=new ne(o);return i||(i=r),Ge.addToCache(f.baseTexture,i),ne.addToCache(f,i),i!==r&&(Ge.addToCache(f.baseTexture,r),ne.addToCache(f,r)),f.baseTexture.valid?Promise.resolve(f):new Promise(A=>{f.baseTexture.once("loaded",()=>A(f))})}static addToCache(t,r){r&&(t.textureCacheIds.includes(r)||t.textureCacheIds.push(r),zr[r]&&zr[r]!==t&&console.warn(`Texture added to the cache with an id [${r}] that already had an entry`),zr[r]=t)}static removeFromCache(t){if(typeof t=="string"){const r=zr[t];if(r){const i=r.textureCacheIds.indexOf(t);return i>-1&&r.textureCacheIds.splice(i,1),delete zr[t],r}}else if(t!=null&&t.textureCacheIds){for(let r=0;r<t.textureCacheIds.length;++r)zr[t.textureCacheIds[r]]===t&&delete zr[t.textureCacheIds[r]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:r,y:i,width:n,height:o}=t,h=r+n>this.baseTexture.width,f=i+o>this.baseTexture.height;if(h||f){const A=h&&f?"and":"or",T=`X: ${r} + ${n} = ${r+n} > ${this.baseTexture.width}`,C=`Y: ${i} + ${o} = ${i+o} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${T} ${A} ${C}`)}this.valid=n&&o&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return ne._EMPTY||(ne._EMPTY=new ne(new Ge),Jo(ne._EMPTY),Jo(ne._EMPTY.baseTexture)),ne._EMPTY}static get WHITE(){if(!ne._WHITE){const t=ue.ADAPTER.createCanvas(16,16),r=t.getContext("2d");t.width=16,t.height=16,r.fillStyle="white",r.fillRect(0,0,16,16),ne._WHITE=new ne(Ge.from(t)),Jo(ne._WHITE),Jo(ne._WHITE.baseTexture)}return ne._WHITE}}class As extends ne{constructor(t,r){super(t,r),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,r,i=!0){const n=this.baseTexture.resolution,o=Math.round(t*n)/n,h=Math.round(r*n)/n;this.valid=o>0&&h>0,this._frame.width=this.orig.width=o,this._frame.height=this.orig.height=h,i&&this.baseTexture.resize(o,h),this.updateUvs()}setResolution(t){const{baseTexture:r}=this;r.resolution!==t&&(r.setResolution(t),this.resize(r.width,r.height,!1))}static create(t){return new As(new ol(t))}}class hl{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,r,i=yr.NONE){const n=new ol(Object.assign({width:t,height:r,resolution:1,multisample:i},this.textureOptions));return new As(n)}getOptimalTexture(t,r,i=1,n=yr.NONE){let o;t=Math.max(Math.ceil(t*i-1e-6),1),r=Math.max(Math.ceil(r*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||r!==this._pixelsHeight?(t=Rn(t),r=Rn(r),o=((t&65535)<<16|r&65535)>>>0,n>1&&(o+=n*4294967296)):o=n>1?-n:-1,this.texturePool[o]||(this.texturePool[o]=[]);let h=this.texturePool[o].pop();return h||(h=this.createTexture(t,r,n)),h.filterPoolKey=o,h.setResolution(i),h}getFilterTexture(t,r,i){const n=this.getOptimalTexture(t.width,t.height,r||t.resolution,i||yr.NONE);return n.filterFrame=t.filterFrame,n}returnTexture(t){const r=t.filterPoolKey;t.filterFrame=null,this.texturePool[r].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const r in this.texturePool){const i=this.texturePool[r];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const r in this.texturePool){if(!(Number(r)<0))continue;const i=this.texturePool[r];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[r]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}hl.SCREEN_KEY=-1;class vc extends hs{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class ll extends hs{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new br(this.vertices),this.uvBuffer=new br(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,r){let i=0,n=0;return this.uvs[0]=i,this.uvs[1]=n,this.uvs[2]=i+r.width/t.width,this.uvs[3]=n,this.uvs[4]=i+r.width/t.width,this.uvs[5]=n+r.height/t.height,this.uvs[6]=i,this.uvs[7]=n+r.height/t.height,i=r.x,n=r.y,this.vertices[0]=i,this.vertices[1]=n,this.vertices[2]=i+r.width,this.vertices[3]=n,this.vertices[4]=i+r.width,this.vertices[5]=n+r.height,this.vertices[6]=i,this.vertices[7]=n+r.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class xc{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=yr.NONE,this.sourceFrame=new Ve,this.destinationFrame=new Ve,this.bindingSourceFrame=new Ve,this.bindingDestinationFrame=new Ve,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ta=[new Ze,new Ze,new Ze,new Ze],ul=new nr;class cl{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new hl,this.statePool=[],this.quad=new vc,this.quadUv=new ll,this.tempRect=new Ve,this.activeState={},this.globalUniforms=new fi({outputFrame:new Ve,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,r){const i=this.renderer,n=this.defaultFilterStack,o=this.statePool.pop()||new xc,h=i.renderTexture;let f,A;if(h.current){const G=h.current;f=G.resolution,A=G.multisample}else f=i.resolution,A=i.multisample;let T=r[0].resolution||f,C=r[0].multisample??A,x=r[0].padding,M=r[0].autoFit,D=r[0].legacy??!0;for(let G=1;G<r.length;G++){const X=r[G];T=Math.min(T,X.resolution||f),C=Math.min(C,X.multisample??A),x=this.useMaxPadding?Math.max(x,X.padding):x+X.padding,M=M&&X.autoFit,D=D||(X.legacy??!0)}n.length===1&&(this.defaultFilterStack[0].renderTexture=h.current),n.push(o),o.resolution=T,o.multisample=C,o.legacy=D,o.target=t,o.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),o.sourceFrame.pad(x);const k=this.tempRect.copyFrom(h.sourceFrame);i.projection.transform&&this.transformAABB(ul.copyFrom(i.projection.transform).invert(),k),M?(o.sourceFrame.fit(k),(o.sourceFrame.width<=0||o.sourceFrame.height<=0)&&(o.sourceFrame.width=0,o.sourceFrame.height=0)):o.sourceFrame.intersects(k)||(o.sourceFrame.width=0,o.sourceFrame.height=0),this.roundFrame(o.sourceFrame,h.current?h.current.resolution:i.resolution,h.sourceFrame,h.destinationFrame,i.projection.transform),o.renderTexture=this.getOptimalFilterTexture(o.sourceFrame.width,o.sourceFrame.height,T,C),o.filters=r,o.destinationFrame.width=o.renderTexture.width,o.destinationFrame.height=o.renderTexture.height;const U=this.tempRect;U.x=0,U.y=0,U.width=o.sourceFrame.width,U.height=o.sourceFrame.height,o.renderTexture.filterFrame=o.sourceFrame,o.bindingSourceFrame.copyFrom(h.sourceFrame),o.bindingDestinationFrame.copyFrom(h.destinationFrame),o.transform=i.projection.transform,i.projection.transform=null,h.bind(o.renderTexture,o.sourceFrame,U),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,r=t.pop(),i=r.filters;this.activeState=r;const n=this.globalUniforms.uniforms;n.outputFrame=r.sourceFrame,n.resolution=r.resolution;const o=n.inputSize,h=n.inputPixel,f=n.inputClamp;if(o[0]=r.destinationFrame.width,o[1]=r.destinationFrame.height,o[2]=1/o[0],o[3]=1/o[1],h[0]=Math.round(o[0]*r.resolution),h[1]=Math.round(o[1]*r.resolution),h[2]=1/h[0],h[3]=1/h[1],f[0]=.5*h[2],f[1]=.5*h[3],f[2]=r.sourceFrame.width*o[2]-.5*h[2],f[3]=r.sourceFrame.height*o[3]-.5*h[3],r.legacy){const T=n.filterArea;T[0]=r.destinationFrame.width,T[1]=r.destinationFrame.height,T[2]=r.sourceFrame.x,T[3]=r.sourceFrame.y,n.filterClamp=n.inputClamp}this.globalUniforms.update();const A=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,r.renderTexture,A.renderTexture,Ti.BLEND,r),this.returnFilterTexture(r.renderTexture);else{let T=r.renderTexture,C=this.getOptimalFilterTexture(T.width,T.height,r.resolution);C.filterFrame=T.filterFrame;let x=0;for(x=0;x<i.length-1;++x){x===1&&r.multisample>1&&(C=this.getOptimalFilterTexture(T.width,T.height,r.resolution),C.filterFrame=T.filterFrame),i[x].apply(this,T,C,Ti.CLEAR,r);const M=T;T=C,C=M}i[x].apply(this,T,A.renderTexture,Ti.BLEND,r),x>1&&r.multisample>1&&this.returnFilterTexture(r.renderTexture),this.returnFilterTexture(T),this.returnFilterTexture(C)}r.clear(),this.statePool.push(r)}bindAndClear(t,r=Ti.CLEAR){const{renderTexture:i,state:n}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const h=this.tempRect;h.x=0,h.y=0,h.width=t.filterFrame.width,h.height=t.filterFrame.height,i.bind(t,t.filterFrame,h)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const o=n.stateId&1||this.forceClear;(r===Ti.CLEAR||r===Ti.BLIT&&o)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,r,i,n){const o=this.renderer;o.state.set(t.state),this.bindAndClear(i,n),t.uniforms.uSampler=r,t.uniforms.filterGlobals=this.globalUniforms,o.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(r._frame,r.filterFrame),o.geometry.bind(this.quadUv),o.geometry.draw(Ai.TRIANGLES)):(o.geometry.bind(this.quad),o.geometry.draw(Ai.TRIANGLE_STRIP))}calculateSpriteMatrix(t,r){const{sourceFrame:i,destinationFrame:n}=this.activeState,{orig:o}=r._texture,h=t.set(n.width,0,0,n.height,i.x,i.y),f=r.worldTransform.copyTo(nr.TEMP_MATRIX);return f.invert(),h.prepend(f),h.scale(1/o.width,1/o.height),h.translate(r.anchor.x,r.anchor.y),h}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,r,i=1,n=yr.NONE){return this.texturePool.getOptimalTexture(t,r,i,n)}getFilterTexture(t,r,i){if(typeof t=="number"){const o=t;t=r,r=o}t=t||this.activeState.renderTexture;const n=this.texturePool.getOptimalTexture(t.width,t.height,r||t.resolution,i||yr.NONE);return n.filterFrame=t.filterFrame,n}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,r){const i=ta[0],n=ta[1],o=ta[2],h=ta[3];i.set(r.left,r.top),n.set(r.left,r.bottom),o.set(r.right,r.top),h.set(r.right,r.bottom),t.apply(i,i),t.apply(n,n),t.apply(o,o),t.apply(h,h);const f=Math.min(i.x,n.x,o.x,h.x),A=Math.min(i.y,n.y,o.y,h.y),T=Math.max(i.x,n.x,o.x,h.x),C=Math.max(i.y,n.y,o.y,h.y);r.x=f,r.y=A,r.width=T-f,r.height=C-A}roundFrame(t,r,i,n,o){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(o){const{a:h,b:f,c:A,d:T}=o;if((Math.abs(f)>1e-4||Math.abs(A)>1e-4)&&(Math.abs(h)>1e-4||Math.abs(T)>1e-4))return}o=o?ul.copyFrom(o):ul.identity(),o.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.transformAABB(o,t),t.ceil(r),this.transformAABB(o.invert(),t)}}}cl.extension={type:ee.RendererSystem,name:"filter"},be.add(cl);class bc{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=yr.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const jp=new Ve;class fl{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Qo(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Ve,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let r=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;ue.PREFER_ENV===ys.WEBGL_LEGACY&&(r=null,i=null),r?t.drawBuffers=n=>r.drawBuffersWEBGL(n):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,r,i=0){const{gl:n}=this;if(t){const o=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,n.bindFramebuffer(n.FRAMEBUFFER,o.framebuffer)),o.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,o.mipLevel=i),o.dirtyId!==t.dirtyId&&(o.dirtyId=t.dirtyId,o.dirtyFormat!==t.dirtyFormat?(o.dirtyFormat=t.dirtyFormat,o.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):o.dirtySize!==t.dirtySize&&(o.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let h=0;h<t.colorTextures.length;h++){const f=t.colorTextures[h];this.renderer.texture.unbind(f.parentTextureArray||f)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),r){const h=r.width>>i,f=r.height>>i,A=h/r.width;this.setViewport(r.x*A,r.y*A,h,f)}else{const h=t.width>>i,f=t.height>>i;this.setViewport(0,0,h,f)}}else this.current&&(this.current=null,n.bindFramebuffer(n.FRAMEBUFFER,null)),r?this.setViewport(r.x,r.y,r.width,r.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,r,i,n){const o=this.viewport;t=Math.round(t),r=Math.round(r),i=Math.round(i),n=Math.round(n),(o.width!==i||o.height!==n||o.x!==t||o.y!==r)&&(o.x=t,o.y=r,o.width=i,o.height=n,this.gl.viewport(t,r,i,n))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,r,i,n,o=Lo.COLOR|Lo.DEPTH){const{gl:h}=this;h.clearColor(t,r,i,n),h.clear(o)}initFramebuffer(t){const{gl:r}=this,i=new bc(r.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:r}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){r.bindRenderbuffer(r.RENDERBUFFER,i.stencil);let h;this.renderer.context.webGLVersion===1?h=r.DEPTH_STENCIL:t.depth&&t.stencil?h=r.DEPTH24_STENCIL8:t.depth?h=r.DEPTH_COMPONENT24:h=r.STENCIL_INDEX8,i.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,i.multisample,h,t.width,t.height):r.renderbufferStorage(r.RENDERBUFFER,h,t.width,t.height)}const n=t.colorTextures;let o=n.length;r.drawBuffers||(o=Math.min(o,1));for(let h=0;h<o;h++){const f=n[h],A=f.parentTextureArray||f;this.renderer.texture.bind(A,0),h===0&&i.msaaBuffer&&(r.bindRenderbuffer(r.RENDERBUFFER,i.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,i.multisample,A._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,r){const{gl:i}=this,n=t.glFramebuffers[this.CONTEXT_UID],o=t.colorTextures;let h=o.length;i.drawBuffers||(h=Math.min(h,1)),n.multisample>1&&this.canMultisampleFramebuffer(t)?n.msaaBuffer=n.msaaBuffer||i.createRenderbuffer():n.msaaBuffer&&(i.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));const f=[];for(let A=0;A<h;A++){const T=o[A],C=T.parentTextureArray||T;this.renderer.texture.bind(C,0),A===0&&n.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,C._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+A,T.target,C._glTextures[this.CONTEXT_UID].texture,r),f.push(i.COLOR_ATTACHMENT0+A))}if(f.length>1&&i.drawBuffers(f),t.depthTexture&&this.writeDepthTexture){const A=t.depthTexture;this.renderer.texture.bind(A,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,A._glTextures[this.CONTEXT_UID].texture,r)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){n.stencil=n.stencil||i.createRenderbuffer();let A,T;this.renderer.context.webGLVersion===1?(A=i.DEPTH_STENCIL_ATTACHMENT,T=i.DEPTH_STENCIL):t.depth&&t.stencil?(A=i.DEPTH_STENCIL_ATTACHMENT,T=i.DEPTH24_STENCIL8):t.depth?(A=i.DEPTH_ATTACHMENT,T=i.DEPTH_COMPONENT24):(A=i.STENCIL_ATTACHMENT,T=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,T,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,T,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,A,i.RENDERBUFFER,n.stencil)}else n.stencil&&(i.deleteRenderbuffer(n.stencil),n.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:r}=this;let i=yr.NONE;if(t<=1||r===null)return i;for(let n=0;n<r.length;n++)if(r[n]<=t){i=r[n];break}return i===1&&(i=yr.NONE),i}blit(t,r,i){const{current:n,renderer:o,gl:h,CONTEXT_UID:f}=this;if(o.context.webGLVersion!==2||!n)return;const A=n.glFramebuffers[f];if(!A)return;if(!t){if(!A.msaaBuffer)return;const C=n.colorTextures[0];if(!C)return;A.blitFramebuffer||(A.blitFramebuffer=new Qo(n.width,n.height),A.blitFramebuffer.addColorTexture(0,C)),t=A.blitFramebuffer,t.colorTextures[0]!==C&&(t.colorTextures[0]=C,t.dirtyId++,t.dirtyFormat++),(t.width!==n.width||t.height!==n.height)&&(t.width=n.width,t.height=n.height,t.dirtyId++,t.dirtySize++)}r||(r=jp,r.width=n.width,r.height=n.height),i||(i=r);const T=r.width===i.width&&r.height===i.height;this.bind(t),h.bindFramebuffer(h.READ_FRAMEBUFFER,A.framebuffer),h.blitFramebuffer(r.left,r.top,r.right,r.bottom,i.left,i.top,i.right,i.bottom,h.COLOR_BUFFER_BIT,T?h.NEAREST:h.LINEAR),h.bindFramebuffer(h.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,r){const i=t.glFramebuffers[this.CONTEXT_UID],n=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const o=this.managedFramebuffers.indexOf(t);o>=0&&this.managedFramebuffers.splice(o,1),t.disposeRunner.remove(this),r||(n.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&n.deleteRenderbuffer(i.msaaBuffer),i.stencil&&n.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,r)}disposeAll(t){const r=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<r.length;i++)this.disposeFramebuffer(r[i],t)}forceStencil(){const t=this.current;if(!t)return;const r=t.glFramebuffers[this.CONTEXT_UID];if(!r||r.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,n=t.height,o=this.gl,h=r.stencil=o.createRenderbuffer();o.bindRenderbuffer(o.RENDERBUFFER,h);let f,A;this.renderer.context.webGLVersion===1?(f=o.DEPTH_STENCIL_ATTACHMENT,A=o.DEPTH_STENCIL):t.depth?(f=o.DEPTH_STENCIL_ATTACHMENT,A=o.DEPTH24_STENCIL8):(f=o.STENCIL_ATTACHMENT,A=o.STENCIL_INDEX8),r.msaaBuffer?o.renderbufferStorageMultisample(o.RENDERBUFFER,r.multisample,A,i,n):o.renderbufferStorage(o.RENDERBUFFER,A,i,n),o.framebufferRenderbuffer(o.FRAMEBUFFER,f,o.RENDERBUFFER,h)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Ve}destroy(){this.renderer=null}}fl.extension={type:ee.RendererSystem,name:"framebuffer"},be.add(fl);const dl={5126:4,5123:2,5121:1};class pl{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,r=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,r.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;ue.PREFER_ENV===ys.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=n=>i.bindVertexArrayOES(n),t.deleteVertexArray=n=>i.deleteVertexArrayOES(n)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(r.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(n,o)=>i.vertexAttribDivisorANGLE(n,o),t.drawElementsInstanced=(n,o,h,f,A)=>i.drawElementsInstancedANGLE(n,o,h,f,A),t.drawArraysInstanced=(n,o,h,f)=>i.drawArraysInstancedANGLE(n,o,h,f)):this.hasInstance=!1}this.canUseUInt32ElementIndex=r.webGLVersion===2||!!r.extensions.uint32ElementIndex}bind(t,r){r=r||this.renderer.shader.shader;const{gl:i}=this;let n=t.glVertexArrayObjects[this.CONTEXT_UID],o=!1;n||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=n={},o=!0);const h=n[r.program.id]||this.initGeometryVao(t,r,o);this._activeGeometry=t,this._activeVao!==h&&(this._activeVao=h,this.hasVao?i.bindVertexArray(h):this.activateVao(t,r.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,r=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const n=t.buffers[i];r.update(n)}}checkCompatibility(t,r){const i=t.attributes,n=r.attributeData;for(const o in n)if(!i[o])throw new Error(`shader and geometry incompatible, geometry missing the "${o}" attribute`)}getSignature(t,r){const i=t.attributes,n=r.attributeData,o=["g",t.id];for(const h in i)n[h]&&o.push(h,n[h].location);return o.join("-")}initGeometryVao(t,r,i=!0){const n=this.gl,o=this.CONTEXT_UID,h=this.renderer.buffer,f=r.program;f.glPrograms[o]||this.renderer.shader.generateProgram(r),this.checkCompatibility(t,f);const A=this.getSignature(t,f),T=t.glVertexArrayObjects[this.CONTEXT_UID];let C=T[A];if(C)return T[f.id]=C,C;const x=t.buffers,M=t.attributes,D={},k={};for(const U in x)D[U]=0,k[U]=0;for(const U in M)!M[U].size&&f.attributeData[U]?M[U].size=f.attributeData[U].size:M[U].size||console.warn(`PIXI Geometry attribute '${U}' size cannot be determined (likely the bound shader does not have the attribute)`),D[M[U].buffer]+=M[U].size*dl[M[U].type];for(const U in M){const G=M[U],X=G.size;G.stride===void 0&&(D[G.buffer]===X*dl[G.type]?G.stride=0:G.stride=D[G.buffer]),G.start===void 0&&(G.start=k[G.buffer],k[G.buffer]+=X*dl[G.type])}C=n.createVertexArray(),n.bindVertexArray(C);for(let U=0;U<x.length;U++){const G=x[U];h.bind(G),i&&G._glBuffers[o].refCount++}return this.activateVao(t,f),T[f.id]=C,T[A]=C,n.bindVertexArray(null),h.unbind(Ei.ARRAY_BUFFER),C}disposeGeometry(t,r){var f;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],n=this.gl,o=t.buffers,h=(f=this.renderer)==null?void 0:f.buffer;if(t.disposeRunner.remove(this),!!i){if(h)for(let A=0;A<o.length;A++){const T=o[A]._glBuffers[this.CONTEXT_UID];T&&(T.refCount--,T.refCount===0&&!r&&h.dispose(o[A],r))}if(!r){for(const A in i)if(A[0]==="g"){const T=i[A];this._activeVao===T&&this.unbind(),n.deleteVertexArray(T)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const r=Object.keys(this.managedGeometries);for(let i=0;i<r.length;i++)this.disposeGeometry(this.managedGeometries[r[i]],t)}activateVao(t,r){const i=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,h=t.buffers,f=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let A=null;for(const T in f){const C=f[T],x=h[C.buffer],M=x._glBuffers[n];if(r.attributeData[T]){A!==M&&(o.bind(x),A=M);const D=r.attributeData[T].location;if(i.enableVertexAttribArray(D),i.vertexAttribPointer(D,C.size,C.type||i.FLOAT,C.normalized,C.stride,C.start),C.instance)if(this.hasInstance)i.vertexAttribDivisor(D,C.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,r,i,n){const{gl:o}=this,h=this._activeGeometry;if(h.indexBuffer){const f=h.indexBuffer.data.BYTES_PER_ELEMENT,A=f===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;f===2||f===4&&this.canUseUInt32ElementIndex?h.instanced?o.drawElementsInstanced(t,r||h.indexBuffer.data.length,A,(i||0)*f,n||1):o.drawElements(t,r||h.indexBuffer.data.length,A,(i||0)*f):console.warn("unsupported index buffer type: uint32")}else h.instanced?o.drawArraysInstanced(t,i,r||h.getSize(),n||1):o.drawArrays(t,i,r||h.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}pl.extension={type:ee.RendererSystem,name:"geometry"},be.add(pl);const Ac=new nr;class ea{constructor(t,r){this._texture=t,this.mapCoord=new nr,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof r>"u"?.5:r,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,r){r===void 0&&(r=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const o=t[n],h=t[n+1];r[n]=o*i.a+h*i.c+i.tx,r[n+1]=o*i.b+h*i.d+i.ty}return r}update(t){const r=this._texture;if(!r||!r.valid||!t&&this._textureID===r._updateID)return!1;this._textureID=r._updateID,this._updateID++;const i=r._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const n=r.orig,o=r.trim;o&&(Ac.set(n.width/o.width,0,0,n.height/o.height,-o.x/o.width,-o.y/o.height),this.mapCoord.append(Ac));const h=r.baseTexture,f=this.uClampFrame,A=this.clampMargin/h.resolution,T=this.clampOffset;return f[0]=(r._frame.x+A+T)/h.width,f[1]=(r._frame.y+A+T)/h.height,f[2]=(r._frame.x+r._frame.width-A+T)/h.width,f[3]=(r._frame.y+r._frame.height-A+T)/h.height,this.uClampOffset[0]=T/h.realWidth,this.uClampOffset[1]=T/h.realHeight,this.isSimple=r._frame.width===h.width&&r._frame.height===h.height&&r.rotate===0,!0}}var qp=`varying vec2 vMaskCoord;
420
+ `;const il=class Mo extends Mi{constructor(t,r,i){const n=Wi.from(t||Mo.defaultVertexSrc,r||Mo.defaultFragmentSrc);super(n,i),this.padding=0,this.resolution=Mo.defaultResolution,this.multisample=Mo.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Pi}apply(t,r,i,n,o){t.applyFilter(this,r,i,n)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Yp}static get defaultFragmentSrc(){return Hp}};il.defaultResolution=1,il.defaultMultisample=yr.NONE;let Gr=il;class Gn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new rr(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:r,background:i,backgroundAlpha:n}=t,o=i??r;o!==void 0&&(this.color=o),this.alpha=n}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Gn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Gn.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"background"},Te.add(Gn);class sl{constructor(t){this.renderer=t,this.emptyRenderer=new Nn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,r){const{boundTextures:i}=this.renderer.texture;for(let n=r-1;n>=0;--n)t[n]=i[n]||null,t[n]&&(t[n]._batchLocation=n)}boundArray(t,r,i,n){const{elements:o,ids:h,count:f}=t;let A=0;for(let T=0;T<f;T++){const C=o[T],x=C._batchLocation;if(x>=0&&x<n&&r[x]===C){h[T]=x;continue}for(;A<n;){const M=r[A];if(M&&M._batchEnabled===i&&M._batchLocation===A){A++;continue}h[T]=A,C._batchLocation=A,r[A]=C;break}}}destroy(){this.renderer=null}}sl.extension={type:ee.RendererSystem,name:"batch"},Te.add(sl);let gc=0;class Vn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=gc++}init(t){if(t.context)this.initFromContext(t.context);else{const r=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:r,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=gc++,this.renderer.runners.contextChange.emit(t);const r=this.renderer.view;r.addEventListener!==void 0&&(r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const r=this.createContext(this.renderer.view,t);this.initFromContext(r)}createContext(t,r){let i;if(ue.PREFER_ENV>=ys.WEBGL2&&(i=t.getContext("webgl2",r)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",r)||t.getContext("experimental-webgl",r),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,r={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,r,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,r,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const r=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),r&&!r.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Vn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Vn.extension={type:ee.RendererSystem,name:"context"},Te.add(Vn);class Qo{constructor(t,r){if(this.width=Math.round(t),this.height=Math.round(r),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new si("disposeFramebuffer"),this.multisample=yr.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,r){return this.colorTextures[t]=r||new Ge(null,{scaleMode:Gi.NEAREST,resolution:1,mipmap:wi.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new Ge(null,{scaleMode:Gi.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:wi.OFF,format:qt.DEPTH_COMPONENT,type:Pe.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,r){if(t=Math.round(t),r=Math.round(r),!t||!r)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&r===this.height)){this.width=t,this.height=r,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const n=this.colorTextures[i],o=n.resolution;n.setSize(t/o,r/o)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,r/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class nl extends Ge{constructor(t={}){if(typeof t=="number"){const r=arguments[0],i=arguments[1],n=arguments[2],o=arguments[3];t={width:r,height:i,scaleMode:n,resolution:o}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=yr.NONE),super(null,t),this.mipmap=wi.OFF,this.valid=!0,this._clear=new rr([0,0,0,0]),this.framebuffer=new Qo(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,r){this.framebuffer.resize(t*this.resolution,r*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Hi extends en{constructor(t){const r=t,i=r.naturalWidth||r.videoWidth||r.displayWidth||r.width,n=r.naturalHeight||r.videoHeight||r.displayHeight||r.height;super(i,n),this.source=t,this.noSubImage=!1}static crossOrigin(t,r,i){i===void 0&&!r.startsWith("data:")?t.crossOrigin=K0(r):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,r,i,n){const o=t.gl,h=r.realWidth,f=r.realHeight;if(n=n||this.source,typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement){if(!n.complete||n.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement&&n.readyState<=1)return!1;return o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===Vr.UNPACK),!this.noSubImage&&r.target===o.TEXTURE_2D&&i.width===h&&i.height===f?o.texSubImage2D(o.TEXTURE_2D,0,0,0,r.format,i.type,n):(i.width=h,i.height=f,o.texImage2D(r.target,0,i.internalFormat,r.format,i.type,n)),!0}update(){if(this.destroyed)return;const t=this.source,r=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(r,i),super.update()}dispose(){this.source=null}}class ol extends Hi{constructor(t,r){if(r=r||{},typeof t=="string"){const i=new Image;Hi.crossOrigin(i,t,r.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(r.createBitmap??ue.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,this.bitmap=null,this._load=null,r.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((r,i)=>{const n=this.source;this.url=n.src;const o=()=>{this.destroyed||(n.onload=null,n.onerror=null,this.update(),this._load=null,this.createBitmap?r(this.process()):r(this))};n.complete&&n.src?o():(n.onload=o,n.onerror=h=>{i(h),this.onError.emit(h)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const r=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(n=>n.blob()).then(n=>r(n,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Vr.UNPACK?"premultiply":"none"})).then(n=>this.destroyed?Promise.reject():(this.bitmap=n,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,r,i){if(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,r,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,r,i,this.bitmap),!this.preserveBitmap){let n=!0;const o=r._glTextures;for(const h in o){const f=o[h];if(f!==i&&f.dirtyId!==r.dirtyId){n=!1;break}}n&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ko{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,r,i){const n=r.width,o=r.height;if(i){const h=t.width/2/n,f=t.height/2/o,A=t.x/n+h,T=t.y/o+f;i=dr.add(i,dr.NW),this.x0=A+h*dr.uX(i),this.y0=T+f*dr.uY(i),i=dr.add(i,2),this.x1=A+h*dr.uX(i),this.y1=T+f*dr.uY(i),i=dr.add(i,2),this.x2=A+h*dr.uX(i),this.y2=T+f*dr.uY(i),i=dr.add(i,2),this.x3=A+h*dr.uX(i),this.y3=T+f*dr.uY(i)}else this.x0=t.x/n,this.y0=t.y/o,this.x1=(t.x+t.width)/n,this.y1=t.y/o,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/o,this.x3=t.x/n,this.y3=(t.y+t.height)/o;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Ko.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const mc=new Ko;function Jo(s){s.destroy=function(){},s.on=function(){},s.once=function(){},s.emit=function(){}}class ne extends ns{constructor(t,r,i,n,o,h,f){if(super(),this.noFrame=!1,r||(this.noFrame=!0,r=new Ve(0,0,1,1)),t instanceof ne&&(t=t.baseTexture),this.baseTexture=t,this._frame=r,this.trim=n,this.valid=!1,this.destroyed=!1,this._uvs=mc,this.uvMatrix=null,this.orig=i||r,this._rotate=Number(o||0),o===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=h?new Ze(h.x,h.y):new Ze(0,0),this.defaultBorders=f,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=r:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:r}=this.baseTexture;r!=null&&r.url&&zr[r.url]&&ne.removeFromCache(r.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,ne.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var n;const t=this._frame.clone(),r=this._frame===this.orig?t:this.orig.clone(),i=new ne(this.baseTexture,!this.noFrame&&t,r,(n=this.trim)==null?void 0:n.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===mc&&(this._uvs=new Ko),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,r={},i=ue.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let o=null;if(n)o=t;else if(t instanceof Ge){if(!t.cacheId){const f=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t.cacheId=`${f}-${vs()}`,Ge.addToCache(t,t.cacheId)}o=t.cacheId}else{if(!t._pixiId){const f=(r==null?void 0:r.pixiIdPrefix)||"pixiid";t._pixiId=`${f}_${vs()}`}o=t._pixiId}let h=zr[o];if(n&&i&&!h)throw new Error(`The cacheId "${o}" does not exist in TextureCache.`);return!h&&!(t instanceof Ge)?(r.resolution||(r.resolution=Xi(t)),h=new ne(new Ge(t,r)),h.baseTexture.cacheId=o,Ge.addToCache(h.baseTexture,o),ne.addToCache(h,o)):!h&&t instanceof Ge&&(h=new ne(t),ne.addToCache(h,o)),h}static fromURL(t,r){const i=Object.assign({autoLoad:!1},r==null?void 0:r.resourceOptions),n=ne.from(t,Object.assign({resourceOptions:i},r),!1),o=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):o.load().then(()=>Promise.resolve(n))}static fromBuffer(t,r,i,n){return new ne(Ge.fromBuffer(t,r,i,n))}static fromLoader(t,r,i,n){const o=new Ge(t,Object.assign({scaleMode:Ge.defaultOptions.scaleMode,resolution:Xi(r)},n)),{resource:h}=o;h instanceof ol&&(h.url=r);const f=new ne(o);return i||(i=r),Ge.addToCache(f.baseTexture,i),ne.addToCache(f,i),i!==r&&(Ge.addToCache(f.baseTexture,r),ne.addToCache(f,r)),f.baseTexture.valid?Promise.resolve(f):new Promise(A=>{f.baseTexture.once("loaded",()=>A(f))})}static addToCache(t,r){r&&(t.textureCacheIds.includes(r)||t.textureCacheIds.push(r),zr[r]&&zr[r]!==t&&console.warn(`Texture added to the cache with an id [${r}] that already had an entry`),zr[r]=t)}static removeFromCache(t){if(typeof t=="string"){const r=zr[t];if(r){const i=r.textureCacheIds.indexOf(t);return i>-1&&r.textureCacheIds.splice(i,1),delete zr[t],r}}else if(t!=null&&t.textureCacheIds){for(let r=0;r<t.textureCacheIds.length;++r)zr[t.textureCacheIds[r]]===t&&delete zr[t.textureCacheIds[r]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:r,y:i,width:n,height:o}=t,h=r+n>this.baseTexture.width,f=i+o>this.baseTexture.height;if(h||f){const A=h&&f?"and":"or",T=`X: ${r} + ${n} = ${r+n} > ${this.baseTexture.width}`,C=`Y: ${i} + ${o} = ${i+o} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${T} ${A} ${C}`)}this.valid=n&&o&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return ne._EMPTY||(ne._EMPTY=new ne(new Ge),Jo(ne._EMPTY),Jo(ne._EMPTY.baseTexture)),ne._EMPTY}static get WHITE(){if(!ne._WHITE){const t=ue.ADAPTER.createCanvas(16,16),r=t.getContext("2d");t.width=16,t.height=16,r.fillStyle="white",r.fillRect(0,0,16,16),ne._WHITE=new ne(Ge.from(t)),Jo(ne._WHITE),Jo(ne._WHITE.baseTexture)}return ne._WHITE}}class As extends ne{constructor(t,r){super(t,r),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,r,i=!0){const n=this.baseTexture.resolution,o=Math.round(t*n)/n,h=Math.round(r*n)/n;this.valid=o>0&&h>0,this._frame.width=this.orig.width=o,this._frame.height=this.orig.height=h,i&&this.baseTexture.resize(o,h),this.updateUvs()}setResolution(t){const{baseTexture:r}=this;r.resolution!==t&&(r.setResolution(t),this.resize(r.width,r.height,!1))}static create(t){return new As(new nl(t))}}class al{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,r,i=yr.NONE){const n=new nl(Object.assign({width:t,height:r,resolution:1,multisample:i},this.textureOptions));return new As(n)}getOptimalTexture(t,r,i=1,n=yr.NONE){let o;t=Math.max(Math.ceil(t*i-1e-6),1),r=Math.max(Math.ceil(r*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||r!==this._pixelsHeight?(t=Rn(t),r=Rn(r),o=((t&65535)<<16|r&65535)>>>0,n>1&&(o+=n*4294967296)):o=n>1?-n:-1,this.texturePool[o]||(this.texturePool[o]=[]);let h=this.texturePool[o].pop();return h||(h=this.createTexture(t,r,n)),h.filterPoolKey=o,h.setResolution(i),h}getFilterTexture(t,r,i){const n=this.getOptimalTexture(t.width,t.height,r||t.resolution,i||yr.NONE);return n.filterFrame=t.filterFrame,n}returnTexture(t){const r=t.filterPoolKey;t.filterFrame=null,this.texturePool[r].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const r in this.texturePool){const i=this.texturePool[r];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const r in this.texturePool){if(!(Number(r)<0))continue;const i=this.texturePool[r];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[r]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}al.SCREEN_KEY=-1;class yc extends hs{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class hl extends hs{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new br(this.vertices),this.uvBuffer=new br(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,r){let i=0,n=0;return this.uvs[0]=i,this.uvs[1]=n,this.uvs[2]=i+r.width/t.width,this.uvs[3]=n,this.uvs[4]=i+r.width/t.width,this.uvs[5]=n+r.height/t.height,this.uvs[6]=i,this.uvs[7]=n+r.height/t.height,i=r.x,n=r.y,this.vertices[0]=i,this.vertices[1]=n,this.vertices[2]=i+r.width,this.vertices[3]=n,this.vertices[4]=i+r.width,this.vertices[5]=n+r.height,this.vertices[6]=i,this.vertices[7]=n+r.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class vc{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=yr.NONE,this.sourceFrame=new Ve,this.destinationFrame=new Ve,this.bindingSourceFrame=new Ve,this.bindingDestinationFrame=new Ve,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ta=[new Ze,new Ze,new Ze,new Ze],ll=new nr;class ul{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new al,this.statePool=[],this.quad=new yc,this.quadUv=new hl,this.tempRect=new Ve,this.activeState={},this.globalUniforms=new fi({outputFrame:new Ve,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,r){const i=this.renderer,n=this.defaultFilterStack,o=this.statePool.pop()||new vc,h=i.renderTexture;let f,A;if(h.current){const G=h.current;f=G.resolution,A=G.multisample}else f=i.resolution,A=i.multisample;let T=r[0].resolution||f,C=r[0].multisample??A,x=r[0].padding,M=r[0].autoFit,D=r[0].legacy??!0;for(let G=1;G<r.length;G++){const X=r[G];T=Math.min(T,X.resolution||f),C=Math.min(C,X.multisample??A),x=this.useMaxPadding?Math.max(x,X.padding):x+X.padding,M=M&&X.autoFit,D=D||(X.legacy??!0)}n.length===1&&(this.defaultFilterStack[0].renderTexture=h.current),n.push(o),o.resolution=T,o.multisample=C,o.legacy=D,o.target=t,o.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),o.sourceFrame.pad(x);const k=this.tempRect.copyFrom(h.sourceFrame);i.projection.transform&&this.transformAABB(ll.copyFrom(i.projection.transform).invert(),k),M?(o.sourceFrame.fit(k),(o.sourceFrame.width<=0||o.sourceFrame.height<=0)&&(o.sourceFrame.width=0,o.sourceFrame.height=0)):o.sourceFrame.intersects(k)||(o.sourceFrame.width=0,o.sourceFrame.height=0),this.roundFrame(o.sourceFrame,h.current?h.current.resolution:i.resolution,h.sourceFrame,h.destinationFrame,i.projection.transform),o.renderTexture=this.getOptimalFilterTexture(o.sourceFrame.width,o.sourceFrame.height,T,C),o.filters=r,o.destinationFrame.width=o.renderTexture.width,o.destinationFrame.height=o.renderTexture.height;const U=this.tempRect;U.x=0,U.y=0,U.width=o.sourceFrame.width,U.height=o.sourceFrame.height,o.renderTexture.filterFrame=o.sourceFrame,o.bindingSourceFrame.copyFrom(h.sourceFrame),o.bindingDestinationFrame.copyFrom(h.destinationFrame),o.transform=i.projection.transform,i.projection.transform=null,h.bind(o.renderTexture,o.sourceFrame,U),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,r=t.pop(),i=r.filters;this.activeState=r;const n=this.globalUniforms.uniforms;n.outputFrame=r.sourceFrame,n.resolution=r.resolution;const o=n.inputSize,h=n.inputPixel,f=n.inputClamp;if(o[0]=r.destinationFrame.width,o[1]=r.destinationFrame.height,o[2]=1/o[0],o[3]=1/o[1],h[0]=Math.round(o[0]*r.resolution),h[1]=Math.round(o[1]*r.resolution),h[2]=1/h[0],h[3]=1/h[1],f[0]=.5*h[2],f[1]=.5*h[3],f[2]=r.sourceFrame.width*o[2]-.5*h[2],f[3]=r.sourceFrame.height*o[3]-.5*h[3],r.legacy){const T=n.filterArea;T[0]=r.destinationFrame.width,T[1]=r.destinationFrame.height,T[2]=r.sourceFrame.x,T[3]=r.sourceFrame.y,n.filterClamp=n.inputClamp}this.globalUniforms.update();const A=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,r.renderTexture,A.renderTexture,Ti.BLEND,r),this.returnFilterTexture(r.renderTexture);else{let T=r.renderTexture,C=this.getOptimalFilterTexture(T.width,T.height,r.resolution);C.filterFrame=T.filterFrame;let x=0;for(x=0;x<i.length-1;++x){x===1&&r.multisample>1&&(C=this.getOptimalFilterTexture(T.width,T.height,r.resolution),C.filterFrame=T.filterFrame),i[x].apply(this,T,C,Ti.CLEAR,r);const M=T;T=C,C=M}i[x].apply(this,T,A.renderTexture,Ti.BLEND,r),x>1&&r.multisample>1&&this.returnFilterTexture(r.renderTexture),this.returnFilterTexture(T),this.returnFilterTexture(C)}r.clear(),this.statePool.push(r)}bindAndClear(t,r=Ti.CLEAR){const{renderTexture:i,state:n}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const h=this.tempRect;h.x=0,h.y=0,h.width=t.filterFrame.width,h.height=t.filterFrame.height,i.bind(t,t.filterFrame,h)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const o=n.stateId&1||this.forceClear;(r===Ti.CLEAR||r===Ti.BLIT&&o)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,r,i,n){const o=this.renderer;o.state.set(t.state),this.bindAndClear(i,n),t.uniforms.uSampler=r,t.uniforms.filterGlobals=this.globalUniforms,o.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(r._frame,r.filterFrame),o.geometry.bind(this.quadUv),o.geometry.draw(Ai.TRIANGLES)):(o.geometry.bind(this.quad),o.geometry.draw(Ai.TRIANGLE_STRIP))}calculateSpriteMatrix(t,r){const{sourceFrame:i,destinationFrame:n}=this.activeState,{orig:o}=r._texture,h=t.set(n.width,0,0,n.height,i.x,i.y),f=r.worldTransform.copyTo(nr.TEMP_MATRIX);return f.invert(),h.prepend(f),h.scale(1/o.width,1/o.height),h.translate(r.anchor.x,r.anchor.y),h}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,r,i=1,n=yr.NONE){return this.texturePool.getOptimalTexture(t,r,i,n)}getFilterTexture(t,r,i){if(typeof t=="number"){const o=t;t=r,r=o}t=t||this.activeState.renderTexture;const n=this.texturePool.getOptimalTexture(t.width,t.height,r||t.resolution,i||yr.NONE);return n.filterFrame=t.filterFrame,n}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,r){const i=ta[0],n=ta[1],o=ta[2],h=ta[3];i.set(r.left,r.top),n.set(r.left,r.bottom),o.set(r.right,r.top),h.set(r.right,r.bottom),t.apply(i,i),t.apply(n,n),t.apply(o,o),t.apply(h,h);const f=Math.min(i.x,n.x,o.x,h.x),A=Math.min(i.y,n.y,o.y,h.y),T=Math.max(i.x,n.x,o.x,h.x),C=Math.max(i.y,n.y,o.y,h.y);r.x=f,r.y=A,r.width=T-f,r.height=C-A}roundFrame(t,r,i,n,o){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(o){const{a:h,b:f,c:A,d:T}=o;if((Math.abs(f)>1e-4||Math.abs(A)>1e-4)&&(Math.abs(h)>1e-4||Math.abs(T)>1e-4))return}o=o?ll.copyFrom(o):ll.identity(),o.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.transformAABB(o,t),t.ceil(r),this.transformAABB(o.invert(),t)}}}ul.extension={type:ee.RendererSystem,name:"filter"},Te.add(ul);class xc{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=yr.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const jp=new Ve;class cl{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Qo(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Ve,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let r=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;ue.PREFER_ENV===ys.WEBGL_LEGACY&&(r=null,i=null),r?t.drawBuffers=n=>r.drawBuffersWEBGL(n):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,r,i=0){const{gl:n}=this;if(t){const o=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,n.bindFramebuffer(n.FRAMEBUFFER,o.framebuffer)),o.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,o.mipLevel=i),o.dirtyId!==t.dirtyId&&(o.dirtyId=t.dirtyId,o.dirtyFormat!==t.dirtyFormat?(o.dirtyFormat=t.dirtyFormat,o.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):o.dirtySize!==t.dirtySize&&(o.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let h=0;h<t.colorTextures.length;h++){const f=t.colorTextures[h];this.renderer.texture.unbind(f.parentTextureArray||f)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),r){const h=r.width>>i,f=r.height>>i,A=h/r.width;this.setViewport(r.x*A,r.y*A,h,f)}else{const h=t.width>>i,f=t.height>>i;this.setViewport(0,0,h,f)}}else this.current&&(this.current=null,n.bindFramebuffer(n.FRAMEBUFFER,null)),r?this.setViewport(r.x,r.y,r.width,r.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,r,i,n){const o=this.viewport;t=Math.round(t),r=Math.round(r),i=Math.round(i),n=Math.round(n),(o.width!==i||o.height!==n||o.x!==t||o.y!==r)&&(o.x=t,o.y=r,o.width=i,o.height=n,this.gl.viewport(t,r,i,n))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,r,i,n,o=Lo.COLOR|Lo.DEPTH){const{gl:h}=this;h.clearColor(t,r,i,n),h.clear(o)}initFramebuffer(t){const{gl:r}=this,i=new xc(r.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:r}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){r.bindRenderbuffer(r.RENDERBUFFER,i.stencil);let h;this.renderer.context.webGLVersion===1?h=r.DEPTH_STENCIL:t.depth&&t.stencil?h=r.DEPTH24_STENCIL8:t.depth?h=r.DEPTH_COMPONENT24:h=r.STENCIL_INDEX8,i.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,i.multisample,h,t.width,t.height):r.renderbufferStorage(r.RENDERBUFFER,h,t.width,t.height)}const n=t.colorTextures;let o=n.length;r.drawBuffers||(o=Math.min(o,1));for(let h=0;h<o;h++){const f=n[h],A=f.parentTextureArray||f;this.renderer.texture.bind(A,0),h===0&&i.msaaBuffer&&(r.bindRenderbuffer(r.RENDERBUFFER,i.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,i.multisample,A._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,r){const{gl:i}=this,n=t.glFramebuffers[this.CONTEXT_UID],o=t.colorTextures;let h=o.length;i.drawBuffers||(h=Math.min(h,1)),n.multisample>1&&this.canMultisampleFramebuffer(t)?n.msaaBuffer=n.msaaBuffer||i.createRenderbuffer():n.msaaBuffer&&(i.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));const f=[];for(let A=0;A<h;A++){const T=o[A],C=T.parentTextureArray||T;this.renderer.texture.bind(C,0),A===0&&n.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,C._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+A,T.target,C._glTextures[this.CONTEXT_UID].texture,r),f.push(i.COLOR_ATTACHMENT0+A))}if(f.length>1&&i.drawBuffers(f),t.depthTexture&&this.writeDepthTexture){const A=t.depthTexture;this.renderer.texture.bind(A,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,A._glTextures[this.CONTEXT_UID].texture,r)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){n.stencil=n.stencil||i.createRenderbuffer();let A,T;this.renderer.context.webGLVersion===1?(A=i.DEPTH_STENCIL_ATTACHMENT,T=i.DEPTH_STENCIL):t.depth&&t.stencil?(A=i.DEPTH_STENCIL_ATTACHMENT,T=i.DEPTH24_STENCIL8):t.depth?(A=i.DEPTH_ATTACHMENT,T=i.DEPTH_COMPONENT24):(A=i.STENCIL_ATTACHMENT,T=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,T,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,T,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,A,i.RENDERBUFFER,n.stencil)}else n.stencil&&(i.deleteRenderbuffer(n.stencil),n.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:r}=this;let i=yr.NONE;if(t<=1||r===null)return i;for(let n=0;n<r.length;n++)if(r[n]<=t){i=r[n];break}return i===1&&(i=yr.NONE),i}blit(t,r,i){const{current:n,renderer:o,gl:h,CONTEXT_UID:f}=this;if(o.context.webGLVersion!==2||!n)return;const A=n.glFramebuffers[f];if(!A)return;if(!t){if(!A.msaaBuffer)return;const C=n.colorTextures[0];if(!C)return;A.blitFramebuffer||(A.blitFramebuffer=new Qo(n.width,n.height),A.blitFramebuffer.addColorTexture(0,C)),t=A.blitFramebuffer,t.colorTextures[0]!==C&&(t.colorTextures[0]=C,t.dirtyId++,t.dirtyFormat++),(t.width!==n.width||t.height!==n.height)&&(t.width=n.width,t.height=n.height,t.dirtyId++,t.dirtySize++)}r||(r=jp,r.width=n.width,r.height=n.height),i||(i=r);const T=r.width===i.width&&r.height===i.height;this.bind(t),h.bindFramebuffer(h.READ_FRAMEBUFFER,A.framebuffer),h.blitFramebuffer(r.left,r.top,r.right,r.bottom,i.left,i.top,i.right,i.bottom,h.COLOR_BUFFER_BIT,T?h.NEAREST:h.LINEAR),h.bindFramebuffer(h.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,r){const i=t.glFramebuffers[this.CONTEXT_UID],n=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const o=this.managedFramebuffers.indexOf(t);o>=0&&this.managedFramebuffers.splice(o,1),t.disposeRunner.remove(this),r||(n.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&n.deleteRenderbuffer(i.msaaBuffer),i.stencil&&n.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,r)}disposeAll(t){const r=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<r.length;i++)this.disposeFramebuffer(r[i],t)}forceStencil(){const t=this.current;if(!t)return;const r=t.glFramebuffers[this.CONTEXT_UID];if(!r||r.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,n=t.height,o=this.gl,h=r.stencil=o.createRenderbuffer();o.bindRenderbuffer(o.RENDERBUFFER,h);let f,A;this.renderer.context.webGLVersion===1?(f=o.DEPTH_STENCIL_ATTACHMENT,A=o.DEPTH_STENCIL):t.depth?(f=o.DEPTH_STENCIL_ATTACHMENT,A=o.DEPTH24_STENCIL8):(f=o.STENCIL_ATTACHMENT,A=o.STENCIL_INDEX8),r.msaaBuffer?o.renderbufferStorageMultisample(o.RENDERBUFFER,r.multisample,A,i,n):o.renderbufferStorage(o.RENDERBUFFER,A,i,n),o.framebufferRenderbuffer(o.FRAMEBUFFER,f,o.RENDERBUFFER,h)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Ve}destroy(){this.renderer=null}}cl.extension={type:ee.RendererSystem,name:"framebuffer"},Te.add(cl);const fl={5126:4,5123:2,5121:1};class dl{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,r=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,r.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;ue.PREFER_ENV===ys.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=n=>i.bindVertexArrayOES(n),t.deleteVertexArray=n=>i.deleteVertexArrayOES(n)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(r.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(n,o)=>i.vertexAttribDivisorANGLE(n,o),t.drawElementsInstanced=(n,o,h,f,A)=>i.drawElementsInstancedANGLE(n,o,h,f,A),t.drawArraysInstanced=(n,o,h,f)=>i.drawArraysInstancedANGLE(n,o,h,f)):this.hasInstance=!1}this.canUseUInt32ElementIndex=r.webGLVersion===2||!!r.extensions.uint32ElementIndex}bind(t,r){r=r||this.renderer.shader.shader;const{gl:i}=this;let n=t.glVertexArrayObjects[this.CONTEXT_UID],o=!1;n||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=n={},o=!0);const h=n[r.program.id]||this.initGeometryVao(t,r,o);this._activeGeometry=t,this._activeVao!==h&&(this._activeVao=h,this.hasVao?i.bindVertexArray(h):this.activateVao(t,r.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,r=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const n=t.buffers[i];r.update(n)}}checkCompatibility(t,r){const i=t.attributes,n=r.attributeData;for(const o in n)if(!i[o])throw new Error(`shader and geometry incompatible, geometry missing the "${o}" attribute`)}getSignature(t,r){const i=t.attributes,n=r.attributeData,o=["g",t.id];for(const h in i)n[h]&&o.push(h,n[h].location);return o.join("-")}initGeometryVao(t,r,i=!0){const n=this.gl,o=this.CONTEXT_UID,h=this.renderer.buffer,f=r.program;f.glPrograms[o]||this.renderer.shader.generateProgram(r),this.checkCompatibility(t,f);const A=this.getSignature(t,f),T=t.glVertexArrayObjects[this.CONTEXT_UID];let C=T[A];if(C)return T[f.id]=C,C;const x=t.buffers,M=t.attributes,D={},k={};for(const U in x)D[U]=0,k[U]=0;for(const U in M)!M[U].size&&f.attributeData[U]?M[U].size=f.attributeData[U].size:M[U].size||console.warn(`PIXI Geometry attribute '${U}' size cannot be determined (likely the bound shader does not have the attribute)`),D[M[U].buffer]+=M[U].size*fl[M[U].type];for(const U in M){const G=M[U],X=G.size;G.stride===void 0&&(D[G.buffer]===X*fl[G.type]?G.stride=0:G.stride=D[G.buffer]),G.start===void 0&&(G.start=k[G.buffer],k[G.buffer]+=X*fl[G.type])}C=n.createVertexArray(),n.bindVertexArray(C);for(let U=0;U<x.length;U++){const G=x[U];h.bind(G),i&&G._glBuffers[o].refCount++}return this.activateVao(t,f),T[f.id]=C,T[A]=C,n.bindVertexArray(null),h.unbind(Ei.ARRAY_BUFFER),C}disposeGeometry(t,r){var f;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],n=this.gl,o=t.buffers,h=(f=this.renderer)==null?void 0:f.buffer;if(t.disposeRunner.remove(this),!!i){if(h)for(let A=0;A<o.length;A++){const T=o[A]._glBuffers[this.CONTEXT_UID];T&&(T.refCount--,T.refCount===0&&!r&&h.dispose(o[A],r))}if(!r){for(const A in i)if(A[0]==="g"){const T=i[A];this._activeVao===T&&this.unbind(),n.deleteVertexArray(T)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const r=Object.keys(this.managedGeometries);for(let i=0;i<r.length;i++)this.disposeGeometry(this.managedGeometries[r[i]],t)}activateVao(t,r){const i=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,h=t.buffers,f=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let A=null;for(const T in f){const C=f[T],x=h[C.buffer],M=x._glBuffers[n];if(r.attributeData[T]){A!==M&&(o.bind(x),A=M);const D=r.attributeData[T].location;if(i.enableVertexAttribArray(D),i.vertexAttribPointer(D,C.size,C.type||i.FLOAT,C.normalized,C.stride,C.start),C.instance)if(this.hasInstance)i.vertexAttribDivisor(D,C.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,r,i,n){const{gl:o}=this,h=this._activeGeometry;if(h.indexBuffer){const f=h.indexBuffer.data.BYTES_PER_ELEMENT,A=f===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;f===2||f===4&&this.canUseUInt32ElementIndex?h.instanced?o.drawElementsInstanced(t,r||h.indexBuffer.data.length,A,(i||0)*f,n||1):o.drawElements(t,r||h.indexBuffer.data.length,A,(i||0)*f):console.warn("unsupported index buffer type: uint32")}else h.instanced?o.drawArraysInstanced(t,i,r||h.getSize(),n||1):o.drawArrays(t,i,r||h.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}dl.extension={type:ee.RendererSystem,name:"geometry"},Te.add(dl);const bc=new nr;class ea{constructor(t,r){this._texture=t,this.mapCoord=new nr,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof r>"u"?.5:r,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,r){r===void 0&&(r=t);const i=this.mapCoord;for(let n=0;n<t.length;n+=2){const o=t[n],h=t[n+1];r[n]=o*i.a+h*i.c+i.tx,r[n+1]=o*i.b+h*i.d+i.ty}return r}update(t){const r=this._texture;if(!r||!r.valid||!t&&this._textureID===r._updateID)return!1;this._textureID=r._updateID,this._updateID++;const i=r._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const n=r.orig,o=r.trim;o&&(bc.set(n.width/o.width,0,0,n.height/o.height,-o.x/o.width,-o.y/o.height),this.mapCoord.append(bc));const h=r.baseTexture,f=this.uClampFrame,A=this.clampMargin/h.resolution,T=this.clampOffset;return f[0]=(r._frame.x+A+T)/h.width,f[1]=(r._frame.y+A+T)/h.height,f[2]=(r._frame.x+r._frame.width-A+T)/h.width,f[3]=(r._frame.y+r._frame.height-A+T)/h.height,this.uClampOffset[0]=T/h.realWidth,this.uClampOffset[1]=T/h.realHeight,this.isSimple=r._frame.width===h.width&&r._frame.height===h.height&&r.rotate===0,!0}}var qp=`varying vec2 vMaskCoord;
421
421
  varying vec2 vTextureCoord;
422
422
 
423
423
  uniform sampler2D uSampler;
@@ -458,7 +458,7 @@ void main(void)
458
458
  vTextureCoord = aTextureCoord;
459
459
  vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
460
460
  }
461
- `;class wc extends Gr{constructor(t,r,i){let n=null;typeof t!="string"&&r===void 0&&i===void 0&&(n=t,t=void 0,r=void 0,i=void 0),super(t||Zp,r||qp,i),this.maskSprite=n,this.maskMatrix=new nr}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,r,i,n){const o=this._maskSprite,h=o._texture;h.valid&&(h.uvMatrix||(h.uvMatrix=new ea(h,0)),h.uvMatrix.update(),this.uniforms.npmAlpha=h.baseTexture.alphaMode?0:1,this.uniforms.mask=h,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,o).prepend(h.uvMatrix.mapCoord),this.uniforms.alpha=o.worldAlpha,this.uniforms.maskClamp=h.uvMatrix.uClampFrame,t.applyFilter(this,r,i,n))}}class Tc{constructor(t=null){this.type=xr.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Gr.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=xr.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class _l{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,r){let i=r;if(!i.isMaskData){const o=this.maskDataPool.pop()||new Tc;o.pooled=!0,o.maskObject=r,i=o}const n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(n),i._colorMask=n?n._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==xr.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case xr.SCISSOR:this.renderer.scissor.push(i);break;case xr.STENCIL:this.renderer.stencil.push(i);break;case xr.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case xr.COLOR:this.pushColorMask(i);break}i.type===xr.SPRITE&&this.maskStack.push(i)}pop(t){const r=this.maskStack.pop();if(!(!r||r._target!==t)){if(r.enabled)switch(r.type){case xr.SCISSOR:this.renderer.scissor.pop(r);break;case xr.STENCIL:this.renderer.stencil.pop(r.maskObject);break;case xr.SPRITE:this.popSpriteMask(r);break;case xr.COLOR:this.popColorMask(r);break}if(r.reset(),r.pooled&&this.maskDataPool.push(r),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===xr.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const r=t.maskObject;r?r.isSprite?t.type=xr.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=xr.SCISSOR:t.type=xr.STENCIL:t.type=xr.COLOR}pushSpriteMask(t){const{maskObject:r}=t,i=t._target;let n=t._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new wc])),n[0].resolution=t.resolution,n[0].multisample=t.multisample,n[0].maskSprite=r;const o=i.filterArea;i.filterArea=r.getBounds(!0),this.renderer.filter.push(i,n),i.filterArea=o,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const r=t._colorMask,i=t._colorMask=r&t.colorMask;i!==r&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const r=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==r&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}_l.extension={type:ee.RendererSystem,name:"mask"},be.add(_l);class Ec{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:r}=this.renderer,i=this.getStackLength();this.maskStack=t;const n=this.getStackLength();n!==i&&(n===0?r.disable(this.glConst):(r.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Cc=new nr,Sc=[],Pc=class Ga extends Ec{constructor(t){super(t),this.glConst=ue.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const r=t._scissorRect,{maskObject:i}=t,{renderer:n}=this,o=n.renderTexture,h=i.getBounds(!0,Sc.pop()??new Ve);this.roundFrameToPixels(h,o.current?o.current.resolution:n.resolution,o.sourceFrame,o.destinationFrame,n.projection.transform),r&&h.fit(r),t._scissorRectLocal=h}static isMatrixRotated(t){if(!t)return!1;const{a:r,b:i,c:n,d:o}=t;return(Math.abs(i)>1e-4||Math.abs(n)>1e-4)&&(Math.abs(r)>1e-4||Math.abs(o)>1e-4)}testScissor(t){const{maskObject:r}=t;if(!r.isFastRect||!r.isFastRect()||Ga.isMatrixRotated(r.worldTransform)||Ga.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,r,i,n,o){Ga.isMatrixRotated(o)||(o=o?Cc.copyFrom(o):Cc.identity(),o.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.renderer.filter.transformAABB(o,t),t.fit(n),t.x=Math.round(t.x*r),t.y=Math.round(t.y*r),t.width=Math.round(t.width*r),t.height=Math.round(t.height*r))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:r}=this.renderer;t._scissorRect||r.enable(r.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:r}=this.renderer;t&&Sc.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():r.disable(r.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let r;this.renderer.renderTexture.current?r=t.y:r=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,r,t.width,t.height)}};Pc.extension={type:ee.RendererSystem,name:"scissor"};let $c=Pc;be.add($c);class gl extends Ec{constructor(t){super(t),this.glConst=ue.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const r=t.maskObject,{gl:i}=this.renderer,n=t._stencilCounter;n===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const o=t._colorMask;o!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,n,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),r.renderable=!0,r.render(this.renderer),this.renderer.batch.flush(),r.renderable=!1,o!==0&&(t._colorMask=o,i.colorMask((o&1)!==0,(o&2)!==0,(o&4)!==0,(o&8)!==0)),this._useCurrent()}pop(t){const r=this.renderer.gl;if(this.getStackLength()===0)r.disable(r.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,n=i?i._colorMask:15;n!==0&&(i._colorMask=0,r.colorMask(!1,!1,!1,!1)),r.stencilOp(r.KEEP,r.KEEP,r.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,n!==0&&(i._colorMask=n,r.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}gl.extension={type:ee.RendererSystem,name:"stencil"},be.add(gl);class ml{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const r in t)this.plugins[r]=new t[r](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}ml.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"_plugin"},be.add(ml);class yl{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new nr,this.transform=null}update(t,r,i,n){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=r||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,n),this.transform&&this.projectionMatrix.append(this.transform);const o=this.renderer;o.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,o.globalUniforms.update(),o.shader.shader&&o.shader.syncUniformGroup(o.shader.shader.uniforms.globals)}calculateProjection(t,r,i,n){const o=this.projectionMatrix,h=n?-1:1;o.identity(),o.a=1/r.width*2,o.d=h*(1/r.height*2),o.tx=-1-r.x*o.a,o.ty=-h-r.y*o.d}setTransform(t){}destroy(){this.renderer=null}}yl.extension={type:ee.RendererSystem,name:"projection"},be.add(yl);const Qp=new rn,Mc=new Ve;class vl{constructor(t){this.renderer=t,this._tempMatrix=new nr}generateTexture(t,r){const{region:i,...n}=r||{},o=(i==null?void 0:i.copyTo(Mc))||t.getLocalBounds(Mc,!0),h=n.resolution||this.renderer.resolution;o.width=Math.max(o.width,1/h),o.height=Math.max(o.height,1/h),n.width=o.width,n.height=o.height,n.resolution=h,n.multisample??(n.multisample=this.renderer.multisample);const f=As.create(n);this._tempMatrix.tx=-o.x,this._tempMatrix.ty=-o.y;const A=t.transform;return t.transform=Qp,this.renderer.render(t,{renderTexture:f,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=A,f}destroy(){}}vl.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"textureGenerator"},be.add(vl);const Vs=new Ve,zn=new Ve;class xl{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Ve,this.destinationFrame=new Ve,this.viewportFrame=new Ve}contextChange(){var r;const t=(r=this.renderer)==null?void 0:r.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,r,i){const n=this.renderer;this.current=t;let o,h,f;t?(o=t.baseTexture,f=o.resolution,r||(Vs.width=t.frame.width,Vs.height=t.frame.height,r=Vs),i||(zn.x=t.frame.x,zn.y=t.frame.y,zn.width=r.width,zn.height=r.height,i=zn),h=o.framebuffer):(f=n.resolution,r||(Vs.width=n._view.screen.width,Vs.height=n._view.screen.height,r=Vs),i||(i=Vs,i.width=r.width,i.height=r.height));const A=this.viewportFrame;A.x=i.x*f,A.y=i.y*f,A.width=i.width*f,A.height=i.height*f,t||(A.y=n.view.height-(A.y+A.height)),A.ceil(),this.renderer.framebuffer.bind(h,A),this.renderer.projection.update(i,r,f,!h),t?this.renderer.mask.setMaskStack(o.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(r),this.destinationFrame.copyFrom(i)}clear(t,r){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,n=rr.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&n.premultiply(n.alpha);const o=this.destinationFrame,h=this.current?this.current.baseTexture:this.renderer._view.screen,f=o.width!==h.width||o.height!==h.height;if(f){let{x:A,y:T,width:C,height:x}=this.viewportFrame;A=Math.round(A),T=Math.round(T),C=Math.round(C),x=Math.round(x),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(A,T,C,x)}this.renderer.framebuffer.clear(n.red,n.green,n.blue,n.alpha,r),f&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}xl.extension={type:ee.RendererSystem,name:"renderTexture"},be.add(xl);class Kp{}class Rc{constructor(t,r){this.program=t,this.uniformData=r,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Jp(s,t){const r={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const o=t.getActiveAttrib(s,n);if(o.name.startsWith("gl_"))continue;const h=dc(t,o.type),f={type:h,name:o.name,size:cc(h),location:t.getAttribLocation(s,o.name)};r[o.name]=f}return r}function t_(s,t){const r={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const o=t.getActiveUniform(s,n),h=o.name.replace(/\[.*?\]$/,""),f=!!o.name.match(/\[.*?\]$/),A=dc(t,o.type);r[h]={name:h,index:n,type:A,size:o.size,isArray:f,value:ac(A,o.size)}}return r}function Ic(s,t){var f;const r=oc(s,s.VERTEX_SHADER,t.vertexSrc),i=oc(s,s.FRAGMENT_SHADER,t.fragmentSrc),n=s.createProgram();s.attachShader(n,r),s.attachShader(n,i);const o=(f=t.extra)==null?void 0:f.transformFeedbackVaryings;if(o&&(typeof s.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(n,o.names,o.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(n),s.getProgramParameter(n,s.LINK_STATUS)||Op(s,n,r,i),t.attributeData=Jp(n,s),t.uniformData=t_(n,s),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const A=Object.keys(t.attributeData);A.sort((T,C)=>T>C?1:-1);for(let T=0;T<A.length;T++)t.attributeData[A[T]].location=T,s.bindAttribLocation(n,T,A[T]);s.linkProgram(n)}s.deleteShader(r),s.deleteShader(i);const h={};for(const A in t.uniformData){const T=t.uniformData[A];h[A]={location:s.getUniformLocation(n,A),value:ac(T.type,T.size)}}return new Rc(n,h)}function e_(s,t,r,i,n){r.buffer.update(n)}const r_={float:`
461
+ `;class Ac extends Gr{constructor(t,r,i){let n=null;typeof t!="string"&&r===void 0&&i===void 0&&(n=t,t=void 0,r=void 0,i=void 0),super(t||Zp,r||qp,i),this.maskSprite=n,this.maskMatrix=new nr}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,r,i,n){const o=this._maskSprite,h=o._texture;h.valid&&(h.uvMatrix||(h.uvMatrix=new ea(h,0)),h.uvMatrix.update(),this.uniforms.npmAlpha=h.baseTexture.alphaMode?0:1,this.uniforms.mask=h,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,o).prepend(h.uvMatrix.mapCoord),this.uniforms.alpha=o.worldAlpha,this.uniforms.maskClamp=h.uvMatrix.uClampFrame,t.applyFilter(this,r,i,n))}}class wc{constructor(t=null){this.type=xr.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Gr.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=xr.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class pl{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,r){let i=r;if(!i.isMaskData){const o=this.maskDataPool.pop()||new wc;o.pooled=!0,o.maskObject=r,i=o}const n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(n),i._colorMask=n?n._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==xr.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case xr.SCISSOR:this.renderer.scissor.push(i);break;case xr.STENCIL:this.renderer.stencil.push(i);break;case xr.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case xr.COLOR:this.pushColorMask(i);break}i.type===xr.SPRITE&&this.maskStack.push(i)}pop(t){const r=this.maskStack.pop();if(!(!r||r._target!==t)){if(r.enabled)switch(r.type){case xr.SCISSOR:this.renderer.scissor.pop(r);break;case xr.STENCIL:this.renderer.stencil.pop(r.maskObject);break;case xr.SPRITE:this.popSpriteMask(r);break;case xr.COLOR:this.popColorMask(r);break}if(r.reset(),r.pooled&&this.maskDataPool.push(r),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===xr.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const r=t.maskObject;r?r.isSprite?t.type=xr.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=xr.SCISSOR:t.type=xr.STENCIL:t.type=xr.COLOR}pushSpriteMask(t){const{maskObject:r}=t,i=t._target;let n=t._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new Ac])),n[0].resolution=t.resolution,n[0].multisample=t.multisample,n[0].maskSprite=r;const o=i.filterArea;i.filterArea=r.getBounds(!0),this.renderer.filter.push(i,n),i.filterArea=o,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const r=t._colorMask,i=t._colorMask=r&t.colorMask;i!==r&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const r=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==r&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}pl.extension={type:ee.RendererSystem,name:"mask"},Te.add(pl);class Tc{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:r}=this.renderer,i=this.getStackLength();this.maskStack=t;const n=this.getStackLength();n!==i&&(n===0?r.disable(this.glConst):(r.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Ec=new nr,Cc=[],Sc=class Ua extends Tc{constructor(t){super(t),this.glConst=ue.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const r=t._scissorRect,{maskObject:i}=t,{renderer:n}=this,o=n.renderTexture,h=i.getBounds(!0,Cc.pop()??new Ve);this.roundFrameToPixels(h,o.current?o.current.resolution:n.resolution,o.sourceFrame,o.destinationFrame,n.projection.transform),r&&h.fit(r),t._scissorRectLocal=h}static isMatrixRotated(t){if(!t)return!1;const{a:r,b:i,c:n,d:o}=t;return(Math.abs(i)>1e-4||Math.abs(n)>1e-4)&&(Math.abs(r)>1e-4||Math.abs(o)>1e-4)}testScissor(t){const{maskObject:r}=t;if(!r.isFastRect||!r.isFastRect()||Ua.isMatrixRotated(r.worldTransform)||Ua.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,r,i,n,o){Ua.isMatrixRotated(o)||(o=o?Ec.copyFrom(o):Ec.identity(),o.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.renderer.filter.transformAABB(o,t),t.fit(n),t.x=Math.round(t.x*r),t.y=Math.round(t.y*r),t.width=Math.round(t.width*r),t.height=Math.round(t.height*r))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:r}=this.renderer;t._scissorRect||r.enable(r.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:r}=this.renderer;t&&Cc.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():r.disable(r.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let r;this.renderer.renderTexture.current?r=t.y:r=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,r,t.width,t.height)}};Sc.extension={type:ee.RendererSystem,name:"scissor"};let Pc=Sc;Te.add(Pc);class _l extends Tc{constructor(t){super(t),this.glConst=ue.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const r=t.maskObject,{gl:i}=this.renderer,n=t._stencilCounter;n===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const o=t._colorMask;o!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,n,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),r.renderable=!0,r.render(this.renderer),this.renderer.batch.flush(),r.renderable=!1,o!==0&&(t._colorMask=o,i.colorMask((o&1)!==0,(o&2)!==0,(o&4)!==0,(o&8)!==0)),this._useCurrent()}pop(t){const r=this.renderer.gl;if(this.getStackLength()===0)r.disable(r.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,n=i?i._colorMask:15;n!==0&&(i._colorMask=0,r.colorMask(!1,!1,!1,!1)),r.stencilOp(r.KEEP,r.KEEP,r.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,n!==0&&(i._colorMask=n,r.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}_l.extension={type:ee.RendererSystem,name:"stencil"},Te.add(_l);class gl{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return Oe("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const r in t)this.plugins[r]=new t[r](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}gl.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"_plugin"},Te.add(gl);class ml{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new nr,this.transform=null}update(t,r,i,n){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=r||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,n),this.transform&&this.projectionMatrix.append(this.transform);const o=this.renderer;o.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,o.globalUniforms.update(),o.shader.shader&&o.shader.syncUniformGroup(o.shader.shader.uniforms.globals)}calculateProjection(t,r,i,n){const o=this.projectionMatrix,h=n?-1:1;o.identity(),o.a=1/r.width*2,o.d=h*(1/r.height*2),o.tx=-1-r.x*o.a,o.ty=-h-r.y*o.d}setTransform(t){}destroy(){this.renderer=null}}ml.extension={type:ee.RendererSystem,name:"projection"},Te.add(ml);const Qp=new rn,$c=new Ve;class yl{constructor(t){this.renderer=t,this._tempMatrix=new nr}generateTexture(t,r){const{region:i,...n}=r||{},o=(i==null?void 0:i.copyTo($c))||t.getLocalBounds($c,!0),h=n.resolution||this.renderer.resolution;o.width=Math.max(o.width,1/h),o.height=Math.max(o.height,1/h),n.width=o.width,n.height=o.height,n.resolution=h,n.multisample??(n.multisample=this.renderer.multisample);const f=As.create(n);this._tempMatrix.tx=-o.x,this._tempMatrix.ty=-o.y;const A=t.transform;return t.transform=Qp,this.renderer.render(t,{renderTexture:f,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=A,f}destroy(){}}yl.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"textureGenerator"},Te.add(yl);const Vs=new Ve,zn=new Ve;class vl{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Ve,this.destinationFrame=new Ve,this.viewportFrame=new Ve}contextChange(){var r;const t=(r=this.renderer)==null?void 0:r.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,r,i){const n=this.renderer;this.current=t;let o,h,f;t?(o=t.baseTexture,f=o.resolution,r||(Vs.width=t.frame.width,Vs.height=t.frame.height,r=Vs),i||(zn.x=t.frame.x,zn.y=t.frame.y,zn.width=r.width,zn.height=r.height,i=zn),h=o.framebuffer):(f=n.resolution,r||(Vs.width=n._view.screen.width,Vs.height=n._view.screen.height,r=Vs),i||(i=Vs,i.width=r.width,i.height=r.height));const A=this.viewportFrame;A.x=i.x*f,A.y=i.y*f,A.width=i.width*f,A.height=i.height*f,t||(A.y=n.view.height-(A.y+A.height)),A.ceil(),this.renderer.framebuffer.bind(h,A),this.renderer.projection.update(i,r,f,!h),t?this.renderer.mask.setMaskStack(o.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(r),this.destinationFrame.copyFrom(i)}clear(t,r){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,n=rr.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&n.premultiply(n.alpha);const o=this.destinationFrame,h=this.current?this.current.baseTexture:this.renderer._view.screen,f=o.width!==h.width||o.height!==h.height;if(f){let{x:A,y:T,width:C,height:x}=this.viewportFrame;A=Math.round(A),T=Math.round(T),C=Math.round(C),x=Math.round(x),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(A,T,C,x)}this.renderer.framebuffer.clear(n.red,n.green,n.blue,n.alpha,r),f&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}vl.extension={type:ee.RendererSystem,name:"renderTexture"},Te.add(vl);class Kp{}class Mc{constructor(t,r){this.program=t,this.uniformData=r,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Jp(s,t){const r={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const o=t.getActiveAttrib(s,n);if(o.name.startsWith("gl_"))continue;const h=fc(t,o.type),f={type:h,name:o.name,size:uc(h),location:t.getAttribLocation(s,o.name)};r[o.name]=f}return r}function t_(s,t){const r={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const o=t.getActiveUniform(s,n),h=o.name.replace(/\[.*?\]$/,""),f=!!o.name.match(/\[.*?\]$/),A=fc(t,o.type);r[h]={name:h,index:n,type:A,size:o.size,isArray:f,value:oc(A,o.size)}}return r}function Rc(s,t){var f;const r=nc(s,s.VERTEX_SHADER,t.vertexSrc),i=nc(s,s.FRAGMENT_SHADER,t.fragmentSrc),n=s.createProgram();s.attachShader(n,r),s.attachShader(n,i);const o=(f=t.extra)==null?void 0:f.transformFeedbackVaryings;if(o&&(typeof s.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(n,o.names,o.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(n),s.getProgramParameter(n,s.LINK_STATUS)||Op(s,n,r,i),t.attributeData=Jp(n,s),t.uniformData=t_(n,s),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const A=Object.keys(t.attributeData);A.sort((T,C)=>T>C?1:-1);for(let T=0;T<A.length;T++)t.attributeData[A[T]].location=T,s.bindAttribLocation(n,T,A[T]);s.linkProgram(n)}s.deleteShader(r),s.deleteShader(i);const h={};for(const A in t.uniformData){const T=t.uniformData[A];h[A]={location:s.getUniformLocation(n,A),value:oc(T.type,T.size)}}return new Mc(n,h)}function e_(s,t,r,i,n){r.buffer.update(n)}const r_={float:`
462
462
  data[offset] = v;
463
463
  `,vec2:`
464
464
  data[offset] = v[0];
@@ -496,7 +496,7 @@ void main(void)
496
496
  {
497
497
  data[offset + i] = v[i];
498
498
  }
499
- `},Dc={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Fc(s){const t=s.map(o=>({data:o,offset:0,dataLen:0,dirty:0}));let r=0,i=0,n=0;for(let o=0;o<t.length;o++){const h=t[o];if(r=Dc[h.data.type],h.data.size>1&&(r=Math.max(r,16)*h.data.size),h.dataLen=r,i%r!==0&&i<16){const f=i%r%16;i+=f,n+=f}i+r>16?(n=Math.ceil(n/16)*16,h.offset=n,n+=r,i=r):(h.offset=n,i+=r,n+=r)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function Lc(s,t){const r=[];for(const i in s)t[i]&&r.push(t[i]);return r.sort((i,n)=>i.index-n.index),r}function Bc(s,t){if(!s.autoManage)return{size:0,syncFunc:e_};const r=Lc(s.uniforms,t),{uboElements:i,size:n}=Fc(r),o=[`
499
+ `},Ic={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Dc(s){const t=s.map(o=>({data:o,offset:0,dataLen:0,dirty:0}));let r=0,i=0,n=0;for(let o=0;o<t.length;o++){const h=t[o];if(r=Ic[h.data.type],h.data.size>1&&(r=Math.max(r,16)*h.data.size),h.dataLen=r,i%r!==0&&i<16){const f=i%r%16;i+=f,n+=f}i+r>16?(n=Math.ceil(n/16)*16,h.offset=n,n+=r,i=r):(h.offset=n,i+=r,n+=r)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function Fc(s,t){const r=[];for(const i in s)t[i]&&r.push(t[i]);return r.sort((i,n)=>i.index-n.index),r}function Lc(s,t){if(!s.autoManage)return{size:0,syncFunc:e_};const r=Fc(s.uniforms,t),{uboElements:i,size:n}=Dc(r),o=[`
500
500
  var v = null;
501
501
  var v2 = null;
502
502
  var cv = null;
@@ -504,7 +504,7 @@ void main(void)
504
504
  var gl = renderer.gl
505
505
  var index = 0;
506
506
  var data = buffer.data;
507
- `];for(let h=0;h<i.length;h++){const f=i[h],A=s.uniforms[f.data.name],T=f.data.name;let C=!1;for(let x=0;x<Gs.length;x++){const M=Gs[x];if(M.codeUbo&&M.test(f.data,A)){o.push(`offset = ${f.offset/4};`,Gs[x].codeUbo(f.data.name,A)),C=!0;break}}if(!C)if(f.data.size>1){const x=cc(f.data.type),M=Math.max(Dc[f.data.type]/16,1),D=x/M,k=(4-D%4)%4;o.push(`
507
+ `];for(let h=0;h<i.length;h++){const f=i[h],A=s.uniforms[f.data.name],T=f.data.name;let C=!1;for(let x=0;x<Gs.length;x++){const M=Gs[x];if(M.codeUbo&&M.test(f.data,A)){o.push(`offset = ${f.offset/4};`,Gs[x].codeUbo(f.data.name,A)),C=!0;break}}if(!C)if(f.data.size>1){const x=uc(f.data.type),M=Math.max(Ic[f.data.type]/16,1),D=x/M,k=(4-D%4)%4;o.push(`
508
508
  cv = ud.${T}.value;
509
509
  v = uv.${T};
510
510
  offset = ${f.offset/4};
@@ -528,7 +528,7 @@ void main(void)
528
528
  `)}}return o.push(`
529
529
  renderer.buffer.update(buffer);
530
530
  `),{size:n,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(`
531
- `))}}let i_=0;const ra={textureCount:0,uboCount:0};class bl{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=i_++}systemCheck(){if(!_c())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,r){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,n=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(n.program)),r||(ra.textureCount=0,ra.uboCount=0,this.syncUniformGroup(t.uniformGroup,ra)),n}setUniforms(t){const r=this.shader.program,i=r.glPrograms[this.renderer.CONTEXT_UID];r.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,r){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,r))}syncUniforms(t,r,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(r.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const r=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[r]||(this.cache[r]=Bp(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[r],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,r){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const n=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,r);t.buffer.update(),n(i.uniformData,t.uniforms,this.renderer,ra,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[r])}createSyncBufferGroup(t,r,i){const{gl:n}=this.renderer;this.renderer.buffer.bind(t.buffer);const o=this.gl.getUniformBlockIndex(r.program,i);r.uniformBufferBindings[i]=this.shader.uniformBindCount,n.uniformBlockBinding(r.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;const h=this.getSignature(t,this.shader.program.uniformData,"ubo");let f=this._uboCache[h];if(f||(f=this._uboCache[h]=Bc(t,this.shader.program.uniformData)),t.autoManage){const A=new Float32Array(f.size/4);t.buffer.update(A)}return r.uniformGroups[t.id]=f.syncFunc,r.uniformGroups[t.id]}getSignature(t,r,i){const n=t.uniforms,o=[`${i}-`];for(const h in n)o.push(h),r[h]&&o.push(r[h].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const r=this.gl,i=t.program,n=Ic(r,i);return i.glPrograms[this.renderer.CONTEXT_UID]=n,n}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}bl.extension={type:ee.RendererSystem,name:"shader"},be.add(bl);class Xn{constructor(t){this.renderer=t}run(t){const{renderer:r}=this;r.runners.init.emit(r.options),t.hello&&console.log(`PixiJS 7.4.3 - ${r.rendererLogId} - https://pixijs.com`),r.resize(r.screen.width,r.screen.height)}destroy(){}}Xn.defaultOptions={hello:!1},Xn.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"startup"},be.add(Xn);function s_(s,t=[]){return t[Re.NORMAL]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.ADD]=[s.ONE,s.ONE],t[Re.MULTIPLY]=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SCREEN]=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.OVERLAY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.DARKEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.LIGHTEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.COLOR_DODGE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.COLOR_BURN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.HARD_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SOFT_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.DIFFERENCE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.EXCLUSION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.HUE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SATURATION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.COLOR]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.LUMINOSITY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.NONE]=[0,0],t[Re.NORMAL_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.ADD_NPM]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t[Re.SCREEN_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SRC_IN]=[s.DST_ALPHA,s.ZERO],t[Re.SRC_OUT]=[s.ONE_MINUS_DST_ALPHA,s.ZERO],t[Re.SRC_ATOP]=[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[Re.DST_OVER]=[s.ONE_MINUS_DST_ALPHA,s.ONE],t[Re.DST_IN]=[s.ZERO,s.SRC_ALPHA],t[Re.DST_OUT]=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t[Re.DST_ATOP]=[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],t[Re.XOR]=[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[Re.SUBTRACT]=[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD],t}const n_=0,o_=1,a_=2,h_=3,l_=4,u_=5,kc=class Eu{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Re.NONE,this._blendEq=!1,this.map=[],this.map[n_]=this.setBlend,this.map[o_]=this.setOffset,this.map[a_]=this.setCullFace,this.map[h_]=this.setDepthTest,this.map[l_]=this.setFrontFace,this.map[u_]=this.setDepthMask,this.checks=[],this.defaultState=new Pi,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=s_(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let r=this.stateId^t.data,i=0;for(;r;)r&1&&this.map[i].call(this,!!(t.data&1<<i)),r=r>>1,i++;this.stateId=t.data}for(let r=0;r<this.checks.length;r++)this.checks[r](this,t)}forceState(t){t=t||this.defaultState;for(let r=0;r<this.map.length;r++)this.map[r].call(this,!!(t.data&1<<r));for(let r=0;r<this.checks.length;r++)this.checks[r](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(Eu.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Eu.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const r=this.blendModes[t],i=this.gl;r.length===2?i.blendFunc(r[0],r[1]):i.blendFuncSeparate(r[0],r[1],r[2],r[3]),r.length===6?(this._blendEq=!0,i.blendEquationSeparate(r[4],r[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,r){this.gl.polygonOffset(t,r)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,r){const i=this.checks.indexOf(t);r&&i===-1?this.checks.push(t):!r&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,r){t.setBlendMode(r.blendMode)}static checkPolygonOffset(t,r){t.setPolygonOffset(1,r.polygonOffset)}destroy(){this.gl=null}};kc.extension={type:ee.RendererSystem,name:"state"};let Oc=kc;be.add(Oc);class Nc extends ns{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const r=(t.priority??[]).filter(n=>t.systems[n]),i=[...r,...Object.keys(t.systems).filter(n=>!r.includes(n))];for(const n of i)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(r=>{this.runners[r]=new si(r)})}addSystem(t,r){const i=new t(this);if(this[r])throw new Error(`Whoops! The name "${r}" is already in use`);this[r]=i,this._systemsHash[r]=i;for(const n in this.runners)this.runners[n].add(i);return this}emitWithCustomOptions(t,r){const i=Object.keys(this._systemsHash);t.items.forEach(n=>{const o=i.find(h=>this._systemsHash[h]===n);n[t.name](r[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Wn=class Va{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Va.defaultMaxIdle,this.checkCountMax=Va.defaultCheckCountMax,this.mode=Va.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Bo.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,r=t.managedTextures;let i=!1;for(let n=0;n<r.length;n++){const o=r[n];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),r[n]=null,i=!0)}if(i){let n=0;for(let o=0;o<r.length;o++)r[o]!==null&&(r[n++]=r[o]);r.length=n}}unload(t){const r=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&r.destroyTexture(i);for(let n=t.children.length-1;n>=0;n--)this.unload(t.children[n])}destroy(){this.renderer=null}};Wn.defaultMode=Bo.AUTO,Wn.defaultMaxIdle=60*60,Wn.defaultCheckCountMax=60*10,Wn.extension={type:ee.RendererSystem,name:"textureGC"};let ws=Wn;be.add(ws);class ia{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Pe.UNSIGNED_BYTE,this.internalFormat=qt.RGBA,this.samplerType=0}}function c_(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[s.RGB]:le.FLOAT,[s.RGBA]:le.FLOAT,[s.ALPHA]:le.FLOAT,[s.LUMINANCE]:le.FLOAT,[s.LUMINANCE_ALPHA]:le.FLOAT,[s.R8]:le.FLOAT,[s.R8_SNORM]:le.FLOAT,[s.RG8]:le.FLOAT,[s.RG8_SNORM]:le.FLOAT,[s.RGB8]:le.FLOAT,[s.RGB8_SNORM]:le.FLOAT,[s.RGB565]:le.FLOAT,[s.RGBA4]:le.FLOAT,[s.RGB5_A1]:le.FLOAT,[s.RGBA8]:le.FLOAT,[s.RGBA8_SNORM]:le.FLOAT,[s.RGB10_A2]:le.FLOAT,[s.RGB10_A2UI]:le.FLOAT,[s.SRGB8]:le.FLOAT,[s.SRGB8_ALPHA8]:le.FLOAT,[s.R16F]:le.FLOAT,[s.RG16F]:le.FLOAT,[s.RGB16F]:le.FLOAT,[s.RGBA16F]:le.FLOAT,[s.R32F]:le.FLOAT,[s.RG32F]:le.FLOAT,[s.RGB32F]:le.FLOAT,[s.RGBA32F]:le.FLOAT,[s.R11F_G11F_B10F]:le.FLOAT,[s.RGB9_E5]:le.FLOAT,[s.R8I]:le.INT,[s.R8UI]:le.UINT,[s.R16I]:le.INT,[s.R16UI]:le.UINT,[s.R32I]:le.INT,[s.R32UI]:le.UINT,[s.RG8I]:le.INT,[s.RG8UI]:le.UINT,[s.RG16I]:le.INT,[s.RG16UI]:le.UINT,[s.RG32I]:le.INT,[s.RG32UI]:le.UINT,[s.RGB8I]:le.INT,[s.RGB8UI]:le.UINT,[s.RGB16I]:le.INT,[s.RGB16UI]:le.UINT,[s.RGB32I]:le.INT,[s.RGB32UI]:le.UINT,[s.RGBA8I]:le.INT,[s.RGBA8UI]:le.UINT,[s.RGBA16I]:le.INT,[s.RGBA16UI]:le.UINT,[s.RGBA32I]:le.INT,[s.RGBA32UI]:le.UINT,[s.DEPTH_COMPONENT16]:le.FLOAT,[s.DEPTH_COMPONENT24]:le.FLOAT,[s.DEPTH_COMPONENT32F]:le.FLOAT,[s.DEPTH_STENCIL]:le.FLOAT,[s.DEPTH24_STENCIL8]:le.FLOAT,[s.DEPTH32F_STENCIL8]:le.FLOAT}:t={[s.RGB]:le.FLOAT,[s.RGBA]:le.FLOAT,[s.ALPHA]:le.FLOAT,[s.LUMINANCE]:le.FLOAT,[s.LUMINANCE_ALPHA]:le.FLOAT,[s.DEPTH_STENCIL]:le.FLOAT},t}function f_(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[Pe.UNSIGNED_BYTE]:{[qt.RGBA]:s.RGBA8,[qt.RGB]:s.RGB8,[qt.RG]:s.RG8,[qt.RED]:s.R8,[qt.RGBA_INTEGER]:s.RGBA8UI,[qt.RGB_INTEGER]:s.RGB8UI,[qt.RG_INTEGER]:s.RG8UI,[qt.RED_INTEGER]:s.R8UI,[qt.ALPHA]:s.ALPHA,[qt.LUMINANCE]:s.LUMINANCE,[qt.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Pe.BYTE]:{[qt.RGBA]:s.RGBA8_SNORM,[qt.RGB]:s.RGB8_SNORM,[qt.RG]:s.RG8_SNORM,[qt.RED]:s.R8_SNORM,[qt.RGBA_INTEGER]:s.RGBA8I,[qt.RGB_INTEGER]:s.RGB8I,[qt.RG_INTEGER]:s.RG8I,[qt.RED_INTEGER]:s.R8I},[Pe.UNSIGNED_SHORT]:{[qt.RGBA_INTEGER]:s.RGBA16UI,[qt.RGB_INTEGER]:s.RGB16UI,[qt.RG_INTEGER]:s.RG16UI,[qt.RED_INTEGER]:s.R16UI,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT16},[Pe.SHORT]:{[qt.RGBA_INTEGER]:s.RGBA16I,[qt.RGB_INTEGER]:s.RGB16I,[qt.RG_INTEGER]:s.RG16I,[qt.RED_INTEGER]:s.R16I},[Pe.UNSIGNED_INT]:{[qt.RGBA_INTEGER]:s.RGBA32UI,[qt.RGB_INTEGER]:s.RGB32UI,[qt.RG_INTEGER]:s.RG32UI,[qt.RED_INTEGER]:s.R32UI,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT24},[Pe.INT]:{[qt.RGBA_INTEGER]:s.RGBA32I,[qt.RGB_INTEGER]:s.RGB32I,[qt.RG_INTEGER]:s.RG32I,[qt.RED_INTEGER]:s.R32I},[Pe.FLOAT]:{[qt.RGBA]:s.RGBA32F,[qt.RGB]:s.RGB32F,[qt.RG]:s.RG32F,[qt.RED]:s.R32F,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT32F},[Pe.HALF_FLOAT]:{[qt.RGBA]:s.RGBA16F,[qt.RGB]:s.RGB16F,[qt.RG]:s.RG16F,[qt.RED]:s.R16F},[Pe.UNSIGNED_SHORT_5_6_5]:{[qt.RGB]:s.RGB565},[Pe.UNSIGNED_SHORT_4_4_4_4]:{[qt.RGBA]:s.RGBA4},[Pe.UNSIGNED_SHORT_5_5_5_1]:{[qt.RGBA]:s.RGB5_A1},[Pe.UNSIGNED_INT_2_10_10_10_REV]:{[qt.RGBA]:s.RGB10_A2,[qt.RGBA_INTEGER]:s.RGB10_A2UI},[Pe.UNSIGNED_INT_10F_11F_11F_REV]:{[qt.RGB]:s.R11F_G11F_B10F},[Pe.UNSIGNED_INT_5_9_9_9_REV]:{[qt.RGB]:s.RGB9_E5},[Pe.UNSIGNED_INT_24_8]:{[qt.DEPTH_STENCIL]:s.DEPTH24_STENCIL8},[Pe.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[qt.DEPTH_STENCIL]:s.DEPTH32F_STENCIL8}}:t={[Pe.UNSIGNED_BYTE]:{[qt.RGBA]:s.RGBA,[qt.RGB]:s.RGB,[qt.ALPHA]:s.ALPHA,[qt.LUMINANCE]:s.LUMINANCE,[qt.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Pe.UNSIGNED_SHORT_5_6_5]:{[qt.RGB]:s.RGB},[Pe.UNSIGNED_SHORT_4_4_4_4]:{[qt.RGBA]:s.RGBA},[Pe.UNSIGNED_SHORT_5_5_5_1]:{[qt.RGBA]:s.RGBA}},t}class Al{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Ge,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=f_(t),this.samplerTypes=c_(t);const r=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=r;for(let n=0;n<r;n++)this.boundTextures[n]=null;this.emptyTextures={};const i=new ia(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ia(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let n=0;n<this.boundTextures.length;n++)this.bind(null,n)}bind(t,r=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const n=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[r]!==t&&(this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),i.bindTexture(t.target,n.texture)),n.dirtyId!==t.dirtyId?(this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),this.updateTexture(t)):n.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[r]=t}else this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[r]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:r,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let n=0;n<i.length;n++)i[n]===this.unknownTexture&&this.bind(null,n)}for(let n=0;n<i.length;n++)i[n]===t&&(this.currentLocation!==n&&(r.activeTexture(r.TEXTURE0+n),this.currentLocation=n),r.bindTexture(t.target,this.emptyTextures[t.target].texture),i[n]=null)}ensureSamplerType(t){const{boundTextures:r,hasIntegerTextures:i,CONTEXT_UID:n}=this;if(i)for(let o=t-1;o>=0;--o){const h=r[o];h&&h._glTextures[n].samplerType!==le.FLOAT&&this.renderer.texture.unbind(h)}}initTexture(t){const r=new ia(this.gl.createTexture());return r.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=r,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),r}initTextureType(t,r){var i;r.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,r.samplerType=this.samplerTypes[r.internalFormat]??le.FLOAT,this.webGLVersion===2&&t.type===Pe.HALF_FLOAT?r.type=this.gl.HALF_FLOAT:r.type=t.type}updateTexture(t){var n;const r=t._glTextures[this.CONTEXT_UID];if(!r)return;const i=this.renderer;if(this.initTextureType(t,r),(n=t.resource)==null?void 0:n.upload(i,t,r))r.samplerType!==le.FLOAT&&(this.hasIntegerTextures=!0);else{const o=t.realWidth,h=t.realHeight,f=i.gl;(r.width!==o||r.height!==h||r.dirtyId<0)&&(r.width=o,r.height=h,f.texImage2D(t.target,0,r.internalFormat,o,h,0,t.format,r.type,null))}t.dirtyStyleId!==r.dirtyStyleId&&this.updateTextureStyle(t),r.dirtyId=t.dirtyId}destroyTexture(t,r){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!r)){const n=this.managedTextures.indexOf(t);n!==-1&&Bs(this.managedTextures,n,1)}}updateTextureStyle(t){var i;const r=t._glTextures[this.CONTEXT_UID];r&&((t.mipmap===wi.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?r.mipmap=!1:r.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?r.wrapMode=Vi.CLAMP:r.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,r)||this.setStyle(t,r),r.dirtyStyleId=t.dirtyStyleId)}setStyle(t,r){const i=this.gl;if(r.mipmap&&t.mipmap!==wi.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,r.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,r.wrapMode),r.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const n=this.renderer.context.extensions.anisotropicFiltering;if(n&&t.anisotropicLevel>0&&t.scaleMode===Gi.LINEAR){const o=Math.min(t.anisotropicLevel,i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,n.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Al.extension={type:ee.RendererSystem,name:"texture"},be.add(Al);class wl{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,r){const{gl:i,renderer:n}=this;r&&n.shader.bind(r),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:r,renderer:i,CONTEXT_UID:n}=this,o=r.createTransformFeedback();t._glTransformFeedbacks[n]=o,r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,o);for(let h=0;h<t.buffers.length;h++){const f=t.buffers[h];f&&(i.buffer.update(f),f._glBuffers[n].refCount++,r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,h,f._glBuffers[n].buffer||null))}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,r){const i=t._glTransformFeedbacks[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this);const o=this.renderer.buffer;if(o)for(let h=0;h<t.buffers.length;h++){const f=t.buffers[h];if(!f)continue;const A=f._glBuffers[this.CONTEXT_UID];A&&(A.refCount--,A.refCount===0&&!r&&o.dispose(f,r))}i&&(r||n.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}wl.extension={type:ee.RendererSystem,name:"transformFeedback"},be.add(wl);class Hn{constructor(t){this.renderer=t}init(t){this.screen=new Ve(0,0,t.width,t.height),this.element=t.view||ue.ADAPTER.createCanvas(),this.resolution=t.resolution||ue.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,r){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(r*this.resolution);const i=this.element.width/this.resolution,n=this.element.height/this.resolution;this.screen.width=i,this.screen.height=n,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${n}px`),this.renderer.emit("resize",i,n),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var r;t&&((r=this.element.parentNode)==null||r.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Hn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Hn.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"_view"},be.add(Hn),ue.PREFER_ENV=ys.WEBGL2,ue.STRICT_TEXTURE_CACHE=!1,ue.RENDER_OPTIONS={...Vn.defaultOptions,...Gn.defaultOptions,...Hn.defaultOptions,...Xn.defaultOptions},Object.defineProperties(ue,{WRAP_MODE:{get(){return Ge.defaultOptions.wrapMode},set(s){Oe("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Ge.defaultOptions.wrapMode=s}},SCALE_MODE:{get(){return Ge.defaultOptions.scaleMode},set(s){Oe("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Ge.defaultOptions.scaleMode=s}},MIPMAP_TEXTURES:{get(){return Ge.defaultOptions.mipmap},set(s){Oe("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Ge.defaultOptions.mipmap=s}},ANISOTROPIC_LEVEL:{get(){return Ge.defaultOptions.anisotropicLevel},set(s){Oe("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Ge.defaultOptions.anisotropicLevel=s}},FILTER_RESOLUTION:{get(){return Oe("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Gr.defaultResolution},set(s){Gr.defaultResolution=s}},FILTER_MULTISAMPLE:{get(){return Oe("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Gr.defaultMultisample},set(s){Gr.defaultMultisample=s}},SPRITE_MAX_TEXTURES:{get(){return bs.defaultMaxTextures},set(s){Oe("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),bs.defaultMaxTextures=s}},SPRITE_BATCH_SIZE:{get(){return bs.defaultBatchSize},set(s){Oe("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),bs.defaultBatchSize=s}},CAN_UPLOAD_SAME_BUFFER:{get(){return bs.canUploadSameBuffer},set(s){Oe("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),bs.canUploadSameBuffer=s}},GC_MODE:{get(){return ws.defaultMode},set(s){Oe("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ws.defaultMode=s}},GC_MAX_IDLE:{get(){return ws.defaultMaxIdle},set(s){Oe("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ws.defaultMaxIdle=s}},GC_MAX_CHECK_COUNT:{get(){return ws.defaultCheckCountMax},set(s){Oe("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ws.defaultCheckCountMax=s}},PRECISION_VERTEX:{get(){return Wi.defaultVertexPrecision},set(s){Oe("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Wi.defaultVertexPrecision=s}},PRECISION_FRAGMENT:{get(){return Wi.defaultFragmentPrecision},set(s){Oe("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Wi.defaultFragmentPrecision=s}}});var ls=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ls||{});class Tl{constructor(t,r=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=r,this.priority=i,this.once=n}match(t,r=null){return this.fn===t&&this.context===r}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const r=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),r}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const r=this.next;return this.next=t?null:r,this.previous=null,r}}const Uc=class ui{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Tl(null,null,1/0),this.deltaMS=1/ui.targetFPMS,this.elapsedMS=1/ui.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,r,i=ls.NORMAL){return this._addListener(new Tl(t,r,i))}addOnce(t,r,i=ls.NORMAL){return this._addListener(new Tl(t,r,i,!0))}_addListener(t){let r=this._head.next,i=this._head;if(!r)t.connect(i);else{for(;r;){if(t.priority>r.priority){t.connect(i);break}i=r,r=r.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,r){let i=this._head.next;for(;i;)i.match(t,r)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,r=this._head;for(;r=r.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let r;if(t>this.lastTime){if(r=this.elapsedMS=t-this.lastTime,r>this._maxElapsedMS&&(r=this._maxElapsedMS),r*=this.speed,this._minElapsedMS){const o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=r,this.deltaTime=this.deltaMS*ui.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const r=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,r)/1e3,ui.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const r=Math.max(this.minFPS,t);this._minElapsedMS=1/(r/1e3)}}static get shared(){if(!ui._shared){const t=ui._shared=new ui;t.autoStart=!0,t._protected=!0}return ui._shared}static get system(){if(!ui._system){const t=ui._system=new ui;t.autoStart=!0,t._protected=!0}return ui._system}};Uc.targetFPMS=.06;let $r=Uc;Object.defineProperties(ue,{TARGET_FPMS:{get(){return $r.targetFPMS},set(s){Oe("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),$r.targetFPMS=s}}});class sa{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(r){this._ticker&&this._ticker.remove(this.render,this),this._ticker=r,r&&r.add(this.render,this,ls.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?$r.shared:new $r,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}sa.extension=ee.Application,be.add(sa);const Gc=[];be.handleByList(ee.Renderer,Gc);function Vc(s){for(const t of Gc)if(t.test(s))return new t(s);throw new Error("Unable to auto-detect a suitable renderer.")}var d_=`attribute vec2 aVertexPosition;
531
+ `))}}let i_=0;const ra={textureCount:0,uboCount:0};class xl{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=i_++}systemCheck(){if(!pc())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,r){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,n=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(n.program)),r||(ra.textureCount=0,ra.uboCount=0,this.syncUniformGroup(t.uniformGroup,ra)),n}setUniforms(t){const r=this.shader.program,i=r.glPrograms[this.renderer.CONTEXT_UID];r.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,r){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,r))}syncUniforms(t,r,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(r.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const r=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[r]||(this.cache[r]=Bp(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[r],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,r){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const n=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,r);t.buffer.update(),n(i.uniformData,t.uniforms,this.renderer,ra,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[r])}createSyncBufferGroup(t,r,i){const{gl:n}=this.renderer;this.renderer.buffer.bind(t.buffer);const o=this.gl.getUniformBlockIndex(r.program,i);r.uniformBufferBindings[i]=this.shader.uniformBindCount,n.uniformBlockBinding(r.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;const h=this.getSignature(t,this.shader.program.uniformData,"ubo");let f=this._uboCache[h];if(f||(f=this._uboCache[h]=Lc(t,this.shader.program.uniformData)),t.autoManage){const A=new Float32Array(f.size/4);t.buffer.update(A)}return r.uniformGroups[t.id]=f.syncFunc,r.uniformGroups[t.id]}getSignature(t,r,i){const n=t.uniforms,o=[`${i}-`];for(const h in n)o.push(h),r[h]&&o.push(r[h].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const r=this.gl,i=t.program,n=Rc(r,i);return i.glPrograms[this.renderer.CONTEXT_UID]=n,n}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}xl.extension={type:ee.RendererSystem,name:"shader"},Te.add(xl);class Xn{constructor(t){this.renderer=t}run(t){const{renderer:r}=this;r.runners.init.emit(r.options),t.hello&&console.log(`PixiJS 7.4.3 - ${r.rendererLogId} - https://pixijs.com`),r.resize(r.screen.width,r.screen.height)}destroy(){}}Xn.defaultOptions={hello:!1},Xn.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"startup"},Te.add(Xn);function s_(s,t=[]){return t[Re.NORMAL]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.ADD]=[s.ONE,s.ONE],t[Re.MULTIPLY]=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SCREEN]=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.OVERLAY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.DARKEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.LIGHTEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.COLOR_DODGE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.COLOR_BURN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.HARD_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SOFT_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.DIFFERENCE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.EXCLUSION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.HUE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SATURATION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.COLOR]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.LUMINOSITY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.NONE]=[0,0],t[Re.NORMAL_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.ADD_NPM]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t[Re.SCREEN_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Re.SRC_IN]=[s.DST_ALPHA,s.ZERO],t[Re.SRC_OUT]=[s.ONE_MINUS_DST_ALPHA,s.ZERO],t[Re.SRC_ATOP]=[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[Re.DST_OVER]=[s.ONE_MINUS_DST_ALPHA,s.ONE],t[Re.DST_IN]=[s.ZERO,s.SRC_ALPHA],t[Re.DST_OUT]=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t[Re.DST_ATOP]=[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],t[Re.XOR]=[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[Re.SUBTRACT]=[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD],t}const n_=0,o_=1,a_=2,h_=3,l_=4,u_=5,Bc=class Tu{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Re.NONE,this._blendEq=!1,this.map=[],this.map[n_]=this.setBlend,this.map[o_]=this.setOffset,this.map[a_]=this.setCullFace,this.map[h_]=this.setDepthTest,this.map[l_]=this.setFrontFace,this.map[u_]=this.setDepthMask,this.checks=[],this.defaultState=new Pi,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=s_(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let r=this.stateId^t.data,i=0;for(;r;)r&1&&this.map[i].call(this,!!(t.data&1<<i)),r=r>>1,i++;this.stateId=t.data}for(let r=0;r<this.checks.length;r++)this.checks[r](this,t)}forceState(t){t=t||this.defaultState;for(let r=0;r<this.map.length;r++)this.map[r].call(this,!!(t.data&1<<r));for(let r=0;r<this.checks.length;r++)this.checks[r](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(Tu.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Tu.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const r=this.blendModes[t],i=this.gl;r.length===2?i.blendFunc(r[0],r[1]):i.blendFuncSeparate(r[0],r[1],r[2],r[3]),r.length===6?(this._blendEq=!0,i.blendEquationSeparate(r[4],r[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,r){this.gl.polygonOffset(t,r)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,r){const i=this.checks.indexOf(t);r&&i===-1?this.checks.push(t):!r&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,r){t.setBlendMode(r.blendMode)}static checkPolygonOffset(t,r){t.setPolygonOffset(1,r.polygonOffset)}destroy(){this.gl=null}};Bc.extension={type:ee.RendererSystem,name:"state"};let kc=Bc;Te.add(kc);class Oc extends ns{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const r=(t.priority??[]).filter(n=>t.systems[n]),i=[...r,...Object.keys(t.systems).filter(n=>!r.includes(n))];for(const n of i)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(r=>{this.runners[r]=new si(r)})}addSystem(t,r){const i=new t(this);if(this[r])throw new Error(`Whoops! The name "${r}" is already in use`);this[r]=i,this._systemsHash[r]=i;for(const n in this.runners)this.runners[n].add(i);return this}emitWithCustomOptions(t,r){const i=Object.keys(this._systemsHash);t.items.forEach(n=>{const o=i.find(h=>this._systemsHash[h]===n);n[t.name](r[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Wn=class Ga{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Ga.defaultMaxIdle,this.checkCountMax=Ga.defaultCheckCountMax,this.mode=Ga.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Bo.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,r=t.managedTextures;let i=!1;for(let n=0;n<r.length;n++){const o=r[n];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),r[n]=null,i=!0)}if(i){let n=0;for(let o=0;o<r.length;o++)r[o]!==null&&(r[n++]=r[o]);r.length=n}}unload(t){const r=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&r.destroyTexture(i);for(let n=t.children.length-1;n>=0;n--)this.unload(t.children[n])}destroy(){this.renderer=null}};Wn.defaultMode=Bo.AUTO,Wn.defaultMaxIdle=60*60,Wn.defaultCheckCountMax=60*10,Wn.extension={type:ee.RendererSystem,name:"textureGC"};let ws=Wn;Te.add(ws);class ia{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Pe.UNSIGNED_BYTE,this.internalFormat=qt.RGBA,this.samplerType=0}}function c_(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[s.RGB]:le.FLOAT,[s.RGBA]:le.FLOAT,[s.ALPHA]:le.FLOAT,[s.LUMINANCE]:le.FLOAT,[s.LUMINANCE_ALPHA]:le.FLOAT,[s.R8]:le.FLOAT,[s.R8_SNORM]:le.FLOAT,[s.RG8]:le.FLOAT,[s.RG8_SNORM]:le.FLOAT,[s.RGB8]:le.FLOAT,[s.RGB8_SNORM]:le.FLOAT,[s.RGB565]:le.FLOAT,[s.RGBA4]:le.FLOAT,[s.RGB5_A1]:le.FLOAT,[s.RGBA8]:le.FLOAT,[s.RGBA8_SNORM]:le.FLOAT,[s.RGB10_A2]:le.FLOAT,[s.RGB10_A2UI]:le.FLOAT,[s.SRGB8]:le.FLOAT,[s.SRGB8_ALPHA8]:le.FLOAT,[s.R16F]:le.FLOAT,[s.RG16F]:le.FLOAT,[s.RGB16F]:le.FLOAT,[s.RGBA16F]:le.FLOAT,[s.R32F]:le.FLOAT,[s.RG32F]:le.FLOAT,[s.RGB32F]:le.FLOAT,[s.RGBA32F]:le.FLOAT,[s.R11F_G11F_B10F]:le.FLOAT,[s.RGB9_E5]:le.FLOAT,[s.R8I]:le.INT,[s.R8UI]:le.UINT,[s.R16I]:le.INT,[s.R16UI]:le.UINT,[s.R32I]:le.INT,[s.R32UI]:le.UINT,[s.RG8I]:le.INT,[s.RG8UI]:le.UINT,[s.RG16I]:le.INT,[s.RG16UI]:le.UINT,[s.RG32I]:le.INT,[s.RG32UI]:le.UINT,[s.RGB8I]:le.INT,[s.RGB8UI]:le.UINT,[s.RGB16I]:le.INT,[s.RGB16UI]:le.UINT,[s.RGB32I]:le.INT,[s.RGB32UI]:le.UINT,[s.RGBA8I]:le.INT,[s.RGBA8UI]:le.UINT,[s.RGBA16I]:le.INT,[s.RGBA16UI]:le.UINT,[s.RGBA32I]:le.INT,[s.RGBA32UI]:le.UINT,[s.DEPTH_COMPONENT16]:le.FLOAT,[s.DEPTH_COMPONENT24]:le.FLOAT,[s.DEPTH_COMPONENT32F]:le.FLOAT,[s.DEPTH_STENCIL]:le.FLOAT,[s.DEPTH24_STENCIL8]:le.FLOAT,[s.DEPTH32F_STENCIL8]:le.FLOAT}:t={[s.RGB]:le.FLOAT,[s.RGBA]:le.FLOAT,[s.ALPHA]:le.FLOAT,[s.LUMINANCE]:le.FLOAT,[s.LUMINANCE_ALPHA]:le.FLOAT,[s.DEPTH_STENCIL]:le.FLOAT},t}function f_(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[Pe.UNSIGNED_BYTE]:{[qt.RGBA]:s.RGBA8,[qt.RGB]:s.RGB8,[qt.RG]:s.RG8,[qt.RED]:s.R8,[qt.RGBA_INTEGER]:s.RGBA8UI,[qt.RGB_INTEGER]:s.RGB8UI,[qt.RG_INTEGER]:s.RG8UI,[qt.RED_INTEGER]:s.R8UI,[qt.ALPHA]:s.ALPHA,[qt.LUMINANCE]:s.LUMINANCE,[qt.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Pe.BYTE]:{[qt.RGBA]:s.RGBA8_SNORM,[qt.RGB]:s.RGB8_SNORM,[qt.RG]:s.RG8_SNORM,[qt.RED]:s.R8_SNORM,[qt.RGBA_INTEGER]:s.RGBA8I,[qt.RGB_INTEGER]:s.RGB8I,[qt.RG_INTEGER]:s.RG8I,[qt.RED_INTEGER]:s.R8I},[Pe.UNSIGNED_SHORT]:{[qt.RGBA_INTEGER]:s.RGBA16UI,[qt.RGB_INTEGER]:s.RGB16UI,[qt.RG_INTEGER]:s.RG16UI,[qt.RED_INTEGER]:s.R16UI,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT16},[Pe.SHORT]:{[qt.RGBA_INTEGER]:s.RGBA16I,[qt.RGB_INTEGER]:s.RGB16I,[qt.RG_INTEGER]:s.RG16I,[qt.RED_INTEGER]:s.R16I},[Pe.UNSIGNED_INT]:{[qt.RGBA_INTEGER]:s.RGBA32UI,[qt.RGB_INTEGER]:s.RGB32UI,[qt.RG_INTEGER]:s.RG32UI,[qt.RED_INTEGER]:s.R32UI,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT24},[Pe.INT]:{[qt.RGBA_INTEGER]:s.RGBA32I,[qt.RGB_INTEGER]:s.RGB32I,[qt.RG_INTEGER]:s.RG32I,[qt.RED_INTEGER]:s.R32I},[Pe.FLOAT]:{[qt.RGBA]:s.RGBA32F,[qt.RGB]:s.RGB32F,[qt.RG]:s.RG32F,[qt.RED]:s.R32F,[qt.DEPTH_COMPONENT]:s.DEPTH_COMPONENT32F},[Pe.HALF_FLOAT]:{[qt.RGBA]:s.RGBA16F,[qt.RGB]:s.RGB16F,[qt.RG]:s.RG16F,[qt.RED]:s.R16F},[Pe.UNSIGNED_SHORT_5_6_5]:{[qt.RGB]:s.RGB565},[Pe.UNSIGNED_SHORT_4_4_4_4]:{[qt.RGBA]:s.RGBA4},[Pe.UNSIGNED_SHORT_5_5_5_1]:{[qt.RGBA]:s.RGB5_A1},[Pe.UNSIGNED_INT_2_10_10_10_REV]:{[qt.RGBA]:s.RGB10_A2,[qt.RGBA_INTEGER]:s.RGB10_A2UI},[Pe.UNSIGNED_INT_10F_11F_11F_REV]:{[qt.RGB]:s.R11F_G11F_B10F},[Pe.UNSIGNED_INT_5_9_9_9_REV]:{[qt.RGB]:s.RGB9_E5},[Pe.UNSIGNED_INT_24_8]:{[qt.DEPTH_STENCIL]:s.DEPTH24_STENCIL8},[Pe.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[qt.DEPTH_STENCIL]:s.DEPTH32F_STENCIL8}}:t={[Pe.UNSIGNED_BYTE]:{[qt.RGBA]:s.RGBA,[qt.RGB]:s.RGB,[qt.ALPHA]:s.ALPHA,[qt.LUMINANCE]:s.LUMINANCE,[qt.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Pe.UNSIGNED_SHORT_5_6_5]:{[qt.RGB]:s.RGB},[Pe.UNSIGNED_SHORT_4_4_4_4]:{[qt.RGBA]:s.RGBA},[Pe.UNSIGNED_SHORT_5_5_5_1]:{[qt.RGBA]:s.RGBA}},t}class bl{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Ge,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=f_(t),this.samplerTypes=c_(t);const r=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=r;for(let n=0;n<r;n++)this.boundTextures[n]=null;this.emptyTextures={};const i=new ia(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ia(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let n=0;n<this.boundTextures.length;n++)this.bind(null,n)}bind(t,r=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const n=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[r]!==t&&(this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),i.bindTexture(t.target,n.texture)),n.dirtyId!==t.dirtyId?(this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),this.updateTexture(t)):n.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[r]=t}else this.currentLocation!==r&&(this.currentLocation=r,i.activeTexture(i.TEXTURE0+r)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[r]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:r,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let n=0;n<i.length;n++)i[n]===this.unknownTexture&&this.bind(null,n)}for(let n=0;n<i.length;n++)i[n]===t&&(this.currentLocation!==n&&(r.activeTexture(r.TEXTURE0+n),this.currentLocation=n),r.bindTexture(t.target,this.emptyTextures[t.target].texture),i[n]=null)}ensureSamplerType(t){const{boundTextures:r,hasIntegerTextures:i,CONTEXT_UID:n}=this;if(i)for(let o=t-1;o>=0;--o){const h=r[o];h&&h._glTextures[n].samplerType!==le.FLOAT&&this.renderer.texture.unbind(h)}}initTexture(t){const r=new ia(this.gl.createTexture());return r.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=r,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),r}initTextureType(t,r){var i;r.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,r.samplerType=this.samplerTypes[r.internalFormat]??le.FLOAT,this.webGLVersion===2&&t.type===Pe.HALF_FLOAT?r.type=this.gl.HALF_FLOAT:r.type=t.type}updateTexture(t){var n;const r=t._glTextures[this.CONTEXT_UID];if(!r)return;const i=this.renderer;if(this.initTextureType(t,r),(n=t.resource)==null?void 0:n.upload(i,t,r))r.samplerType!==le.FLOAT&&(this.hasIntegerTextures=!0);else{const o=t.realWidth,h=t.realHeight,f=i.gl;(r.width!==o||r.height!==h||r.dirtyId<0)&&(r.width=o,r.height=h,f.texImage2D(t.target,0,r.internalFormat,o,h,0,t.format,r.type,null))}t.dirtyStyleId!==r.dirtyStyleId&&this.updateTextureStyle(t),r.dirtyId=t.dirtyId}destroyTexture(t,r){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!r)){const n=this.managedTextures.indexOf(t);n!==-1&&Bs(this.managedTextures,n,1)}}updateTextureStyle(t){var i;const r=t._glTextures[this.CONTEXT_UID];r&&((t.mipmap===wi.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?r.mipmap=!1:r.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?r.wrapMode=Vi.CLAMP:r.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,r)||this.setStyle(t,r),r.dirtyStyleId=t.dirtyStyleId)}setStyle(t,r){const i=this.gl;if(r.mipmap&&t.mipmap!==wi.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,r.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,r.wrapMode),r.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const n=this.renderer.context.extensions.anisotropicFiltering;if(n&&t.anisotropicLevel>0&&t.scaleMode===Gi.LINEAR){const o=Math.min(t.anisotropicLevel,i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,n.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Gi.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}bl.extension={type:ee.RendererSystem,name:"texture"},Te.add(bl);class Al{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,r){const{gl:i,renderer:n}=this;r&&n.shader.bind(r),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:r,renderer:i,CONTEXT_UID:n}=this,o=r.createTransformFeedback();t._glTransformFeedbacks[n]=o,r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,o);for(let h=0;h<t.buffers.length;h++){const f=t.buffers[h];f&&(i.buffer.update(f),f._glBuffers[n].refCount++,r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,h,f._glBuffers[n].buffer||null))}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,r){const i=t._glTransformFeedbacks[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this);const o=this.renderer.buffer;if(o)for(let h=0;h<t.buffers.length;h++){const f=t.buffers[h];if(!f)continue;const A=f._glBuffers[this.CONTEXT_UID];A&&(A.refCount--,A.refCount===0&&!r&&o.dispose(f,r))}i&&(r||n.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Al.extension={type:ee.RendererSystem,name:"transformFeedback"},Te.add(Al);class Hn{constructor(t){this.renderer=t}init(t){this.screen=new Ve(0,0,t.width,t.height),this.element=t.view||ue.ADAPTER.createCanvas(),this.resolution=t.resolution||ue.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,r){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(r*this.resolution);const i=this.element.width/this.resolution,n=this.element.height/this.resolution;this.screen.width=i,this.screen.height=n,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${n}px`),this.renderer.emit("resize",i,n),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var r;t&&((r=this.element.parentNode)==null||r.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Hn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Hn.extension={type:[ee.RendererSystem,ee.CanvasRendererSystem],name:"_view"},Te.add(Hn),ue.PREFER_ENV=ys.WEBGL2,ue.STRICT_TEXTURE_CACHE=!1,ue.RENDER_OPTIONS={...Vn.defaultOptions,...Gn.defaultOptions,...Hn.defaultOptions,...Xn.defaultOptions},Object.defineProperties(ue,{WRAP_MODE:{get(){return Ge.defaultOptions.wrapMode},set(s){Oe("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Ge.defaultOptions.wrapMode=s}},SCALE_MODE:{get(){return Ge.defaultOptions.scaleMode},set(s){Oe("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Ge.defaultOptions.scaleMode=s}},MIPMAP_TEXTURES:{get(){return Ge.defaultOptions.mipmap},set(s){Oe("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Ge.defaultOptions.mipmap=s}},ANISOTROPIC_LEVEL:{get(){return Ge.defaultOptions.anisotropicLevel},set(s){Oe("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Ge.defaultOptions.anisotropicLevel=s}},FILTER_RESOLUTION:{get(){return Oe("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Gr.defaultResolution},set(s){Gr.defaultResolution=s}},FILTER_MULTISAMPLE:{get(){return Oe("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Gr.defaultMultisample},set(s){Gr.defaultMultisample=s}},SPRITE_MAX_TEXTURES:{get(){return bs.defaultMaxTextures},set(s){Oe("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),bs.defaultMaxTextures=s}},SPRITE_BATCH_SIZE:{get(){return bs.defaultBatchSize},set(s){Oe("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),bs.defaultBatchSize=s}},CAN_UPLOAD_SAME_BUFFER:{get(){return bs.canUploadSameBuffer},set(s){Oe("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),bs.canUploadSameBuffer=s}},GC_MODE:{get(){return ws.defaultMode},set(s){Oe("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ws.defaultMode=s}},GC_MAX_IDLE:{get(){return ws.defaultMaxIdle},set(s){Oe("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ws.defaultMaxIdle=s}},GC_MAX_CHECK_COUNT:{get(){return ws.defaultCheckCountMax},set(s){Oe("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ws.defaultCheckCountMax=s}},PRECISION_VERTEX:{get(){return Wi.defaultVertexPrecision},set(s){Oe("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Wi.defaultVertexPrecision=s}},PRECISION_FRAGMENT:{get(){return Wi.defaultFragmentPrecision},set(s){Oe("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Wi.defaultFragmentPrecision=s}}});var ls=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ls||{});class wl{constructor(t,r=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=r,this.priority=i,this.once=n}match(t,r=null){return this.fn===t&&this.context===r}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const r=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),r}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const r=this.next;return this.next=t?null:r,this.previous=null,r}}const Nc=class ui{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new wl(null,null,1/0),this.deltaMS=1/ui.targetFPMS,this.elapsedMS=1/ui.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,r,i=ls.NORMAL){return this._addListener(new wl(t,r,i))}addOnce(t,r,i=ls.NORMAL){return this._addListener(new wl(t,r,i,!0))}_addListener(t){let r=this._head.next,i=this._head;if(!r)t.connect(i);else{for(;r;){if(t.priority>r.priority){t.connect(i);break}i=r,r=r.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,r){let i=this._head.next;for(;i;)i.match(t,r)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,r=this._head;for(;r=r.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let r;if(t>this.lastTime){if(r=this.elapsedMS=t-this.lastTime,r>this._maxElapsedMS&&(r=this._maxElapsedMS),r*=this.speed,this._minElapsedMS){const o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=r,this.deltaTime=this.deltaMS*ui.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const r=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,r)/1e3,ui.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const r=Math.max(this.minFPS,t);this._minElapsedMS=1/(r/1e3)}}static get shared(){if(!ui._shared){const t=ui._shared=new ui;t.autoStart=!0,t._protected=!0}return ui._shared}static get system(){if(!ui._system){const t=ui._system=new ui;t.autoStart=!0,t._protected=!0}return ui._system}};Nc.targetFPMS=.06;let $r=Nc;Object.defineProperties(ue,{TARGET_FPMS:{get(){return $r.targetFPMS},set(s){Oe("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),$r.targetFPMS=s}}});class Tl{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(r){this._ticker&&this._ticker.remove(this.render,this),this._ticker=r,r&&r.add(this.render,this,ls.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?$r.shared:new $r,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Tl.extension=ee.Application,Te.add(Tl);const Uc=[];Te.handleByList(ee.Renderer,Uc);function Gc(s){for(const t of Uc)if(t.test(s))return new t(s);throw new Error("Unable to auto-detect a suitable renderer.")}var d_=`attribute vec2 aVertexPosition;
532
532
  attribute vec2 aTextureCoord;
533
533
 
534
534
  uniform mat3 projectionMatrix;
@@ -565,7 +565,7 @@ void main(void)
565
565
  gl_Position = filterVertexPosition();
566
566
  vTextureCoord = filterTextureCoord();
567
567
  }
568
- `;const zc=d_,El=p_;class Cl{constructor(t){this.renderer=t}contextChange(t){let r;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),r=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),r=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}r>=yr.HIGH?this.multisample=yr.HIGH:r>=yr.MEDIUM?this.multisample=yr.MEDIUM:r>=yr.LOW?this.multisample=yr.LOW:this.multisample=yr.NONE}destroy(){}}Cl.extension={type:ee.RendererSystem,name:"_multisample"},be.add(Cl);class __{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Sl{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);r.bindBuffer(t.type,n.buffer)}unbind(t){const{gl:r}=this;r.bindBuffer(t,null)}bindBufferBase(t,r){const{gl:i,CONTEXT_UID:n}=this;if(this.boundBufferBases[r]!==t){const o=t._glBuffers[n]||this.createGLBuffer(t);this.boundBufferBases[r]=t,i.bindBufferBase(i.UNIFORM_BUFFER,r,o.buffer)}}bindBufferRange(t,r,i){const{gl:n,CONTEXT_UID:o}=this;i=i||0;const h=t._glBuffers[o]||this.createGLBuffer(t);n.bindBufferRange(n.UNIFORM_BUFFER,r||0,h.buffer,i*256,256)}update(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==n.updateID)if(n.updateID=t._updateID,r.bindBuffer(t.type,n.buffer),n.byteLength>=t.data.byteLength)r.bufferSubData(t.type,0,t.data);else{const o=t.static?r.STATIC_DRAW:r.DYNAMIC_DRAW;n.byteLength=t.data.byteLength,r.bufferData(t.type,t.data,o)}}dispose(t,r){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this),i&&(r||n.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const r=Object.keys(this.managedBuffers);for(let i=0;i<r.length;i++)this.dispose(this.managedBuffers[r[i]],t)}createGLBuffer(t){const{CONTEXT_UID:r,gl:i}=this;return t._glBuffers[r]=new __(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[r]}}Sl.extension={type:ee.RendererSystem,name:"buffer"},be.add(Sl);class Pl{constructor(t){this.renderer=t}render(t,r){const i=this.renderer;let n,o,h,f;if(r&&(n=r.renderTexture,o=r.clear,h=r.transform,f=r.skipUpdateTransform),this.renderingToScreen=!n,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=h,!i.context.isLost){if(n||(this.lastObjectRendered=t),!f){const A=t.enableTempParent();t.updateTransform(),t.disableTempParent(A)}i.renderTexture.bind(n),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),n&&(r.blit&&i.framebuffer.blit(),n.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Pl.extension={type:ee.RendererSystem,name:"objectRenderer"},be.add(Pl);const na=class Cu extends Nc{constructor(t){super(),this.type=Ya.WEBGL,t=Object.assign({},ue.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new fi({projectionMatrix:new nr},!0);const r={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Cu.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(r),"useContextAlpha"in t&&(Oe("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Cu.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:D0()}render(t,r){this.objectRenderer.render(t,r)}resize(t,r){this._view.resizeView(t,r)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return Oe("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Oe("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Oe("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Oe("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Oe("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Oe("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Oe("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return Oe("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,r){return this.textureGenerator.generateTexture(t,r)}};na.extension={type:ee.Renderer,priority:1},na.__plugins={},na.__systems={};let oa=na;be.handleByMap(ee.RendererPlugin,oa.__plugins),be.handleByMap(ee.RendererSystem,oa.__systems),be.add(oa);class $l extends en{constructor(t,r){const{width:i,height:n}=r||{};super(i,n),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){const h=new Ge;this.items.push(h),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,r){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof en?this.addResourceAt(t[i],i):this.addResourceAt(Qh(t[i],r),i))}dispose(){for(let t=0,r=this.length;t<r;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,r){if(!this.items[r])throw new Error(`Index ${r} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[r].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let r=0;r<this.length;r++)this.items[r].parentTextureArray=t,this.items[r].on("update",t.update,t)}unbind(t){super.unbind(t);for(let r=0;r<this.length;r++)this.items[r].parentTextureArray=null,this.items[r].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(r=>r.resource).filter(r=>r).map(r=>r.load());return this._load=Promise.all(t).then(()=>{const{realWidth:r,realHeight:i}=this.items[0];return this.resize(r,i),this.update(),Promise.resolve(this)}),this._load}}class Xc extends $l{constructor(t,r){const{width:i,height:n}=r||{};let o,h;Array.isArray(t)?(o=t,h=t.length):h=t,super(h,{width:i,height:n}),o&&this.initFromArray(o,r)}addBaseTextureAt(t,r){if(t.resource)this.addResourceAt(t.resource,r);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=Fs.TEXTURE_2D_ARRAY}upload(t,r,i){const{length:n,itemDirtyIds:o,items:h}=this,{gl:f}=t;i.dirtyId<0&&f.texImage3D(f.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,n,0,r.format,i.type,null);for(let A=0;A<n;A++){const T=h[A];o[A]<T.dirtyId&&(o[A]=T.dirtyId,T.valid&&f.texSubImage3D(f.TEXTURE_2D_ARRAY,0,0,0,A,T.resource.width,T.resource.height,1,r.format,i.type,T.resource.source))}return!0}}class Wc extends Hi{constructor(t){super(t)}static test(t){const{OffscreenCanvas:r}=globalThis;return r&&t instanceof r?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Hc=class Ro extends $l{constructor(t,r){const{width:i,height:n,autoLoad:o,linkBaseTexture:h}=r||{};if(t&&t.length!==Ro.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:n});for(let f=0;f<Ro.SIDES;f++)this.items[f].target=Fs.TEXTURE_CUBE_MAP_POSITIVE_X+f;this.linkBaseTexture=h!==!1,t&&this.initFromArray(t,r),o!==!1&&this.load()}bind(t){super.bind(t),t.target=Fs.TEXTURE_CUBE_MAP}addBaseTextureAt(t,r,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[r])throw new Error(`Index ${r} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,r);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=Fs.TEXTURE_CUBE_MAP_POSITIVE_X+r,t.parentTextureArray=this.baseTexture,this.items[r]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[r]=t,this}upload(t,r,i){const n=this.itemDirtyIds;for(let o=0;o<Ro.SIDES;o++){const h=this.items[o];(n[o]<h.dirtyId||i.dirtyId<r.dirtyId)&&(h.valid&&h.resource?(h.resource.upload(t,h,i),n[o]=h.dirtyId):n[o]<-1&&(t.gl.texImage2D(h.target,0,i.internalFormat,r.realWidth,r.realHeight,0,r.format,i.type,null),n[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Ro.SIDES}};Hc.SIDES=6;let Yc=Hc;class zs extends Hi{constructor(t,r){r=r||{};let i,n,o;typeof t=="string"?(i=zs.EMPTY,n=t,o=!0):(i=t,n=null,o=!1),super(i),this.url=n,this.crossOrigin=r.crossOrigin??!0,this.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,this.ownsImageBitmap=r.ownsImageBitmap??o,this._load=null,r.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,r)=>{if(this.url===null){t(this);return}try{const i=await ue.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const n=await i.blob();if(this.destroyed)return;const o=await createImageBitmap(n,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Vr.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;r(i),this.onError.emit(i)}}),this._load)}upload(t,r,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),super.upload(t,r,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return zs._EMPTY=zs._EMPTY??ue.ADAPTER.createCanvas(0,0),zs._EMPTY}}const Ml=class za extends Hi{constructor(t,r){r=r||{},super(ue.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=r.scale||1,this._overrideWidth=r.width,this._overrideHeight=r.height,this._resolve=null,this._crossorigin=r.crossorigin,this._load=null,r.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},za.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;Hi.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=r=>{this._resolve&&(t.onerror=null,this.onError.emit(r))},t.onload=()=>{if(!this._resolve)return;const r=t.width,i=t.height;if(!r||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let n=r*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(n=this._overrideWidth||this._overrideHeight/i*r,o=this._overrideHeight||this._overrideWidth/r*i),n=Math.round(n),o=Math.round(o);const h=this.source;h.width=n,h.height=o,h._pixiId=`canvas_${vs()}`,h.getContext("2d").drawImage(t,0,0,r,i,0,0,n,o),this._resolve(),this._resolve=null}}static getSize(t){const r=za.SVG_SIZE.exec(t),i={};return r&&(i[r[1]]=Math.round(parseFloat(r[3])),i[r[5]]=Math.round(parseFloat(r[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,r){return r==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&za.SVG_XML.test(t)}};Ml.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Ml.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let aa=Ml;class g_ extends Hi{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Rl=class Su extends Hi{constructor(t,r){if(r=r||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");r.autoLoad!==!1&&i.setAttribute("preload","auto"),r.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),r.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),r.loop===!0&&i.setAttribute("loop",""),r.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const n=t[0].src||t[0];Hi.crossOrigin(i,n,r.crossorigin);for(let o=0;o<t.length;++o){const h=document.createElement("source");let{src:f,mime:A}=t[o];if(f=f||t[o],f.startsWith("data:"))A=f.slice(5,f.indexOf(";"));else if(!f.startsWith("blob:")){const T=f.split("?").shift().toLowerCase(),C=T.slice(T.lastIndexOf(".")+1);A=A||Su.MIME_TYPES[C]||`video/${C}`}h.src=f,A&&(h.type=A),i.appendChild(h)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=r.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=r.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),r.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const r=$r.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((r,i)=>{this.valid?r(this):(this._resolve=r,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const r=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!r&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||($r.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,r){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Su.TYPES.includes(r)}};Rl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Rl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Il=Rl;zo.push(zs,al,Wc,Il,g_,aa,In,Yc,Xc);class m_{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new si("disposeTransformFeedback")}bindBuffer(t,r){this.buffers[t]=r}destroy(){this.disposeRunner.emit(this,!1)}}const y_="7.4.3";class Yn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?Ve.EMPTY:(t=t||new Ve(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,r){const{a:i,b:n,c:o,d:h,tx:f,ty:A}=t,T=i*r.x+o*r.y+f,C=n*r.x+h*r.y+A;this.minX=Math.min(this.minX,T),this.maxX=Math.max(this.maxX,T),this.minY=Math.min(this.minY,C),this.maxY=Math.max(this.maxY,C)}addQuad(t){let r=this.minX,i=this.minY,n=this.maxX,o=this.maxY,h=t[0],f=t[1];r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,h=t[2],f=t[3],r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,h=t[4],f=t[5],r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,h=t[6],f=t[7],r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,this.minX=r,this.minY=i,this.maxX=n,this.maxY=o}addFrame(t,r,i,n,o){this.addFrameMatrix(t.worldTransform,r,i,n,o)}addFrameMatrix(t,r,i,n,o){const h=t.a,f=t.b,A=t.c,T=t.d,C=t.tx,x=t.ty;let M=this.minX,D=this.minY,k=this.maxX,U=this.maxY,G=h*r+A*i+C,X=f*r+T*i+x;M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,G=h*n+A*i+C,X=f*n+T*i+x,M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,G=h*r+A*o+C,X=f*r+T*o+x,M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,G=h*n+A*o+C,X=f*n+T*o+x,M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,this.minX=M,this.minY=D,this.maxX=k,this.maxY=U}addVertexData(t,r,i){let n=this.minX,o=this.minY,h=this.maxX,f=this.maxY;for(let A=r;A<i;A+=2){const T=t[A],C=t[A+1];n=T<n?T:n,o=C<o?C:o,h=T>h?T:h,f=C>f?C:f}this.minX=n,this.minY=o,this.maxX=h,this.maxY=f}addVertices(t,r,i,n){this.addVerticesMatrix(t.worldTransform,r,i,n)}addVerticesMatrix(t,r,i,n,o=0,h=o){const f=t.a,A=t.b,T=t.c,C=t.d,x=t.tx,M=t.ty;let D=this.minX,k=this.minY,U=this.maxX,G=this.maxY;for(let X=i;X<n;X+=2){const J=r[X],Z=r[X+1],it=f*J+T*Z+x,Q=C*Z+A*J+M;D=Math.min(D,it-o),U=Math.max(U,it+o),k=Math.min(k,Q-h),G=Math.max(G,Q+h)}this.minX=D,this.minY=k,this.maxX=U,this.maxY=G}addBounds(t){const r=this.minX,i=this.minY,n=this.maxX,o=this.maxY;this.minX=t.minX<r?t.minX:r,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>n?t.maxX:n,this.maxY=t.maxY>o?t.maxY:o}addBoundsMask(t,r){const i=t.minX>r.minX?t.minX:r.minX,n=t.minY>r.minY?t.minY:r.minY,o=t.maxX<r.maxX?t.maxX:r.maxX,h=t.maxY<r.maxY?t.maxY:r.maxY;if(i<=o&&n<=h){const f=this.minX,A=this.minY,T=this.maxX,C=this.maxY;this.minX=i<f?i:f,this.minY=n<A?n:A,this.maxX=o>T?o:T,this.maxY=h>C?h:C}}addBoundsMatrix(t,r){this.addFrameMatrix(r,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,r){const i=t.minX>r.x?t.minX:r.x,n=t.minY>r.y?t.minY:r.y,o=t.maxX<r.x+r.width?t.maxX:r.x+r.width,h=t.maxY<r.y+r.height?t.maxY:r.y+r.height;if(i<=o&&n<=h){const f=this.minX,A=this.minY,T=this.maxX,C=this.maxY;this.minX=i<f?i:f,this.minY=n<A?n:A,this.maxX=o>T?o:T,this.maxY=h>C?h:C}}pad(t=0,r=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=r,this.maxY+=r)}addFramePad(t,r,i,n,o,h){t-=o,r-=h,i+=o,n+=h,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<r?this.minY:r,this.maxY=this.maxY>n?this.maxY:n}}class pr extends ns{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new rn,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Yn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const r=Object.keys(t);for(let i=0;i<r.length;++i){const n=r[i];Object.defineProperty(pr.prototype,n,Object.getOwnPropertyDescriptor(t,n))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,r){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),r||(this._boundsRect||(this._boundsRect=new Ve),r=this._boundsRect),this._bounds.getRectangle(r)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Yn);const r=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const n=this._bounds,o=this._boundsID;this._bounds=this._localBounds;const h=this.getBounds(!1,t);return this.parent=i,this.transform=r,this._bounds=n,this._bounds.updateID+=this._boundsID-o,h}toGlobal(t,r,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,r)}toLocal(t,r,i,n){return r&&(t=r.toGlobal(t,i,n)),n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,r=0,i=1,n=1,o=0,h=0,f=0,A=0,T=0){return this.position.x=t,this.position.y=r,this.scale.x=i||1,this.scale.y=n||1,this.rotation=o,this.skew.x=h,this.skew.y=f,this.pivot.x=A,this.pivot.y=T,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new jc),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*ic}set angle(t){this.transform.rotation=t*sc}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount--,r._maskRefCount===0&&(r.renderable=!0,r.isMask=!1))}if(this._mask=t,this._mask){const r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount===0&&(r.renderable=!1,r.isMask=!0),r._maskRefCount++)}}}}class jc extends pr{constructor(){super(...arguments),this.sortDirty=null}}pr.prototype.displayObjectUpdateTransform=pr.prototype.updateTransform;const v_=new nr;function x_(s,t){return s.zIndex===t.zIndex?s._lastSortedIndex-t._lastSortedIndex:s.zIndex-t.zIndex}const qc=class Pu extends pr{constructor(){super(),this.children=[],this.sortableChildren=Pu.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let r=0;r<t.length;r++)this.addChild(t[r]);else{const r=t[0];r.parent&&r.parent.removeChild(r),r.parent=this,this.sortDirty=!0,r.transform._parentID=-1,this.children.push(r),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",r,this,this.children.length-1),r.emit("added",this)}return t[0]}addChildAt(t,r){if(r<0||r>this.children.length)throw new Error(`${t}addChildAt: The index ${r} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(r,0,t),this._boundsID++,this.onChildrenChange(r),t.emit("added",this),this.emit("childAdded",t,this,r),t}swapChildren(t,r){if(t===r)return;const i=this.getChildIndex(t),n=this.getChildIndex(r);this.children[i]=r,this.children[n]=t,this.onChildrenChange(i<n?i:n)}getChildIndex(t){const r=this.children.indexOf(t);if(r===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return r}setChildIndex(t,r){if(r<0||r>=this.children.length)throw new Error(`The index ${r} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Bs(this.children,i,1),this.children.splice(r,0,t),this.onChildrenChange(r)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let r=0;r<t.length;r++)this.removeChild(t[r]);else{const r=t[0],i=this.children.indexOf(r);if(i===-1)return null;r.parent=null,r.transform._parentID=-1,Bs(this.children,i,1),this._boundsID++,this.onChildrenChange(i),r.emit("removed",this),this.emit("childRemoved",r,this,i)}return t[0]}removeChildAt(t){const r=this.getChildAt(t);return r.parent=null,r.transform._parentID=-1,Bs(this.children,t,1),this._boundsID++,this.onChildrenChange(t),r.emit("removed",this),this.emit("childRemoved",r,this,t),r}removeChildren(t=0,r=this.children.length){const i=t,n=r,o=n-i;let h;if(o>0&&o<=n){h=this.children.splice(i,o);for(let f=0;f<h.length;++f)h[f].parent=null,h[f].transform&&(h[f].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let f=0;f<h.length;++f)h[f].emit("removed",this),this.emit("childRemoved",h[f],this,f);return h}else if(o===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let r=0,i=this.children.length;r<i;++r){const n=this.children[r];n._lastSortedIndex=r,!t&&n.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(x_),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,r=this.children.length;t<r;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const r=this.children[t];if(!(!r.visible||!r.renderable))if(r.calculateBounds(),r._mask){const i=r._mask.isMaskData?r._mask.maskObject:r._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(r._bounds,i._bounds)):this._bounds.addBounds(r._bounds)}else r.filterArea?this._bounds.addBoundsArea(r._bounds,r.filterArea):this._bounds.addBounds(r._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,r=!1){const i=super.getLocalBounds(t);if(!r)for(let n=0,o=this.children.length;n<o;++n){const h=this.children[n];h.visible&&h.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const r=t.renderTexture.sourceFrame;if(!(r.width>0&&r.height>0))return;let i,n;this.cullArea?(i=this.cullArea,n=this.worldTransform):this._render!==Pu.prototype._render&&(i=this.getBounds(!0));const o=t.projection.transform;if(o&&(n?(n=v_.copyFrom(n),n.prepend(o)):n=o),i&&r.intersects(i,n))this._render(t);else if(this.cullArea)return;for(let h=0,f=this.children.length;h<f;++h){const A=this.children[h],T=A.cullable;A.cullable=T||!this.cullArea,A.render(t),A.cullable=T}}render(t){var r;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(r=this.filters)!=null&&r.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,n=this.children.length;i<n;++i)this.children[i].render(t)}}renderAdvanced(t){var o,h,f;const r=this.filters,i=this._mask;if(r){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let A=0;A<r.length;A++)r[A].enabled&&this._enabledFilters.push(r[A])}const n=r&&((o=this._enabledFilters)==null?void 0:o.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==xr.NONE));if(n&&t.batch.flush(),r&&((h=this._enabledFilters)!=null&&h.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let A=0,T=this.children.length;A<T;++A)this.children[A].render(t)}n&&t.batch.flush(),i&&t.mask.pop(this),r&&((f=this._enabledFilters)!=null&&f.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const r=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(r)for(let n=0;n<i.length;++n)i[n].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const r=this.getLocalBounds().width;r!==0?this.scale.x=t/r:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const r=this.getLocalBounds().height;r!==0?this.scale.y=t/r:this.scale.y=1,this._height=t}};qc.defaultSortableChildren=!1;let Zr=qc;Zr.prototype.containerUpdateTransform=Zr.prototype.updateTransform,Object.defineProperties(ue,{SORTABLE_CHILDREN:{get(){return Zr.defaultSortableChildren},set(s){Oe("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Zr.defaultSortableChildren=s}}});const jn=new Ze,b_=new Uint16Array([0,1,2,0,2,3]);class us extends Zr{constructor(t){super(),this._anchor=new $i(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new rr(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Re.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ne.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=b_,this.pluginName="batch",this.isSprite=!0,this._roundPixels=ue.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=as(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=as(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const r=this.transform.worldTransform,i=r.a,n=r.b,o=r.c,h=r.d,f=r.tx,A=r.ty,T=this.vertexData,C=t.trim,x=t.orig,M=this._anchor;let D=0,k=0,U=0,G=0;if(C?(k=C.x-M._x*x.width,D=k+C.width,G=C.y-M._y*x.height,U=G+C.height):(k=-M._x*x.width,D=k+x.width,G=-M._y*x.height,U=G+x.height),T[0]=i*k+o*G+f,T[1]=h*G+n*k+A,T[2]=i*D+o*G+f,T[3]=h*G+n*D+A,T[4]=i*D+o*U+f,T[5]=h*U+n*D+A,T[6]=i*k+o*U+f,T[7]=h*U+n*k+A,this._roundPixels){const X=ue.RESOLUTION;for(let J=0;J<T.length;++J)T[J]=Math.round(T[J]*X)/X}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,r=this.vertexTrimmedData,i=t.orig,n=this._anchor,o=this.transform.worldTransform,h=o.a,f=o.b,A=o.c,T=o.d,C=o.tx,x=o.ty,M=-n._x*i.width,D=M+i.width,k=-n._y*i.height,U=k+i.height;if(r[0]=h*M+A*k+C,r[1]=T*k+f*M+x,r[2]=h*D+A*k+C,r[3]=T*k+f*D+x,r[4]=h*D+A*U+C,r[5]=T*U+f*D+x,r[6]=h*M+A*U+C,r[7]=T*U+f*M+x,this._roundPixels){const G=ue.RESOLUTION;for(let X=0;X<r.length;++X)r[X]=Math.round(r[X]*G)/G}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,r=this._texture.orig;!t||t.width===r.width&&t.height===r.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Yn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,jn);const r=this._texture.orig.width,i=this._texture.orig.height,n=-r*this.anchor.x;let o=0;return jn.x>=n&&jn.x<n+r&&(o=-i*this.anchor.y,jn.y>=o&&jn.y<o+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const r=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!r)}this._texture=null}static from(t,r){const i=t instanceof ne?t:ne.from(t,r);return new us(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const r=as(this.scale.x)||1;this.scale.x=r*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const r=as(this.scale.y)||1;this.scale.y=r*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||ne.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Zc=new nr;pr.prototype._cacheAsBitmap=!1,pr.prototype._cacheData=null,pr.prototype._cacheAsBitmapResolution=null,pr.prototype._cacheAsBitmapMultisample=null;class A_{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(pr.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(s){s!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(s){s!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(s){if(this._cacheAsBitmap===s)return;this._cacheAsBitmap=s;let t;s?(this._cacheData||(this._cacheData=new A_),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),pr.prototype._renderCached=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(s),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(s))},pr.prototype._initCachedDisplayObject=function(s){var M,D;if((M=this._cacheData)!=null&&M.sprite)return;const t=this.alpha;this.alpha=1,s.batch.flush();const r=this.getLocalBounds(new Ve,!0);if((D=this.filters)!=null&&D.length){const k=this.filters[0].padding;r.pad(k)}const i=this.cacheAsBitmapResolution||s.resolution;r.ceil(i),r.width=Math.max(r.width,1/i),r.height=Math.max(r.height,1/i);const n=s.renderTexture.current,o=s.renderTexture.sourceFrame.clone(),h=s.renderTexture.destinationFrame.clone(),f=s.projection.transform,A=As.create({width:r.width,height:r.height,resolution:i,multisample:this.cacheAsBitmapMultisample??s.multisample}),T=`cacheAsBitmap_${vs()}`;this._cacheData.textureCacheId=T,Ge.addToCache(A.baseTexture,T),ne.addToCache(A,T);const C=this.transform.localTransform.copyTo(Zc).invert().translate(-r.x,-r.y);this.render=this._cacheData.originalRender,s.render(this,{renderTexture:A,clear:!0,transform:C,skipUpdateTransform:!1}),s.framebuffer.blit(),s.projection.transform=f,s.renderTexture.bind(n,o,h),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const x=new us(A);x.transform.worldTransform=this.transform.worldTransform,x.anchor.x=-(r.x/r.width),x.anchor.y=-(r.y/r.height),x.alpha=t,x._bounds=this._bounds,this._cacheData.sprite=x,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=x.containsPoint.bind(x)},pr.prototype._renderCachedCanvas=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(s),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(s))},pr.prototype._initCachedDisplayObjectCanvas=function(s){var C;if((C=this._cacheData)!=null&&C.sprite)return;const t=this.getLocalBounds(new Ve,!0),r=this.alpha;this.alpha=1;const i=s.canvasContext.activeContext,n=s._projTransform,o=this.cacheAsBitmapResolution||s.resolution;t.ceil(o),t.width=Math.max(t.width,1/o),t.height=Math.max(t.height,1/o);const h=As.create({width:t.width,height:t.height,resolution:o}),f=`cacheAsBitmap_${vs()}`;this._cacheData.textureCacheId=f,Ge.addToCache(h.baseTexture,f),ne.addToCache(h,f);const A=Zc;this.transform.localTransform.copyTo(A),A.invert(),A.tx-=t.x,A.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,s.render(this,{renderTexture:h,clear:!0,transform:A,skipUpdateTransform:!1}),s.canvasContext.activeContext=i,s._projTransform=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=r;const T=new us(h);T.transform.worldTransform=this.transform.worldTransform,T.anchor.x=-(t.x/t.width),T.anchor.y=-(t.y/t.height),T.alpha=r,T._bounds=this._bounds,this._cacheData.sprite=T,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=s._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=T.containsPoint.bind(T)},pr.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},pr.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},pr.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Ge.removeFromCache(this._cacheData.textureCacheId),ne.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},pr.prototype._cacheAsBitmapDestroy=function(s){this.cacheAsBitmap=!1,this.destroy(s)},pr.prototype.name=null,Zr.prototype.getChildByName=function(s,t){for(let r=0,i=this.children.length;r<i;r++)if(this.children[r].name===s)return this.children[r];if(t)for(let r=0,i=this.children.length;r<i;r++){const n=this.children[r];if(!n.getChildByName)continue;const o=n.getChildByName(s,!0);if(o)return o}return null},pr.prototype.getGlobalPosition=function(s=new Ze,t=!1){return this.parent?this.parent.toGlobal(this.position,s,t):(s.x=this.position.x,s.y=this.position.y),s};var w_=`varying vec2 vTextureCoord;
568
+ `;const Vc=d_,El=p_;class Cl{constructor(t){this.renderer=t}contextChange(t){let r;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),r=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),r=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}r>=yr.HIGH?this.multisample=yr.HIGH:r>=yr.MEDIUM?this.multisample=yr.MEDIUM:r>=yr.LOW?this.multisample=yr.LOW:this.multisample=yr.NONE}destroy(){}}Cl.extension={type:ee.RendererSystem,name:"_multisample"},Te.add(Cl);class __{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Sl{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);r.bindBuffer(t.type,n.buffer)}unbind(t){const{gl:r}=this;r.bindBuffer(t,null)}bindBufferBase(t,r){const{gl:i,CONTEXT_UID:n}=this;if(this.boundBufferBases[r]!==t){const o=t._glBuffers[n]||this.createGLBuffer(t);this.boundBufferBases[r]=t,i.bindBufferBase(i.UNIFORM_BUFFER,r,o.buffer)}}bindBufferRange(t,r,i){const{gl:n,CONTEXT_UID:o}=this;i=i||0;const h=t._glBuffers[o]||this.createGLBuffer(t);n.bindBufferRange(n.UNIFORM_BUFFER,r||0,h.buffer,i*256,256)}update(t){const{gl:r,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==n.updateID)if(n.updateID=t._updateID,r.bindBuffer(t.type,n.buffer),n.byteLength>=t.data.byteLength)r.bufferSubData(t.type,0,t.data);else{const o=t.static?r.STATIC_DRAW:r.DYNAMIC_DRAW;n.byteLength=t.data.byteLength,r.bufferData(t.type,t.data,o)}}dispose(t,r){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this),i&&(r||n.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const r=Object.keys(this.managedBuffers);for(let i=0;i<r.length;i++)this.dispose(this.managedBuffers[r[i]],t)}createGLBuffer(t){const{CONTEXT_UID:r,gl:i}=this;return t._glBuffers[r]=new __(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[r]}}Sl.extension={type:ee.RendererSystem,name:"buffer"},Te.add(Sl);class Pl{constructor(t){this.renderer=t}render(t,r){const i=this.renderer;let n,o,h,f;if(r&&(n=r.renderTexture,o=r.clear,h=r.transform,f=r.skipUpdateTransform),this.renderingToScreen=!n,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=h,!i.context.isLost){if(n||(this.lastObjectRendered=t),!f){const A=t.enableTempParent();t.updateTransform(),t.disableTempParent(A)}i.renderTexture.bind(n),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),n&&(r.blit&&i.framebuffer.blit(),n.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Pl.extension={type:ee.RendererSystem,name:"objectRenderer"},Te.add(Pl);const sa=class Eu extends Oc{constructor(t){super(),this.type=Ha.WEBGL,t=Object.assign({},ue.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new fi({projectionMatrix:new nr},!0);const r={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Eu.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(r),"useContextAlpha"in t&&(Oe("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Eu.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:I0()}render(t,r){this.objectRenderer.render(t,r)}resize(t,r){this._view.resizeView(t,r)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return Oe("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Oe("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Oe("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Oe("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){Oe("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return Oe("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){Oe("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return Oe("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,r){return this.textureGenerator.generateTexture(t,r)}};sa.extension={type:ee.Renderer,priority:1},sa.__plugins={},sa.__systems={};let na=sa;Te.handleByMap(ee.RendererPlugin,na.__plugins),Te.handleByMap(ee.RendererSystem,na.__systems),Te.add(na);class $l extends en{constructor(t,r){const{width:i,height:n}=r||{};super(i,n),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){const h=new Ge;this.items.push(h),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,r){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof en?this.addResourceAt(t[i],i):this.addResourceAt(Zh(t[i],r),i))}dispose(){for(let t=0,r=this.length;t<r;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,r){if(!this.items[r])throw new Error(`Index ${r} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[r].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let r=0;r<this.length;r++)this.items[r].parentTextureArray=t,this.items[r].on("update",t.update,t)}unbind(t){super.unbind(t);for(let r=0;r<this.length;r++)this.items[r].parentTextureArray=null,this.items[r].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(r=>r.resource).filter(r=>r).map(r=>r.load());return this._load=Promise.all(t).then(()=>{const{realWidth:r,realHeight:i}=this.items[0];return this.resize(r,i),this.update(),Promise.resolve(this)}),this._load}}class zc extends $l{constructor(t,r){const{width:i,height:n}=r||{};let o,h;Array.isArray(t)?(o=t,h=t.length):h=t,super(h,{width:i,height:n}),o&&this.initFromArray(o,r)}addBaseTextureAt(t,r){if(t.resource)this.addResourceAt(t.resource,r);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=Fs.TEXTURE_2D_ARRAY}upload(t,r,i){const{length:n,itemDirtyIds:o,items:h}=this,{gl:f}=t;i.dirtyId<0&&f.texImage3D(f.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,n,0,r.format,i.type,null);for(let A=0;A<n;A++){const T=h[A];o[A]<T.dirtyId&&(o[A]=T.dirtyId,T.valid&&f.texSubImage3D(f.TEXTURE_2D_ARRAY,0,0,0,A,T.resource.width,T.resource.height,1,r.format,i.type,T.resource.source))}return!0}}class Xc extends Hi{constructor(t){super(t)}static test(t){const{OffscreenCanvas:r}=globalThis;return r&&t instanceof r?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Wc=class Ro extends $l{constructor(t,r){const{width:i,height:n,autoLoad:o,linkBaseTexture:h}=r||{};if(t&&t.length!==Ro.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:n});for(let f=0;f<Ro.SIDES;f++)this.items[f].target=Fs.TEXTURE_CUBE_MAP_POSITIVE_X+f;this.linkBaseTexture=h!==!1,t&&this.initFromArray(t,r),o!==!1&&this.load()}bind(t){super.bind(t),t.target=Fs.TEXTURE_CUBE_MAP}addBaseTextureAt(t,r,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[r])throw new Error(`Index ${r} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,r);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=Fs.TEXTURE_CUBE_MAP_POSITIVE_X+r,t.parentTextureArray=this.baseTexture,this.items[r]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[r]=t,this}upload(t,r,i){const n=this.itemDirtyIds;for(let o=0;o<Ro.SIDES;o++){const h=this.items[o];(n[o]<h.dirtyId||i.dirtyId<r.dirtyId)&&(h.valid&&h.resource?(h.resource.upload(t,h,i),n[o]=h.dirtyId):n[o]<-1&&(t.gl.texImage2D(h.target,0,i.internalFormat,r.realWidth,r.realHeight,0,r.format,i.type,null),n[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Ro.SIDES}};Wc.SIDES=6;let Hc=Wc;class zs extends Hi{constructor(t,r){r=r||{};let i,n,o;typeof t=="string"?(i=zs.EMPTY,n=t,o=!0):(i=t,n=null,o=!1),super(i),this.url=n,this.crossOrigin=r.crossOrigin??!0,this.alphaMode=typeof r.alphaMode=="number"?r.alphaMode:null,this.ownsImageBitmap=r.ownsImageBitmap??o,this._load=null,r.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,r)=>{if(this.url===null){t(this);return}try{const i=await ue.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const n=await i.blob();if(this.destroyed)return;const o=await createImageBitmap(n,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Vr.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;r(i),this.onError.emit(i)}}),this._load)}upload(t,r,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(r.alphaMode=this.alphaMode),super.upload(t,r,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return zs._EMPTY=zs._EMPTY??ue.ADAPTER.createCanvas(0,0),zs._EMPTY}}const Ml=class Va extends Hi{constructor(t,r){r=r||{},super(ue.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=r.scale||1,this._overrideWidth=r.width,this._overrideHeight=r.height,this._resolve=null,this._crossorigin=r.crossorigin,this._load=null,r.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Va.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;Hi.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=r=>{this._resolve&&(t.onerror=null,this.onError.emit(r))},t.onload=()=>{if(!this._resolve)return;const r=t.width,i=t.height;if(!r||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let n=r*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(n=this._overrideWidth||this._overrideHeight/i*r,o=this._overrideHeight||this._overrideWidth/r*i),n=Math.round(n),o=Math.round(o);const h=this.source;h.width=n,h.height=o,h._pixiId=`canvas_${vs()}`,h.getContext("2d").drawImage(t,0,0,r,i,0,0,n,o),this._resolve(),this._resolve=null}}static getSize(t){const r=Va.SVG_SIZE.exec(t),i={};return r&&(i[r[1]]=Math.round(parseFloat(r[3])),i[r[5]]=Math.round(parseFloat(r[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,r){return r==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Va.SVG_XML.test(t)}};Ml.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Ml.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let oa=Ml;class g_ extends Hi{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Rl=class Cu extends Hi{constructor(t,r){if(r=r||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");r.autoLoad!==!1&&i.setAttribute("preload","auto"),r.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),r.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),r.loop===!0&&i.setAttribute("loop",""),r.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const n=t[0].src||t[0];Hi.crossOrigin(i,n,r.crossorigin);for(let o=0;o<t.length;++o){const h=document.createElement("source");let{src:f,mime:A}=t[o];if(f=f||t[o],f.startsWith("data:"))A=f.slice(5,f.indexOf(";"));else if(!f.startsWith("blob:")){const T=f.split("?").shift().toLowerCase(),C=T.slice(T.lastIndexOf(".")+1);A=A||Cu.MIME_TYPES[C]||`video/${C}`}h.src=f,A&&(h.type=A),i.appendChild(h)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=r.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=r.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),r.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const r=$r.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((r,i)=>{this.valid?r(this):(this._resolve=r,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const r=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!r&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||($r.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,r){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Cu.TYPES.includes(r)}};Rl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Rl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Il=Rl;zo.push(zs,ol,Xc,Il,g_,oa,In,Hc,zc);class m_{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new si("disposeTransformFeedback")}bindBuffer(t,r){this.buffers[t]=r}destroy(){this.disposeRunner.emit(this,!1)}}const y_="7.4.3";class Yn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?Ve.EMPTY:(t=t||new Ve(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,r){const{a:i,b:n,c:o,d:h,tx:f,ty:A}=t,T=i*r.x+o*r.y+f,C=n*r.x+h*r.y+A;this.minX=Math.min(this.minX,T),this.maxX=Math.max(this.maxX,T),this.minY=Math.min(this.minY,C),this.maxY=Math.max(this.maxY,C)}addQuad(t){let r=this.minX,i=this.minY,n=this.maxX,o=this.maxY,h=t[0],f=t[1];r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,h=t[2],f=t[3],r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,h=t[4],f=t[5],r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,h=t[6],f=t[7],r=h<r?h:r,i=f<i?f:i,n=h>n?h:n,o=f>o?f:o,this.minX=r,this.minY=i,this.maxX=n,this.maxY=o}addFrame(t,r,i,n,o){this.addFrameMatrix(t.worldTransform,r,i,n,o)}addFrameMatrix(t,r,i,n,o){const h=t.a,f=t.b,A=t.c,T=t.d,C=t.tx,x=t.ty;let M=this.minX,D=this.minY,k=this.maxX,U=this.maxY,G=h*r+A*i+C,X=f*r+T*i+x;M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,G=h*n+A*i+C,X=f*n+T*i+x,M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,G=h*r+A*o+C,X=f*r+T*o+x,M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,G=h*n+A*o+C,X=f*n+T*o+x,M=G<M?G:M,D=X<D?X:D,k=G>k?G:k,U=X>U?X:U,this.minX=M,this.minY=D,this.maxX=k,this.maxY=U}addVertexData(t,r,i){let n=this.minX,o=this.minY,h=this.maxX,f=this.maxY;for(let A=r;A<i;A+=2){const T=t[A],C=t[A+1];n=T<n?T:n,o=C<o?C:o,h=T>h?T:h,f=C>f?C:f}this.minX=n,this.minY=o,this.maxX=h,this.maxY=f}addVertices(t,r,i,n){this.addVerticesMatrix(t.worldTransform,r,i,n)}addVerticesMatrix(t,r,i,n,o=0,h=o){const f=t.a,A=t.b,T=t.c,C=t.d,x=t.tx,M=t.ty;let D=this.minX,k=this.minY,U=this.maxX,G=this.maxY;for(let X=i;X<n;X+=2){const J=r[X],Z=r[X+1],it=f*J+T*Z+x,Q=C*Z+A*J+M;D=Math.min(D,it-o),U=Math.max(U,it+o),k=Math.min(k,Q-h),G=Math.max(G,Q+h)}this.minX=D,this.minY=k,this.maxX=U,this.maxY=G}addBounds(t){const r=this.minX,i=this.minY,n=this.maxX,o=this.maxY;this.minX=t.minX<r?t.minX:r,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>n?t.maxX:n,this.maxY=t.maxY>o?t.maxY:o}addBoundsMask(t,r){const i=t.minX>r.minX?t.minX:r.minX,n=t.minY>r.minY?t.minY:r.minY,o=t.maxX<r.maxX?t.maxX:r.maxX,h=t.maxY<r.maxY?t.maxY:r.maxY;if(i<=o&&n<=h){const f=this.minX,A=this.minY,T=this.maxX,C=this.maxY;this.minX=i<f?i:f,this.minY=n<A?n:A,this.maxX=o>T?o:T,this.maxY=h>C?h:C}}addBoundsMatrix(t,r){this.addFrameMatrix(r,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,r){const i=t.minX>r.x?t.minX:r.x,n=t.minY>r.y?t.minY:r.y,o=t.maxX<r.x+r.width?t.maxX:r.x+r.width,h=t.maxY<r.y+r.height?t.maxY:r.y+r.height;if(i<=o&&n<=h){const f=this.minX,A=this.minY,T=this.maxX,C=this.maxY;this.minX=i<f?i:f,this.minY=n<A?n:A,this.maxX=o>T?o:T,this.maxY=h>C?h:C}}pad(t=0,r=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=r,this.maxY+=r)}addFramePad(t,r,i,n,o,h){t-=o,r-=h,i+=o,n+=h,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<r?this.minY:r,this.maxY=this.maxY>n?this.maxY:n}}class pr extends ns{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new rn,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Yn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const r=Object.keys(t);for(let i=0;i<r.length;++i){const n=r[i];Object.defineProperty(pr.prototype,n,Object.getOwnPropertyDescriptor(t,n))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,r){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),r||(this._boundsRect||(this._boundsRect=new Ve),r=this._boundsRect),this._bounds.getRectangle(r)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Yn);const r=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const n=this._bounds,o=this._boundsID;this._bounds=this._localBounds;const h=this.getBounds(!1,t);return this.parent=i,this.transform=r,this._bounds=n,this._bounds.updateID+=this._boundsID-o,h}toGlobal(t,r,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,r)}toLocal(t,r,i,n){return r&&(t=r.toGlobal(t,i,n)),n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,r=0,i=1,n=1,o=0,h=0,f=0,A=0,T=0){return this.position.x=t,this.position.y=r,this.scale.x=i||1,this.scale.y=n||1,this.rotation=o,this.skew.x=h,this.skew.y=f,this.pivot.x=A,this.pivot.y=T,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new Yc),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*rc}set angle(t){this.transform.rotation=t*ic}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount--,r._maskRefCount===0&&(r.renderable=!0,r.isMask=!1))}if(this._mask=t,this._mask){const r=this._mask.isMaskData?this._mask.maskObject:this._mask;r&&(r._maskRefCount===0&&(r.renderable=!1,r.isMask=!0),r._maskRefCount++)}}}}class Yc extends pr{constructor(){super(...arguments),this.sortDirty=null}}pr.prototype.displayObjectUpdateTransform=pr.prototype.updateTransform;const v_=new nr;function x_(s,t){return s.zIndex===t.zIndex?s._lastSortedIndex-t._lastSortedIndex:s.zIndex-t.zIndex}const jc=class Su extends pr{constructor(){super(),this.children=[],this.sortableChildren=Su.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let r=0;r<t.length;r++)this.addChild(t[r]);else{const r=t[0];r.parent&&r.parent.removeChild(r),r.parent=this,this.sortDirty=!0,r.transform._parentID=-1,this.children.push(r),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",r,this,this.children.length-1),r.emit("added",this)}return t[0]}addChildAt(t,r){if(r<0||r>this.children.length)throw new Error(`${t}addChildAt: The index ${r} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(r,0,t),this._boundsID++,this.onChildrenChange(r),t.emit("added",this),this.emit("childAdded",t,this,r),t}swapChildren(t,r){if(t===r)return;const i=this.getChildIndex(t),n=this.getChildIndex(r);this.children[i]=r,this.children[n]=t,this.onChildrenChange(i<n?i:n)}getChildIndex(t){const r=this.children.indexOf(t);if(r===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return r}setChildIndex(t,r){if(r<0||r>=this.children.length)throw new Error(`The index ${r} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Bs(this.children,i,1),this.children.splice(r,0,t),this.onChildrenChange(r)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let r=0;r<t.length;r++)this.removeChild(t[r]);else{const r=t[0],i=this.children.indexOf(r);if(i===-1)return null;r.parent=null,r.transform._parentID=-1,Bs(this.children,i,1),this._boundsID++,this.onChildrenChange(i),r.emit("removed",this),this.emit("childRemoved",r,this,i)}return t[0]}removeChildAt(t){const r=this.getChildAt(t);return r.parent=null,r.transform._parentID=-1,Bs(this.children,t,1),this._boundsID++,this.onChildrenChange(t),r.emit("removed",this),this.emit("childRemoved",r,this,t),r}removeChildren(t=0,r=this.children.length){const i=t,n=r,o=n-i;let h;if(o>0&&o<=n){h=this.children.splice(i,o);for(let f=0;f<h.length;++f)h[f].parent=null,h[f].transform&&(h[f].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let f=0;f<h.length;++f)h[f].emit("removed",this),this.emit("childRemoved",h[f],this,f);return h}else if(o===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let r=0,i=this.children.length;r<i;++r){const n=this.children[r];n._lastSortedIndex=r,!t&&n.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(x_),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,r=this.children.length;t<r;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const r=this.children[t];if(!(!r.visible||!r.renderable))if(r.calculateBounds(),r._mask){const i=r._mask.isMaskData?r._mask.maskObject:r._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(r._bounds,i._bounds)):this._bounds.addBounds(r._bounds)}else r.filterArea?this._bounds.addBoundsArea(r._bounds,r.filterArea):this._bounds.addBounds(r._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,r=!1){const i=super.getLocalBounds(t);if(!r)for(let n=0,o=this.children.length;n<o;++n){const h=this.children[n];h.visible&&h.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const r=t.renderTexture.sourceFrame;if(!(r.width>0&&r.height>0))return;let i,n;this.cullArea?(i=this.cullArea,n=this.worldTransform):this._render!==Su.prototype._render&&(i=this.getBounds(!0));const o=t.projection.transform;if(o&&(n?(n=v_.copyFrom(n),n.prepend(o)):n=o),i&&r.intersects(i,n))this._render(t);else if(this.cullArea)return;for(let h=0,f=this.children.length;h<f;++h){const A=this.children[h],T=A.cullable;A.cullable=T||!this.cullArea,A.render(t),A.cullable=T}}render(t){var r;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(r=this.filters)!=null&&r.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,n=this.children.length;i<n;++i)this.children[i].render(t)}}renderAdvanced(t){var o,h,f;const r=this.filters,i=this._mask;if(r){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let A=0;A<r.length;A++)r[A].enabled&&this._enabledFilters.push(r[A])}const n=r&&((o=this._enabledFilters)==null?void 0:o.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==xr.NONE));if(n&&t.batch.flush(),r&&((h=this._enabledFilters)!=null&&h.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let A=0,T=this.children.length;A<T;++A)this.children[A].render(t)}n&&t.batch.flush(),i&&t.mask.pop(this),r&&((f=this._enabledFilters)!=null&&f.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const r=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(r)for(let n=0;n<i.length;++n)i[n].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const r=this.getLocalBounds().width;r!==0?this.scale.x=t/r:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const r=this.getLocalBounds().height;r!==0?this.scale.y=t/r:this.scale.y=1,this._height=t}};jc.defaultSortableChildren=!1;let Zr=jc;Zr.prototype.containerUpdateTransform=Zr.prototype.updateTransform,Object.defineProperties(ue,{SORTABLE_CHILDREN:{get(){return Zr.defaultSortableChildren},set(s){Oe("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Zr.defaultSortableChildren=s}}});const jn=new Ze,b_=new Uint16Array([0,1,2,0,2,3]);class us extends Zr{constructor(t){super(),this._anchor=new $i(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new rr(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Re.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ne.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=b_,this.pluginName="batch",this.isSprite=!0,this._roundPixels=ue.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=as(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=as(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const r=this.transform.worldTransform,i=r.a,n=r.b,o=r.c,h=r.d,f=r.tx,A=r.ty,T=this.vertexData,C=t.trim,x=t.orig,M=this._anchor;let D=0,k=0,U=0,G=0;if(C?(k=C.x-M._x*x.width,D=k+C.width,G=C.y-M._y*x.height,U=G+C.height):(k=-M._x*x.width,D=k+x.width,G=-M._y*x.height,U=G+x.height),T[0]=i*k+o*G+f,T[1]=h*G+n*k+A,T[2]=i*D+o*G+f,T[3]=h*G+n*D+A,T[4]=i*D+o*U+f,T[5]=h*U+n*D+A,T[6]=i*k+o*U+f,T[7]=h*U+n*k+A,this._roundPixels){const X=ue.RESOLUTION;for(let J=0;J<T.length;++J)T[J]=Math.round(T[J]*X)/X}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,r=this.vertexTrimmedData,i=t.orig,n=this._anchor,o=this.transform.worldTransform,h=o.a,f=o.b,A=o.c,T=o.d,C=o.tx,x=o.ty,M=-n._x*i.width,D=M+i.width,k=-n._y*i.height,U=k+i.height;if(r[0]=h*M+A*k+C,r[1]=T*k+f*M+x,r[2]=h*D+A*k+C,r[3]=T*k+f*D+x,r[4]=h*D+A*U+C,r[5]=T*U+f*D+x,r[6]=h*M+A*U+C,r[7]=T*U+f*M+x,this._roundPixels){const G=ue.RESOLUTION;for(let X=0;X<r.length;++X)r[X]=Math.round(r[X]*G)/G}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,r=this._texture.orig;!t||t.width===r.width&&t.height===r.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Yn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,jn);const r=this._texture.orig.width,i=this._texture.orig.height,n=-r*this.anchor.x;let o=0;return jn.x>=n&&jn.x<n+r&&(o=-i*this.anchor.y,jn.y>=o&&jn.y<o+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const r=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!r)}this._texture=null}static from(t,r){const i=t instanceof ne?t:ne.from(t,r);return new us(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const r=as(this.scale.x)||1;this.scale.x=r*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const r=as(this.scale.y)||1;this.scale.y=r*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||ne.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const qc=new nr;pr.prototype._cacheAsBitmap=!1,pr.prototype._cacheData=null,pr.prototype._cacheAsBitmapResolution=null,pr.prototype._cacheAsBitmapMultisample=null;class A_{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(pr.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(s){s!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(s){s!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(s){if(this._cacheAsBitmap===s)return;this._cacheAsBitmap=s;let t;s?(this._cacheData||(this._cacheData=new A_),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),pr.prototype._renderCached=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(s),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(s))},pr.prototype._initCachedDisplayObject=function(s){var M,D;if((M=this._cacheData)!=null&&M.sprite)return;const t=this.alpha;this.alpha=1,s.batch.flush();const r=this.getLocalBounds(new Ve,!0);if((D=this.filters)!=null&&D.length){const k=this.filters[0].padding;r.pad(k)}const i=this.cacheAsBitmapResolution||s.resolution;r.ceil(i),r.width=Math.max(r.width,1/i),r.height=Math.max(r.height,1/i);const n=s.renderTexture.current,o=s.renderTexture.sourceFrame.clone(),h=s.renderTexture.destinationFrame.clone(),f=s.projection.transform,A=As.create({width:r.width,height:r.height,resolution:i,multisample:this.cacheAsBitmapMultisample??s.multisample}),T=`cacheAsBitmap_${vs()}`;this._cacheData.textureCacheId=T,Ge.addToCache(A.baseTexture,T),ne.addToCache(A,T);const C=this.transform.localTransform.copyTo(qc).invert().translate(-r.x,-r.y);this.render=this._cacheData.originalRender,s.render(this,{renderTexture:A,clear:!0,transform:C,skipUpdateTransform:!1}),s.framebuffer.blit(),s.projection.transform=f,s.renderTexture.bind(n,o,h),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const x=new us(A);x.transform.worldTransform=this.transform.worldTransform,x.anchor.x=-(r.x/r.width),x.anchor.y=-(r.y/r.height),x.alpha=t,x._bounds=this._bounds,this._cacheData.sprite=x,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=x.containsPoint.bind(x)},pr.prototype._renderCachedCanvas=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(s),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(s))},pr.prototype._initCachedDisplayObjectCanvas=function(s){var C;if((C=this._cacheData)!=null&&C.sprite)return;const t=this.getLocalBounds(new Ve,!0),r=this.alpha;this.alpha=1;const i=s.canvasContext.activeContext,n=s._projTransform,o=this.cacheAsBitmapResolution||s.resolution;t.ceil(o),t.width=Math.max(t.width,1/o),t.height=Math.max(t.height,1/o);const h=As.create({width:t.width,height:t.height,resolution:o}),f=`cacheAsBitmap_${vs()}`;this._cacheData.textureCacheId=f,Ge.addToCache(h.baseTexture,f),ne.addToCache(h,f);const A=qc;this.transform.localTransform.copyTo(A),A.invert(),A.tx-=t.x,A.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,s.render(this,{renderTexture:h,clear:!0,transform:A,skipUpdateTransform:!1}),s.canvasContext.activeContext=i,s._projTransform=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=r;const T=new us(h);T.transform.worldTransform=this.transform.worldTransform,T.anchor.x=-(t.x/t.width),T.anchor.y=-(t.y/t.height),T.alpha=r,T._bounds=this._bounds,this._cacheData.sprite=T,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=s._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=T.containsPoint.bind(T)},pr.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},pr.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},pr.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Ge.removeFromCache(this._cacheData.textureCacheId),ne.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},pr.prototype._cacheAsBitmapDestroy=function(s){this.cacheAsBitmap=!1,this.destroy(s)},pr.prototype.name=null,Zr.prototype.getChildByName=function(s,t){for(let r=0,i=this.children.length;r<i;r++)if(this.children[r].name===s)return this.children[r];if(t)for(let r=0,i=this.children.length;r<i;r++){const n=this.children[r];if(!n.getChildByName)continue;const o=n.getChildByName(s,!0);if(o)return o}return null},pr.prototype.getGlobalPosition=function(s=new Ze,t=!1){return this.parent?this.parent.toGlobal(this.position,s,t):(s.x=this.position.x,s.y=this.position.y),s};var w_=`varying vec2 vTextureCoord;
569
569
 
570
570
  uniform sampler2D uSampler;
571
571
  uniform float uAlpha;
@@ -574,7 +574,7 @@ void main(void)
574
574
  {
575
575
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
576
576
  }
577
- `;class Qc extends Gr{constructor(t=1){super(zc,w_,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const T_={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},E_=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
577
+ `;class Zc extends Gr{constructor(t=1){super(Vc,w_,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const T_={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},E_=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
578
578
  `);function C_(s){const t=T_[s],r=t.length;let i=E_,n="";const o="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let h;for(let f=0;f<s;f++){let A=o.replace("%index%",f.toString());h=f,f>=r&&(h=s-f-1),A=A.replace("%value%",t[h].toString()),n+=A,n+=`
579
579
  `}return i=i.replace("%blur%",n),i=i.replace("%size%",s.toString()),i}const S_=`
580
580
  attribute vec2 aVertexPosition;
@@ -607,7 +607,7 @@ void main(void)
607
607
  vec2 textureCoord = filterTextureCoord();
608
608
  %blur%
609
609
  }`;function P_(s,t){const r=Math.ceil(s/2);let i=S_,n="",o;t?o="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":o="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let h=0;h<s;h++){let f=o.replace("%index%",h.toString());f=f.replace("%sampleIndex%",`${h-(r-1)}.0`),n+=f,n+=`
610
- `}return i=i.replace("%blur%",n),i=i.replace("%size%",s.toString()),i}class ha extends Gr{constructor(t,r=8,i=4,n=Gr.defaultResolution,o=5){const h=P_(o,t),f=C_(o);super(h,f),this.horizontal=t,this.resolution=n,this._quality=0,this.quality=i,this.blur=r}apply(t,r,i,n){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/r.width):this.uniforms.strength=1/i.height*(i.height/r.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/r.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/r.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,r,i,n);else{const o=t.getFilterTexture(),h=t.renderer;let f=r,A=o;this.state.blend=!1,t.applyFilter(this,f,A,Ti.CLEAR);for(let T=1;T<this.passes-1;T++){t.bindAndClear(f,Ti.BLIT),this.uniforms.uSampler=A;const C=A;A=f,f=C,h.shader.bind(this),h.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,A,i,n),t.returnFilterTexture(o)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Kc extends Gr{constructor(t=8,r=4,i=Gr.defaultResolution,n=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ha(!0,t,r,i,n),this.blurYFilter=new ha(!1,t,r,i,n),this.resolution=i,this.quality=r,this.blur=t,this.repeatEdgePixels=!1}apply(t,r,i,n){const o=Math.abs(this.blurXFilter.strength),h=Math.abs(this.blurYFilter.strength);if(o&&h){const f=t.getFilterTexture();this.blurXFilter.apply(t,r,f,Ti.CLEAR),this.blurYFilter.apply(t,f,i,n),t.returnFilterTexture(f)}else h?this.blurYFilter.apply(t,r,i,n):this.blurXFilter.apply(t,r,i,n)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var $_=`varying vec2 vTextureCoord;
610
+ `}return i=i.replace("%blur%",n),i=i.replace("%size%",s.toString()),i}class aa extends Gr{constructor(t,r=8,i=4,n=Gr.defaultResolution,o=5){const h=P_(o,t),f=C_(o);super(h,f),this.horizontal=t,this.resolution=n,this._quality=0,this.quality=i,this.blur=r}apply(t,r,i,n){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/r.width):this.uniforms.strength=1/i.height*(i.height/r.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/r.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/r.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,r,i,n);else{const o=t.getFilterTexture(),h=t.renderer;let f=r,A=o;this.state.blend=!1,t.applyFilter(this,f,A,Ti.CLEAR);for(let T=1;T<this.passes-1;T++){t.bindAndClear(f,Ti.BLIT),this.uniforms.uSampler=A;const C=A;A=f,f=C,h.shader.bind(this),h.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,A,i,n),t.returnFilterTexture(o)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Qc extends Gr{constructor(t=8,r=4,i=Gr.defaultResolution,n=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new aa(!0,t,r,i,n),this.blurYFilter=new aa(!1,t,r,i,n),this.resolution=i,this.quality=r,this.blur=t,this.repeatEdgePixels=!1}apply(t,r,i,n){const o=Math.abs(this.blurXFilter.strength),h=Math.abs(this.blurYFilter.strength);if(o&&h){const f=t.getFilterTexture();this.blurXFilter.apply(t,r,f,Ti.CLEAR),this.blurYFilter.apply(t,f,i,n),t.returnFilterTexture(f)}else h?this.blurYFilter.apply(t,r,i,n):this.blurXFilter.apply(t,r,i,n)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var $_=`varying vec2 vTextureCoord;
611
611
  uniform sampler2D uSampler;
612
612
  uniform float m[20];
613
613
  uniform float uAlpha;
@@ -659,7 +659,7 @@ void main(void)
659
659
 
660
660
  gl_FragColor = vec4(rgb, result.a);
661
661
  }
662
- `;class la extends Gr{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(El,$_,t),this.alpha=1}_loadMatrix(t,r=!1){let i=t;r&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,r,i){return t[0]=r[0]*i[0]+r[1]*i[5]+r[2]*i[10]+r[3]*i[15],t[1]=r[0]*i[1]+r[1]*i[6]+r[2]*i[11]+r[3]*i[16],t[2]=r[0]*i[2]+r[1]*i[7]+r[2]*i[12]+r[3]*i[17],t[3]=r[0]*i[3]+r[1]*i[8]+r[2]*i[13]+r[3]*i[18],t[4]=r[0]*i[4]+r[1]*i[9]+r[2]*i[14]+r[3]*i[19]+r[4],t[5]=r[5]*i[0]+r[6]*i[5]+r[7]*i[10]+r[8]*i[15],t[6]=r[5]*i[1]+r[6]*i[6]+r[7]*i[11]+r[8]*i[16],t[7]=r[5]*i[2]+r[6]*i[7]+r[7]*i[12]+r[8]*i[17],t[8]=r[5]*i[3]+r[6]*i[8]+r[7]*i[13]+r[8]*i[18],t[9]=r[5]*i[4]+r[6]*i[9]+r[7]*i[14]+r[8]*i[19]+r[9],t[10]=r[10]*i[0]+r[11]*i[5]+r[12]*i[10]+r[13]*i[15],t[11]=r[10]*i[1]+r[11]*i[6]+r[12]*i[11]+r[13]*i[16],t[12]=r[10]*i[2]+r[11]*i[7]+r[12]*i[12]+r[13]*i[17],t[13]=r[10]*i[3]+r[11]*i[8]+r[12]*i[13]+r[13]*i[18],t[14]=r[10]*i[4]+r[11]*i[9]+r[12]*i[14]+r[13]*i[19]+r[14],t[15]=r[15]*i[0]+r[16]*i[5]+r[17]*i[10]+r[18]*i[15],t[16]=r[15]*i[1]+r[16]*i[6]+r[17]*i[11]+r[18]*i[16],t[17]=r[15]*i[2]+r[16]*i[7]+r[17]*i[12]+r[18]*i[17],t[18]=r[15]*i[3]+r[16]*i[8]+r[17]*i[13]+r[18]*i[18],t[19]=r[15]*i[4]+r[16]*i[9]+r[17]*i[14]+r[18]*i[19]+r[19],t}_colorMatrix(t){const r=new Float32Array(t);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r}brightness(t,r){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,r)}tint(t,r){const[i,n,o]=rr.shared.setValue(t).toArray(),h=[i,0,0,0,0,0,n,0,0,0,0,0,o,0,0,0,0,0,1,0];this._loadMatrix(h,r)}greyscale(t,r){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,r)}blackAndWhite(t){const r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,t)}hue(t,r){t=(t||0)/180*Math.PI;const i=Math.cos(t),n=Math.sin(t),o=Math.sqrt,h=1/3,f=o(h),A=i+(1-i)*h,T=h*(1-i)-f*n,C=h*(1-i)+f*n,x=h*(1-i)+f*n,M=i+h*(1-i),D=h*(1-i)-f*n,k=h*(1-i)-f*n,U=h*(1-i)+f*n,G=i+h*(1-i),X=[A,T,C,0,0,x,M,D,0,0,k,U,G,0,0,0,0,0,1,0];this._loadMatrix(X,r)}contrast(t,r){const i=(t||0)+1,n=-.5*(i-1),o=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(o,r)}saturate(t=0,r){const i=t*2/3+1,n=(i-1)*-.5,o=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(o,r)}desaturate(){this.saturate(-1)}negative(t){const r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,t)}sepia(t){const r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,t)}technicolor(t){const r=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(r,t)}polaroid(t){const r=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(r,t)}toBGR(t){const r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,t)}kodachrome(t){const r=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(r,t)}browni(t){const r=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(r,t)}vintage(t){const r=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(r,t)}colorTone(t,r,i,n,o){t=t||.2,r=r||.15,i=i||16770432,n=n||3375104;const h=rr.shared,[f,A,T]=h.setValue(i).toArray(),[C,x,M]=h.setValue(n).toArray(),D=[.3,.59,.11,0,0,f,A,T,t,0,C,x,M,r,0,f-C,A-x,T-M,0,0];this._loadMatrix(D,o)}night(t,r){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,r)}predator(t,r){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,r)}lsd(t){const r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}la.prototype.grayscale=la.prototype.greyscale;var M_=`varying vec2 vFilterCoord;
662
+ `;class ha extends Gr{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(El,$_,t),this.alpha=1}_loadMatrix(t,r=!1){let i=t;r&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,r,i){return t[0]=r[0]*i[0]+r[1]*i[5]+r[2]*i[10]+r[3]*i[15],t[1]=r[0]*i[1]+r[1]*i[6]+r[2]*i[11]+r[3]*i[16],t[2]=r[0]*i[2]+r[1]*i[7]+r[2]*i[12]+r[3]*i[17],t[3]=r[0]*i[3]+r[1]*i[8]+r[2]*i[13]+r[3]*i[18],t[4]=r[0]*i[4]+r[1]*i[9]+r[2]*i[14]+r[3]*i[19]+r[4],t[5]=r[5]*i[0]+r[6]*i[5]+r[7]*i[10]+r[8]*i[15],t[6]=r[5]*i[1]+r[6]*i[6]+r[7]*i[11]+r[8]*i[16],t[7]=r[5]*i[2]+r[6]*i[7]+r[7]*i[12]+r[8]*i[17],t[8]=r[5]*i[3]+r[6]*i[8]+r[7]*i[13]+r[8]*i[18],t[9]=r[5]*i[4]+r[6]*i[9]+r[7]*i[14]+r[8]*i[19]+r[9],t[10]=r[10]*i[0]+r[11]*i[5]+r[12]*i[10]+r[13]*i[15],t[11]=r[10]*i[1]+r[11]*i[6]+r[12]*i[11]+r[13]*i[16],t[12]=r[10]*i[2]+r[11]*i[7]+r[12]*i[12]+r[13]*i[17],t[13]=r[10]*i[3]+r[11]*i[8]+r[12]*i[13]+r[13]*i[18],t[14]=r[10]*i[4]+r[11]*i[9]+r[12]*i[14]+r[13]*i[19]+r[14],t[15]=r[15]*i[0]+r[16]*i[5]+r[17]*i[10]+r[18]*i[15],t[16]=r[15]*i[1]+r[16]*i[6]+r[17]*i[11]+r[18]*i[16],t[17]=r[15]*i[2]+r[16]*i[7]+r[17]*i[12]+r[18]*i[17],t[18]=r[15]*i[3]+r[16]*i[8]+r[17]*i[13]+r[18]*i[18],t[19]=r[15]*i[4]+r[16]*i[9]+r[17]*i[14]+r[18]*i[19]+r[19],t}_colorMatrix(t){const r=new Float32Array(t);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r}brightness(t,r){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,r)}tint(t,r){const[i,n,o]=rr.shared.setValue(t).toArray(),h=[i,0,0,0,0,0,n,0,0,0,0,0,o,0,0,0,0,0,1,0];this._loadMatrix(h,r)}greyscale(t,r){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,r)}blackAndWhite(t){const r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,t)}hue(t,r){t=(t||0)/180*Math.PI;const i=Math.cos(t),n=Math.sin(t),o=Math.sqrt,h=1/3,f=o(h),A=i+(1-i)*h,T=h*(1-i)-f*n,C=h*(1-i)+f*n,x=h*(1-i)+f*n,M=i+h*(1-i),D=h*(1-i)-f*n,k=h*(1-i)-f*n,U=h*(1-i)+f*n,G=i+h*(1-i),X=[A,T,C,0,0,x,M,D,0,0,k,U,G,0,0,0,0,0,1,0];this._loadMatrix(X,r)}contrast(t,r){const i=(t||0)+1,n=-.5*(i-1),o=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(o,r)}saturate(t=0,r){const i=t*2/3+1,n=(i-1)*-.5,o=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(o,r)}desaturate(){this.saturate(-1)}negative(t){const r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,t)}sepia(t){const r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,t)}technicolor(t){const r=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(r,t)}polaroid(t){const r=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(r,t)}toBGR(t){const r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,t)}kodachrome(t){const r=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(r,t)}browni(t){const r=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(r,t)}vintage(t){const r=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(r,t)}colorTone(t,r,i,n,o){t=t||.2,r=r||.15,i=i||16770432,n=n||3375104;const h=rr.shared,[f,A,T]=h.setValue(i).toArray(),[C,x,M]=h.setValue(n).toArray(),D=[.3,.59,.11,0,0,f,A,T,t,0,C,x,M,r,0,f-C,A-x,T-M,0,0];this._loadMatrix(D,o)}night(t,r){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,r)}predator(t,r){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,r)}lsd(t){const r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}ha.prototype.grayscale=ha.prototype.greyscale;var M_=`varying vec2 vFilterCoord;
663
663
  varying vec2 vTextureCoord;
664
664
 
665
665
  uniform vec2 scale;
@@ -708,7 +708,7 @@ void main(void)
708
708
  vTextureCoord = filterTextureCoord();
709
709
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
710
710
  }
711
- `;class Jc extends Gr{constructor(t,r){const i=new nr;t.renderable=!1,super(R_,M_,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,r==null&&(r=20),this.scale=new Ze(r,r)}apply(t,r,i,n){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const o=this.maskSprite.worldTransform,h=Math.sqrt(o.a*o.a+o.b*o.b),f=Math.sqrt(o.c*o.c+o.d*o.d);h!==0&&f!==0&&(this.uniforms.rotation[0]=o.a/h,this.uniforms.rotation[1]=o.b/h,this.uniforms.rotation[2]=o.c/f,this.uniforms.rotation[3]=o.d/f),t.applyFilter(this,r,i,n)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var I_=`varying vec2 v_rgbNW;
711
+ `;class Kc extends Gr{constructor(t,r){const i=new nr;t.renderable=!1,super(R_,M_,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,r==null&&(r=20),this.scale=new Ze(r,r)}apply(t,r,i,n){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const o=this.maskSprite.worldTransform,h=Math.sqrt(o.a*o.a+o.b*o.b),f=Math.sqrt(o.c*o.c+o.d*o.d);h!==0&&f!==0&&(this.uniforms.rotation[0]=o.a/h,this.uniforms.rotation[1]=o.b/h,this.uniforms.rotation[2]=o.c/f,this.uniforms.rotation[3]=o.d/f),t.applyFilter(this,r,i,n)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var I_=`varying vec2 v_rgbNW;
712
712
  varying vec2 v_rgbNE;
713
713
  varying vec2 v_rgbSW;
714
714
  varying vec2 v_rgbSE;
@@ -871,7 +871,7 @@ void main(void) {
871
871
 
872
872
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
873
873
  }
874
- `;class tf extends Gr{constructor(){super(D_,I_)}}var F_=`precision highp float;
874
+ `;class Jc extends Gr{constructor(){super(D_,I_)}}var F_=`precision highp float;
875
875
 
876
876
  varying vec2 vTextureCoord;
877
877
  varying vec4 vColor;
@@ -905,8 +905,8 @@ void main()
905
905
 
906
906
  gl_FragColor = color;
907
907
  }
908
- `;class ef extends Gr{constructor(t=.5,r=Math.random()){super(El,F_,{uNoise:0,uSeed:0}),this.noise=t,this.seed=r}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Dl={AlphaFilter:Qc,BlurFilter:Kc,BlurFilterPass:ha,ColorMatrixFilter:la,DisplacementFilter:Jc,FXAAFilter:tf,NoiseFilter:ef};Object.entries(Dl).forEach(([s,t])=>{Object.defineProperty(Dl,s,{get(){return Oe("7.1.0",`filters.${s} has moved to ${s}`),t}})});class L_{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||($r.system.add(this.tickerUpdate,this,ls.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&($r.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Ts=new L_;class nn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=nn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Ze,this.page=new Ze,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,r,i,n,o){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class qn extends nn{constructor(){super(...arguments),this.client=new Ze,this.movement=new Ze,this.offset=new Ze,this.global=new Ze,this.screen=new Ze}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,r,i){return t.worldTransform.applyInverse(i||this.global,r)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,r,i,n,o,h,f,A,T,C,x,M,D,k,U){throw new Error("Method not implemented.")}}class di extends qn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Xs extends qn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Xs.DOM_DELTA_PIXEL=0,Xs.DOM_DELTA_LINE=1,Xs.DOM_DELTA_PAGE=2;const B_=2048,k_=new Ze,Fl=new Ze;class rf{constructor(t){this.dispatch=new ns,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,r){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:r,priority:0}),this.mappingTable[t].sort((i,n)=>i.priority-n.priority)}dispatchEvent(t,r){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,r),this.dispatch.emit(r||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const r=this.mappingTable[t.type];if(r)for(let i=0,n=r.length;i<n;i++)r[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,r){Ts.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,k_.set(t,r),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,r){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,o=i.length-1;n<o;n++)if(t.currentTarget=i[n],this.notifyTarget(t,r),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,r),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,r),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,r,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(r)?r:[r];for(let o=i.length-1;o>=0;o--)n.forEach(h=>{t.currentTarget=i[o],this.notifyTarget(t,h)})}propagationPath(t){const r=[t];for(let i=0;i<B_&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");r.push(t.parent),t=t.parent}return r.reverse(),r}hitTestMoveRecursive(t,r,i,n,o,h=!1){let f=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||r==="dynamic")&&(Ts.pauseUpdate=!1),t.interactiveChildren&&t.children){const C=t.children;for(let x=C.length-1;x>=0;x--){const M=C[x],D=this.hitTestMoveRecursive(M,this._isInteractive(r)?r:M.eventMode,i,n,o,h||o(t,i));if(D){if(D.length>0&&!D[D.length-1].parent)continue;const k=t.isInteractive();(D.length>0||k)&&(k&&this._allInteractiveElements.push(t),D.push(t)),this._hitElements.length===0&&(this._hitElements=D),f=!0}}}const A=this._isInteractive(r),T=t.isInteractive();return A&&T&&this._allInteractiveElements.push(t),h||this._hitElements.length>0?null:f?this._hitElements:A&&!o(t,i)&&n(t,i)?T?[t]:[]:null}hitTestRecursive(t,r,i,n,o){if(this._interactivePrune(t)||o(t,i))return null;if((t.eventMode==="dynamic"||r==="dynamic")&&(Ts.pauseUpdate=!1),t.interactiveChildren&&t.children){const A=t.children;for(let T=A.length-1;T>=0;T--){const C=A[T],x=this.hitTestRecursive(C,this._isInteractive(r)?r:C.eventMode,i,n,o);if(x){if(x.length>0&&!x[x.length-1].parent)continue;const M=t.isInteractive();return(x.length>0||M)&&x.push(t),x}}}const h=this._isInteractive(r),f=t.isInteractive();return h&&n(t,i)?f?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,r){var i;if(t.hitArea&&(t.worldTransform.applyInverse(r,Fl),!t.hitArea.contains(Fl.x,Fl.y)))return!0;if(t._mask){const n=t._mask.isMaskData?t._mask.maskObject:t._mask;if(n&&!((i=n.containsPoint)!=null&&i.call(n,r)))return!0}return!1}hitTestFn(t,r){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(r):!1}notifyTarget(t,r){var o,h;r=r??t.type;const i=`on${r}`;(h=(o=t.currentTarget)[i])==null||h.call(o,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${r}capture`:r;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,r)}mapPointerDown(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerdown"),r.pointerType==="touch")this.dispatchEvent(r,"touchstart");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const n=r.button===2;this.dispatchEvent(r,n?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=r.composedPath(),this.freeEvent(r)}mapPointerMove(t){var A,T;if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=r.pointerType==="mouse"||r.pointerType==="pen",n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.overTargets);if(((A=n.overTargets)==null?void 0:A.length)>0&&o!==r.target){const C=t.type==="mousemove"?"mouseout":"pointerout",x=this.createPointerEvent(t,C,o);if(this.dispatchEvent(x,"pointerout"),i&&this.dispatchEvent(x,"mouseout"),!r.composedPath().includes(o)){const M=this.createPointerEvent(t,"pointerleave",o);for(M.eventPhase=M.AT_TARGET;M.target&&!r.composedPath().includes(M.target);)M.currentTarget=M.target,this.notifyTarget(M),i&&this.notifyTarget(M,"mouseleave"),M.target=M.target.parent;this.freeEvent(M)}this.freeEvent(x)}if(o!==r.target){const C=t.type==="mousemove"?"mouseover":"pointerover",x=this.clonePointerEvent(r,C);this.dispatchEvent(x,"pointerover"),i&&this.dispatchEvent(x,"mouseover");let M=o==null?void 0:o.parent;for(;M&&M!==this.rootTarget.parent&&M!==r.target;)M=M.parent;if(!M||M===this.rootTarget.parent){const D=this.clonePointerEvent(r,"pointerenter");for(D.eventPhase=D.AT_TARGET;D.target&&D.target!==o&&D.target!==this.rootTarget.parent;)D.currentTarget=D.target,this.notifyTarget(D),i&&this.notifyTarget(D,"mouseenter"),D.target=D.target.parent;this.freeEvent(D)}this.freeEvent(x)}const h=[],f=this.enableGlobalMoveEvents??!0;this.moveOnAll?h.push("pointermove"):this.dispatchEvent(r,"pointermove"),f&&h.push("globalpointermove"),r.pointerType==="touch"&&(this.moveOnAll?h.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),f&&h.push("globaltouchmove")),i&&(this.moveOnAll?h.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),f&&h.push("globalmousemove"),this.cursor=(T=r.target)==null?void 0:T.cursor),h.length>0&&this.all(r,h),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var h;if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(h=i.target)==null?void 0:h.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId);if(r.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(r.overTargets),o=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(o),i&&this.dispatchEvent(o,"mouseout");const h=this.createPointerEvent(t,"pointerleave",n);for(h.eventPhase=h.AT_TARGET;h.target&&h.target!==this.rootTarget.parent;)h.currentTarget=h.target,this.notifyTarget(h),i&&this.notifyTarget(h,"mouseleave"),h.target=h.target.parent;r.overTargets=null,this.freeEvent(o),this.freeEvent(h)}this.cursor=null}mapPointerUp(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const f=i.button===2;this.dispatchEvent(i,f?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.pressTargetsByButton[t.button]);let h=o;if(o&&!i.composedPath().includes(o)){let f=o;for(;f&&!i.composedPath().includes(f);){if(i.currentTarget=f,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const A=i.button===2;this.notifyTarget(i,A?"rightupoutside":"mouseupoutside")}f=f.parent}delete n.pressTargetsByButton[t.button],h=f}if(h){const f=this.clonePointerEvent(i,"click");f.target=h,f.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:f.target,timeStamp:r});const A=n.clicksByButton[t.button];if(A.target===f.target&&r-A.timeStamp<200?++A.clickCount:A.clickCount=1,A.target=f.target,A.timeStamp=r,f.detail=A.clickCount,f.pointerType==="mouse"){const T=f.button===2;this.dispatchEvent(f,T?"rightclick":"click")}else f.pointerType==="touch"&&this.dispatchEvent(f,"tap");this.dispatchEvent(f,"pointertap"),this.freeEvent(f)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.findMountedTarget(r.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let o=i;for(;o;)n.currentTarget=o,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),o=o.parent;delete r.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof Xs)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const r=this.createWheelEvent(t);this.dispatchEvent(r),this.freeEvent(r)}findMountedTarget(t){if(!t)return null;let r=t[0];for(let i=1;i<t.length&&t[i].parent===r;i++)r=t[i];return r}createPointerEvent(t,r,i){const n=this.allocateEvent(di);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof r=="string"&&(n.type=r),n}createWheelEvent(t){const r=this.allocateEvent(Xs);return this.copyWheelData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=this.hitTest(r.global.x,r.global.y),r}clonePointerEvent(t,r){const i=this.allocateEvent(di);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=r??i.type,i}copyWheelData(t,r){r.deltaMode=t.deltaMode,r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ}copyPointerData(t,r){t instanceof di&&r instanceof di&&(r.pointerId=t.pointerId,r.width=t.width,r.height=t.height,r.isPrimary=t.isPrimary,r.pointerType=t.pointerType,r.pressure=t.pressure,r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist)}copyMouseData(t,r){t instanceof qn&&r instanceof qn&&(r.altKey=t.altKey,r.button=t.button,r.buttons=t.buttons,r.client.copyFrom(t.client),r.ctrlKey=t.ctrlKey,r.metaKey=t.metaKey,r.movement.copyFrom(t.movement),r.screen.copyFrom(t.screen),r.shiftKey=t.shiftKey,r.global.copyFrom(t.global))}copyData(t,r){r.isTrusted=t.isTrusted,r.srcElement=t.srcElement,r.timeStamp=performance.now(),r.type=t.type,r.detail=t.detail,r.view=t.view,r.which=t.which,r.layer.copyFrom(t.layer),r.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const r=this.eventPool.get(t).pop()||new t(this);return r.eventPhase=r.NONE,r.currentTarget=null,r.path=null,r.target=null,r}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const r=t.constructor;this.eventPool.has(r)||this.eventPool.set(r,[]),this.eventPool.get(r).push(t)}notifyListeners(t,r){const i=t.currentTarget._events[r];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(r,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let n=0,o=i.length;n<o&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(r,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const O_=1,N_={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ll=class $u{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new rf(null),Ts.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new di(null),this.rootWheelEvent=new Xs(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...$u.defaultEventFeatures},{set:(r,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),r[i]=n,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:r,resolution:i}=this.renderer;this.setTargetElement(r),this.resolution=i,$u._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let r=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(r=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":r&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":r&&Object.assign(this.domElement.style,i);break}else r&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const r=this.normalizeToPointerData(t);this.autoPreventDefault&&r[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,n=r.length;i<n;i++){const o=r[i],h=this.bootstrapEvent(this.rootPointerEvent,o);this.rootBoundary.mapEvent(h)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Ts.pointerMoved();const r=this.normalizeToPointerData(t);for(let i=0,n=r.length;i<n;i++){const o=this.bootstrapEvent(this.rootPointerEvent,r[i]);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let r=t.target;t.composedPath&&t.composedPath().length>0&&(r=t.composedPath()[0]);const i=r!==this.domElement?"outside":"",n=this.normalizeToPointerData(t);for(let o=0,h=n.length;o<h;o++){const f=this.bootstrapEvent(this.rootPointerEvent,n[o]);f.type+=i,this.rootBoundary.mapEvent(f)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const r=this.normalizeToPointerData(t);for(let i=0,n=r.length;i<n;i++){const o=this.bootstrapEvent(this.rootPointerEvent,r[i]);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const r=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(r)}setTargetElement(t){this.removeEvents(),this.domElement=t,Ts.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Ts.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Ts.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,r,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},o=1/this.resolution;t.x=(r-n.left)*(this.domElement.width/n.width)*o,t.y=(i-n.top)*(this.domElement.height/n.height)*o}normalizeToPointerData(t){const r=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const o=t.changedTouches[i];typeof o.button>"u"&&(o.button=0),typeof o.buttons>"u"&&(o.buttons=1),typeof o.isPrimary>"u"&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,o.type=t.type,r.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=O_),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,r.push(i)}else r.push(t);return r}normalizeWheelEvent(t){const r=this.rootWheelEvent;return this.transferMouseData(r,t),r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ,r.deltaMode=t.deltaMode,this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.copyFrom(r.screen),r.offset.copyFrom(r.screen),r.nativeEvent=t,r.type=t.type,r}bootstrapEvent(t,r){return t.originalEvent=null,t.nativeEvent=r,t.pointerId=r.pointerId,t.width=r.width,t.height=r.height,t.isPrimary=r.isPrimary,t.pointerType=r.pointerType,t.pressure=r.pressure,t.tangentialPressure=r.tangentialPressure,t.tiltX=r.tiltX,t.tiltY=r.tiltY,t.twist=r.twist,this.transferMouseData(t,r),this.mapPositionToPoint(t.screen,r.clientX,r.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=r.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=N_[t.type]||t.type),t}transferMouseData(t,r){t.isTrusted=r.isTrusted,t.srcElement=r.srcElement,t.timeStamp=performance.now(),t.type=r.type,t.altKey=r.altKey,t.button=r.button,t.buttons=r.buttons,t.client.x=r.clientX,t.client.y=r.clientY,t.ctrlKey=r.ctrlKey,t.metaKey=r.metaKey,t.movement.x=r.movementX,t.movement.y=r.movementY,t.page.x=r.pageX,t.page.y=r.pageY,t.relatedTarget=null,t.shiftKey=r.shiftKey}};Ll.extension={name:"events",type:[ee.RendererSystem,ee.CanvasRendererSystem]},Ll.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ua=Ll;be.add(ua);function sf(s){return s==="dynamic"||s==="static"}const nf={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??sf(ua.defaultEventMode)},set interactive(s){Oe("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=s,this.eventMode=s?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??ua.defaultEventMode},set eventMode(s){this._internalInteractive=sf(s),this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,r){const i=typeof r=="boolean"&&r||typeof r=="object"&&r.capture,n=typeof r=="object"?r.signal:void 0,o=typeof r=="object"?r.once===!0:!1,h=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const f=typeof t=="function"?t:t.handleEvent,A=this;n&&n.addEventListener("abort",()=>{A.off(s,f,h)}),o?A.once(s,f,h):A.on(s,f,h)},removeEventListener(s,t,r){const i=typeof r=="boolean"&&r||typeof r=="object"&&r.capture,n=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,n)},dispatchEvent(s){if(!(s instanceof nn))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};pr.mixin(nf);const of={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};pr.mixin(of);const U_=9,ca=100,G_=0,V_=0,af=2,hf=1,z_=-1e3,X_=-1e3,W_=2;class Bl{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Ci.tablet||Ci.phone)&&this.createTouchHook();const r=document.createElement("div");r.style.width=`${ca}px`,r.style.height=`${ca}px`,r.style.position="absolute",r.style.top=`${G_}px`,r.style.left=`${V_}px`,r.style.zIndex=af.toString(),this.div=r,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${hf}px`,t.style.height=`${hf}px`,t.style.position="absolute",t.style.top=`${z_}px`,t.style.left=`${X_}px`,t.style.zIndex=W_.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const r=t.children;if(r)for(let i=0;i<r.length;i++)this.updateAccessibleObjects(r[i])}update(){const t=performance.now();if(Ci.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:r,y:i,width:n,height:o}=this.renderer.view.getBoundingClientRect(),{width:h,height:f,resolution:A}=this.renderer,T=n/h*A,C=o/f*A;let x=this.div;x.style.left=`${r}px`,x.style.top=`${i}px`,x.style.width=`${h}px`,x.style.height=`${f}px`;for(let M=0;M<this.children.length;M++){const D=this.children[M];if(D.renderId!==this.renderId)D._accessibleActive=!1,Bs(this.children,M,1),this.div.removeChild(D._accessibleDiv),this.pool.push(D._accessibleDiv),D._accessibleDiv=null,M--;else{x=D._accessibleDiv;let k=D.hitArea;const U=D.worldTransform;D.hitArea?(x.style.left=`${(U.tx+k.x*U.a)*T}px`,x.style.top=`${(U.ty+k.y*U.d)*C}px`,x.style.width=`${k.width*U.a*T}px`,x.style.height=`${k.height*U.d*C}px`):(k=D.getBounds(),this.capHitArea(k),x.style.left=`${k.x*T}px`,x.style.top=`${k.y*C}px`,x.style.width=`${k.width*T}px`,x.style.height=`${k.height*C}px`,x.title!==D.accessibleTitle&&D.accessibleTitle!==null&&(x.title=D.accessibleTitle),x.getAttribute("aria-label")!==D.accessibleHint&&D.accessibleHint!==null&&x.setAttribute("aria-label",D.accessibleHint)),(D.accessibleTitle!==x.title||D.tabIndex!==x.tabIndex)&&(x.title=D.accessibleTitle,x.tabIndex=D.tabIndex,this.debug&&this.updateDebugHTML(x))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:r,height:i}=this.renderer;t.x+t.width>r&&(t.width=r-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let r=this.pool.pop();r||(r=document.createElement("button"),r.style.width=`${ca}px`,r.style.height=`${ca}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=af.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=t.accessiblePointerEvents,r.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?r.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(r.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&r.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(r),t._accessibleActive=!0,t._accessibleDiv=r,r.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,r){const{displayObject:i}=t.target,n=this.renderer.events.rootBoundary,o=Object.assign(new nn(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,r.forEach(h=>n.dispatchEvent(o,h))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===U_&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Bl.extension={name:"accessibility",type:[ee.RendererPlugin,ee.CanvasRendererPlugin]},be.add(Bl);const lf=class Mu{constructor(t){this.stage=new Zr,t=Object.assign({forceCanvas:!1},t),this.renderer=Vc(t),Mu._plugins.forEach(r=>{r.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,r){const i=Mu._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(r),this.stage=null,this.renderer.destroy(t),this.renderer=null}};lf._plugins=[];let kl=lf;be.handleByList(ee.Application,kl._plugins);class Ol{static init(t){Object.defineProperty(this,"resizeTo",{set(r){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=r,r&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let r,i;if(this._resizeTo===globalThis.window)r=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:o}=this._resizeTo;r=n,i=o}this.renderer.resize(r,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Ol.extension=ee.Application,be.add(Ol);const uf={loader:ee.LoadParser,resolver:ee.ResolveParser,cache:ee.CacheParser,detection:ee.DetectionParser};be.handle(ee.Asset,s=>{const t=s.ref;Object.entries(uf).filter(([r])=>!!t[r]).forEach(([r,i])=>be.add(Object.assign(t[r],{extension:t[r].extension??i})))},s=>{const t=s.ref;Object.keys(uf).filter(r=>!!t[r]).forEach(r=>be.remove(t[r]))});class H_{constructor(t,r=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=r}add(t){t.forEach(r=>{this._assetList.push(r)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],r=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<r;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Ws(s,t){if(Array.isArray(t)){for(const r of t)if(s.startsWith(`data:${r}`))return!0;return!1}return s.startsWith(`data:${t}`)}function cs(s,t){const r=s.split("?")[0],i=Pr.extname(r).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const pi=(s,t,r=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||r?t(i):i):s),fa=(s,t)=>{const r=t.split("?")[1];return r&&(s+=`?${r}`),s};function cf(s,t,r,i,n){const o=t[r];for(let h=0;h<o.length;h++){const f=o[h];r<t.length-1?cf(s.replace(i[r],f),t,r+1,i,n):n.push(s.replace(i[r],f))}}function ff(s){const t=/\{(.*?)\}/g,r=s.match(t),i=[];if(r){const n=[];r.forEach(o=>{const h=o.substring(1,o.length-1).split(",");n.push(h)}),cf(s,n,0,r,i)}else i.push(s);return i}const Zn=s=>!Array.isArray(s);class Y_{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const r=this._cache.get(t);return r||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),r}set(t,r){const i=pi(t);let n;for(let f=0;f<this.parsers.length;f++){const A=this.parsers[f];if(A.test(r)){n=A.getCacheableAssets(i,r);break}}n||(n={},i.forEach(f=>{n[f]=r}));const o=Object.keys(n),h={cacheKeys:o,keys:i};if(i.forEach(f=>{this._cacheMap.set(f,h)}),o.forEach(f=>{const A=n?n[f]:r;this._cache.has(f)&&this._cache.get(f)!==A&&console.warn("[Cache] already has key:",f),this._cache.set(f,n[f])}),r instanceof ne){const f=r;i.forEach(A=>{f.baseTexture!==ne.EMPTY.baseTexture&&Ge.addToCache(f.baseTexture,A),ne.addToCache(f,A)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const r=this._cacheMap.get(t);r.cacheKeys.forEach(i=>{this._cache.delete(i)}),r.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Es=new Y_;class j_{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,r,i)=>(this._parsersValidated=!1,t[r]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,r){const i={promise:null,parser:null};return i.promise=(async()=>{var h,f;let n=null,o=null;if(r.loadParser&&(o=this._parserHash[r.loadParser],o||console.warn(`[Assets] specified load parser "${r.loadParser}" not found while loading ${t}`)),!o){for(let A=0;A<this.parsers.length;A++){const T=this.parsers[A];if(T.load&&((h=T.test)!=null&&h.call(T,t,r,this))){o=T;break}}if(!o)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}n=await o.load(t,r,this),i.parser=o;for(let A=0;A<this.parsers.length;A++){const T=this.parsers[A];T.parse&&T.parse&&await((f=T.testParse)==null?void 0:f.call(T,n,r,this))&&(n=await T.parse(n,r,this)||n,i.parser=T)}return n})(),i}async load(t,r){this._parsersValidated||this._validateParsers();let i=0;const n={},o=Zn(t),h=pi(t,T=>({alias:[T],src:T})),f=h.length,A=h.map(async T=>{const C=Pr.toAbsolute(T.src);if(!n[T.src])try{this.promiseCache[C]||(this.promiseCache[C]=this._getLoadPromiseAndParser(C,T)),n[T.src]=await this.promiseCache[C].promise,r&&r(++i/f)}catch(x){throw delete this.promiseCache[C],delete n[T.src],new Error(`[Loader.load] Failed to load ${C}.
909
- ${x}`)}});return await Promise.all(A),o?n[h[0].src]:n}async unload(t){const r=pi(t,i=>({alias:[i],src:i})).map(async i=>{var h,f;const n=Pr.toAbsolute(i.src),o=this.promiseCache[n];if(o){const A=await o.promise;delete this.promiseCache[n],(f=(h=o.parser)==null?void 0:h.unload)==null||f.call(h,A,i,this)}});await Promise.all(r)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,r)=>(t[r.name]&&console.warn(`[Assets] loadParser name conflict "${r.name}"`),{...t,[r.name]:r}),{})}}var _i=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(_i||{});const q_=".json",Z_="application/json",df={extension:{type:ee.LoadParser,priority:_i.Low},name:"loadJson",test(s){return Ws(s,Z_)||cs(s,q_)},async load(s){return await(await ue.ADAPTER.fetch(s)).json()}};be.add(df);const Q_=".txt",K_="text/plain",pf={name:"loadTxt",extension:{type:ee.LoadParser,priority:_i.Low},test(s){return Ws(s,K_)||cs(s,Q_)},async load(s){return await(await ue.ADAPTER.fetch(s)).text()}};be.add(pf);const J_=["normal","bold","100","200","300","400","500","600","700","800","900"],tg=[".ttf",".otf",".woff",".woff2"],eg=["font/ttf","font/otf","font/woff","font/woff2"],rg=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function _f(s){const t=Pr.extname(s),r=Pr.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let i=r.length>0;for(const o of r)if(!o.match(rg)){i=!1;break}let n=r.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const ig=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function sg(s){return ig.test(s)?s:encodeURI(s)}const gf={extension:{type:ee.LoadParser,priority:_i.Low},name:"loadWebFont",test(s){return Ws(s,eg)||cs(s,tg)},async load(s,t){var i,n,o;const r=ue.ADAPTER.getFontFaceSet();if(r){const h=[],f=((i=t.data)==null?void 0:i.family)??_f(s),A=((o=(n=t.data)==null?void 0:n.weights)==null?void 0:o.filter(C=>J_.includes(C)))??["normal"],T=t.data??{};for(let C=0;C<A.length;C++){const x=A[C],M=new FontFace(f,`url(${sg(s)})`,{...T,weight:x});await M.load(),r.add(M),h.push(M)}return h.length===1?h[0]:h}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>ue.ADAPTER.getFontFaceSet().delete(t))}};be.add(gf);const ng=`(function() {
908
+ `;class tf extends Gr{constructor(t=.5,r=Math.random()){super(El,F_,{uNoise:0,uSeed:0}),this.noise=t,this.seed=r}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Dl={AlphaFilter:Zc,BlurFilter:Qc,BlurFilterPass:aa,ColorMatrixFilter:ha,DisplacementFilter:Kc,FXAAFilter:Jc,NoiseFilter:tf};Object.entries(Dl).forEach(([s,t])=>{Object.defineProperty(Dl,s,{get(){return Oe("7.1.0",`filters.${s} has moved to ${s}`),t}})});class L_{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||($r.system.add(this.tickerUpdate,this,ls.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&($r.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Ts=new L_;class nn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=nn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Ze,this.page=new Ze,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,r,i,n,o){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class qn extends nn{constructor(){super(...arguments),this.client=new Ze,this.movement=new Ze,this.offset=new Ze,this.global=new Ze,this.screen=new Ze}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,r,i){return t.worldTransform.applyInverse(i||this.global,r)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,r,i,n,o,h,f,A,T,C,x,M,D,k,U){throw new Error("Method not implemented.")}}class di extends qn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Xs extends qn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Xs.DOM_DELTA_PIXEL=0,Xs.DOM_DELTA_LINE=1,Xs.DOM_DELTA_PAGE=2;const B_=2048,k_=new Ze,Fl=new Ze;class ef{constructor(t){this.dispatch=new ns,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,r){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:r,priority:0}),this.mappingTable[t].sort((i,n)=>i.priority-n.priority)}dispatchEvent(t,r){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,r),this.dispatch.emit(r||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const r=this.mappingTable[t.type];if(r)for(let i=0,n=r.length;i<n;i++)r[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,r){Ts.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,k_.set(t,r),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,r){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,o=i.length-1;n<o;n++)if(t.currentTarget=i[n],this.notifyTarget(t,r),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,r),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,r),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,r,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(r)?r:[r];for(let o=i.length-1;o>=0;o--)n.forEach(h=>{t.currentTarget=i[o],this.notifyTarget(t,h)})}propagationPath(t){const r=[t];for(let i=0;i<B_&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");r.push(t.parent),t=t.parent}return r.reverse(),r}hitTestMoveRecursive(t,r,i,n,o,h=!1){let f=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||r==="dynamic")&&(Ts.pauseUpdate=!1),t.interactiveChildren&&t.children){const C=t.children;for(let x=C.length-1;x>=0;x--){const M=C[x],D=this.hitTestMoveRecursive(M,this._isInteractive(r)?r:M.eventMode,i,n,o,h||o(t,i));if(D){if(D.length>0&&!D[D.length-1].parent)continue;const k=t.isInteractive();(D.length>0||k)&&(k&&this._allInteractiveElements.push(t),D.push(t)),this._hitElements.length===0&&(this._hitElements=D),f=!0}}}const A=this._isInteractive(r),T=t.isInteractive();return A&&T&&this._allInteractiveElements.push(t),h||this._hitElements.length>0?null:f?this._hitElements:A&&!o(t,i)&&n(t,i)?T?[t]:[]:null}hitTestRecursive(t,r,i,n,o){if(this._interactivePrune(t)||o(t,i))return null;if((t.eventMode==="dynamic"||r==="dynamic")&&(Ts.pauseUpdate=!1),t.interactiveChildren&&t.children){const A=t.children;for(let T=A.length-1;T>=0;T--){const C=A[T],x=this.hitTestRecursive(C,this._isInteractive(r)?r:C.eventMode,i,n,o);if(x){if(x.length>0&&!x[x.length-1].parent)continue;const M=t.isInteractive();return(x.length>0||M)&&x.push(t),x}}}const h=this._isInteractive(r),f=t.isInteractive();return h&&n(t,i)?f?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,r){var i;if(t.hitArea&&(t.worldTransform.applyInverse(r,Fl),!t.hitArea.contains(Fl.x,Fl.y)))return!0;if(t._mask){const n=t._mask.isMaskData?t._mask.maskObject:t._mask;if(n&&!((i=n.containsPoint)!=null&&i.call(n,r)))return!0}return!1}hitTestFn(t,r){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(r):!1}notifyTarget(t,r){var o,h;r=r??t.type;const i=`on${r}`;(h=(o=t.currentTarget)[i])==null||h.call(o,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${r}capture`:r;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,r)}mapPointerDown(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerdown"),r.pointerType==="touch")this.dispatchEvent(r,"touchstart");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const n=r.button===2;this.dispatchEvent(r,n?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=r.composedPath(),this.freeEvent(r)}mapPointerMove(t){var A,T;if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=r.pointerType==="mouse"||r.pointerType==="pen",n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.overTargets);if(((A=n.overTargets)==null?void 0:A.length)>0&&o!==r.target){const C=t.type==="mousemove"?"mouseout":"pointerout",x=this.createPointerEvent(t,C,o);if(this.dispatchEvent(x,"pointerout"),i&&this.dispatchEvent(x,"mouseout"),!r.composedPath().includes(o)){const M=this.createPointerEvent(t,"pointerleave",o);for(M.eventPhase=M.AT_TARGET;M.target&&!r.composedPath().includes(M.target);)M.currentTarget=M.target,this.notifyTarget(M),i&&this.notifyTarget(M,"mouseleave"),M.target=M.target.parent;this.freeEvent(M)}this.freeEvent(x)}if(o!==r.target){const C=t.type==="mousemove"?"mouseover":"pointerover",x=this.clonePointerEvent(r,C);this.dispatchEvent(x,"pointerover"),i&&this.dispatchEvent(x,"mouseover");let M=o==null?void 0:o.parent;for(;M&&M!==this.rootTarget.parent&&M!==r.target;)M=M.parent;if(!M||M===this.rootTarget.parent){const D=this.clonePointerEvent(r,"pointerenter");for(D.eventPhase=D.AT_TARGET;D.target&&D.target!==o&&D.target!==this.rootTarget.parent;)D.currentTarget=D.target,this.notifyTarget(D),i&&this.notifyTarget(D,"mouseenter"),D.target=D.target.parent;this.freeEvent(D)}this.freeEvent(x)}const h=[],f=this.enableGlobalMoveEvents??!0;this.moveOnAll?h.push("pointermove"):this.dispatchEvent(r,"pointermove"),f&&h.push("globalpointermove"),r.pointerType==="touch"&&(this.moveOnAll?h.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),f&&h.push("globaltouchmove")),i&&(this.moveOnAll?h.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),f&&h.push("globalmousemove"),this.cursor=(T=r.target)==null?void 0:T.cursor),h.length>0&&this.all(r,h),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(t){var h;if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(h=i.target)==null?void 0:h.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId);if(r.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(r.overTargets),o=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(o),i&&this.dispatchEvent(o,"mouseout");const h=this.createPointerEvent(t,"pointerleave",n);for(h.eventPhase=h.AT_TARGET;h.target&&h.target!==this.rootTarget.parent;)h.currentTarget=h.target,this.notifyTarget(h),i&&this.notifyTarget(h,"mouseleave"),h.target=h.target.parent;r.overTargets=null,this.freeEvent(o),this.freeEvent(h)}this.cursor=null}mapPointerUp(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const f=i.button===2;this.dispatchEvent(i,f?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),o=this.findMountedTarget(n.pressTargetsByButton[t.button]);let h=o;if(o&&!i.composedPath().includes(o)){let f=o;for(;f&&!i.composedPath().includes(f);){if(i.currentTarget=f,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const A=i.button===2;this.notifyTarget(i,A?"rightupoutside":"mouseupoutside")}f=f.parent}delete n.pressTargetsByButton[t.button],h=f}if(h){const f=this.clonePointerEvent(i,"click");f.target=h,f.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:f.target,timeStamp:r});const A=n.clicksByButton[t.button];if(A.target===f.target&&r-A.timeStamp<200?++A.clickCount:A.clickCount=1,A.target=f.target,A.timeStamp=r,f.detail=A.clickCount,f.pointerType==="mouse"){const T=f.button===2;this.dispatchEvent(f,T?"rightclick":"click")}else f.pointerType==="touch"&&this.dispatchEvent(f,"tap");this.dispatchEvent(f,"pointertap"),this.freeEvent(f)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof di)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.findMountedTarget(r.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let o=i;for(;o;)n.currentTarget=o,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),o=o.parent;delete r.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof Xs)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const r=this.createWheelEvent(t);this.dispatchEvent(r),this.freeEvent(r)}findMountedTarget(t){if(!t)return null;let r=t[0];for(let i=1;i<t.length&&t[i].parent===r;i++)r=t[i];return r}createPointerEvent(t,r,i){const n=this.allocateEvent(di);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof r=="string"&&(n.type=r),n}createWheelEvent(t){const r=this.allocateEvent(Xs);return this.copyWheelData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=this.hitTest(r.global.x,r.global.y),r}clonePointerEvent(t,r){const i=this.allocateEvent(di);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=r??i.type,i}copyWheelData(t,r){r.deltaMode=t.deltaMode,r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ}copyPointerData(t,r){t instanceof di&&r instanceof di&&(r.pointerId=t.pointerId,r.width=t.width,r.height=t.height,r.isPrimary=t.isPrimary,r.pointerType=t.pointerType,r.pressure=t.pressure,r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist)}copyMouseData(t,r){t instanceof qn&&r instanceof qn&&(r.altKey=t.altKey,r.button=t.button,r.buttons=t.buttons,r.client.copyFrom(t.client),r.ctrlKey=t.ctrlKey,r.metaKey=t.metaKey,r.movement.copyFrom(t.movement),r.screen.copyFrom(t.screen),r.shiftKey=t.shiftKey,r.global.copyFrom(t.global))}copyData(t,r){r.isTrusted=t.isTrusted,r.srcElement=t.srcElement,r.timeStamp=performance.now(),r.type=t.type,r.detail=t.detail,r.view=t.view,r.which=t.which,r.layer.copyFrom(t.layer),r.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const r=this.eventPool.get(t).pop()||new t(this);return r.eventPhase=r.NONE,r.currentTarget=null,r.path=null,r.target=null,r}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const r=t.constructor;this.eventPool.has(r)||this.eventPool.set(r,[]),this.eventPool.get(r).push(t)}notifyListeners(t,r){const i=t.currentTarget._events[r];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(r,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let n=0,o=i.length;n<o&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(r,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const O_=1,N_={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ll=class Pu{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ef(null),Ts.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new di(null),this.rootWheelEvent=new Xs(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Pu.defaultEventFeatures},{set:(r,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),r[i]=n,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:r,resolution:i}=this.renderer;this.setTargetElement(r),this.resolution=i,Pu._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let r=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(r=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":r&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":r&&Object.assign(this.domElement.style,i);break}else r&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const r=this.normalizeToPointerData(t);this.autoPreventDefault&&r[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,n=r.length;i<n;i++){const o=r[i],h=this.bootstrapEvent(this.rootPointerEvent,o);this.rootBoundary.mapEvent(h)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Ts.pointerMoved();const r=this.normalizeToPointerData(t);for(let i=0,n=r.length;i<n;i++){const o=this.bootstrapEvent(this.rootPointerEvent,r[i]);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let r=t.target;t.composedPath&&t.composedPath().length>0&&(r=t.composedPath()[0]);const i=r!==this.domElement?"outside":"",n=this.normalizeToPointerData(t);for(let o=0,h=n.length;o<h;o++){const f=this.bootstrapEvent(this.rootPointerEvent,n[o]);f.type+=i,this.rootBoundary.mapEvent(f)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const r=this.normalizeToPointerData(t);for(let i=0,n=r.length;i<n;i++){const o=this.bootstrapEvent(this.rootPointerEvent,r[i]);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const r=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(r)}setTargetElement(t){this.removeEvents(),this.domElement=t,Ts.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Ts.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Ts.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,r,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},o=1/this.resolution;t.x=(r-n.left)*(this.domElement.width/n.width)*o,t.y=(i-n.top)*(this.domElement.height/n.height)*o}normalizeToPointerData(t){const r=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const o=t.changedTouches[i];typeof o.button>"u"&&(o.button=0),typeof o.buttons>"u"&&(o.buttons=1),typeof o.isPrimary>"u"&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,o.type=t.type,r.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=O_),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,r.push(i)}else r.push(t);return r}normalizeWheelEvent(t){const r=this.rootWheelEvent;return this.transferMouseData(r,t),r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ,r.deltaMode=t.deltaMode,this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.copyFrom(r.screen),r.offset.copyFrom(r.screen),r.nativeEvent=t,r.type=t.type,r}bootstrapEvent(t,r){return t.originalEvent=null,t.nativeEvent=r,t.pointerId=r.pointerId,t.width=r.width,t.height=r.height,t.isPrimary=r.isPrimary,t.pointerType=r.pointerType,t.pressure=r.pressure,t.tangentialPressure=r.tangentialPressure,t.tiltX=r.tiltX,t.tiltY=r.tiltY,t.twist=r.twist,this.transferMouseData(t,r),this.mapPositionToPoint(t.screen,r.clientX,r.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=r.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=N_[t.type]||t.type),t}transferMouseData(t,r){t.isTrusted=r.isTrusted,t.srcElement=r.srcElement,t.timeStamp=performance.now(),t.type=r.type,t.altKey=r.altKey,t.button=r.button,t.buttons=r.buttons,t.client.x=r.clientX,t.client.y=r.clientY,t.ctrlKey=r.ctrlKey,t.metaKey=r.metaKey,t.movement.x=r.movementX,t.movement.y=r.movementY,t.page.x=r.pageX,t.page.y=r.pageY,t.relatedTarget=null,t.shiftKey=r.shiftKey}};Ll.extension={name:"events",type:[ee.RendererSystem,ee.CanvasRendererSystem]},Ll.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let la=Ll;Te.add(la);function rf(s){return s==="dynamic"||s==="static"}const sf={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??rf(la.defaultEventMode)},set interactive(s){Oe("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=s,this.eventMode=s?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??la.defaultEventMode},set eventMode(s){this._internalInteractive=rf(s),this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,r){const i=typeof r=="boolean"&&r||typeof r=="object"&&r.capture,n=typeof r=="object"?r.signal:void 0,o=typeof r=="object"?r.once===!0:!1,h=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const f=typeof t=="function"?t:t.handleEvent,A=this;n&&n.addEventListener("abort",()=>{A.off(s,f,h)}),o?A.once(s,f,h):A.on(s,f,h)},removeEventListener(s,t,r){const i=typeof r=="boolean"&&r||typeof r=="object"&&r.capture,n=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,n)},dispatchEvent(s){if(!(s instanceof nn))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};pr.mixin(sf);const nf={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};pr.mixin(nf);const U_=9,ua=100,G_=0,V_=0,of=2,af=1,z_=-1e3,X_=-1e3,W_=2;class Bl{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Ci.tablet||Ci.phone)&&this.createTouchHook();const r=document.createElement("div");r.style.width=`${ua}px`,r.style.height=`${ua}px`,r.style.position="absolute",r.style.top=`${G_}px`,r.style.left=`${V_}px`,r.style.zIndex=of.toString(),this.div=r,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${af}px`,t.style.height=`${af}px`,t.style.position="absolute",t.style.top=`${z_}px`,t.style.left=`${X_}px`,t.style.zIndex=W_.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const r=t.children;if(r)for(let i=0;i<r.length;i++)this.updateAccessibleObjects(r[i])}update(){const t=performance.now();if(Ci.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:r,y:i,width:n,height:o}=this.renderer.view.getBoundingClientRect(),{width:h,height:f,resolution:A}=this.renderer,T=n/h*A,C=o/f*A;let x=this.div;x.style.left=`${r}px`,x.style.top=`${i}px`,x.style.width=`${h}px`,x.style.height=`${f}px`;for(let M=0;M<this.children.length;M++){const D=this.children[M];if(D.renderId!==this.renderId)D._accessibleActive=!1,Bs(this.children,M,1),this.div.removeChild(D._accessibleDiv),this.pool.push(D._accessibleDiv),D._accessibleDiv=null,M--;else{x=D._accessibleDiv;let k=D.hitArea;const U=D.worldTransform;D.hitArea?(x.style.left=`${(U.tx+k.x*U.a)*T}px`,x.style.top=`${(U.ty+k.y*U.d)*C}px`,x.style.width=`${k.width*U.a*T}px`,x.style.height=`${k.height*U.d*C}px`):(k=D.getBounds(),this.capHitArea(k),x.style.left=`${k.x*T}px`,x.style.top=`${k.y*C}px`,x.style.width=`${k.width*T}px`,x.style.height=`${k.height*C}px`,x.title!==D.accessibleTitle&&D.accessibleTitle!==null&&(x.title=D.accessibleTitle),x.getAttribute("aria-label")!==D.accessibleHint&&D.accessibleHint!==null&&x.setAttribute("aria-label",D.accessibleHint)),(D.accessibleTitle!==x.title||D.tabIndex!==x.tabIndex)&&(x.title=D.accessibleTitle,x.tabIndex=D.tabIndex,this.debug&&this.updateDebugHTML(x))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:r,height:i}=this.renderer;t.x+t.width>r&&(t.width=r-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let r=this.pool.pop();r||(r=document.createElement("button"),r.style.width=`${ua}px`,r.style.height=`${ua}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=of.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=t.accessiblePointerEvents,r.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?r.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(r.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&r.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(r),t._accessibleActive=!0,t._accessibleDiv=r,r.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,r){const{displayObject:i}=t.target,n=this.renderer.events.rootBoundary,o=Object.assign(new nn(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,r.forEach(h=>n.dispatchEvent(o,h))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===U_&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Bl.extension={name:"accessibility",type:[ee.RendererPlugin,ee.CanvasRendererPlugin]},Te.add(Bl);const hf=class $u{constructor(t){this.stage=new Zr,t=Object.assign({forceCanvas:!1},t),this.renderer=Gc(t),$u._plugins.forEach(r=>{r.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,r){const i=$u._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(r),this.stage=null,this.renderer.destroy(t),this.renderer=null}};hf._plugins=[];let kl=hf;Te.handleByList(ee.Application,kl._plugins);class Ol{static init(t){Object.defineProperty(this,"resizeTo",{set(r){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=r,r&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let r,i;if(this._resizeTo===globalThis.window)r=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:o}=this._resizeTo;r=n,i=o}this.renderer.resize(r,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Ol.extension=ee.Application,Te.add(Ol);const lf={loader:ee.LoadParser,resolver:ee.ResolveParser,cache:ee.CacheParser,detection:ee.DetectionParser};Te.handle(ee.Asset,s=>{const t=s.ref;Object.entries(lf).filter(([r])=>!!t[r]).forEach(([r,i])=>Te.add(Object.assign(t[r],{extension:t[r].extension??i})))},s=>{const t=s.ref;Object.keys(lf).filter(r=>!!t[r]).forEach(r=>Te.remove(t[r]))});class H_{constructor(t,r=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=r}add(t){t.forEach(r=>{this._assetList.push(r)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],r=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<r;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Ws(s,t){if(Array.isArray(t)){for(const r of t)if(s.startsWith(`data:${r}`))return!0;return!1}return s.startsWith(`data:${t}`)}function cs(s,t){const r=s.split("?")[0],i=Pr.extname(r).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const pi=(s,t,r=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||r?t(i):i):s),ca=(s,t)=>{const r=t.split("?")[1];return r&&(s+=`?${r}`),s};function uf(s,t,r,i,n){const o=t[r];for(let h=0;h<o.length;h++){const f=o[h];r<t.length-1?uf(s.replace(i[r],f),t,r+1,i,n):n.push(s.replace(i[r],f))}}function cf(s){const t=/\{(.*?)\}/g,r=s.match(t),i=[];if(r){const n=[];r.forEach(o=>{const h=o.substring(1,o.length-1).split(",");n.push(h)}),uf(s,n,0,r,i)}else i.push(s);return i}const Zn=s=>!Array.isArray(s);class Y_{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const r=this._cache.get(t);return r||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),r}set(t,r){const i=pi(t);let n;for(let f=0;f<this.parsers.length;f++){const A=this.parsers[f];if(A.test(r)){n=A.getCacheableAssets(i,r);break}}n||(n={},i.forEach(f=>{n[f]=r}));const o=Object.keys(n),h={cacheKeys:o,keys:i};if(i.forEach(f=>{this._cacheMap.set(f,h)}),o.forEach(f=>{const A=n?n[f]:r;this._cache.has(f)&&this._cache.get(f)!==A&&console.warn("[Cache] already has key:",f),this._cache.set(f,n[f])}),r instanceof ne){const f=r;i.forEach(A=>{f.baseTexture!==ne.EMPTY.baseTexture&&Ge.addToCache(f.baseTexture,A),ne.addToCache(f,A)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const r=this._cacheMap.get(t);r.cacheKeys.forEach(i=>{this._cache.delete(i)}),r.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Es=new Y_;class j_{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,r,i)=>(this._parsersValidated=!1,t[r]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,r){const i={promise:null,parser:null};return i.promise=(async()=>{var h,f;let n=null,o=null;if(r.loadParser&&(o=this._parserHash[r.loadParser],o||console.warn(`[Assets] specified load parser "${r.loadParser}" not found while loading ${t}`)),!o){for(let A=0;A<this.parsers.length;A++){const T=this.parsers[A];if(T.load&&((h=T.test)!=null&&h.call(T,t,r,this))){o=T;break}}if(!o)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}n=await o.load(t,r,this),i.parser=o;for(let A=0;A<this.parsers.length;A++){const T=this.parsers[A];T.parse&&T.parse&&await((f=T.testParse)==null?void 0:f.call(T,n,r,this))&&(n=await T.parse(n,r,this)||n,i.parser=T)}return n})(),i}async load(t,r){this._parsersValidated||this._validateParsers();let i=0;const n={},o=Zn(t),h=pi(t,T=>({alias:[T],src:T})),f=h.length,A=h.map(async T=>{const C=Pr.toAbsolute(T.src);if(!n[T.src])try{this.promiseCache[C]||(this.promiseCache[C]=this._getLoadPromiseAndParser(C,T)),n[T.src]=await this.promiseCache[C].promise,r&&r(++i/f)}catch(x){throw delete this.promiseCache[C],delete n[T.src],new Error(`[Loader.load] Failed to load ${C}.
909
+ ${x}`)}});return await Promise.all(A),o?n[h[0].src]:n}async unload(t){const r=pi(t,i=>({alias:[i],src:i})).map(async i=>{var h,f;const n=Pr.toAbsolute(i.src),o=this.promiseCache[n];if(o){const A=await o.promise;delete this.promiseCache[n],(f=(h=o.parser)==null?void 0:h.unload)==null||f.call(h,A,i,this)}});await Promise.all(r)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,r)=>(t[r.name]&&console.warn(`[Assets] loadParser name conflict "${r.name}"`),{...t,[r.name]:r}),{})}}var _i=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(_i||{});const q_=".json",Z_="application/json",ff={extension:{type:ee.LoadParser,priority:_i.Low},name:"loadJson",test(s){return Ws(s,Z_)||cs(s,q_)},async load(s){return await(await ue.ADAPTER.fetch(s)).json()}};Te.add(ff);const Q_=".txt",K_="text/plain",df={name:"loadTxt",extension:{type:ee.LoadParser,priority:_i.Low},test(s){return Ws(s,K_)||cs(s,Q_)},async load(s){return await(await ue.ADAPTER.fetch(s)).text()}};Te.add(df);const J_=["normal","bold","100","200","300","400","500","600","700","800","900"],tg=[".ttf",".otf",".woff",".woff2"],eg=["font/ttf","font/otf","font/woff","font/woff2"],rg=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function pf(s){const t=Pr.extname(s),r=Pr.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let i=r.length>0;for(const o of r)if(!o.match(rg)){i=!1;break}let n=r.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const ig=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function sg(s){return ig.test(s)?s:encodeURI(s)}const _f={extension:{type:ee.LoadParser,priority:_i.Low},name:"loadWebFont",test(s){return Ws(s,eg)||cs(s,tg)},async load(s,t){var i,n,o;const r=ue.ADAPTER.getFontFaceSet();if(r){const h=[],f=((i=t.data)==null?void 0:i.family)??pf(s),A=((o=(n=t.data)==null?void 0:n.weights)==null?void 0:o.filter(C=>J_.includes(C)))??["normal"],T=t.data??{};for(let C=0;C<A.length;C++){const x=A[C],M=new FontFace(f,`url(${sg(s)})`,{...T,weight:x});await M.load(),r.add(M),h.push(M)}return h.length===1?h[0]:h}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>ue.ADAPTER.getFontFaceSet().delete(t))}};Te.add(_f);const ng=`(function() {
910
910
  "use strict";
911
911
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
912
912
  async function checkImageBitmap() {
@@ -949,8 +949,8 @@ ${x}`)}});return await Promise.all(A),o?n[h[0].src]:n}async unload(t){const r=pi
949
949
  }
950
950
  };
951
951
  })();
952
- `;let an=null;class mf{constructor(){an||(an=URL.createObjectURL(new Blob([og],{type:"application/javascript"}))),this.worker=new Worker(an)}}mf.revokeObjectURL=function(){an&&(URL.revokeObjectURL(an),an=null)};let yf=0,Ul;class ag{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:r}=new Nl;r.addEventListener("message",i=>{r.terminate(),Nl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ul===void 0&&(Ul=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Ul&&(this._createdWorkers++,t=new mf().worker,t.addEventListener("message",r=>{this.complete(r.data),this.returnWorker(r.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,r){await this._initWorkers();const i=new Promise((n,o)=>{this.queue.push({id:t,arguments:r,resolve:n,reject:o})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const r=this.queue.pop(),i=r.id;this.resolveHash[yf]={resolve:r.resolve,reject:r.reject},t.postMessage({data:r.arguments,uuid:yf++,id:i})}}const vf=new ag;function hn(s,t,r){s.resource.internal=!0;const i=new ne(s),n=()=>{delete t.promiseCache[r],Es.has(r)&&Es.remove(r)};return i.baseTexture.once("destroyed",()=>{r in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),n())}),i.once("destroyed",()=>{s.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const hg=[".jpeg",".jpg",".png",".webp",".avif"],lg=["image/jpeg","image/png","image/webp","image/avif"];async function xf(s){const t=await ue.ADAPTER.fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const r=await t.blob();return await createImageBitmap(r)}const Qn={name:"loadTextures",extension:{type:ee.LoadParser,priority:_i.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ws(s,lg)||cs(s,hg)},async load(s,t,r){var f;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let n;i?this.config.preferWorkers&&await vf.isImageBitmapSupported()?n=await vf.loadImageBitmap(s):n=await xf(s):n=await new Promise((A,T)=>{const C=new Image;C.crossOrigin=this.config.crossOrigin,C.src=s,C.complete?A(C):(C.onload=()=>A(C),C.onerror=x=>T(x))});const o={...t.data};o.resolution??(o.resolution=Xi(s)),i&&((f=o.resourceOptions)==null?void 0:f.ownsImageBitmap)===void 0&&(o.resourceOptions={...o.resourceOptions},o.resourceOptions.ownsImageBitmap=!0);const h=new Ge(n,o);return h.resource.src=s,hn(h,r,s)},unload(s){s.destroy(!0)}};be.add(Qn);const ug=".svg",cg="image/svg+xml",bf={extension:{type:ee.LoadParser,priority:_i.High},name:"loadSVG",test(s){return Ws(s,cg)||cs(s,ug)},async testParse(s){return aa.test(s)},async parse(s,t,r){var o;const i=new aa(s,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions);await i.load();const n=new Ge(i,{resolution:Xi(s),...t==null?void 0:t.data});return n.resource.src=t.src,hn(n,r,t.src)},async load(s,t){return(await ue.ADAPTER.fetch(s)).text()},unload:Qn.unload};be.add(bf);const fg=[".mp4",".m4v",".webm",".ogv"],dg=["video/mp4","video/webm","video/ogg"],Af={name:"loadVideo",extension:{type:ee.LoadParser,priority:_i.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(s){return Ws(s,dg)||cs(s,fg)},async load(s,t,r){var h;let i;const n=await(await ue.ADAPTER.fetch(s)).blob(),o=URL.createObjectURL(n);try{const f={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(h=t==null?void 0:t.data)==null?void 0:h.resourceOptions,autoLoad:!0},A=new Il(o,f);await A.load();const T=new Ge(A,{alphaMode:await I0(),resolution:Xi(s),...t==null?void 0:t.data});T.resource.src=s,i=hn(T,r,s),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(o)})}catch(f){throw URL.revokeObjectURL(o),f}return i},unload(s){s.destroy(!0)}};be.add(Af);class pg{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,r)=>`${t}${this._bundleIdConnector}${r}`,extractAssetIdFromBundle:(t,r)=>r.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(r=>{this._preferredOrder.push(r),r.priority||(r.priority=Object.keys(r.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const r=t;this._defaultSearchParams=Object.keys(r).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(r[i])}`).join("&")}}getAlias(t){const{alias:r,name:i,src:n,srcs:o}=t;return pi(r||i||n||o,h=>typeof h=="string"?h:Array.isArray(h)?h.map(f=>(f==null?void 0:f.src)??(f==null?void 0:f.srcs)??f):h!=null&&h.src||h!=null&&h.srcs?h.src??h.srcs:h,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(r=>{this.addBundle(r.name,r.assets)})}addBundle(t,r){const i=[];Array.isArray(r)?r.forEach(n=>{const o=n.src??n.srcs,h=n.alias??n.name;let f;if(typeof h=="string"){const A=this._createBundleAssetId(t,h);i.push(A),f=[h,A]}else{const A=h.map(T=>this._createBundleAssetId(t,T));i.push(...A),f=[...h,...A]}this.add({...n,alias:f,src:o})}):Object.keys(r).forEach(n=>{const o=[n,this._createBundleAssetId(t,n)];if(typeof r[n]=="string")this.add({alias:o,src:r[n]});else if(Array.isArray(r[n]))this.add({alias:o,src:r[n]});else{const h=r[n],f=h.src??h.srcs;this.add({...h,alias:o,src:Array.isArray(f)?f:[f]})}i.push(...o)}),this._bundles[t]=i}add(t,r,i,n,o){const h=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(Oe("7.2.0",`Assets.add now uses an object instead of individual parameters.
953
- Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),h.push({alias:t,src:r,data:i,format:n,loadParser:o})):Array.isArray(t)?h.push(...t):h.push(t);let f;f=A=>{this.hasKey(A)&&console.warn(`[Resolver] already has key: ${A} overwriting`)},pi(h).forEach(A=>{const{src:T,srcs:C}=A;let{data:x,format:M,loadParser:D}=A;const k=pi(T||C).map(X=>typeof X=="string"?ff(X):Array.isArray(X)?X:[X]),U=this.getAlias(A);Array.isArray(U)?U.forEach(f):f(U);const G=[];k.forEach(X=>{X.forEach(J=>{let Z={};if(typeof J!="object"){Z.src=J;for(let it=0;it<this._parsers.length;it++){const Q=this._parsers[it];if(Q.test(J)){Z=Q.parse(J);break}}}else x=J.data??x,M=J.format??M,D=J.loadParser??D,Z={...Z,...J};if(!U)throw new Error(`[Resolver] alias is undefined for this asset: ${Z.src}`);Z=this.buildResolvedAsset(Z,{aliases:U,data:x,format:M,loadParser:D}),G.push(Z)})}),U.forEach(X=>{this._assetMap[X]=G})})}resolveBundle(t){const r=Zn(t);t=pi(t);const i={};return t.forEach(n=>{const o=this._bundles[n];if(o){const h=this.resolve(o),f={};for(const A in h){const T=h[A];f[this._extractAssetIdFromBundle(n,A)]=T}i[n]=f}}),r?i[t[0]]:i}resolveUrl(t){const r=this.resolve(t);if(typeof t!="string"){const i={};for(const n in r)i[n]=r[n].src;return i}return r.src}resolve(t){const r=Zn(t);t=pi(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let o=this._assetMap[n];const h=o[0],f=this._getPreferredOrder(o);f==null||f.priority.forEach(A=>{f.params[A].forEach(T=>{const C=o.filter(x=>x[A]?x[A]===T:!1);C.length&&(o=C)})}),this._resolverHash[n]=o[0]??h}else this._resolverHash[n]=this.buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),r?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let r=0;r<t.length;r++){const i=t[0],n=this._preferredOrder.find(o=>o.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const r=/\?/.test(t)?"&":"?";return`${t}${r}${this._defaultSearchParams}`}buildResolvedAsset(t,r){const{aliases:i,data:n,loadParser:o,format:h}=r;return(this._basePath||this._rootPath)&&(t.src=Pr.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=o??t.loadParser,t.format=h??t.format??Pr.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class wf{constructor(){this._detections=[],this._initialized=!1,this.resolver=new pg,this.loader=new j_,this.cache=Es,this._backgroundLoader=new H_(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var o,h;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let f=t.manifest;typeof f=="string"&&(f=await this.load(f)),this.resolver.addManifest(f)}const r=((o=t.texturePreference)==null?void 0:o.resolution)??1,i=typeof r=="number"?[r]:r,n=await this._detectFormats({preferredFormats:(h=t.texturePreference)==null?void 0:h.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,r,i,n,o){this.resolver.add(t,r,i,n,o)}async load(t,r){this._initialized||await this.init();const i=Zn(t),n=pi(t).map(f=>{if(typeof f!="string"){const A=this.resolver.getAlias(f);return A.some(T=>!this.resolver.hasKey(T))&&this.add(f),Array.isArray(A)?A[0]:A}return this.resolver.hasKey(f)||this.add({alias:f,src:f}),f}),o=this.resolver.resolve(n),h=await this._mapLoadToResolve(o,r);return i?h[n[0]]:h}addBundle(t,r){this.resolver.addBundle(t,r)}async loadBundle(t,r){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),o={},h=Object.keys(n);let f=0,A=0;const T=()=>{r==null||r(++f/A)},C=h.map(x=>{const M=n[x];return A+=Object.keys(M).length,this._mapLoadToResolve(M,T).then(D=>{o[x]=D})});return await Promise.all(C),i?o[t[0]]:o}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const r=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(r))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const r=this.resolver.resolveBundle(t);Object.values(r).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Es.get(t);const r={};for(let i=0;i<t.length;i++)r[i]=Es.get(t[i]);return r}async _mapLoadToResolve(t,r){const i=Object.values(t),n=Object.keys(t);this._backgroundLoader.active=!1;const o=await this.loader.load(i,r);this._backgroundLoader.active=!0;const h={};return i.forEach((f,A)=>{const T=o[f.src],C=[f.src];f.alias&&C.push(...f.alias),h[n[A]]=T,Es.set(C,T)}),h}async unload(t){this._initialized||await this.init();const r=pi(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(r);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=pi(t);const r=this.resolver.resolveBundle(t),i=Object.keys(r).map(n=>this._unloadFromResolved(r[n]));await Promise.all(i)}async _unloadFromResolved(t){const r=Object.values(t);r.forEach(i=>{Es.remove(i.src)}),await this.loader.unload(r)}async _detectFormats(t){let r=[];t.preferredFormats&&(r=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?r=await i.add(r):t.skipDetections||(r=await i.remove(r));return r=r.filter((i,n)=>r.indexOf(i)===n),r}get detections(){return this._detections}get preferWorkers(){return Qn.config.preferWorkers}set preferWorkers(t){Oe("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(r=>{r.config&&Object.keys(r.config).filter(i=>i in t).forEach(i=>{r.config[i]=t[i]})})}}const Kn=new wf;be.handleByList(ee.LoadParser,Kn.loader.parsers).handleByList(ee.ResolveParser,Kn.resolver.parsers).handleByList(ee.CacheParser,Kn.cache.parsers).handleByList(ee.DetectionParser,Kn.detections);const Tf={extension:ee.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof ne),getCacheableAssets:(s,t)=>{const r={};return s.forEach(i=>{t.forEach((n,o)=>{r[i+(o===0?"":o+1)]=n})}),r}};be.add(Tf);async function Ef(s){if("Image"in globalThis)return new Promise(t=>{const r=new Image;r.onload=()=>{t(!0)},r.onerror=()=>{t(!1)},r.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Cf={extension:{type:ee.DetectionParser,priority:1},test:async()=>Ef("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")};be.add(Cf);const Sf={extension:{type:ee.DetectionParser,priority:0},test:async()=>Ef("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};be.add(Sf);const Pf=["png","jpg","jpeg"],$f={extension:{type:ee.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Pf],remove:async s=>s.filter(t=>!Pf.includes(t))};be.add($f);const _g="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Gl(s){return _g?!1:document.createElement("video").canPlayType(s)!==""}const Mf={extension:{type:ee.DetectionParser,priority:0},test:async()=>Gl("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")};be.add(Mf);const Rf={extension:{type:ee.DetectionParser,priority:0},test:async()=>Gl("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")};be.add(Rf);const If={extension:{type:ee.DetectionParser,priority:0},test:async()=>Gl("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")};be.add(If);const Df={extension:ee.ResolveParser,test:Qn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ue.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:Pr.extname(s).slice(1),src:s}}};be.add(Df);var Fr=(s=>(s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",s[s.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",s[s.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",s[s.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",s[s.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",s[s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",s[s.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",s[s.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",s[s.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",s[s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",s[s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",s[s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",s))(Fr||{});const Jn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Yi,ln;function Ff(){ln={bptc:Yi.getExtension("EXT_texture_compression_bptc"),astc:Yi.getExtension("WEBGL_compressed_texture_astc"),etc:Yi.getExtension("WEBGL_compressed_texture_etc"),s3tc:Yi.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Yi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Yi.getExtension("WEBGL_compressed_texture_pvrtc")||Yi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Yi.getExtension("WEBGL_compressed_texture_etc1"),atc:Yi.getExtension("WEBGL_compressed_texture_atc")}}const Lf={extension:{type:ee.DetectionParser,priority:2},test:async()=>{const s=ue.ADAPTER.createCanvas().getContext("webgl");return s?(Yi=s,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async s=>{ln||Ff();const t=[];for(const r in ln)ln[r]&&t.push(r);return[...t,...s]},remove:async s=>(ln||Ff(),s.filter(t=>!(t in ln)))};be.add(Lf);class Bf extends In{constructor(t,r={width:1,height:1,autoLoad:!0}){let i,n;typeof t=="string"?(i=t,n=new Uint8Array):(i=null,n=t),super(n,r),this.origin=i,this.buffer=n?new Vo(n):null,this._load=null,this.loaded=!1,this.origin!==null&&r.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Vo(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Cs extends Bf{constructor(t,r){super(t,r),this.format=r.format,this.levels=r.levels||1,this._width=r.width,this._height=r.height,this._extension=Cs._formatToExtension(this.format),(r.levelBuffers||this.buffer)&&(this._levelBuffers=r.levelBuffers||Cs._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,r,i){const n=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;n.pixelStorei(n.UNPACK_ALIGNMENT,4);for(let o=0,h=this.levels;o<h;o++){const{levelID:f,levelWidth:A,levelHeight:T,levelBuffer:C}=this._levelBuffers[o];n.compressedTexImage2D(n.TEXTURE_2D,f,this.format,A,T,0,C)}return!0}onBlobLoaded(){this._levelBuffers=Cs._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,r,i,n,o,h,f){const A=new Array(i);let T=t.byteOffset,C=h,x=f,M=C+n-1&~(n-1),D=x+o-1&~(o-1),k=M*D*Jn[r];for(let U=0;U<i;U++)A[U]={levelID:U,levelWidth:i>1?C:M,levelHeight:i>1?x:D,levelBuffer:new Uint8Array(t.buffer,T,k)},T+=k,C=C>>1||1,x=x>>1||1,M=C+n-1&~(n-1),D=x+o-1&~(o-1),k=M*D*Jn[r];return A}}const Vl=4,da=124,gg=32,kf=20,mg=542327876,pa={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},yg={FOURCC:2},_a={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},vg=1,xg=2,bg=4,Ag=64,wg=512,Tg=131072,Eg=827611204,Cg=861165636,Sg=894720068,Pg=808540228,$g=4,Mg={[Eg]:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Cg]:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Sg]:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT},Rg={70:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Fr.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Fr.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Fr.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Fr.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Of(s){const t=new Uint32Array(s);if(t[0]!==mg)throw new Error("Invalid DDS file magic word");const r=new Uint32Array(s,0,da/Uint32Array.BYTES_PER_ELEMENT),i=r[pa.HEIGHT],n=r[pa.WIDTH],o=r[pa.MIPMAP_COUNT],h=new Uint32Array(s,pa.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,gg/Uint32Array.BYTES_PER_ELEMENT),f=h[vg];if(f&bg){const A=h[yg.FOURCC];if(A!==Pg){const J=Mg[A],Z=Vl+da,it=new Uint8Array(s,Z);return[new Cs(it,{format:J,width:n,height:i,levels:o})]}const T=Vl+da,C=new Uint32Array(t.buffer,T,kf/Uint32Array.BYTES_PER_ELEMENT),x=C[_a.DXGI_FORMAT],M=C[_a.RESOURCE_DIMENSION],D=C[_a.MISC_FLAG],k=C[_a.ARRAY_SIZE],U=Rg[x];if(U===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${x}`);if(D===$g)throw new Error("DDSParser does not support cubemap textures");if(M===6)throw new Error("DDSParser does not supported 3D texture data");const G=new Array,X=Vl+da+kf;if(k===1)G.push(new Uint8Array(s,X));else{const J=Jn[U];let Z=0,it=n,Q=i;for(let et=0;et<o;et++){const ft=Math.max(1,it+3&-4),wt=Math.max(1,Q+3&-4),Rt=ft*wt*J;Z+=Rt,it=it>>>1,Q=Q>>>1}let _t=X;for(let et=0;et<k;et++)G.push(new Uint8Array(s,_t,Z)),_t+=Z}return G.map(J=>new Cs(J,{format:U,width:n,height:i,levels:o}))}throw f&Ag?new Error("DDSParser does not support uncompressed texture data."):f&wg?new Error("DDSParser does not supported YUV uncompressed texture data."):f&Tg?new Error("DDSParser does not support single-channel (lumninance) texture data!"):f&xg?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Nf=[171,75,84,88,32,49,49,187,13,10,26,10],Ig=67305985,Ri={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},zl=64,Xl={[Pe.UNSIGNED_BYTE]:1,[Pe.UNSIGNED_SHORT]:2,[Pe.INT]:4,[Pe.UNSIGNED_INT]:4,[Pe.FLOAT]:4,[Pe.HALF_FLOAT]:8},Uf={[qt.RGBA]:4,[qt.RGB]:3,[qt.RG]:2,[qt.RED]:1,[qt.LUMINANCE]:1,[qt.LUMINANCE_ALPHA]:2,[qt.ALPHA]:1},Gf={[Pe.UNSIGNED_SHORT_4_4_4_4]:2,[Pe.UNSIGNED_SHORT_5_5_5_1]:2,[Pe.UNSIGNED_SHORT_5_6_5]:2};function Vf(s,t,r=!1){const i=new DataView(t);if(!Dg(s,i))return null;const n=i.getUint32(Ri.ENDIANNESS,!0)===Ig,o=i.getUint32(Ri.GL_TYPE,n),h=i.getUint32(Ri.GL_FORMAT,n),f=i.getUint32(Ri.GL_INTERNAL_FORMAT,n),A=i.getUint32(Ri.PIXEL_WIDTH,n),T=i.getUint32(Ri.PIXEL_HEIGHT,n)||1,C=i.getUint32(Ri.PIXEL_DEPTH,n)||1,x=i.getUint32(Ri.NUMBER_OF_ARRAY_ELEMENTS,n)||1,M=i.getUint32(Ri.NUMBER_OF_FACES,n),D=i.getUint32(Ri.NUMBER_OF_MIPMAP_LEVELS,n),k=i.getUint32(Ri.BYTES_OF_KEY_VALUE_DATA,n);if(T===0||C!==1)throw new Error("Only 2D textures are supported");if(M!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(x!==1)throw new Error("WebGL does not support array textures");const U=4,G=4,X=A+3&-4,J=T+3&-4,Z=new Array(x);let it=A*T;o===0&&(it=X*J);let Q;if(o!==0?Xl[o]?Q=Xl[o]*Uf[h]:Q=Gf[o]:Q=Jn[f],Q===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const _t=r?Lg(i,k,n):null;let et=it*Q,ft=A,wt=T,Rt=X,It=J,pt=zl+k;for(let xt=0;xt<D;xt++){const Ct=i.getUint32(pt,n);let Gt=pt+4;for(let st=0;st<x;st++){let nt=Z[st];nt||(nt=Z[st]=new Array(D)),nt[xt]={levelID:xt,levelWidth:D>1||o!==0?ft:Rt,levelHeight:D>1||o!==0?wt:It,levelBuffer:new Uint8Array(t,Gt,et)},Gt+=et}pt+=Ct+4,pt=pt%4!==0?pt+4-pt%4:pt,ft=ft>>1||1,wt=wt>>1||1,Rt=ft+U-1&-4,It=wt+G-1&-4,et=Rt*It*Q}return o!==0?{uncompressed:Z.map(xt=>{let Ct=xt[0].levelBuffer,Gt=!1;return o===Pe.FLOAT?Ct=new Float32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4):o===Pe.UNSIGNED_INT?(Gt=!0,Ct=new Uint32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4)):o===Pe.INT&&(Gt=!0,Ct=new Int32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4)),{resource:new In(Ct,{width:xt[0].levelWidth,height:xt[0].levelHeight}),type:o,format:Gt?Fg(h):h}}),kvData:_t}:{compressed:Z.map(xt=>new Cs(null,{format:f,width:A,height:T,levels:D,levelBuffers:xt})),kvData:_t}}function Dg(s,t){for(let r=0;r<Nf.length;r++)if(t.getUint8(r)!==Nf[r])return console.error(`${s} is not a valid *.ktx file!`),!1;return!0}function Fg(s){switch(s){case qt.RGBA:return qt.RGBA_INTEGER;case qt.RGB:return qt.RGB_INTEGER;case qt.RG:return qt.RG_INTEGER;case qt.RED:return qt.RED_INTEGER;default:return s}}function Lg(s,t,r){const i=new Map;let n=0;for(;n<t;){const o=s.getUint32(zl+n,r),h=zl+n+4,f=3-(o+3)%4;if(o===0||o>t-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let A=0;for(;A<o&&s.getUint8(h+A)!==0;A++);if(A===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const T=new TextDecoder().decode(new Uint8Array(s.buffer,h,A)),C=new DataView(s.buffer,h+A+1,o-A-1);i.set(T,C),n+=4+o+f}return i}const zf={extension:{type:ee.LoadParser,priority:_i.High},name:"loadDDS",test(s){return cs(s,".dds")},async load(s,t,r){const i=await(await ue.ADAPTER.fetch(s)).arrayBuffer(),n=Of(i).map(o=>{const h=new Ge(o,{mipmap:wi.OFF,alphaMode:Vr.NO_PREMULTIPLIED_ALPHA,resolution:Xi(s),...t.data});return hn(h,r,s)});return n.length===1?n[0]:n},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};be.add(zf);const Xf={extension:{type:ee.LoadParser,priority:_i.High},name:"loadKTX",test(s){return cs(s,".ktx")},async load(s,t,r){const i=await(await ue.ADAPTER.fetch(s)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:h}=Vf(s,i),f=n??o,A={mipmap:wi.OFF,alphaMode:Vr.NO_PREMULTIPLIED_ALPHA,resolution:Xi(s),...t.data},T=f.map(C=>{f===o&&Object.assign(A,{type:C.type,format:C.format});const x=C.resource??C,M=new Ge(x,A);return M.ktxKeyValueData=h,hn(M,r,s)});return T.length===1?T[0]:T},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};be.add(Xf);const Bg=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Wf={extension:ee.ResolveParser,test:s=>{const t=Pr.extname(s).slice(1);return["basis","ktx","dds"].includes(t)},parse:s=>{var i,n;const t=s.split("."),r=t.pop();if(["ktx","dds"].includes(r)){const o=t.pop();if(Bg.includes(o))return{resolution:parseFloat(((i=ue.RETINA_PREFIX.exec(s))==null?void 0:i[1])??"1"),format:o,src:s}}return{resolution:parseFloat(((n=ue.RETINA_PREFIX.exec(s))==null?void 0:n[1])??"1"),format:r,src:s}}};be.add(Wf);const ga=new Ve,kg=4,Hf=class Io{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var r;const t=(r=this.renderer)==null?void 0:r.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,r,i,n){const o=new Image;return o.src=await this.base64(t,r,i,n),o}async base64(t,r,i,n){const o=this.canvas(t,n);if(o.toBlob!==void 0)return new Promise((h,f)=>{o.toBlob(A=>{if(!A){f(new Error("ICanvas.toBlob failed!"));return}const T=new FileReader;T.onload=()=>h(T.result),T.onerror=f,T.readAsDataURL(A)},r,i)});if(o.toDataURL!==void 0)return o.toDataURL(r,i);if(o.convertToBlob!==void 0){const h=await o.convertToBlob({type:r,quality:i});return new Promise((f,A)=>{const T=new FileReader;T.onload=()=>f(T.result),T.onerror=A,T.readAsDataURL(h)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,r){const{pixels:i,width:n,height:o,flipY:h,premultipliedAlpha:f}=this._rawPixels(t,r);h&&Io._flipY(i,n,o),f&&Io._unpremultiplyAlpha(i);const A=new j0(n,o,1),T=new ImageData(new Uint8ClampedArray(i.buffer),n,o);return A.context.putImageData(T,0,0),A.canvas}pixels(t,r){const{pixels:i,width:n,height:o,flipY:h,premultipliedAlpha:f}=this._rawPixels(t,r);return h&&Io._flipY(i,n,o),f&&Io._unpremultiplyAlpha(i),i}_rawPixels(t,r){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let n,o=!1,h=!1,f,A=!1;t&&(t instanceof As?f=t:(f=i.generateTexture(t,{region:r,resolution:i.resolution,multisample:i.multisample}),A=!0,r&&(ga.width=r.width,ga.height=r.height,r=ga)));const T=i.gl;if(f){if(n=f.baseTexture.resolution,r=r??f.frame,o=!1,h=f.baseTexture.alphaMode>0&&f.baseTexture.format===qt.RGBA,!A){i.renderTexture.bind(f);const D=f.framebuffer.glFramebuffers[i.CONTEXT_UID];D.blitFramebuffer&&i.framebuffer.bind(D.blitFramebuffer)}}else n=i.resolution,r||(r=ga,r.width=i.width/n,r.height=i.height/n),o=!0,h=this._rendererPremultipliedAlpha,i.renderTexture.bind();const C=Math.max(Math.round(r.width*n),1),x=Math.max(Math.round(r.height*n),1),M=new Uint8Array(kg*C*x);return T.readPixels(Math.round(r.x*n),Math.round(r.y*n),C,x,T.RGBA,T.UNSIGNED_BYTE,M),A&&(f==null||f.destroy(!0)),{pixels:M,width:C,height:x,flipY:o,premultipliedAlpha:h}}destroy(){this.renderer=null}static _flipY(t,r,i){const n=r<<2,o=i>>1,h=new Uint8Array(n);for(let f=0;f<o;f++){const A=f*n,T=(i-f-1)*n;h.set(t.subarray(A,A+n)),t.copyWithin(A,T,T+n),t.set(h,T)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const r=t.length;for(let i=0;i<r;i+=4){const n=t[i+3];if(n!==0){const o=255.001/n;t[i]=t[i]*o+.5,t[i+1]=t[i+1]*o+.5,t[i+2]=t[i+2]*o+.5}}}};Hf.extension={name:"extract",type:ee.RendererSystem};let Yf=Hf;be.add(Yf);const to={build(s){const t=s.points;let r,i,n,o,h,f;if(s.type===Dr.CIRC){const k=s.shape;r=k.x,i=k.y,h=f=k.radius,n=o=0}else if(s.type===Dr.ELIP){const k=s.shape;r=k.x,i=k.y,h=k.width,f=k.height,n=o=0}else{const k=s.shape,U=k.width/2,G=k.height/2;r=k.x+U,i=k.y+G,h=f=Math.max(0,Math.min(k.radius,Math.min(U,G))),n=U-h,o=G-f}if(!(h>=0&&f>=0&&n>=0&&o>=0)){t.length=0;return}const A=Math.ceil(2.3*Math.sqrt(h+f)),T=A*8+(n?4:0)+(o?4:0);if(t.length=T,T===0)return;if(A===0){t.length=8,t[0]=t[6]=r+n,t[1]=t[3]=i+o,t[2]=t[4]=r-n,t[5]=t[7]=i-o;return}let C=0,x=A*4+(n?2:0)+2,M=x,D=T;{const k=n+h,U=o,G=r+k,X=r-k,J=i+U;if(t[C++]=G,t[C++]=J,t[--x]=J,t[--x]=X,o){const Z=i-U;t[M++]=X,t[M++]=Z,t[--D]=Z,t[--D]=G}}for(let k=1;k<A;k++){const U=Math.PI/2*(k/A),G=n+Math.cos(U)*h,X=o+Math.sin(U)*f,J=r+G,Z=r-G,it=i+X,Q=i-X;t[C++]=J,t[C++]=it,t[--x]=it,t[--x]=Z,t[M++]=Z,t[M++]=Q,t[--D]=Q,t[--D]=J}{const k=n,U=o+f,G=r+k,X=r-k,J=i+U,Z=i-U;t[C++]=G,t[C++]=J,t[--D]=Z,t[--D]=G,n&&(t[C++]=X,t[C++]=J,t[--D]=Z,t[--D]=X)}},triangulate(s,t){const r=s.points,i=t.points,n=t.indices;if(r.length===0)return;let o=i.length/2;const h=o;let f,A;if(s.type!==Dr.RREC){const C=s.shape;f=C.x,A=C.y}else{const C=s.shape;f=C.x+C.width/2,A=C.y+C.height/2}const T=s.matrix;i.push(s.matrix?T.a*f+T.c*A+T.tx:f,s.matrix?T.b*f+T.d*A+T.ty:A),o++,i.push(r[0],r[1]);for(let C=2;C<r.length;C+=2)i.push(r[C],r[C+1]),n.push(o++,h,o);n.push(h+1,h,o)}};function jf(s,t=!1){const r=s.length;if(r<6)return;let i=0;for(let n=0,o=s[r-2],h=s[r-1];n<r;n+=2){const f=s[n],A=s[n+1];i+=(f-o)*(A+h),o=f,h=A}if(!t&&i>0||t&&i<=0){const n=r/2;for(let o=n+n%2;o<r;o+=2){const h=r-o-2,f=r-o-1,A=o,T=o+1;[s[h],s[A]]=[s[A],s[h]],[s[f],s[T]]=[s[T],s[f]]}}}const Wl={build(s){s.points=s.shape.points.slice()},triangulate(s,t){let r=s.points;const i=s.holes,n=t.points,o=t.indices;if(r.length>=6){jf(r,!1);const h=[];for(let T=0;T<i.length;T++){const C=i[T];jf(C.points,!0),h.push(r.length/2),r=r.concat(C.points)}const f=Qu(r,h,2);if(!f)return;const A=n.length/2;for(let T=0;T<f.length;T+=3)o.push(f[T]+A),o.push(f[T+1]+A),o.push(f[T+2]+A);for(let T=0;T<r.length;T++)n.push(r[T])}}},qf={build(s){const t=s.shape,r=t.x,i=t.y,n=t.width,o=t.height,h=s.points;h.length=0,n>=0&&o>=0&&h.push(r,i,r+n,i,r+n,i+o,r,i+o)},triangulate(s,t){const r=s.points,i=t.points;if(r.length===0)return;const n=i.length/2;i.push(r[0],r[1],r[2],r[3],r[6],r[7],r[4],r[5]),t.indices.push(n,n+1,n+2,n+1,n+2,n+3)}},Zf={build(s){to.build(s)},triangulate(s,t){to.triangulate(s,t)}};var ni=(s=>(s.MITER="miter",s.BEVEL="bevel",s.ROUND="round",s))(ni||{}),fs=(s=>(s.BUTT="butt",s.ROUND="round",s.SQUARE="square",s))(fs||{});const Ss={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,t=20){if(!this.adaptive||!s||isNaN(s))return t;let r=Math.ceil(s/this.maxLength);return r<this.minSegments?r=this.minSegments:r>this.maxSegments&&(r=this.maxSegments),r}},Og=Ss;class Hl{static curveTo(t,r,i,n,o,h){const f=h[h.length-2],A=h[h.length-1]-r,T=f-t,C=n-r,x=i-t,M=Math.abs(A*x-T*C);if(M<1e-8||o===0)return(h[h.length-2]!==t||h[h.length-1]!==r)&&h.push(t,r),null;const D=A*A+T*T,k=C*C+x*x,U=A*C+T*x,G=o*Math.sqrt(D)/M,X=o*Math.sqrt(k)/M,J=G*U/D,Z=X*U/k,it=G*x+X*T,Q=G*C+X*A,_t=T*(X+J),et=A*(X+J),ft=x*(G+Z),wt=C*(G+Z),Rt=Math.atan2(et-Q,_t-it),It=Math.atan2(wt-Q,ft-it);return{cx:it+t,cy:Q+r,radius:o,startAngle:Rt,endAngle:It,anticlockwise:T*C>x*A}}static arc(t,r,i,n,o,h,f,A,T){const C=f-h,x=Ss._segmentsCount(Math.abs(C)*o,Math.ceil(Math.abs(C)/Fn)*40),M=C/(x*2),D=M*2,k=Math.cos(M),U=Math.sin(M),G=x-1,X=G%1/G;for(let J=0;J<=G;++J){const Z=J+X*J,it=M+h+D*Z,Q=Math.cos(it),_t=-Math.sin(it);T.push((k*Q+U*_t)*o+i,(k*-_t+U*Q)*o+n)}}}class Qf{constructor(){this.reset()}begin(t,r,i){this.reset(),this.style=t,this.start=r,this.attribStart=i}end(t,r){this.attribSize=r-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class ma{static curveLength(t,r,i,n,o,h,f,A){let T=0,C=0,x=0,M=0,D=0,k=0,U=0,G=0,X=0,J=0,Z=0,it=t,Q=r;for(let _t=1;_t<=10;++_t)C=_t/10,x=C*C,M=x*C,D=1-C,k=D*D,U=k*D,G=U*t+3*k*C*i+3*D*x*o+M*f,X=U*r+3*k*C*n+3*D*x*h+M*A,J=it-G,Z=Q-X,it=G,Q=X,T+=Math.sqrt(J*J+Z*Z);return T}static curveTo(t,r,i,n,o,h,f){const A=f[f.length-2],T=f[f.length-1];f.length-=2;const C=Ss._segmentsCount(ma.curveLength(A,T,t,r,i,n,o,h));let x=0,M=0,D=0,k=0,U=0;f.push(A,T);for(let G=1,X=0;G<=C;++G)X=G/C,x=1-X,M=x*x,D=M*x,k=X*X,U=k*X,f.push(D*A+3*M*X*t+3*x*k*i+U*o,D*T+3*M*X*r+3*x*k*n+U*h)}}function Kf(s,t,r,i,n,o,h,f){const A=s-r*n,T=t-i*n,C=s+r*o,x=t+i*o;let M,D;h?(M=i,D=-r):(M=-i,D=r);const k=A+M,U=T+D,G=C+M,X=x+D;return f.push(k,U,G,X),2}function Hs(s,t,r,i,n,o,h,f){const A=r-s,T=i-t;let C=Math.atan2(A,T),x=Math.atan2(n-s,o-t);f&&C<x?C+=Math.PI*2:!f&&C>x&&(x+=Math.PI*2);let M=C;const D=x-C,k=Math.abs(D),U=Math.sqrt(A*A+T*T),G=(15*k*Math.sqrt(U)/Math.PI>>0)+1,X=D/G;if(M+=X,f){h.push(s,t,r,i);for(let J=1,Z=M;J<G;J++,Z+=X)h.push(s,t,s+Math.sin(Z)*U,t+Math.cos(Z)*U);h.push(s,t,n,o)}else{h.push(r,i,s,t);for(let J=1,Z=M;J<G;J++,Z+=X)h.push(s+Math.sin(Z)*U,t+Math.cos(Z)*U,s,t);h.push(n,o,s,t)}return G*2}function Ng(s,t){const r=s.shape;let i=s.points||r.points.slice();const n=t.closePointEps;if(i.length===0)return;const o=s.lineStyle,h=new Ze(i[0],i[1]),f=new Ze(i[i.length-2],i[i.length-1]),A=r.type!==Dr.POLY||r.closeStroke,T=Math.abs(h.x-f.x)<n&&Math.abs(h.y-f.y)<n;if(A){i=i.slice(),T&&(i.pop(),i.pop(),f.set(i[i.length-2],i[i.length-1]));const nt=(h.x+f.x)*.5,Y=(f.y+h.y)*.5;i.unshift(nt,Y),i.push(nt,Y)}const C=t.points,x=i.length/2;let M=i.length;const D=C.length/2,k=o.width/2,U=k*k,G=o.miterLimit*o.miterLimit;let X=i[0],J=i[1],Z=i[2],it=i[3],Q=0,_t=0,et=-(J-it),ft=X-Z,wt=0,Rt=0,It=Math.sqrt(et*et+ft*ft);et/=It,ft/=It,et*=k,ft*=k;const pt=o.alignment,xt=(1-pt)*2,Ct=pt*2;A||(o.cap===fs.ROUND?M+=Hs(X-et*(xt-Ct)*.5,J-ft*(xt-Ct)*.5,X-et*xt,J-ft*xt,X+et*Ct,J+ft*Ct,C,!0)+2:o.cap===fs.SQUARE&&(M+=Kf(X,J,et,ft,xt,Ct,!0,C))),C.push(X-et*xt,J-ft*xt,X+et*Ct,J+ft*Ct);for(let nt=1;nt<x-1;++nt){X=i[(nt-1)*2],J=i[(nt-1)*2+1],Z=i[nt*2],it=i[nt*2+1],Q=i[(nt+1)*2],_t=i[(nt+1)*2+1],et=-(J-it),ft=X-Z,It=Math.sqrt(et*et+ft*ft),et/=It,ft/=It,et*=k,ft*=k,wt=-(it-_t),Rt=Z-Q,It=Math.sqrt(wt*wt+Rt*Rt),wt/=It,Rt/=It,wt*=k,Rt*=k;const Y=Z-X,gt=J-it,ot=Z-Q,ht=_t-it,dt=Y*ot+gt*ht,At=gt*ot-ht*Y,Et=At<0;if(Math.abs(At)<.001*Math.abs(dt)){C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),dt>=0&&(o.join===ni.ROUND?M+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Rt*xt,C,!1)+4:M+=2,C.push(Z-wt*Ct,it-Rt*Ct,Z+wt*xt,it+Rt*xt));continue}const Dt=(-et+X)*(-ft+it)-(-et+Z)*(-ft+J),oe=(-wt+Q)*(-Rt+it)-(-wt+Z)*(-Rt+_t),kt=(Y*oe-ot*Dt)/At,se=(ht*Dt-gt*oe)/At,Kt=(kt-Z)*(kt-Z)+(se-it)*(se-it),Xt=Z+(kt-Z)*xt,_e=it+(se-it)*xt,$e=Z-(kt-Z)*Ct,Jt=it-(se-it)*Ct,De=Math.min(Y*Y+gt*gt,ot*ot+ht*ht),xe=Et?xt:Ct,ae=De+xe*xe*U,Lr=Kt<=ae;let vr=o.join;if(vr===ni.MITER&&Kt/U>G&&(vr=ni.BEVEL),Lr)switch(vr){case ni.MITER:{C.push(Xt,_e,$e,Jt);break}case ni.BEVEL:{Et?C.push(Xt,_e,Z+et*Ct,it+ft*Ct,Xt,_e,Z+wt*Ct,it+Rt*Ct):C.push(Z-et*xt,it-ft*xt,$e,Jt,Z-wt*xt,it-Rt*xt,$e,Jt),M+=2;break}case ni.ROUND:{Et?(C.push(Xt,_e,Z+et*Ct,it+ft*Ct),M+=Hs(Z,it,Z+et*Ct,it+ft*Ct,Z+wt*Ct,it+Rt*Ct,C,!0)+4,C.push(Xt,_e,Z+wt*Ct,it+Rt*Ct)):(C.push(Z-et*xt,it-ft*xt,$e,Jt),M+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Rt*xt,C,!1)+4,C.push(Z-wt*xt,it-Rt*xt,$e,Jt));break}}else{switch(C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),vr){case ni.MITER:{Et?C.push($e,Jt,$e,Jt):C.push(Xt,_e,Xt,_e),M+=2;break}case ni.ROUND:{Et?M+=Hs(Z,it,Z+et*Ct,it+ft*Ct,Z+wt*Ct,it+Rt*Ct,C,!0)+2:M+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Rt*xt,C,!1)+2;break}}C.push(Z-wt*xt,it-Rt*xt,Z+wt*Ct,it+Rt*Ct),M+=2}}X=i[(x-2)*2],J=i[(x-2)*2+1],Z=i[(x-1)*2],it=i[(x-1)*2+1],et=-(J-it),ft=X-Z,It=Math.sqrt(et*et+ft*ft),et/=It,ft/=It,et*=k,ft*=k,C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),A||(o.cap===fs.ROUND?M+=Hs(Z-et*(xt-Ct)*.5,it-ft*(xt-Ct)*.5,Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct,C,!1)+2:o.cap===fs.SQUARE&&(M+=Kf(Z,it,et,ft,xt,Ct,!1,C)));const Gt=t.indices,st=Ss.epsilon*Ss.epsilon;for(let nt=D;nt<M+D-2;++nt)X=C[nt*2],J=C[nt*2+1],Z=C[(nt+1)*2],it=C[(nt+1)*2+1],Q=C[(nt+2)*2],_t=C[(nt+2)*2+1],!(Math.abs(X*(it-_t)+Z*(_t-J)+Q*(J-it))<st)&&Gt.push(nt,nt+1,nt+2)}function Ug(s,t){let r=0;const i=s.shape,n=s.points||i.points,o=i.type!==Dr.POLY||i.closeStroke;if(n.length===0)return;const h=t.points,f=t.indices,A=n.length/2,T=h.length/2;let C=T;for(h.push(n[0],n[1]),r=1;r<A;r++)h.push(n[r*2],n[r*2+1]),f.push(C,C+1),C++;o&&f.push(C,T)}function Yl(s,t){s.lineStyle.native?Ug(s,t):Ng(s,t)}class ya{static curveLength(t,r,i,n,o,h){const f=t-2*i+o,A=r-2*n+h,T=2*i-2*t,C=2*n-2*r,x=4*(f*f+A*A),M=4*(f*T+A*C),D=T*T+C*C,k=2*Math.sqrt(x+M+D),U=Math.sqrt(x),G=2*x*U,X=2*Math.sqrt(D),J=M/U;return(G*k+U*M*(k-X)+(4*D*x-M*M)*Math.log((2*U+J+k)/(J+X)))/(4*G)}static curveTo(t,r,i,n,o){const h=o[o.length-2],f=o[o.length-1],A=Ss._segmentsCount(ya.curveLength(h,f,t,r,i,n));let T=0,C=0;for(let x=1;x<=A;++x){const M=x/A;T=h+(t-h)*M,C=f+(r-f)*M,o.push(T+(t+(i-t)*M-T)*M,C+(r+(n-r)*M-C)*M)}}}const va={[Dr.POLY]:Wl,[Dr.CIRC]:to,[Dr.ELIP]:to,[Dr.RECT]:qf,[Dr.RREC]:Zf},jl=[],eo=[];class ro{constructor(t,r=null,i=null,n=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=r,this.matrix=n,this.type=t.type}clone(){return new ro(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const un=new Ze,Jf=class _2 extends Jh{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Yn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),eo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const r=this.batches[t];r.reset(),jl.push(r)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,r=null,i=null,n=null){const o=new ro(t,r,i,n);return this.graphicsData.push(o),this.dirty++,this}drawHole(t,r=null){if(!this.graphicsData.length)return null;const i=new ro(t,null,null,r),n=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=n.lineStyle,n.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const r=this.graphicsData;for(let i=0;i<r.length;++i){const n=r[i];if(n.fillStyle.visible&&n.shape&&(n.matrix?n.matrix.applyInverse(t,un):un.copyFrom(t),n.shape.contains(un.x,un.y))){let o=!1;if(n.holes){for(let h=0;h<n.holes.length;h++)if(n.holes[h].shape.contains(un.x,un.y)){o=!0;break}}if(!o)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,r=this.graphicsData;let i=null,n=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],n=i.style);for(let A=this.shapeIndex;A<r.length;A++){this.shapeIndex++;const T=r[A],C=T.fillStyle,x=T.lineStyle;va[T.type].build(T),T.matrix&&this.transformPoints(T.points,T.matrix),(C.visible||x.visible)&&this.processHoles(T.holes);for(let M=0;M<2;M++){const D=M===0?C:x;if(!D.visible)continue;const k=D.texture.baseTexture,U=this.indices.length,G=this.points.length/2;k.wrapMode=Vi.REPEAT,M===0?this.processFill(T):this.processLine(T);const X=this.points.length/2-G;X!==0&&(i&&!this._compareStyles(n,D)&&(i.end(U,G),i=null),i||(i=jl.pop()||new Qf,i.begin(D,U,G),this.batches.push(i),n=D),this.addUvs(this.points,t,D.texture,G,X,D.matrix))}}const o=this.indices.length,h=this.points.length/2;if(i&&i.end(o,h),this.batches.length===0){this.batchable=!0;return}const f=h>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&f===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=f?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,r){return!(!t||!r||t.texture.baseTexture!==r.texture.baseTexture||t.color+t.alpha!==r.color+r.alpha||!!t.native!=!!r.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,r=this.graphicsData.length;t<r;t++){const i=this.graphicsData[t],n=i.fillStyle,o=i.lineStyle;if(n&&!n.texture.baseTexture.valid||o&&!o.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let r=0,i=t.length;r<i;r++){const n=t[r];for(let o=0;o<n.size;o++){const h=n.start+o;this.indicesUint16[h]=this.indicesUint16[h]-n.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let r=0;r<t.length;r++)if(t[r].style.native)return!1;return this.points.length<_2.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++Ge._globalBatch;for(let x=0;x<this.drawCalls.length;x++)this.drawCalls[x].texArray.clear(),eo.push(this.drawCalls[x]);this.drawCalls.length=0;const r=this.colors,i=this.textureIds;let n=eo.pop();n||(n=new Xo,n.texArray=new Zo),n.texArray.count=0,n.start=0,n.size=0,n.type=Ai.TRIANGLES;let o=0,h=null,f=0,A=!1,T=Ai.TRIANGLES,C=0;this.drawCalls.push(n);for(let x=0;x<this.batches.length;x++){const M=this.batches[x],D=8,k=M.style,U=k.texture.baseTexture;A!==!!k.native&&(A=!!k.native,T=A?Ai.LINES:Ai.TRIANGLES,h=null,o=D,t++),h!==U&&(h=U,U._batchEnabled!==t&&(o===D&&(t++,o=0,n.size>0&&(n=eo.pop(),n||(n=new Xo,n.texArray=new Zo),this.drawCalls.push(n)),n.start=C,n.size=0,n.texArray.count=0,n.type=T),U.touched=1,U._batchEnabled=t,U._batchLocation=o,U.wrapMode=Vi.REPEAT,n.texArray.elements[n.texArray.count++]=U,o++)),n.size+=M.size,C+=M.size,f=U._batchLocation,this.addColors(r,k.color,k.alpha,M.attribSize,M.attribStart),this.addTextureIds(i,f,M.attribSize,M.attribStart)}Ge._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,r=this.uvs,i=this.colors,n=this.textureIds,o=new ArrayBuffer(t.length*3*4),h=new Float32Array(o),f=new Uint32Array(o);let A=0;for(let T=0;T<t.length/2;T++)h[A++]=t[T*2],h[A++]=t[T*2+1],h[A++]=r[T*2],h[A++]=r[T*2+1],f[A++]=i[T],h[A++]=n[T];this._buffer.update(o),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Wl.triangulate(t,this):va[t.type].triangulate(t,this)}processLine(t){Yl(t,this);for(let r=0;r<t.holes.length;r++)Yl(t.holes[r],this)}processHoles(t){for(let r=0;r<t.length;r++){const i=t[r];va[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,r){for(let i=0;i<t.length/2;i++){const n=t[i*2],o=t[i*2+1];t[i*2]=r.a*n+r.c*o+r.tx,t[i*2+1]=r.b*n+r.d*o+r.ty}}addColors(t,r,i,n,o=0){const h=rr.shared.setValue(r).toLittleEndianNumber(),f=rr.shared.setValue(h).toPremultiplied(i);t.length=Math.max(t.length,o+n);for(let A=0;A<n;A++)t[o+A]=f}addTextureIds(t,r,i,n=0){t.length=Math.max(t.length,n+i);for(let o=0;o<i;o++)t[n+o]=r}addUvs(t,r,i,n,o,h=null){let f=0;const A=r.length,T=i.frame;for(;f<o;){let x=t[(n+f)*2],M=t[(n+f)*2+1];if(h){const D=h.a*x+h.c*M+h.tx;M=h.b*x+h.d*M+h.ty,x=D}f++,r.push(x/T.width,M/T.height)}const C=i.baseTexture;(T.width<C.width||T.height<C.height)&&this.adjustUvs(r,i,A,o)}adjustUvs(t,r,i,n){const o=r.baseTexture,h=1e-6,f=i+n*2,A=r.frame,T=A.width/o.width,C=A.height/o.height;let x=A.x/A.width,M=A.y/A.height,D=Math.floor(t[i]+h),k=Math.floor(t[i+1]+h);for(let U=i+2;U<f;U+=2)D=Math.min(D,Math.floor(t[U]+h)),k=Math.min(k,Math.floor(t[U+1]+h));x-=D,M-=k;for(let U=i;U<f;U+=2)t[U]=(t[U]+x)*T,t[U+1]=(t[U+1]+M)*C}};Jf.BATCHABLE_SIZE=100;let td=Jf;class io{constructor(){this.color=16777215,this.alpha=1,this.texture=ne.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new io;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=ne.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class xa extends io{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=fs.BUTT,this.join=ni.MITER,this.miterLimit=10}clone(){const t=new xa;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=fs.BUTT,this.join=ni.MITER,this.miterLimit=10}}const ql={},Zl=class Xa extends Zr{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new io,this._lineStyle=new xa,this._matrix=null,this._holeMode=!1,this.state=Pi.for2d(),this._geometry=t||new td,this._geometry.refCount++,this._transformID=-1,this._tintColor=new rr(16777215),this.blendMode=Re.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Xa(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,r=0,i,n=.5,o=!1){return typeof t=="number"&&(t={width:t,color:r,alpha:i,alignment:n,native:o}),this.lineTextureStyle(t)}lineTextureStyle(t){const r={width:0,texture:ne.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:fs.BUTT,join:ni.MITER,miterLimit:10};t=Object.assign(r,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,r=this.currentPath.points.length;r>2&&(this.drawShape(this.currentPath),this.currentPath=new xs,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[r-2],t[r-1]))}else this.currentPath=new xs,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,r){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=r,this}lineTo(t,r){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,n=i[i.length-2],o=i[i.length-1];return(n!==t||o!==r)&&i.push(t,r),this}_initCurve(t=0,r=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,r]):this.moveTo(t,r)}quadraticCurveTo(t,r,i,n){this._initCurve();const o=this.currentPath.points;return o.length===0&&this.moveTo(0,0),ya.curveTo(t,r,i,n,o),this}bezierCurveTo(t,r,i,n,o,h){return this._initCurve(),ma.curveTo(t,r,i,n,o,h,this.currentPath.points),this}arcTo(t,r,i,n,o){this._initCurve(t,r);const h=this.currentPath.points,f=Hl.curveTo(t,r,i,n,o,h);if(f){const{cx:A,cy:T,radius:C,startAngle:x,endAngle:M,anticlockwise:D}=f;this.arc(A,T,C,x,M,D)}return this}arc(t,r,i,n,o,h=!1){if(n===o)return this;if(!h&&o<=n?o+=Fn:h&&n<=o&&(n+=Fn),o-n===0)return this;const f=t+Math.cos(n)*i,A=r+Math.sin(n)*i,T=this._geometry.closePointEps;let C=this.currentPath?this.currentPath.points:null;if(C){const x=Math.abs(C[C.length-2]-f),M=Math.abs(C[C.length-1]-A);x<T&&M<T||C.push(f,A)}else this.moveTo(f,A),C=this.currentPath.points;return Hl.arc(f,A,t,r,i,n,o,h,C),this}beginFill(t=0,r){return this.beginTextureFill({texture:ne.WHITE,color:t,alpha:r})}normalizeColor(t){const r=rr.shared.setValue(t.color??0);t.color=r.toNumber(),t.alpha??(t.alpha=r.alpha)}beginTextureFill(t){const r={texture:ne.WHITE,color:16777215,matrix:null};t=Object.assign(r,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,r,i,n){return this.drawShape(new Ve(t,r,i,n))}drawRoundedRect(t,r,i,n,o){return this.drawShape(new kn(t,r,i,n,o))}drawCircle(t,r,i){return this.drawShape(new Ln(t,r,i))}drawEllipse(t,r,i,n){return this.drawShape(new Bn(t,r,i,n))}drawPolygon(...t){let r,i=!0;const n=t[0];n.points?(i=n.closeStroke,r=n.points):Array.isArray(t[0])?r=t[0]:r=t;const o=new xs(r);return o.closeStroke=i,this.drawShape(o),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Dr.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const r=this._geometry;r.updateBatches(),r.batchable?(this.batchDirty!==r.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,r=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let n=0;n<i;n++){const o=t.batches[n],h=o.style.color,f=new Float32Array(this.vertexData.buffer,o.attribStart*4*2,o.attribSize*2),A=new Float32Array(t.uvsFloat32.buffer,o.attribStart*4*2,o.attribSize*2),T=new Uint16Array(t.indicesUint16.buffer,o.start*2,o.size),C={vertexData:f,blendMode:r,indices:T,uvs:A,_batchRGB:rr.shared.setValue(h).toRgbArray(),_tintRGB:h,_texture:o.style.texture,alpha:o.style.alpha,worldAlpha:1};this.batches[n]=C}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let r=0,i=this.batches.length;r<i;r++){const n=this.batches[r];n.worldAlpha=this.worldAlpha*n.alpha,t.plugins[this.pluginName].render(n)}}}_renderDirect(t){const r=this._resolveDirectShader(t),i=this._geometry,n=this.worldAlpha,o=r.uniforms,h=i.drawCalls;o.translationMatrix=this.transform.worldTransform,rr.shared.setValue(this._tintColor).premultiply(n).toArray(o.tint),t.shader.bind(r),t.geometry.bind(i,r),t.state.set(this.state);for(let f=0,A=h.length;f<A;f++)this._renderDrawCallDirect(t,i.drawCalls[f])}_renderDrawCallDirect(t,r){const{texArray:i,type:n,size:o,start:h}=r,f=i.count;for(let A=0;A<f;A++)t.texture.bind(i.elements[A],A);t.geometry.draw(n,o,h)}_resolveDirectShader(t){let r=this.shader;const i=this.pluginName;if(!r){if(!ql[i]){const{maxTextures:n}=t.plugins[i],o=new Int32Array(n);for(let A=0;A<n;A++)o[A]=A;const h={tint:new Float32Array([1,1,1,1]),translationMatrix:new nr,default:fi.from({uSamplers:o},!0)},f=t.plugins[i]._shader.program;ql[i]=new Mi(f,h)}r=ql[i]}return r}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:r,minY:i,maxX:n,maxY:o}=t.bounds;this._bounds.addFrame(this.transform,r,i,n,o)}containsPoint(t){return this.worldTransform.applyInverse(t,Xa._TEMP_POINT),this._geometry.containsPoint(Xa._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const r=this.batches[t];r._tintRGB=rr.shared.setValue(this._tintColor).multiply(r._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const r=this.transform.worldTransform,i=r.a,n=r.b,o=r.c,h=r.d,f=r.tx,A=r.ty,T=this._geometry.points,C=this.vertexData;let x=0;for(let M=0;M<T.length;M+=2){const D=T[M],k=T[M+1];C[x++]=i*D+o*k+f,C[x++]=h*k+n*D+A}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Zl.curves=Ss,Zl._TEMP_POINT=new Ze;let Ql=Zl;const Gg={buildPoly:Wl,buildCircle:to,buildRectangle:qf,buildRoundedRectangle:Zf,buildLine:Yl,ArcUtils:Hl,BezierUtils:ma,QuadraticUtils:ya,BatchPart:Qf,FILL_COMMANDS:va,BATCH_POOL:jl,DRAW_CALL_POOL:eo};class ed{constructor(t,r){this.uvBuffer=t,this.uvMatrix=r,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const r=this.uvBuffer.data;(!this.data||this.data.length!==r.length)&&(this.data=new Float32Array(r.length)),this.uvMatrix.multiplyUvs(r,this.data),this._updateID++}}const Kl=new Ze,rd=new xs,sd=class g2 extends Zr{constructor(t,r,i,n=Ai.TRIANGLES){super(),this.geometry=t,this.shader=r,this.state=i||Pi.for2d(),this.drawMode=n,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=ue.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const r=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Ai.TRIANGLES&&r.length<g2.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const r=this.shader;r.alpha=this.worldAlpha,r.update&&r.update(),t.batch.flush(),r.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(r),t.state.set(this.state),t.geometry.bind(this.geometry,r),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const r=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=r.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const n=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[n]),t.plugins[n].render(this)}calculateVertices(){const t=this.geometry.buffers[0],r=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==r.length&&(this.vertexData=new Float32Array(r.length));const n=this.transform.worldTransform,o=n.a,h=n.b,f=n.c,A=n.d,T=n.tx,C=n.ty,x=this.vertexData;for(let M=0;M<x.length/2;M++){const D=r[M*2],k=r[M*2+1];x[M*2]=o*D+f*k+T,x[M*2+1]=h*D+A*k+C}if(this._roundPixels){const M=ue.RESOLUTION;for(let D=0;D<x.length;++D)x[D]=Math.round(x[D]*M)/M}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],r=this.shader;r.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new ed(t,r.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Kl);const r=this.geometry.getBuffer("aVertexPosition").data,i=rd.points,n=this.geometry.getIndex().data,o=n.length,h=this.drawMode===4?3:1;for(let f=0;f+2<o;f+=h){const A=n[f]*2,T=n[f+1]*2,C=n[f+2]*2;if(i[0]=r[A],i[1]=r[A+1],i[2]=r[T],i[3]=r[T+1],i[4]=r[C],i[5]=r[C+1],rd.contains(Kl.x,Kl.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};sd.BATCHABLE_SIZE=100;let cn=sd;class so extends hs{constructor(t,r,i){super();const n=new br(t),o=new br(r,!0),h=new br(i,!0,!0);this.addAttribute("aVertexPosition",n,2,!1,Pe.FLOAT).addAttribute("aTextureCoord",o,2,!1,Pe.FLOAT).addIndex(h),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Vg=`varying vec2 vTextureCoord;
952
+ `;let an=null;class gf{constructor(){an||(an=URL.createObjectURL(new Blob([og],{type:"application/javascript"}))),this.worker=new Worker(an)}}gf.revokeObjectURL=function(){an&&(URL.revokeObjectURL(an),an=null)};let mf=0,Ul;class ag{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:r}=new Nl;r.addEventListener("message",i=>{r.terminate(),Nl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ul===void 0&&(Ul=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Ul&&(this._createdWorkers++,t=new gf().worker,t.addEventListener("message",r=>{this.complete(r.data),this.returnWorker(r.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,r){await this._initWorkers();const i=new Promise((n,o)=>{this.queue.push({id:t,arguments:r,resolve:n,reject:o})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const r=this.queue.pop(),i=r.id;this.resolveHash[mf]={resolve:r.resolve,reject:r.reject},t.postMessage({data:r.arguments,uuid:mf++,id:i})}}const yf=new ag;function hn(s,t,r){s.resource.internal=!0;const i=new ne(s),n=()=>{delete t.promiseCache[r],Es.has(r)&&Es.remove(r)};return i.baseTexture.once("destroyed",()=>{r in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),n())}),i.once("destroyed",()=>{s.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const hg=[".jpeg",".jpg",".png",".webp",".avif"],lg=["image/jpeg","image/png","image/webp","image/avif"];async function vf(s){const t=await ue.ADAPTER.fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const r=await t.blob();return await createImageBitmap(r)}const Qn={name:"loadTextures",extension:{type:ee.LoadParser,priority:_i.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ws(s,lg)||cs(s,hg)},async load(s,t,r){var f;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let n;i?this.config.preferWorkers&&await yf.isImageBitmapSupported()?n=await yf.loadImageBitmap(s):n=await vf(s):n=await new Promise((A,T)=>{const C=new Image;C.crossOrigin=this.config.crossOrigin,C.src=s,C.complete?A(C):(C.onload=()=>A(C),C.onerror=x=>T(x))});const o={...t.data};o.resolution??(o.resolution=Xi(s)),i&&((f=o.resourceOptions)==null?void 0:f.ownsImageBitmap)===void 0&&(o.resourceOptions={...o.resourceOptions},o.resourceOptions.ownsImageBitmap=!0);const h=new Ge(n,o);return h.resource.src=s,hn(h,r,s)},unload(s){s.destroy(!0)}};Te.add(Qn);const ug=".svg",cg="image/svg+xml",xf={extension:{type:ee.LoadParser,priority:_i.High},name:"loadSVG",test(s){return Ws(s,cg)||cs(s,ug)},async testParse(s){return oa.test(s)},async parse(s,t,r){var o;const i=new oa(s,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions);await i.load();const n=new Ge(i,{resolution:Xi(s),...t==null?void 0:t.data});return n.resource.src=t.src,hn(n,r,t.src)},async load(s,t){return(await ue.ADAPTER.fetch(s)).text()},unload:Qn.unload};Te.add(xf);const fg=[".mp4",".m4v",".webm",".ogv"],dg=["video/mp4","video/webm","video/ogg"],bf={name:"loadVideo",extension:{type:ee.LoadParser,priority:_i.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(s){return Ws(s,dg)||cs(s,fg)},async load(s,t,r){var h;let i;const n=await(await ue.ADAPTER.fetch(s)).blob(),o=URL.createObjectURL(n);try{const f={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(h=t==null?void 0:t.data)==null?void 0:h.resourceOptions,autoLoad:!0},A=new Il(o,f);await A.load();const T=new Ge(A,{alphaMode:await R0(),resolution:Xi(s),...t==null?void 0:t.data});T.resource.src=s,i=hn(T,r,s),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(o)})}catch(f){throw URL.revokeObjectURL(o),f}return i},unload(s){s.destroy(!0)}};Te.add(bf);class pg{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,r)=>`${t}${this._bundleIdConnector}${r}`,extractAssetIdFromBundle:(t,r)=>r.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(r=>{this._preferredOrder.push(r),r.priority||(r.priority=Object.keys(r.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const r=t;this._defaultSearchParams=Object.keys(r).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(r[i])}`).join("&")}}getAlias(t){const{alias:r,name:i,src:n,srcs:o}=t;return pi(r||i||n||o,h=>typeof h=="string"?h:Array.isArray(h)?h.map(f=>(f==null?void 0:f.src)??(f==null?void 0:f.srcs)??f):h!=null&&h.src||h!=null&&h.srcs?h.src??h.srcs:h,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(r=>{this.addBundle(r.name,r.assets)})}addBundle(t,r){const i=[];Array.isArray(r)?r.forEach(n=>{const o=n.src??n.srcs,h=n.alias??n.name;let f;if(typeof h=="string"){const A=this._createBundleAssetId(t,h);i.push(A),f=[h,A]}else{const A=h.map(T=>this._createBundleAssetId(t,T));i.push(...A),f=[...h,...A]}this.add({...n,alias:f,src:o})}):Object.keys(r).forEach(n=>{const o=[n,this._createBundleAssetId(t,n)];if(typeof r[n]=="string")this.add({alias:o,src:r[n]});else if(Array.isArray(r[n]))this.add({alias:o,src:r[n]});else{const h=r[n],f=h.src??h.srcs;this.add({...h,alias:o,src:Array.isArray(f)?f:[f]})}i.push(...o)}),this._bundles[t]=i}add(t,r,i,n,o){const h=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(Oe("7.2.0",`Assets.add now uses an object instead of individual parameters.
953
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),h.push({alias:t,src:r,data:i,format:n,loadParser:o})):Array.isArray(t)?h.push(...t):h.push(t);let f;f=A=>{this.hasKey(A)&&console.warn(`[Resolver] already has key: ${A} overwriting`)},pi(h).forEach(A=>{const{src:T,srcs:C}=A;let{data:x,format:M,loadParser:D}=A;const k=pi(T||C).map(X=>typeof X=="string"?cf(X):Array.isArray(X)?X:[X]),U=this.getAlias(A);Array.isArray(U)?U.forEach(f):f(U);const G=[];k.forEach(X=>{X.forEach(J=>{let Z={};if(typeof J!="object"){Z.src=J;for(let it=0;it<this._parsers.length;it++){const Q=this._parsers[it];if(Q.test(J)){Z=Q.parse(J);break}}}else x=J.data??x,M=J.format??M,D=J.loadParser??D,Z={...Z,...J};if(!U)throw new Error(`[Resolver] alias is undefined for this asset: ${Z.src}`);Z=this.buildResolvedAsset(Z,{aliases:U,data:x,format:M,loadParser:D}),G.push(Z)})}),U.forEach(X=>{this._assetMap[X]=G})})}resolveBundle(t){const r=Zn(t);t=pi(t);const i={};return t.forEach(n=>{const o=this._bundles[n];if(o){const h=this.resolve(o),f={};for(const A in h){const T=h[A];f[this._extractAssetIdFromBundle(n,A)]=T}i[n]=f}}),r?i[t[0]]:i}resolveUrl(t){const r=this.resolve(t);if(typeof t!="string"){const i={};for(const n in r)i[n]=r[n].src;return i}return r.src}resolve(t){const r=Zn(t);t=pi(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let o=this._assetMap[n];const h=o[0],f=this._getPreferredOrder(o);f==null||f.priority.forEach(A=>{f.params[A].forEach(T=>{const C=o.filter(x=>x[A]?x[A]===T:!1);C.length&&(o=C)})}),this._resolverHash[n]=o[0]??h}else this._resolverHash[n]=this.buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),r?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let r=0;r<t.length;r++){const i=t[0],n=this._preferredOrder.find(o=>o.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const r=/\?/.test(t)?"&":"?";return`${t}${r}${this._defaultSearchParams}`}buildResolvedAsset(t,r){const{aliases:i,data:n,loadParser:o,format:h}=r;return(this._basePath||this._rootPath)&&(t.src=Pr.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=o??t.loadParser,t.format=h??t.format??Pr.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Af{constructor(){this._detections=[],this._initialized=!1,this.resolver=new pg,this.loader=new j_,this.cache=Es,this._backgroundLoader=new H_(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var o,h;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let f=t.manifest;typeof f=="string"&&(f=await this.load(f)),this.resolver.addManifest(f)}const r=((o=t.texturePreference)==null?void 0:o.resolution)??1,i=typeof r=="number"?[r]:r,n=await this._detectFormats({preferredFormats:(h=t.texturePreference)==null?void 0:h.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,r,i,n,o){this.resolver.add(t,r,i,n,o)}async load(t,r){this._initialized||await this.init();const i=Zn(t),n=pi(t).map(f=>{if(typeof f!="string"){const A=this.resolver.getAlias(f);return A.some(T=>!this.resolver.hasKey(T))&&this.add(f),Array.isArray(A)?A[0]:A}return this.resolver.hasKey(f)||this.add({alias:f,src:f}),f}),o=this.resolver.resolve(n),h=await this._mapLoadToResolve(o,r);return i?h[n[0]]:h}addBundle(t,r){this.resolver.addBundle(t,r)}async loadBundle(t,r){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),o={},h=Object.keys(n);let f=0,A=0;const T=()=>{r==null||r(++f/A)},C=h.map(x=>{const M=n[x];return A+=Object.keys(M).length,this._mapLoadToResolve(M,T).then(D=>{o[x]=D})});return await Promise.all(C),i?o[t[0]]:o}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const r=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(r))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const r=this.resolver.resolveBundle(t);Object.values(r).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Es.get(t);const r={};for(let i=0;i<t.length;i++)r[i]=Es.get(t[i]);return r}async _mapLoadToResolve(t,r){const i=Object.values(t),n=Object.keys(t);this._backgroundLoader.active=!1;const o=await this.loader.load(i,r);this._backgroundLoader.active=!0;const h={};return i.forEach((f,A)=>{const T=o[f.src],C=[f.src];f.alias&&C.push(...f.alias),h[n[A]]=T,Es.set(C,T)}),h}async unload(t){this._initialized||await this.init();const r=pi(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(r);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=pi(t);const r=this.resolver.resolveBundle(t),i=Object.keys(r).map(n=>this._unloadFromResolved(r[n]));await Promise.all(i)}async _unloadFromResolved(t){const r=Object.values(t);r.forEach(i=>{Es.remove(i.src)}),await this.loader.unload(r)}async _detectFormats(t){let r=[];t.preferredFormats&&(r=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?r=await i.add(r):t.skipDetections||(r=await i.remove(r));return r=r.filter((i,n)=>r.indexOf(i)===n),r}get detections(){return this._detections}get preferWorkers(){return Qn.config.preferWorkers}set preferWorkers(t){Oe("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(r=>{r.config&&Object.keys(r.config).filter(i=>i in t).forEach(i=>{r.config[i]=t[i]})})}}const Kn=new Af;Te.handleByList(ee.LoadParser,Kn.loader.parsers).handleByList(ee.ResolveParser,Kn.resolver.parsers).handleByList(ee.CacheParser,Kn.cache.parsers).handleByList(ee.DetectionParser,Kn.detections);const wf={extension:ee.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof ne),getCacheableAssets:(s,t)=>{const r={};return s.forEach(i=>{t.forEach((n,o)=>{r[i+(o===0?"":o+1)]=n})}),r}};Te.add(wf);async function Tf(s){if("Image"in globalThis)return new Promise(t=>{const r=new Image;r.onload=()=>{t(!0)},r.onerror=()=>{t(!1)},r.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Ef={extension:{type:ee.DetectionParser,priority:1},test:async()=>Tf("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")};Te.add(Ef);const Cf={extension:{type:ee.DetectionParser,priority:0},test:async()=>Tf("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};Te.add(Cf);const Sf=["png","jpg","jpeg"],Pf={extension:{type:ee.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Sf],remove:async s=>s.filter(t=>!Sf.includes(t))};Te.add(Pf);const _g="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Gl(s){return _g?!1:document.createElement("video").canPlayType(s)!==""}const $f={extension:{type:ee.DetectionParser,priority:0},test:async()=>Gl("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")};Te.add($f);const Mf={extension:{type:ee.DetectionParser,priority:0},test:async()=>Gl("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")};Te.add(Mf);const Rf={extension:{type:ee.DetectionParser,priority:0},test:async()=>Gl("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")};Te.add(Rf);const If={extension:ee.ResolveParser,test:Qn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ue.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:Pr.extname(s).slice(1),src:s}}};Te.add(If);var Fr=(s=>(s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",s[s.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",s[s.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",s[s.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",s[s.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",s[s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",s[s.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",s[s.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",s[s.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",s[s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",s[s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",s[s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",s))(Fr||{});const Jn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Yi,ln;function Df(){ln={bptc:Yi.getExtension("EXT_texture_compression_bptc"),astc:Yi.getExtension("WEBGL_compressed_texture_astc"),etc:Yi.getExtension("WEBGL_compressed_texture_etc"),s3tc:Yi.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Yi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Yi.getExtension("WEBGL_compressed_texture_pvrtc")||Yi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Yi.getExtension("WEBGL_compressed_texture_etc1"),atc:Yi.getExtension("WEBGL_compressed_texture_atc")}}const Ff={extension:{type:ee.DetectionParser,priority:2},test:async()=>{const s=ue.ADAPTER.createCanvas().getContext("webgl");return s?(Yi=s,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async s=>{ln||Df();const t=[];for(const r in ln)ln[r]&&t.push(r);return[...t,...s]},remove:async s=>(ln||Df(),s.filter(t=>!(t in ln)))};Te.add(Ff);class Lf extends In{constructor(t,r={width:1,height:1,autoLoad:!0}){let i,n;typeof t=="string"?(i=t,n=new Uint8Array):(i=null,n=t),super(n,r),this.origin=i,this.buffer=n?new Vo(n):null,this._load=null,this.loaded=!1,this.origin!==null&&r.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Vo(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Cs extends Lf{constructor(t,r){super(t,r),this.format=r.format,this.levels=r.levels||1,this._width=r.width,this._height=r.height,this._extension=Cs._formatToExtension(this.format),(r.levelBuffers||this.buffer)&&(this._levelBuffers=r.levelBuffers||Cs._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,r,i){const n=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;n.pixelStorei(n.UNPACK_ALIGNMENT,4);for(let o=0,h=this.levels;o<h;o++){const{levelID:f,levelWidth:A,levelHeight:T,levelBuffer:C}=this._levelBuffers[o];n.compressedTexImage2D(n.TEXTURE_2D,f,this.format,A,T,0,C)}return!0}onBlobLoaded(){this._levelBuffers=Cs._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,r,i,n,o,h,f){const A=new Array(i);let T=t.byteOffset,C=h,x=f,M=C+n-1&~(n-1),D=x+o-1&~(o-1),k=M*D*Jn[r];for(let U=0;U<i;U++)A[U]={levelID:U,levelWidth:i>1?C:M,levelHeight:i>1?x:D,levelBuffer:new Uint8Array(t.buffer,T,k)},T+=k,C=C>>1||1,x=x>>1||1,M=C+n-1&~(n-1),D=x+o-1&~(o-1),k=M*D*Jn[r];return A}}const Vl=4,fa=124,gg=32,Bf=20,mg=542327876,da={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},yg={FOURCC:2},pa={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},vg=1,xg=2,bg=4,Ag=64,wg=512,Tg=131072,Eg=827611204,Cg=861165636,Sg=894720068,Pg=808540228,$g=4,Mg={[Eg]:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Cg]:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Sg]:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT},Rg={70:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Fr.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Fr.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Fr.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Fr.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Fr.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Fr.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Fr.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Fr.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function kf(s){const t=new Uint32Array(s);if(t[0]!==mg)throw new Error("Invalid DDS file magic word");const r=new Uint32Array(s,0,fa/Uint32Array.BYTES_PER_ELEMENT),i=r[da.HEIGHT],n=r[da.WIDTH],o=r[da.MIPMAP_COUNT],h=new Uint32Array(s,da.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,gg/Uint32Array.BYTES_PER_ELEMENT),f=h[vg];if(f&bg){const A=h[yg.FOURCC];if(A!==Pg){const J=Mg[A],Z=Vl+fa,it=new Uint8Array(s,Z);return[new Cs(it,{format:J,width:n,height:i,levels:o})]}const T=Vl+fa,C=new Uint32Array(t.buffer,T,Bf/Uint32Array.BYTES_PER_ELEMENT),x=C[pa.DXGI_FORMAT],M=C[pa.RESOURCE_DIMENSION],D=C[pa.MISC_FLAG],k=C[pa.ARRAY_SIZE],U=Rg[x];if(U===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${x}`);if(D===$g)throw new Error("DDSParser does not support cubemap textures");if(M===6)throw new Error("DDSParser does not supported 3D texture data");const G=new Array,X=Vl+fa+Bf;if(k===1)G.push(new Uint8Array(s,X));else{const J=Jn[U];let Z=0,it=n,Q=i;for(let et=0;et<o;et++){const ft=Math.max(1,it+3&-4),wt=Math.max(1,Q+3&-4),Rt=ft*wt*J;Z+=Rt,it=it>>>1,Q=Q>>>1}let _t=X;for(let et=0;et<k;et++)G.push(new Uint8Array(s,_t,Z)),_t+=Z}return G.map(J=>new Cs(J,{format:U,width:n,height:i,levels:o}))}throw f&Ag?new Error("DDSParser does not support uncompressed texture data."):f&wg?new Error("DDSParser does not supported YUV uncompressed texture data."):f&Tg?new Error("DDSParser does not support single-channel (lumninance) texture data!"):f&xg?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Of=[171,75,84,88,32,49,49,187,13,10,26,10],Ig=67305985,Ri={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},zl=64,Xl={[Pe.UNSIGNED_BYTE]:1,[Pe.UNSIGNED_SHORT]:2,[Pe.INT]:4,[Pe.UNSIGNED_INT]:4,[Pe.FLOAT]:4,[Pe.HALF_FLOAT]:8},Nf={[qt.RGBA]:4,[qt.RGB]:3,[qt.RG]:2,[qt.RED]:1,[qt.LUMINANCE]:1,[qt.LUMINANCE_ALPHA]:2,[qt.ALPHA]:1},Uf={[Pe.UNSIGNED_SHORT_4_4_4_4]:2,[Pe.UNSIGNED_SHORT_5_5_5_1]:2,[Pe.UNSIGNED_SHORT_5_6_5]:2};function Gf(s,t,r=!1){const i=new DataView(t);if(!Dg(s,i))return null;const n=i.getUint32(Ri.ENDIANNESS,!0)===Ig,o=i.getUint32(Ri.GL_TYPE,n),h=i.getUint32(Ri.GL_FORMAT,n),f=i.getUint32(Ri.GL_INTERNAL_FORMAT,n),A=i.getUint32(Ri.PIXEL_WIDTH,n),T=i.getUint32(Ri.PIXEL_HEIGHT,n)||1,C=i.getUint32(Ri.PIXEL_DEPTH,n)||1,x=i.getUint32(Ri.NUMBER_OF_ARRAY_ELEMENTS,n)||1,M=i.getUint32(Ri.NUMBER_OF_FACES,n),D=i.getUint32(Ri.NUMBER_OF_MIPMAP_LEVELS,n),k=i.getUint32(Ri.BYTES_OF_KEY_VALUE_DATA,n);if(T===0||C!==1)throw new Error("Only 2D textures are supported");if(M!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(x!==1)throw new Error("WebGL does not support array textures");const U=4,G=4,X=A+3&-4,J=T+3&-4,Z=new Array(x);let it=A*T;o===0&&(it=X*J);let Q;if(o!==0?Xl[o]?Q=Xl[o]*Nf[h]:Q=Uf[o]:Q=Jn[f],Q===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const _t=r?Lg(i,k,n):null;let et=it*Q,ft=A,wt=T,Rt=X,It=J,pt=zl+k;for(let xt=0;xt<D;xt++){const Ct=i.getUint32(pt,n);let Gt=pt+4;for(let st=0;st<x;st++){let nt=Z[st];nt||(nt=Z[st]=new Array(D)),nt[xt]={levelID:xt,levelWidth:D>1||o!==0?ft:Rt,levelHeight:D>1||o!==0?wt:It,levelBuffer:new Uint8Array(t,Gt,et)},Gt+=et}pt+=Ct+4,pt=pt%4!==0?pt+4-pt%4:pt,ft=ft>>1||1,wt=wt>>1||1,Rt=ft+U-1&-4,It=wt+G-1&-4,et=Rt*It*Q}return o!==0?{uncompressed:Z.map(xt=>{let Ct=xt[0].levelBuffer,Gt=!1;return o===Pe.FLOAT?Ct=new Float32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4):o===Pe.UNSIGNED_INT?(Gt=!0,Ct=new Uint32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4)):o===Pe.INT&&(Gt=!0,Ct=new Int32Array(xt[0].levelBuffer.buffer,xt[0].levelBuffer.byteOffset,xt[0].levelBuffer.byteLength/4)),{resource:new In(Ct,{width:xt[0].levelWidth,height:xt[0].levelHeight}),type:o,format:Gt?Fg(h):h}}),kvData:_t}:{compressed:Z.map(xt=>new Cs(null,{format:f,width:A,height:T,levels:D,levelBuffers:xt})),kvData:_t}}function Dg(s,t){for(let r=0;r<Of.length;r++)if(t.getUint8(r)!==Of[r])return console.error(`${s} is not a valid *.ktx file!`),!1;return!0}function Fg(s){switch(s){case qt.RGBA:return qt.RGBA_INTEGER;case qt.RGB:return qt.RGB_INTEGER;case qt.RG:return qt.RG_INTEGER;case qt.RED:return qt.RED_INTEGER;default:return s}}function Lg(s,t,r){const i=new Map;let n=0;for(;n<t;){const o=s.getUint32(zl+n,r),h=zl+n+4,f=3-(o+3)%4;if(o===0||o>t-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let A=0;for(;A<o&&s.getUint8(h+A)!==0;A++);if(A===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const T=new TextDecoder().decode(new Uint8Array(s.buffer,h,A)),C=new DataView(s.buffer,h+A+1,o-A-1);i.set(T,C),n+=4+o+f}return i}const Vf={extension:{type:ee.LoadParser,priority:_i.High},name:"loadDDS",test(s){return cs(s,".dds")},async load(s,t,r){const i=await(await ue.ADAPTER.fetch(s)).arrayBuffer(),n=kf(i).map(o=>{const h=new Ge(o,{mipmap:wi.OFF,alphaMode:Vr.NO_PREMULTIPLIED_ALPHA,resolution:Xi(s),...t.data});return hn(h,r,s)});return n.length===1?n[0]:n},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};Te.add(Vf);const zf={extension:{type:ee.LoadParser,priority:_i.High},name:"loadKTX",test(s){return cs(s,".ktx")},async load(s,t,r){const i=await(await ue.ADAPTER.fetch(s)).arrayBuffer(),{compressed:n,uncompressed:o,kvData:h}=Gf(s,i),f=n??o,A={mipmap:wi.OFF,alphaMode:Vr.NO_PREMULTIPLIED_ALPHA,resolution:Xi(s),...t.data},T=f.map(C=>{f===o&&Object.assign(A,{type:C.type,format:C.format});const x=C.resource??C,M=new Ge(x,A);return M.ktxKeyValueData=h,hn(M,r,s)});return T.length===1?T[0]:T},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};Te.add(zf);const Bg=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Xf={extension:ee.ResolveParser,test:s=>{const t=Pr.extname(s).slice(1);return["basis","ktx","dds"].includes(t)},parse:s=>{var i,n;const t=s.split("."),r=t.pop();if(["ktx","dds"].includes(r)){const o=t.pop();if(Bg.includes(o))return{resolution:parseFloat(((i=ue.RETINA_PREFIX.exec(s))==null?void 0:i[1])??"1"),format:o,src:s}}return{resolution:parseFloat(((n=ue.RETINA_PREFIX.exec(s))==null?void 0:n[1])??"1"),format:r,src:s}}};Te.add(Xf);const _a=new Ve,kg=4,Wf=class Io{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var r;const t=(r=this.renderer)==null?void 0:r.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,r,i,n){const o=new Image;return o.src=await this.base64(t,r,i,n),o}async base64(t,r,i,n){const o=this.canvas(t,n);if(o.toBlob!==void 0)return new Promise((h,f)=>{o.toBlob(A=>{if(!A){f(new Error("ICanvas.toBlob failed!"));return}const T=new FileReader;T.onload=()=>h(T.result),T.onerror=f,T.readAsDataURL(A)},r,i)});if(o.toDataURL!==void 0)return o.toDataURL(r,i);if(o.convertToBlob!==void 0){const h=await o.convertToBlob({type:r,quality:i});return new Promise((f,A)=>{const T=new FileReader;T.onload=()=>f(T.result),T.onerror=A,T.readAsDataURL(h)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,r){const{pixels:i,width:n,height:o,flipY:h,premultipliedAlpha:f}=this._rawPixels(t,r);h&&Io._flipY(i,n,o),f&&Io._unpremultiplyAlpha(i);const A=new Y0(n,o,1),T=new ImageData(new Uint8ClampedArray(i.buffer),n,o);return A.context.putImageData(T,0,0),A.canvas}pixels(t,r){const{pixels:i,width:n,height:o,flipY:h,premultipliedAlpha:f}=this._rawPixels(t,r);return h&&Io._flipY(i,n,o),f&&Io._unpremultiplyAlpha(i),i}_rawPixels(t,r){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let n,o=!1,h=!1,f,A=!1;t&&(t instanceof As?f=t:(f=i.generateTexture(t,{region:r,resolution:i.resolution,multisample:i.multisample}),A=!0,r&&(_a.width=r.width,_a.height=r.height,r=_a)));const T=i.gl;if(f){if(n=f.baseTexture.resolution,r=r??f.frame,o=!1,h=f.baseTexture.alphaMode>0&&f.baseTexture.format===qt.RGBA,!A){i.renderTexture.bind(f);const D=f.framebuffer.glFramebuffers[i.CONTEXT_UID];D.blitFramebuffer&&i.framebuffer.bind(D.blitFramebuffer)}}else n=i.resolution,r||(r=_a,r.width=i.width/n,r.height=i.height/n),o=!0,h=this._rendererPremultipliedAlpha,i.renderTexture.bind();const C=Math.max(Math.round(r.width*n),1),x=Math.max(Math.round(r.height*n),1),M=new Uint8Array(kg*C*x);return T.readPixels(Math.round(r.x*n),Math.round(r.y*n),C,x,T.RGBA,T.UNSIGNED_BYTE,M),A&&(f==null||f.destroy(!0)),{pixels:M,width:C,height:x,flipY:o,premultipliedAlpha:h}}destroy(){this.renderer=null}static _flipY(t,r,i){const n=r<<2,o=i>>1,h=new Uint8Array(n);for(let f=0;f<o;f++){const A=f*n,T=(i-f-1)*n;h.set(t.subarray(A,A+n)),t.copyWithin(A,T,T+n),t.set(h,T)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const r=t.length;for(let i=0;i<r;i+=4){const n=t[i+3];if(n!==0){const o=255.001/n;t[i]=t[i]*o+.5,t[i+1]=t[i+1]*o+.5,t[i+2]=t[i+2]*o+.5}}}};Wf.extension={name:"extract",type:ee.RendererSystem};let Hf=Wf;Te.add(Hf);const to={build(s){const t=s.points;let r,i,n,o,h,f;if(s.type===Dr.CIRC){const k=s.shape;r=k.x,i=k.y,h=f=k.radius,n=o=0}else if(s.type===Dr.ELIP){const k=s.shape;r=k.x,i=k.y,h=k.width,f=k.height,n=o=0}else{const k=s.shape,U=k.width/2,G=k.height/2;r=k.x+U,i=k.y+G,h=f=Math.max(0,Math.min(k.radius,Math.min(U,G))),n=U-h,o=G-f}if(!(h>=0&&f>=0&&n>=0&&o>=0)){t.length=0;return}const A=Math.ceil(2.3*Math.sqrt(h+f)),T=A*8+(n?4:0)+(o?4:0);if(t.length=T,T===0)return;if(A===0){t.length=8,t[0]=t[6]=r+n,t[1]=t[3]=i+o,t[2]=t[4]=r-n,t[5]=t[7]=i-o;return}let C=0,x=A*4+(n?2:0)+2,M=x,D=T;{const k=n+h,U=o,G=r+k,X=r-k,J=i+U;if(t[C++]=G,t[C++]=J,t[--x]=J,t[--x]=X,o){const Z=i-U;t[M++]=X,t[M++]=Z,t[--D]=Z,t[--D]=G}}for(let k=1;k<A;k++){const U=Math.PI/2*(k/A),G=n+Math.cos(U)*h,X=o+Math.sin(U)*f,J=r+G,Z=r-G,it=i+X,Q=i-X;t[C++]=J,t[C++]=it,t[--x]=it,t[--x]=Z,t[M++]=Z,t[M++]=Q,t[--D]=Q,t[--D]=J}{const k=n,U=o+f,G=r+k,X=r-k,J=i+U,Z=i-U;t[C++]=G,t[C++]=J,t[--D]=Z,t[--D]=G,n&&(t[C++]=X,t[C++]=J,t[--D]=Z,t[--D]=X)}},triangulate(s,t){const r=s.points,i=t.points,n=t.indices;if(r.length===0)return;let o=i.length/2;const h=o;let f,A;if(s.type!==Dr.RREC){const C=s.shape;f=C.x,A=C.y}else{const C=s.shape;f=C.x+C.width/2,A=C.y+C.height/2}const T=s.matrix;i.push(s.matrix?T.a*f+T.c*A+T.tx:f,s.matrix?T.b*f+T.d*A+T.ty:A),o++,i.push(r[0],r[1]);for(let C=2;C<r.length;C+=2)i.push(r[C],r[C+1]),n.push(o++,h,o);n.push(h+1,h,o)}};function Yf(s,t=!1){const r=s.length;if(r<6)return;let i=0;for(let n=0,o=s[r-2],h=s[r-1];n<r;n+=2){const f=s[n],A=s[n+1];i+=(f-o)*(A+h),o=f,h=A}if(!t&&i>0||t&&i<=0){const n=r/2;for(let o=n+n%2;o<r;o+=2){const h=r-o-2,f=r-o-1,A=o,T=o+1;[s[h],s[A]]=[s[A],s[h]],[s[f],s[T]]=[s[T],s[f]]}}}const Wl={build(s){s.points=s.shape.points.slice()},triangulate(s,t){let r=s.points;const i=s.holes,n=t.points,o=t.indices;if(r.length>=6){Yf(r,!1);const h=[];for(let T=0;T<i.length;T++){const C=i[T];Yf(C.points,!0),h.push(r.length/2),r=r.concat(C.points)}const f=Zu(r,h,2);if(!f)return;const A=n.length/2;for(let T=0;T<f.length;T+=3)o.push(f[T]+A),o.push(f[T+1]+A),o.push(f[T+2]+A);for(let T=0;T<r.length;T++)n.push(r[T])}}},jf={build(s){const t=s.shape,r=t.x,i=t.y,n=t.width,o=t.height,h=s.points;h.length=0,n>=0&&o>=0&&h.push(r,i,r+n,i,r+n,i+o,r,i+o)},triangulate(s,t){const r=s.points,i=t.points;if(r.length===0)return;const n=i.length/2;i.push(r[0],r[1],r[2],r[3],r[6],r[7],r[4],r[5]),t.indices.push(n,n+1,n+2,n+1,n+2,n+3)}},qf={build(s){to.build(s)},triangulate(s,t){to.triangulate(s,t)}};var ni=(s=>(s.MITER="miter",s.BEVEL="bevel",s.ROUND="round",s))(ni||{}),fs=(s=>(s.BUTT="butt",s.ROUND="round",s.SQUARE="square",s))(fs||{});const Ss={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,t=20){if(!this.adaptive||!s||isNaN(s))return t;let r=Math.ceil(s/this.maxLength);return r<this.minSegments?r=this.minSegments:r>this.maxSegments&&(r=this.maxSegments),r}},Og=Ss;class Hl{static curveTo(t,r,i,n,o,h){const f=h[h.length-2],A=h[h.length-1]-r,T=f-t,C=n-r,x=i-t,M=Math.abs(A*x-T*C);if(M<1e-8||o===0)return(h[h.length-2]!==t||h[h.length-1]!==r)&&h.push(t,r),null;const D=A*A+T*T,k=C*C+x*x,U=A*C+T*x,G=o*Math.sqrt(D)/M,X=o*Math.sqrt(k)/M,J=G*U/D,Z=X*U/k,it=G*x+X*T,Q=G*C+X*A,_t=T*(X+J),et=A*(X+J),ft=x*(G+Z),wt=C*(G+Z),Rt=Math.atan2(et-Q,_t-it),It=Math.atan2(wt-Q,ft-it);return{cx:it+t,cy:Q+r,radius:o,startAngle:Rt,endAngle:It,anticlockwise:T*C>x*A}}static arc(t,r,i,n,o,h,f,A,T){const C=f-h,x=Ss._segmentsCount(Math.abs(C)*o,Math.ceil(Math.abs(C)/Fn)*40),M=C/(x*2),D=M*2,k=Math.cos(M),U=Math.sin(M),G=x-1,X=G%1/G;for(let J=0;J<=G;++J){const Z=J+X*J,it=M+h+D*Z,Q=Math.cos(it),_t=-Math.sin(it);T.push((k*Q+U*_t)*o+i,(k*-_t+U*Q)*o+n)}}}class Zf{constructor(){this.reset()}begin(t,r,i){this.reset(),this.style=t,this.start=r,this.attribStart=i}end(t,r){this.attribSize=r-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class ga{static curveLength(t,r,i,n,o,h,f,A){let T=0,C=0,x=0,M=0,D=0,k=0,U=0,G=0,X=0,J=0,Z=0,it=t,Q=r;for(let _t=1;_t<=10;++_t)C=_t/10,x=C*C,M=x*C,D=1-C,k=D*D,U=k*D,G=U*t+3*k*C*i+3*D*x*o+M*f,X=U*r+3*k*C*n+3*D*x*h+M*A,J=it-G,Z=Q-X,it=G,Q=X,T+=Math.sqrt(J*J+Z*Z);return T}static curveTo(t,r,i,n,o,h,f){const A=f[f.length-2],T=f[f.length-1];f.length-=2;const C=Ss._segmentsCount(ga.curveLength(A,T,t,r,i,n,o,h));let x=0,M=0,D=0,k=0,U=0;f.push(A,T);for(let G=1,X=0;G<=C;++G)X=G/C,x=1-X,M=x*x,D=M*x,k=X*X,U=k*X,f.push(D*A+3*M*X*t+3*x*k*i+U*o,D*T+3*M*X*r+3*x*k*n+U*h)}}function Qf(s,t,r,i,n,o,h,f){const A=s-r*n,T=t-i*n,C=s+r*o,x=t+i*o;let M,D;h?(M=i,D=-r):(M=-i,D=r);const k=A+M,U=T+D,G=C+M,X=x+D;return f.push(k,U,G,X),2}function Hs(s,t,r,i,n,o,h,f){const A=r-s,T=i-t;let C=Math.atan2(A,T),x=Math.atan2(n-s,o-t);f&&C<x?C+=Math.PI*2:!f&&C>x&&(x+=Math.PI*2);let M=C;const D=x-C,k=Math.abs(D),U=Math.sqrt(A*A+T*T),G=(15*k*Math.sqrt(U)/Math.PI>>0)+1,X=D/G;if(M+=X,f){h.push(s,t,r,i);for(let J=1,Z=M;J<G;J++,Z+=X)h.push(s,t,s+Math.sin(Z)*U,t+Math.cos(Z)*U);h.push(s,t,n,o)}else{h.push(r,i,s,t);for(let J=1,Z=M;J<G;J++,Z+=X)h.push(s+Math.sin(Z)*U,t+Math.cos(Z)*U,s,t);h.push(n,o,s,t)}return G*2}function Ng(s,t){const r=s.shape;let i=s.points||r.points.slice();const n=t.closePointEps;if(i.length===0)return;const o=s.lineStyle,h=new Ze(i[0],i[1]),f=new Ze(i[i.length-2],i[i.length-1]),A=r.type!==Dr.POLY||r.closeStroke,T=Math.abs(h.x-f.x)<n&&Math.abs(h.y-f.y)<n;if(A){i=i.slice(),T&&(i.pop(),i.pop(),f.set(i[i.length-2],i[i.length-1]));const nt=(h.x+f.x)*.5,Y=(f.y+h.y)*.5;i.unshift(nt,Y),i.push(nt,Y)}const C=t.points,x=i.length/2;let M=i.length;const D=C.length/2,k=o.width/2,U=k*k,G=o.miterLimit*o.miterLimit;let X=i[0],J=i[1],Z=i[2],it=i[3],Q=0,_t=0,et=-(J-it),ft=X-Z,wt=0,Rt=0,It=Math.sqrt(et*et+ft*ft);et/=It,ft/=It,et*=k,ft*=k;const pt=o.alignment,xt=(1-pt)*2,Ct=pt*2;A||(o.cap===fs.ROUND?M+=Hs(X-et*(xt-Ct)*.5,J-ft*(xt-Ct)*.5,X-et*xt,J-ft*xt,X+et*Ct,J+ft*Ct,C,!0)+2:o.cap===fs.SQUARE&&(M+=Qf(X,J,et,ft,xt,Ct,!0,C))),C.push(X-et*xt,J-ft*xt,X+et*Ct,J+ft*Ct);for(let nt=1;nt<x-1;++nt){X=i[(nt-1)*2],J=i[(nt-1)*2+1],Z=i[nt*2],it=i[nt*2+1],Q=i[(nt+1)*2],_t=i[(nt+1)*2+1],et=-(J-it),ft=X-Z,It=Math.sqrt(et*et+ft*ft),et/=It,ft/=It,et*=k,ft*=k,wt=-(it-_t),Rt=Z-Q,It=Math.sqrt(wt*wt+Rt*Rt),wt/=It,Rt/=It,wt*=k,Rt*=k;const Y=Z-X,gt=J-it,ot=Z-Q,ht=_t-it,dt=Y*ot+gt*ht,At=gt*ot-ht*Y,Et=At<0;if(Math.abs(At)<.001*Math.abs(dt)){C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),dt>=0&&(o.join===ni.ROUND?M+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Rt*xt,C,!1)+4:M+=2,C.push(Z-wt*Ct,it-Rt*Ct,Z+wt*xt,it+Rt*xt));continue}const Dt=(-et+X)*(-ft+it)-(-et+Z)*(-ft+J),oe=(-wt+Q)*(-Rt+it)-(-wt+Z)*(-Rt+_t),kt=(Y*oe-ot*Dt)/At,se=(ht*Dt-gt*oe)/At,Kt=(kt-Z)*(kt-Z)+(se-it)*(se-it),Xt=Z+(kt-Z)*xt,_e=it+(se-it)*xt,$e=Z-(kt-Z)*Ct,Jt=it-(se-it)*Ct,De=Math.min(Y*Y+gt*gt,ot*ot+ht*ht),xe=Et?xt:Ct,ae=De+xe*xe*U,Lr=Kt<=ae;let vr=o.join;if(vr===ni.MITER&&Kt/U>G&&(vr=ni.BEVEL),Lr)switch(vr){case ni.MITER:{C.push(Xt,_e,$e,Jt);break}case ni.BEVEL:{Et?C.push(Xt,_e,Z+et*Ct,it+ft*Ct,Xt,_e,Z+wt*Ct,it+Rt*Ct):C.push(Z-et*xt,it-ft*xt,$e,Jt,Z-wt*xt,it-Rt*xt,$e,Jt),M+=2;break}case ni.ROUND:{Et?(C.push(Xt,_e,Z+et*Ct,it+ft*Ct),M+=Hs(Z,it,Z+et*Ct,it+ft*Ct,Z+wt*Ct,it+Rt*Ct,C,!0)+4,C.push(Xt,_e,Z+wt*Ct,it+Rt*Ct)):(C.push(Z-et*xt,it-ft*xt,$e,Jt),M+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Rt*xt,C,!1)+4,C.push(Z-wt*xt,it-Rt*xt,$e,Jt));break}}else{switch(C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),vr){case ni.MITER:{Et?C.push($e,Jt,$e,Jt):C.push(Xt,_e,Xt,_e),M+=2;break}case ni.ROUND:{Et?M+=Hs(Z,it,Z+et*Ct,it+ft*Ct,Z+wt*Ct,it+Rt*Ct,C,!0)+2:M+=Hs(Z,it,Z-et*xt,it-ft*xt,Z-wt*xt,it-Rt*xt,C,!1)+2;break}}C.push(Z-wt*xt,it-Rt*xt,Z+wt*Ct,it+Rt*Ct),M+=2}}X=i[(x-2)*2],J=i[(x-2)*2+1],Z=i[(x-1)*2],it=i[(x-1)*2+1],et=-(J-it),ft=X-Z,It=Math.sqrt(et*et+ft*ft),et/=It,ft/=It,et*=k,ft*=k,C.push(Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct),A||(o.cap===fs.ROUND?M+=Hs(Z-et*(xt-Ct)*.5,it-ft*(xt-Ct)*.5,Z-et*xt,it-ft*xt,Z+et*Ct,it+ft*Ct,C,!1)+2:o.cap===fs.SQUARE&&(M+=Qf(Z,it,et,ft,xt,Ct,!1,C)));const Gt=t.indices,st=Ss.epsilon*Ss.epsilon;for(let nt=D;nt<M+D-2;++nt)X=C[nt*2],J=C[nt*2+1],Z=C[(nt+1)*2],it=C[(nt+1)*2+1],Q=C[(nt+2)*2],_t=C[(nt+2)*2+1],!(Math.abs(X*(it-_t)+Z*(_t-J)+Q*(J-it))<st)&&Gt.push(nt,nt+1,nt+2)}function Ug(s,t){let r=0;const i=s.shape,n=s.points||i.points,o=i.type!==Dr.POLY||i.closeStroke;if(n.length===0)return;const h=t.points,f=t.indices,A=n.length/2,T=h.length/2;let C=T;for(h.push(n[0],n[1]),r=1;r<A;r++)h.push(n[r*2],n[r*2+1]),f.push(C,C+1),C++;o&&f.push(C,T)}function Yl(s,t){s.lineStyle.native?Ug(s,t):Ng(s,t)}class ma{static curveLength(t,r,i,n,o,h){const f=t-2*i+o,A=r-2*n+h,T=2*i-2*t,C=2*n-2*r,x=4*(f*f+A*A),M=4*(f*T+A*C),D=T*T+C*C,k=2*Math.sqrt(x+M+D),U=Math.sqrt(x),G=2*x*U,X=2*Math.sqrt(D),J=M/U;return(G*k+U*M*(k-X)+(4*D*x-M*M)*Math.log((2*U+J+k)/(J+X)))/(4*G)}static curveTo(t,r,i,n,o){const h=o[o.length-2],f=o[o.length-1],A=Ss._segmentsCount(ma.curveLength(h,f,t,r,i,n));let T=0,C=0;for(let x=1;x<=A;++x){const M=x/A;T=h+(t-h)*M,C=f+(r-f)*M,o.push(T+(t+(i-t)*M-T)*M,C+(r+(n-r)*M-C)*M)}}}const ya={[Dr.POLY]:Wl,[Dr.CIRC]:to,[Dr.ELIP]:to,[Dr.RECT]:jf,[Dr.RREC]:qf},jl=[],eo=[];class ro{constructor(t,r=null,i=null,n=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=r,this.matrix=n,this.type=t.type}clone(){return new ro(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const un=new Ze,Kf=class _2 extends Kh{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Yn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),eo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const r=this.batches[t];r.reset(),jl.push(r)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,r=null,i=null,n=null){const o=new ro(t,r,i,n);return this.graphicsData.push(o),this.dirty++,this}drawHole(t,r=null){if(!this.graphicsData.length)return null;const i=new ro(t,null,null,r),n=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=n.lineStyle,n.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const r=this.graphicsData;for(let i=0;i<r.length;++i){const n=r[i];if(n.fillStyle.visible&&n.shape&&(n.matrix?n.matrix.applyInverse(t,un):un.copyFrom(t),n.shape.contains(un.x,un.y))){let o=!1;if(n.holes){for(let h=0;h<n.holes.length;h++)if(n.holes[h].shape.contains(un.x,un.y)){o=!0;break}}if(!o)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,r=this.graphicsData;let i=null,n=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],n=i.style);for(let A=this.shapeIndex;A<r.length;A++){this.shapeIndex++;const T=r[A],C=T.fillStyle,x=T.lineStyle;ya[T.type].build(T),T.matrix&&this.transformPoints(T.points,T.matrix),(C.visible||x.visible)&&this.processHoles(T.holes);for(let M=0;M<2;M++){const D=M===0?C:x;if(!D.visible)continue;const k=D.texture.baseTexture,U=this.indices.length,G=this.points.length/2;k.wrapMode=Vi.REPEAT,M===0?this.processFill(T):this.processLine(T);const X=this.points.length/2-G;X!==0&&(i&&!this._compareStyles(n,D)&&(i.end(U,G),i=null),i||(i=jl.pop()||new Zf,i.begin(D,U,G),this.batches.push(i),n=D),this.addUvs(this.points,t,D.texture,G,X,D.matrix))}}const o=this.indices.length,h=this.points.length/2;if(i&&i.end(o,h),this.batches.length===0){this.batchable=!0;return}const f=h>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&f===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=f?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,r){return!(!t||!r||t.texture.baseTexture!==r.texture.baseTexture||t.color+t.alpha!==r.color+r.alpha||!!t.native!=!!r.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,r=this.graphicsData.length;t<r;t++){const i=this.graphicsData[t],n=i.fillStyle,o=i.lineStyle;if(n&&!n.texture.baseTexture.valid||o&&!o.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let r=0,i=t.length;r<i;r++){const n=t[r];for(let o=0;o<n.size;o++){const h=n.start+o;this.indicesUint16[h]=this.indicesUint16[h]-n.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let r=0;r<t.length;r++)if(t[r].style.native)return!1;return this.points.length<_2.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++Ge._globalBatch;for(let x=0;x<this.drawCalls.length;x++)this.drawCalls[x].texArray.clear(),eo.push(this.drawCalls[x]);this.drawCalls.length=0;const r=this.colors,i=this.textureIds;let n=eo.pop();n||(n=new Xo,n.texArray=new Zo),n.texArray.count=0,n.start=0,n.size=0,n.type=Ai.TRIANGLES;let o=0,h=null,f=0,A=!1,T=Ai.TRIANGLES,C=0;this.drawCalls.push(n);for(let x=0;x<this.batches.length;x++){const M=this.batches[x],D=8,k=M.style,U=k.texture.baseTexture;A!==!!k.native&&(A=!!k.native,T=A?Ai.LINES:Ai.TRIANGLES,h=null,o=D,t++),h!==U&&(h=U,U._batchEnabled!==t&&(o===D&&(t++,o=0,n.size>0&&(n=eo.pop(),n||(n=new Xo,n.texArray=new Zo),this.drawCalls.push(n)),n.start=C,n.size=0,n.texArray.count=0,n.type=T),U.touched=1,U._batchEnabled=t,U._batchLocation=o,U.wrapMode=Vi.REPEAT,n.texArray.elements[n.texArray.count++]=U,o++)),n.size+=M.size,C+=M.size,f=U._batchLocation,this.addColors(r,k.color,k.alpha,M.attribSize,M.attribStart),this.addTextureIds(i,f,M.attribSize,M.attribStart)}Ge._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,r=this.uvs,i=this.colors,n=this.textureIds,o=new ArrayBuffer(t.length*3*4),h=new Float32Array(o),f=new Uint32Array(o);let A=0;for(let T=0;T<t.length/2;T++)h[A++]=t[T*2],h[A++]=t[T*2+1],h[A++]=r[T*2],h[A++]=r[T*2+1],f[A++]=i[T],h[A++]=n[T];this._buffer.update(o),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Wl.triangulate(t,this):ya[t.type].triangulate(t,this)}processLine(t){Yl(t,this);for(let r=0;r<t.holes.length;r++)Yl(t.holes[r],this)}processHoles(t){for(let r=0;r<t.length;r++){const i=t[r];ya[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,r){for(let i=0;i<t.length/2;i++){const n=t[i*2],o=t[i*2+1];t[i*2]=r.a*n+r.c*o+r.tx,t[i*2+1]=r.b*n+r.d*o+r.ty}}addColors(t,r,i,n,o=0){const h=rr.shared.setValue(r).toLittleEndianNumber(),f=rr.shared.setValue(h).toPremultiplied(i);t.length=Math.max(t.length,o+n);for(let A=0;A<n;A++)t[o+A]=f}addTextureIds(t,r,i,n=0){t.length=Math.max(t.length,n+i);for(let o=0;o<i;o++)t[n+o]=r}addUvs(t,r,i,n,o,h=null){let f=0;const A=r.length,T=i.frame;for(;f<o;){let x=t[(n+f)*2],M=t[(n+f)*2+1];if(h){const D=h.a*x+h.c*M+h.tx;M=h.b*x+h.d*M+h.ty,x=D}f++,r.push(x/T.width,M/T.height)}const C=i.baseTexture;(T.width<C.width||T.height<C.height)&&this.adjustUvs(r,i,A,o)}adjustUvs(t,r,i,n){const o=r.baseTexture,h=1e-6,f=i+n*2,A=r.frame,T=A.width/o.width,C=A.height/o.height;let x=A.x/A.width,M=A.y/A.height,D=Math.floor(t[i]+h),k=Math.floor(t[i+1]+h);for(let U=i+2;U<f;U+=2)D=Math.min(D,Math.floor(t[U]+h)),k=Math.min(k,Math.floor(t[U+1]+h));x-=D,M-=k;for(let U=i;U<f;U+=2)t[U]=(t[U]+x)*T,t[U+1]=(t[U+1]+M)*C}};Kf.BATCHABLE_SIZE=100;let Jf=Kf;class io{constructor(){this.color=16777215,this.alpha=1,this.texture=ne.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new io;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=ne.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class va extends io{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=fs.BUTT,this.join=ni.MITER,this.miterLimit=10}clone(){const t=new va;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=fs.BUTT,this.join=ni.MITER,this.miterLimit=10}}const ql={},Zl=class za extends Zr{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new io,this._lineStyle=new va,this._matrix=null,this._holeMode=!1,this.state=Pi.for2d(),this._geometry=t||new Jf,this._geometry.refCount++,this._transformID=-1,this._tintColor=new rr(16777215),this.blendMode=Re.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new za(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,r=0,i,n=.5,o=!1){return typeof t=="number"&&(t={width:t,color:r,alpha:i,alignment:n,native:o}),this.lineTextureStyle(t)}lineTextureStyle(t){const r={width:0,texture:ne.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:fs.BUTT,join:ni.MITER,miterLimit:10};t=Object.assign(r,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,r=this.currentPath.points.length;r>2&&(this.drawShape(this.currentPath),this.currentPath=new xs,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[r-2],t[r-1]))}else this.currentPath=new xs,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,r){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=r,this}lineTo(t,r){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,n=i[i.length-2],o=i[i.length-1];return(n!==t||o!==r)&&i.push(t,r),this}_initCurve(t=0,r=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,r]):this.moveTo(t,r)}quadraticCurveTo(t,r,i,n){this._initCurve();const o=this.currentPath.points;return o.length===0&&this.moveTo(0,0),ma.curveTo(t,r,i,n,o),this}bezierCurveTo(t,r,i,n,o,h){return this._initCurve(),ga.curveTo(t,r,i,n,o,h,this.currentPath.points),this}arcTo(t,r,i,n,o){this._initCurve(t,r);const h=this.currentPath.points,f=Hl.curveTo(t,r,i,n,o,h);if(f){const{cx:A,cy:T,radius:C,startAngle:x,endAngle:M,anticlockwise:D}=f;this.arc(A,T,C,x,M,D)}return this}arc(t,r,i,n,o,h=!1){if(n===o)return this;if(!h&&o<=n?o+=Fn:h&&n<=o&&(n+=Fn),o-n===0)return this;const f=t+Math.cos(n)*i,A=r+Math.sin(n)*i,T=this._geometry.closePointEps;let C=this.currentPath?this.currentPath.points:null;if(C){const x=Math.abs(C[C.length-2]-f),M=Math.abs(C[C.length-1]-A);x<T&&M<T||C.push(f,A)}else this.moveTo(f,A),C=this.currentPath.points;return Hl.arc(f,A,t,r,i,n,o,h,C),this}beginFill(t=0,r){return this.beginTextureFill({texture:ne.WHITE,color:t,alpha:r})}normalizeColor(t){const r=rr.shared.setValue(t.color??0);t.color=r.toNumber(),t.alpha??(t.alpha=r.alpha)}beginTextureFill(t){const r={texture:ne.WHITE,color:16777215,matrix:null};t=Object.assign(r,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,r,i,n){return this.drawShape(new Ve(t,r,i,n))}drawRoundedRect(t,r,i,n,o){return this.drawShape(new kn(t,r,i,n,o))}drawCircle(t,r,i){return this.drawShape(new Ln(t,r,i))}drawEllipse(t,r,i,n){return this.drawShape(new Bn(t,r,i,n))}drawPolygon(...t){let r,i=!0;const n=t[0];n.points?(i=n.closeStroke,r=n.points):Array.isArray(t[0])?r=t[0]:r=t;const o=new xs(r);return o.closeStroke=i,this.drawShape(o),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Dr.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const r=this._geometry;r.updateBatches(),r.batchable?(this.batchDirty!==r.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,r=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let n=0;n<i;n++){const o=t.batches[n],h=o.style.color,f=new Float32Array(this.vertexData.buffer,o.attribStart*4*2,o.attribSize*2),A=new Float32Array(t.uvsFloat32.buffer,o.attribStart*4*2,o.attribSize*2),T=new Uint16Array(t.indicesUint16.buffer,o.start*2,o.size),C={vertexData:f,blendMode:r,indices:T,uvs:A,_batchRGB:rr.shared.setValue(h).toRgbArray(),_tintRGB:h,_texture:o.style.texture,alpha:o.style.alpha,worldAlpha:1};this.batches[n]=C}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let r=0,i=this.batches.length;r<i;r++){const n=this.batches[r];n.worldAlpha=this.worldAlpha*n.alpha,t.plugins[this.pluginName].render(n)}}}_renderDirect(t){const r=this._resolveDirectShader(t),i=this._geometry,n=this.worldAlpha,o=r.uniforms,h=i.drawCalls;o.translationMatrix=this.transform.worldTransform,rr.shared.setValue(this._tintColor).premultiply(n).toArray(o.tint),t.shader.bind(r),t.geometry.bind(i,r),t.state.set(this.state);for(let f=0,A=h.length;f<A;f++)this._renderDrawCallDirect(t,i.drawCalls[f])}_renderDrawCallDirect(t,r){const{texArray:i,type:n,size:o,start:h}=r,f=i.count;for(let A=0;A<f;A++)t.texture.bind(i.elements[A],A);t.geometry.draw(n,o,h)}_resolveDirectShader(t){let r=this.shader;const i=this.pluginName;if(!r){if(!ql[i]){const{maxTextures:n}=t.plugins[i],o=new Int32Array(n);for(let A=0;A<n;A++)o[A]=A;const h={tint:new Float32Array([1,1,1,1]),translationMatrix:new nr,default:fi.from({uSamplers:o},!0)},f=t.plugins[i]._shader.program;ql[i]=new Mi(f,h)}r=ql[i]}return r}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:r,minY:i,maxX:n,maxY:o}=t.bounds;this._bounds.addFrame(this.transform,r,i,n,o)}containsPoint(t){return this.worldTransform.applyInverse(t,za._TEMP_POINT),this._geometry.containsPoint(za._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const r=this.batches[t];r._tintRGB=rr.shared.setValue(this._tintColor).multiply(r._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const r=this.transform.worldTransform,i=r.a,n=r.b,o=r.c,h=r.d,f=r.tx,A=r.ty,T=this._geometry.points,C=this.vertexData;let x=0;for(let M=0;M<T.length;M+=2){const D=T[M],k=T[M+1];C[x++]=i*D+o*k+f,C[x++]=h*k+n*D+A}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Zl.curves=Ss,Zl._TEMP_POINT=new Ze;let Ql=Zl;const Gg={buildPoly:Wl,buildCircle:to,buildRectangle:jf,buildRoundedRectangle:qf,buildLine:Yl,ArcUtils:Hl,BezierUtils:ga,QuadraticUtils:ma,BatchPart:Zf,FILL_COMMANDS:ya,BATCH_POOL:jl,DRAW_CALL_POOL:eo};class td{constructor(t,r){this.uvBuffer=t,this.uvMatrix=r,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const r=this.uvBuffer.data;(!this.data||this.data.length!==r.length)&&(this.data=new Float32Array(r.length)),this.uvMatrix.multiplyUvs(r,this.data),this._updateID++}}const Kl=new Ze,ed=new xs,rd=class g2 extends Zr{constructor(t,r,i,n=Ai.TRIANGLES){super(),this.geometry=t,this.shader=r,this.state=i||Pi.for2d(),this.drawMode=n,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=ue.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const r=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Ai.TRIANGLES&&r.length<g2.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const r=this.shader;r.alpha=this.worldAlpha,r.update&&r.update(),t.batch.flush(),r.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(r),t.state.set(this.state),t.geometry.bind(this.geometry,r),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const r=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=r.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const n=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[n]),t.plugins[n].render(this)}calculateVertices(){const t=this.geometry.buffers[0],r=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==r.length&&(this.vertexData=new Float32Array(r.length));const n=this.transform.worldTransform,o=n.a,h=n.b,f=n.c,A=n.d,T=n.tx,C=n.ty,x=this.vertexData;for(let M=0;M<x.length/2;M++){const D=r[M*2],k=r[M*2+1];x[M*2]=o*D+f*k+T,x[M*2+1]=h*D+A*k+C}if(this._roundPixels){const M=ue.RESOLUTION;for(let D=0;D<x.length;++D)x[D]=Math.round(x[D]*M)/M}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],r=this.shader;r.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new td(t,r.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Kl);const r=this.geometry.getBuffer("aVertexPosition").data,i=ed.points,n=this.geometry.getIndex().data,o=n.length,h=this.drawMode===4?3:1;for(let f=0;f+2<o;f+=h){const A=n[f]*2,T=n[f+1]*2,C=n[f+2]*2;if(i[0]=r[A],i[1]=r[A+1],i[2]=r[T],i[3]=r[T+1],i[4]=r[C],i[5]=r[C+1],ed.contains(Kl.x,Kl.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};rd.BATCHABLE_SIZE=100;let cn=rd;class so extends hs{constructor(t,r,i){super();const n=new br(t),o=new br(r,!0),h=new br(i,!0,!0);this.addAttribute("aVertexPosition",n,2,!1,Pe.FLOAT).addAttribute("aTextureCoord",o,2,!1,Pe.FLOAT).addIndex(h),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Vg=`varying vec2 vTextureCoord;
954
954
  uniform vec4 uColor;
955
955
 
956
956
  uniform sampler2D uSampler;
@@ -974,7 +974,7 @@ void main(void)
974
974
 
975
975
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
976
976
  }
977
- `;class fn extends Mi{constructor(t,r){const i={uSampler:t,alpha:1,uTextureMatrix:nr.IDENTITY,uColor:new Float32Array([1,1,1,1])};r=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},r),r.uniforms&&Object.assign(i,r.uniforms),super(r.program||Wi.from(zg,Vg),i),this._colorDirty=!1,this.uvMatrix=new ea(t),this.batchable=r.program===void 0,this.pluginName=r.pluginName,this._tintColor=new rr(r.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=r.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;rr.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class nd extends so{constructor(t=100,r=100,i=10,n=10){super(),this.segWidth=i,this.segHeight=n,this.width=t,this.height=r,this.build()}build(){const t=this.segWidth*this.segHeight,r=[],i=[],n=[],o=this.segWidth-1,h=this.segHeight-1,f=this.width/o,A=this.height/h;for(let C=0;C<t;C++){const x=C%this.segWidth,M=C/this.segWidth|0;r.push(x*f,M*A),i.push(x/o,M/h)}const T=o*h;for(let C=0;C<T;C++){const x=C%o,M=C/o|0,D=M*this.segWidth+x,k=M*this.segWidth+x+1,U=(M+1)*this.segWidth+x,G=(M+1)*this.segWidth+x+1;n.push(D,k,U,k,G,U)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class od extends so{constructor(t=200,r,i=0){super(new Float32Array(r.length*4),new Float32Array(r.length*4),new Uint16Array((r.length-1)*6)),this.points=r,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const r=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),n=this.getIndex();if(t.length<1)return;r.data.length/4!==t.length&&(r.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),n.data=new Uint16Array((t.length-1)*6));const o=i.data,h=n.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;let f=0,A=t[0];const T=this._width*this.textureScale,C=t.length;for(let M=0;M<C;M++){const D=M*4;if(this.textureScale>0){const k=A.x-t[M].x,U=A.y-t[M].y,G=Math.sqrt(k*k+U*U);A=t[M],f+=G/T}else f=M/(C-1);o[D]=f,o[D+1]=0,o[D+2]=f,o[D+3]=1}let x=0;for(let M=0;M<C-1;M++){const D=M*2;h[x++]=D,h[x++]=D+1,h[x++]=D+2,h[x++]=D+2,h[x++]=D+1,h[x++]=D+3}i.update(),n.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let r=t[0],i,n=0,o=0;const h=this.buffers[0].data,f=t.length,A=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let T=0;T<f;T++){const C=t[T],x=T*4;T<t.length-1?i=t[T+1]:i=C,o=-(i.x-r.x),n=i.y-r.y;const M=Math.sqrt(n*n+o*o);M<1e-6?(n=0,o=0):(n/=M,o/=M,n*=A,o*=A),h[x]=C.x+n,h[x+1]=C.y+o,h[x+2]=C.x-n,h[x+3]=C.y-o,r=C}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class ad extends cn{constructor(t,r,i){const n=new nd(t.width,t.height,r,i),o=new fn(ne.WHITE);super(n,o),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:r,height:i}=this.shader.texture;this.autoResize&&(t.width!==r||t.height!==i)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}const ba=10;class Xg extends ad{constructor(t,r,i,n,o){var h,f,A,T;super(ne.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=r??((h=t.defaultBorders)==null?void 0:h.left)??ba,this._rightWidth=n??((f=t.defaultBorders)==null?void 0:f.right)??ba,this._topHeight=i??((A=t.defaultBorders)==null?void 0:A.top)??ba,this._bottomHeight=o??((T=t.defaultBorders)==null?void 0:T.bottom)??ba,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,r=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*r,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*r,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,r=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*r,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*r,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,r=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,n=this._height>i?1:this._height/i;return Math.min(r,n)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,r=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const i=1/this._origWidth,n=1/this._origHeight;r[0]=r[8]=r[16]=r[24]=0,r[1]=r[3]=r[5]=r[7]=0,r[6]=r[14]=r[22]=r[30]=1,r[25]=r[27]=r[29]=r[31]=1,r[2]=r[10]=r[18]=r[26]=i*this._leftWidth,r[4]=r[12]=r[20]=r[28]=1-i*this._rightWidth,r[9]=r[11]=r[13]=r[15]=n*this._topHeight,r[17]=r[19]=r[21]=r[23]=1-n*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class Wg extends cn{constructor(t=ne.EMPTY,r,i,n,o){const h=new so(r,i,n);h.getBuffer("aVertexPosition").static=!1;const f=new fn(t);super(h,f,null,o),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}class Hg extends cn{constructor(t,r,i=0){const n=new od(t.height,r,i),o=new fn(t);i>0&&(t.baseTexture.wrapMode=Vi.REPEAT),super(n,o),this.autoUpdate=!0}_render(t){const r=this.geometry;(this.autoUpdate||r._width!==this.shader.texture.height)&&(r._width=this.shader.texture.height,r.update()),super._render(t)}}class Yg extends Zr{constructor(t=1500,r,i=16384,n=!1){super();const o=16384;i>o&&(i=o),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=Re.NORMAL,this.autoResize=n,this.roundPixels=!0,this.baseTexture=null,this.setProperties(r),this._tintColor=new rr(0),this.tintRgb=new Float32Array(3),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const r=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.length<r;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[r]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class hd{constructor(t,r,i){this.geometry=new hs,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let n=0;n<t.length;++n){let o=t[n];o={attributeName:o.attributeName,size:o.size,uploadFunction:o.uploadFunction,type:o.type||Pe.FLOAT,offset:o.offset},r[n]?this.dynamicProperties.push(o):this.staticProperties.push(o)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let r=0;this.indexBuffer=new br(Y0(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let h=0;h<this.dynamicProperties.length;++h){const f=this.dynamicProperties[h];f.offset=r,r+=f.size,this.dynamicStride+=f.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new br(this.dynamicData,!1,!1);let n=0;this.staticStride=0;for(let h=0;h<this.staticProperties.length;++h){const f=this.staticProperties[h];f.offset=n,n+=f.size,this.staticStride+=f.size}const o=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(o),this.staticDataUint32=new Uint32Array(o),this.staticBuffer=new br(this.staticData,!0,!1);for(let h=0;h<this.dynamicProperties.length;++h){const f=this.dynamicProperties[h];t.addAttribute(f.attributeName,this.dynamicBuffer,0,f.type===Pe.UNSIGNED_BYTE,f.type,this.dynamicStride*4,f.offset*4)}for(let h=0;h<this.staticProperties.length;++h){const f=this.staticProperties[h];t.addAttribute(f.attributeName,this.staticBuffer,0,f.type===Pe.UNSIGNED_BYTE,f.type,this.staticStride*4,f.offset*4)}}uploadDynamic(t,r,i){for(let n=0;n<this.dynamicProperties.length;n++){const o=this.dynamicProperties[n];o.uploadFunction(t,r,i,o.type===Pe.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,o.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,r,i){for(let n=0;n<this.staticProperties.length;n++){const o=this.staticProperties[n];o.uploadFunction(t,r,i,o.type===Pe.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,o.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var jg=`varying vec2 vTextureCoord;
977
+ `;class fn extends Mi{constructor(t,r){const i={uSampler:t,alpha:1,uTextureMatrix:nr.IDENTITY,uColor:new Float32Array([1,1,1,1])};r=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},r),r.uniforms&&Object.assign(i,r.uniforms),super(r.program||Wi.from(zg,Vg),i),this._colorDirty=!1,this.uvMatrix=new ea(t),this.batchable=r.program===void 0,this.pluginName=r.pluginName,this._tintColor=new rr(r.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=r.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;rr.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class sd extends so{constructor(t=100,r=100,i=10,n=10){super(),this.segWidth=i,this.segHeight=n,this.width=t,this.height=r,this.build()}build(){const t=this.segWidth*this.segHeight,r=[],i=[],n=[],o=this.segWidth-1,h=this.segHeight-1,f=this.width/o,A=this.height/h;for(let C=0;C<t;C++){const x=C%this.segWidth,M=C/this.segWidth|0;r.push(x*f,M*A),i.push(x/o,M/h)}const T=o*h;for(let C=0;C<T;C++){const x=C%o,M=C/o|0,D=M*this.segWidth+x,k=M*this.segWidth+x+1,U=(M+1)*this.segWidth+x,G=(M+1)*this.segWidth+x+1;n.push(D,k,U,k,G,U)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class nd extends so{constructor(t=200,r,i=0){super(new Float32Array(r.length*4),new Float32Array(r.length*4),new Uint16Array((r.length-1)*6)),this.points=r,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const r=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),n=this.getIndex();if(t.length<1)return;r.data.length/4!==t.length&&(r.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),n.data=new Uint16Array((t.length-1)*6));const o=i.data,h=n.data;o[0]=0,o[1]=0,o[2]=0,o[3]=1;let f=0,A=t[0];const T=this._width*this.textureScale,C=t.length;for(let M=0;M<C;M++){const D=M*4;if(this.textureScale>0){const k=A.x-t[M].x,U=A.y-t[M].y,G=Math.sqrt(k*k+U*U);A=t[M],f+=G/T}else f=M/(C-1);o[D]=f,o[D+1]=0,o[D+2]=f,o[D+3]=1}let x=0;for(let M=0;M<C-1;M++){const D=M*2;h[x++]=D,h[x++]=D+1,h[x++]=D+2,h[x++]=D+2,h[x++]=D+1,h[x++]=D+3}i.update(),n.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let r=t[0],i,n=0,o=0;const h=this.buffers[0].data,f=t.length,A=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let T=0;T<f;T++){const C=t[T],x=T*4;T<t.length-1?i=t[T+1]:i=C,o=-(i.x-r.x),n=i.y-r.y;const M=Math.sqrt(n*n+o*o);M<1e-6?(n=0,o=0):(n/=M,o/=M,n*=A,o*=A),h[x]=C.x+n,h[x+1]=C.y+o,h[x+2]=C.x-n,h[x+3]=C.y-o,r=C}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class od extends cn{constructor(t,r,i){const n=new sd(t.width,t.height,r,i),o=new fn(ne.WHITE);super(n,o),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:r,height:i}=this.shader.texture;this.autoResize&&(t.width!==r||t.height!==i)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}const xa=10;class Xg extends od{constructor(t,r,i,n,o){var h,f,A,T;super(ne.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=r??((h=t.defaultBorders)==null?void 0:h.left)??xa,this._rightWidth=n??((f=t.defaultBorders)==null?void 0:f.right)??xa,this._topHeight=i??((A=t.defaultBorders)==null?void 0:A.top)??xa,this._bottomHeight=o??((T=t.defaultBorders)==null?void 0:T.bottom)??xa,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,r=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*r,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*r,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,r=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*r,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*r,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,r=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,n=this._height>i?1:this._height/i;return Math.min(r,n)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,r=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const i=1/this._origWidth,n=1/this._origHeight;r[0]=r[8]=r[16]=r[24]=0,r[1]=r[3]=r[5]=r[7]=0,r[6]=r[14]=r[22]=r[30]=1,r[25]=r[27]=r[29]=r[31]=1,r[2]=r[10]=r[18]=r[26]=i*this._leftWidth,r[4]=r[12]=r[20]=r[28]=1-i*this._rightWidth,r[9]=r[11]=r[13]=r[15]=n*this._topHeight,r[17]=r[19]=r[21]=r[23]=1-n*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class Wg extends cn{constructor(t=ne.EMPTY,r,i,n,o){const h=new so(r,i,n);h.getBuffer("aVertexPosition").static=!1;const f=new fn(t);super(h,f,null,o),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}class Hg extends cn{constructor(t,r,i=0){const n=new nd(t.height,r,i),o=new fn(t);i>0&&(t.baseTexture.wrapMode=Vi.REPEAT),super(n,o),this.autoUpdate=!0}_render(t){const r=this.geometry;(this.autoUpdate||r._width!==this.shader.texture.height)&&(r._width=this.shader.texture.height,r.update()),super._render(t)}}class Yg extends Zr{constructor(t=1500,r,i=16384,n=!1){super();const o=16384;i>o&&(i=o),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=Re.NORMAL,this.autoResize=n,this.roundPixels=!0,this.baseTexture=null,this.setProperties(r),this._tintColor=new rr(0),this.tintRgb=new Float32Array(3),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const r=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.length<r;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[r]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class ad{constructor(t,r,i){this.geometry=new hs,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let n=0;n<t.length;++n){let o=t[n];o={attributeName:o.attributeName,size:o.size,uploadFunction:o.uploadFunction,type:o.type||Pe.FLOAT,offset:o.offset},r[n]?this.dynamicProperties.push(o):this.staticProperties.push(o)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let r=0;this.indexBuffer=new br(H0(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let h=0;h<this.dynamicProperties.length;++h){const f=this.dynamicProperties[h];f.offset=r,r+=f.size,this.dynamicStride+=f.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new br(this.dynamicData,!1,!1);let n=0;this.staticStride=0;for(let h=0;h<this.staticProperties.length;++h){const f=this.staticProperties[h];f.offset=n,n+=f.size,this.staticStride+=f.size}const o=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(o),this.staticDataUint32=new Uint32Array(o),this.staticBuffer=new br(this.staticData,!0,!1);for(let h=0;h<this.dynamicProperties.length;++h){const f=this.dynamicProperties[h];t.addAttribute(f.attributeName,this.dynamicBuffer,0,f.type===Pe.UNSIGNED_BYTE,f.type,this.dynamicStride*4,f.offset*4)}for(let h=0;h<this.staticProperties.length;++h){const f=this.staticProperties[h];t.addAttribute(f.attributeName,this.staticBuffer,0,f.type===Pe.UNSIGNED_BYTE,f.type,this.staticStride*4,f.offset*4)}}uploadDynamic(t,r,i){for(let n=0;n<this.dynamicProperties.length;n++){const o=this.dynamicProperties[n];o.uploadFunction(t,r,i,o.type===Pe.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,o.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,r,i){for(let n=0;n<this.staticProperties.length;n++){const o=this.staticProperties[n];o.uploadFunction(t,r,i,o.type===Pe.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,o.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var jg=`varying vec2 vTextureCoord;
978
978
  varying vec4 vColor;
979
979
 
980
980
  uniform sampler2D uSampler;
@@ -1007,8 +1007,8 @@ void main(void){
1007
1007
  vTextureCoord = aTextureCoord;
1008
1008
  vColor = aColor * uColor;
1009
1009
  }
1010
- `;class Jl extends Nn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new nr,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Pe.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Mi.from(qg,jg,{}),this.state=Pi.for2d()}render(t){const r=t.children,i=t._maxSize,n=t._batchSize,o=this.renderer;let h=r.length;if(h===0)return;h>i&&!t.autoResize&&(h=i);let f=t._buffers;f||(f=t._buffers=this.generateBuffers(t));const A=r[0]._texture.baseTexture,T=A.alphaMode>0;this.state.blendMode=Oh(t.blendMode,T),o.state.set(this.state);const C=o.gl,x=t.worldTransform.copyTo(this.tempMatrix);x.prepend(o.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=x.toArray(!0),this.shader.uniforms.uColor=rr.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,T).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=A,this.renderer.shader.bind(this.shader);let M=!1;for(let D=0,k=0;D<h;D+=n,k+=1){let U=h-D;U>n&&(U=n),k>=f.length&&f.push(this._generateOneMoreBuffer(t));const G=f[k];G.uploadDynamic(r,D,U);const X=t._bufferUpdateIDs[k]||0;M=M||G._updateID<X,M&&(G._updateID=t._updateID,G.uploadStatic(r,D,U)),o.geometry.bind(G.geometry),C.drawElements(C.TRIANGLES,U*6,C.UNSIGNED_SHORT,0)}}generateBuffers(t){const r=[],i=t._maxSize,n=t._batchSize,o=t._properties;for(let h=0;h<i;h+=n)r.push(new hd(this.properties,o,n));return r}_generateOneMoreBuffer(t){const r=t._batchSize,i=t._properties;return new hd(this.properties,i,r)}uploadVertices(t,r,i,n,o,h){let f=0,A=0,T=0,C=0;for(let x=0;x<i;++x){const M=t[r+x],D=M._texture,k=M.scale.x,U=M.scale.y,G=D.trim,X=D.orig;G?(A=G.x-M.anchor.x*X.width,f=A+G.width,C=G.y-M.anchor.y*X.height,T=C+G.height):(f=X.width*(1-M.anchor.x),A=X.width*-M.anchor.x,T=X.height*(1-M.anchor.y),C=X.height*-M.anchor.y),n[h]=A*k,n[h+1]=C*U,n[h+o]=f*k,n[h+o+1]=C*U,n[h+o*2]=f*k,n[h+o*2+1]=T*U,n[h+o*3]=A*k,n[h+o*3+1]=T*U,h+=o*4}}uploadPosition(t,r,i,n,o,h){for(let f=0;f<i;f++){const A=t[r+f].position;n[h]=A.x,n[h+1]=A.y,n[h+o]=A.x,n[h+o+1]=A.y,n[h+o*2]=A.x,n[h+o*2+1]=A.y,n[h+o*3]=A.x,n[h+o*3+1]=A.y,h+=o*4}}uploadRotation(t,r,i,n,o,h){for(let f=0;f<i;f++){const A=t[r+f].rotation;n[h]=A,n[h+o]=A,n[h+o*2]=A,n[h+o*3]=A,h+=o*4}}uploadUvs(t,r,i,n,o,h){for(let f=0;f<i;++f){const A=t[r+f]._texture._uvs;A?(n[h]=A.x0,n[h+1]=A.y0,n[h+o]=A.x1,n[h+o+1]=A.y1,n[h+o*2]=A.x2,n[h+o*2+1]=A.y2,n[h+o*3]=A.x3,n[h+o*3+1]=A.y3,h+=o*4):(n[h]=0,n[h+1]=0,n[h+o]=0,n[h+o+1]=0,n[h+o*2]=0,n[h+o*2+1]=0,n[h+o*3]=0,n[h+o*3+1]=0,h+=o*4)}}uploadTint(t,r,i,n,o,h){for(let f=0;f<i;++f){const A=t[r+f],T=rr.shared.setValue(A._tintRGB).toPremultiplied(A.alpha,A.texture.baseTexture.alphaMode>0);n[h]=T,n[h+o]=T,n[h+o*2]=T,n[h+o*3]=T,h+=o*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Jl.extension={name:"particle",type:ee.RendererPlugin},be.add(Jl);var no=(s=>(s[s.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",s[s.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",s))(no||{});const Aa={willReadFrequently:!0},ji=class Se{static get experimentalLetterSpacingSupported(){let t=Se._experimentalLetterSpacingSupported;if(t!==void 0){const r=ue.ADAPTER.getCanvasRenderingContext2D().prototype;t=Se._experimentalLetterSpacingSupported="letterSpacing"in r||"textLetterSpacing"in r}return t}constructor(t,r,i,n,o,h,f,A,T){this.text=t,this.style=r,this.width=i,this.height=n,this.lines=o,this.lineWidths=h,this.lineHeight=f,this.maxLineWidth=A,this.fontProperties=T}static measureText(t,r,i,n=Se._canvas){i=i??r.wordWrap;const o=r.toFontString(),h=Se.measureFont(o);h.fontSize===0&&(h.fontSize=r.fontSize,h.ascent=r.fontSize);const f=n.getContext("2d",Aa);f.font=o;const A=(i?Se.wordWrap(t,r,n):t).split(/(?:\r\n|\r|\n)/),T=new Array(A.length);let C=0;for(let k=0;k<A.length;k++){const U=Se._measureText(A[k],r.letterSpacing,f);T[k]=U,C=Math.max(C,U)}let x=C+r.strokeThickness;r.dropShadow&&(x+=r.dropShadowDistance);const M=r.lineHeight||h.fontSize+r.strokeThickness;let D=Math.max(M,h.fontSize+r.strokeThickness*2)+r.leading+(A.length-1)*(M+r.leading);return r.dropShadow&&(D+=r.dropShadowDistance),new Se(t,r,x,D,A,T,M+r.leading,C,h)}static _measureText(t,r,i){let n=!1;Se.experimentalLetterSpacingSupported&&(Se.experimentalLetterSpacing?(i.letterSpacing=`${r}px`,i.textLetterSpacing=`${r}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let o=i.measureText(t).width;return o>0&&(n?o-=r:o+=(Se.graphemeSegmenter(t).length-1)*r),o}static wordWrap(t,r,i=Se._canvas){const n=i.getContext("2d",Aa);let o=0,h="",f="";const A=Object.create(null),{letterSpacing:T,whiteSpace:C}=r,x=Se.collapseSpaces(C),M=Se.collapseNewlines(C);let D=!x;const k=r.wordWrapWidth+T,U=Se.tokenize(t);for(let G=0;G<U.length;G++){let X=U[G];if(Se.isNewline(X)){if(!M){f+=Se.addLine(h),D=!x,h="",o=0;continue}X=" "}if(x){const Z=Se.isBreakingSpace(X),it=Se.isBreakingSpace(h[h.length-1]);if(Z&&it)continue}const J=Se.getFromCache(X,T,A,n);if(J>k)if(h!==""&&(f+=Se.addLine(h),h="",o=0),Se.canBreakWords(X,r.breakWords)){const Z=Se.wordWrapSplit(X);for(let it=0;it<Z.length;it++){let Q=Z[it],_t=Q,et=1;for(;Z[it+et];){const wt=Z[it+et];if(!Se.canBreakChars(_t,wt,X,it,r.breakWords))Q+=wt;else break;_t=wt,et++}it+=et-1;const ft=Se.getFromCache(Q,T,A,n);ft+o>k&&(f+=Se.addLine(h),D=!1,h="",o=0),h+=Q,o+=ft}}else{h.length>0&&(f+=Se.addLine(h),h="",o=0);const Z=G===U.length-1;f+=Se.addLine(X,!Z),D=!1,h="",o=0}else J+o>k&&(D=!1,f+=Se.addLine(h),h="",o=0),(h.length>0||!Se.isBreakingSpace(X)||D)&&(h+=X,o+=J)}return f+=Se.addLine(h,!1),f}static addLine(t,r=!0){return t=Se.trimRight(t),t=r?`${t}
1011
- `:t,t}static getFromCache(t,r,i,n){let o=i[t];return typeof o!="number"&&(o=Se._measureText(t,r,n)+r,i[t]=o),o}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let r=t.length-1;r>=0;r--){const i=t[r];if(!Se.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:Se._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,r){return typeof t!="string"?!1:Se._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const r=[];let i="";if(typeof t!="string")return r;for(let n=0;n<t.length;n++){const o=t[n],h=t[n+1];if(Se.isBreakingSpace(o,h)||Se.isNewline(o)){i!==""&&(r.push(i),i=""),r.push(o);continue}i+=o}return i!==""&&r.push(i),r}static canBreakWords(t,r){return r}static canBreakChars(t,r,i,n,o){return!0}static wordWrapSplit(t){return Se.graphemeSegmenter(t)}static measureFont(t){if(Se._fonts[t])return Se._fonts[t];const r={ascent:0,descent:0,fontSize:0},i=Se._canvas,n=Se._context;n.font=t;const o=Se.METRICS_STRING+Se.BASELINE_SYMBOL,h=Math.ceil(n.measureText(o).width);let f=Math.ceil(n.measureText(Se.BASELINE_SYMBOL).width);const A=Math.ceil(Se.HEIGHT_MULTIPLIER*f);if(f=f*Se.BASELINE_MULTIPLIER|0,h===0||A===0)return Se._fonts[t]=r,r;i.width=h,i.height=A,n.fillStyle="#f00",n.fillRect(0,0,h,A),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(o,0,f);const T=n.getImageData(0,0,h,A).data,C=T.length,x=h*4;let M=0,D=0,k=!1;for(M=0;M<f;++M){for(let U=0;U<x;U+=4)if(T[D+U]!==255){k=!0;break}if(!k)D+=x;else break}for(r.ascent=f-M,D=C-x,k=!1,M=A;M>f;--M){for(let U=0;U<x;U+=4)if(T[D+U]!==255){k=!0;break}if(!k)D-=x;else break}return r.descent=M-f,r.fontSize=r.ascent+r.descent,Se._fonts[t]=r,r}static clearMetrics(t=""){t?delete Se._fonts[t]:Se._fonts={}}static get _canvas(){var t;if(!Se.__canvas){let r;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Aa))!=null&&t.measureText)return Se.__canvas=i,i;r=ue.ADAPTER.createCanvas()}catch{r=ue.ADAPTER.createCanvas()}r.width=r.height=10,Se.__canvas=r}return Se.__canvas}static get _context(){return Se.__context||(Se.__context=Se._canvas.getContext("2d",Aa)),Se.__context}};ji.METRICS_STRING="|ÉqÅ",ji.BASELINE_SYMBOL="M",ji.BASELINE_MULTIPLIER=1.4,ji.HEIGHT_MULTIPLIER=2,ji.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(r=>r.segment)}return s=>[...s]})(),ji.experimentalLetterSpacing=!1,ji._fonts={},ji._newlines=[10,13],ji._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let ds=ji;const Zg=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],ld=class Do{constructor(t){this.styleID=0,this.reset(),eu(this,t,t)}clone(){const t={};return eu(t,this,Do.defaultStyle),new Do(t)}reset(){eu(this,Do.defaultStyle,Do.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const r=tu(t);this._dropShadowColor!==r&&(this._dropShadowColor=r,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const r=tu(t);this._fill!==r&&(this._fill=r,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Qg(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const r=tu(t);this._stroke!==r&&(this._stroke=r,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let r=this.fontFamily;Array.isArray(this.fontFamily)||(r=this.fontFamily.split(","));for(let i=r.length-1;i>=0;i--){let n=r[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!Zg.includes(n)&&(n=`"${n}"`),r[i]=n}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${r.join(",")}`}};ld.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:no.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let ps=ld;function tu(s){const t=rr.shared,r=i=>{const n=t.setValue(i);return n.alpha===1?n.toHex():n.toRgbaString()};return Array.isArray(s)?s.map(r):r(s)}function Qg(s,t){if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let r=0;r<s.length;++r)if(s[r]!==t[r])return!1;return!0}function eu(s,t,r){for(const i in r)Array.isArray(t[i])?s[i]=t[i].slice():s[i]=t[i]}const Kg={texture:!0,children:!1,baseTexture:!0},ud=class Ru extends us{constructor(t,r,i){let n=!1;i||(i=ue.ADAPTER.createCanvas(),n=!0),i.width=3,i.height=3;const o=ne.from(i);o.orig=new Ve,o.trim=new Ve,super(o),this._ownCanvas=n,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Ru.defaultResolution??ue.RESOLUTION,this._autoResolution=Ru.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=r,this.localStyleID=-1}static get experimentalLetterSpacing(){return ds.experimentalLetterSpacing}static set experimentalLetterSpacing(t){Oe("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),ds.experimentalLetterSpacing=t}updateText(t){const r=this._style;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,n=ds.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),o=n.width,h=n.height,f=n.lines,A=n.lineHeight,T=n.lineWidths,C=n.maxLineWidth,x=n.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,o)+r.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,h)+r.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=r.strokeThickness,i.textBaseline=r.textBaseline,i.lineJoin=r.lineJoin,i.miterLimit=r.miterLimit;let M,D;const k=r.dropShadow?2:1;for(let U=0;U<k;++U){const G=r.dropShadow&&U===0,X=G?Math.ceil(Math.max(1,h)+r.padding*2):0,J=X*this._resolution;if(G){i.fillStyle="black",i.strokeStyle="black";const it=r.dropShadowColor,Q=r.dropShadowBlur*this._resolution,_t=r.dropShadowDistance*this._resolution;i.shadowColor=rr.shared.setValue(it).setAlpha(r.dropShadowAlpha).toRgbaString(),i.shadowBlur=Q,i.shadowOffsetX=Math.cos(r.dropShadowAngle)*_t,i.shadowOffsetY=Math.sin(r.dropShadowAngle)*_t+J}else i.fillStyle=this._generateFillStyle(r,f,n),i.strokeStyle=r.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let Z=(A-x.fontSize)/2;A-x.fontSize<0&&(Z=0);for(let it=0;it<f.length;it++)M=r.strokeThickness/2,D=r.strokeThickness/2+it*A+x.ascent+Z,r.align==="right"?M+=C-T[it]:r.align==="center"&&(M+=(C-T[it])/2),r.stroke&&r.strokeThickness&&this.drawLetterSpacing(f[it],M+r.padding,D+r.padding-X,!0),r.fill&&this.drawLetterSpacing(f[it],M+r.padding,D+r.padding-X)}this.updateTexture()}drawLetterSpacing(t,r,i,n=!1){const o=this._style.letterSpacing;let h=!1;if(ds.experimentalLetterSpacingSupported&&(ds.experimentalLetterSpacing?(this.context.letterSpacing=`${o}px`,this.context.textLetterSpacing=`${o}px`,h=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),o===0||h){n?this.context.strokeText(t,r,i):this.context.fillText(t,r,i);return}let f=r;const A=ds.graphemeSegmenter(t);let T=this.context.measureText(t).width,C=0;for(let x=0;x<A.length;++x){const M=A[x];n?this.context.strokeText(M,f,i):this.context.fillText(M,f,i);let D="";for(let k=x+1;k<A.length;++k)D+=A[k];C=this.context.measureText(D).width,f+=T-C+o,T=C}}updateTexture(){const t=this.canvas;if(this._style.trim){const h=K0(t);h.data&&(t.width=h.width,t.height=h.height,this.context.putImageData(h.data,0,0))}const r=this._texture,i=this._style,n=i.trim?0:i.padding,o=r.baseTexture;r.trim.width=r._frame.width=t.width/this._resolution,r.trim.height=r._frame.height=t.height/this._resolution,r.trim.x=-n,r.trim.y=-n,r.orig.width=r._frame.width-n*2,r.orig.height=r._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(t.width,t.height,this._resolution),r.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,r){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,r)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,r,i){const n=t.fill;if(Array.isArray(n)){if(n.length===1)return n[0]}else return n;let o;const h=t.dropShadow?t.dropShadowDistance:0,f=t.padding||0,A=this.canvas.width/this._resolution-h-f*2,T=this.canvas.height/this._resolution-h-f*2,C=n.slice(),x=t.fillGradientStops.slice();if(!x.length){const M=C.length+1;for(let D=1;D<M;++D)x.push(D/M)}if(C.unshift(n[0]),x.unshift(0),C.push(n[n.length-1]),x.push(1),t.fillGradientType===no.LINEAR_VERTICAL){o=this.context.createLinearGradient(A/2,f,A/2,T+f);const M=i.fontProperties.fontSize+t.strokeThickness;for(let D=0;D<r.length;D++){const k=i.lineHeight*(D-1)+M,U=i.lineHeight*D;let G=U;D>0&&k>U&&(G=(U+k)/2);const X=U+M,J=i.lineHeight*(D+1);let Z=X;D+1<r.length&&J<X&&(Z=(X+J)/2);const it=(Z-G)/T;for(let Q=0;Q<C.length;Q++){let _t=0;typeof x[Q]=="number"?_t=x[Q]:_t=Q/C.length;let et=Math.min(1,Math.max(0,G/T+_t*it));et=Number(et.toFixed(5)),o.addColorStop(et,C[Q])}}}else{o=this.context.createLinearGradient(f,T/2,A+f,T/2);const M=C.length+1;let D=1;for(let k=0;k<C.length;k++){let U;typeof x[k]=="number"?U=x[k]:U=D/M,o.addColorStop(U,C[k]),D++}}return o}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Kg,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const r=as(this.scale.x)||1;this.scale.x=r*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const r=as(this.scale.y)||1;this.scale.y=r*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof ps?this._style=t:this._style=new ps(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};ud.defaultAutoResolution=!0;let ru=ud;class cd{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Jg(s,t){var i;let r=!1;if((i=s==null?void 0:s._textures)!=null&&i.length){for(let n=0;n<s._textures.length;n++)if(s._textures[n]instanceof ne){const o=s._textures[n].baseTexture;t.includes(o)||(t.push(o),r=!0)}}return r}function tm(s,t){if(s.baseTexture instanceof Ge){const r=s.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function em(s,t){if(s._texture&&s._texture instanceof ne){const r=s._texture.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function rm(s,t){return t instanceof ru?(t.updateText(!0),!0):!1}function im(s,t){if(t instanceof ps){const r=t.toFontString();return ds.measureFont(r),!0}return!1}function sm(s,t){if(s instanceof ru){t.includes(s.style)||t.push(s.style),t.includes(s)||t.push(s);const r=s._texture.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function nm(s,t){return s instanceof ps?(t.includes(s)||t.push(s),!0):!1}const fd=class m2{constructor(t){this.limiter=new cd(m2.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(sm),this.registerFindHook(nm),this.registerFindHook(Jg),this.registerFindHook(tm),this.registerFindHook(em),this.registerUploadHook(rm),this.registerUploadHook(im)}upload(t){return new Promise(r=>{t&&this.add(t),this.queue.length?(this.completes.push(r),this.ticking||(this.ticking=!0,$r.system.addOnce(this.tick,this,ls.UTILITY))):r()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let r=!1;if(t&&!t._destroyed){for(let i=0,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),r=!0;break}}r||this.queue.shift()}if(this.queue.length)$r.system.addOnce(this.tick,this,ls.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let r=0,i=t.length;r<i;r++)t[r]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let r=0,i=this.addHooks.length;r<i&&!this.addHooks[r](t,this.queue);r++);if(t instanceof Zr)for(let r=t.children.length-1;r>=0;r--)this.add(t.children[r]);return this}destroy(){this.ticking&&$r.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};fd.uploadsPerFrame=4;let wa=fd;Object.defineProperties(ue,{UPLOADS_PER_FRAME:{get(){return wa.uploadsPerFrame},set(s){Oe("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),wa.uploadsPerFrame=s}}});function dd(s,t){return t instanceof Ge?(t._glTextures[s.CONTEXT_UID]||s.texture.bind(t),!0):!1}function om(s,t){if(!(t instanceof Ql))return!1;const{geometry:r}=t;t.finishPoly(),r.updateBatches();const{batches:i}=r;for(let n=0;n<i.length;n++){const{texture:o}=i[n].style;o&&dd(s,o.baseTexture)}return r.batchable||s.geometry.bind(r,t._resolveDirectShader(s)),!0}function am(s,t){return s instanceof Ql?(t.push(s),!0):!1}class iu extends wa{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(am),this.registerUploadHook(dd),this.registerUploadHook(om)}}iu.extension={name:"prepare",type:ee.RendererSystem},be.add(iu);class hm{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart<this.maxMilliseconds}}class Ta extends us{constructor(t,r=!0){super(t[0]instanceof ne?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=r,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&($r.shared.add(this.update,this,ls.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const r=this.animationSpeed*t,i=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=r/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=r;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i||this.animationSpeed<0&&this.currentFrame>i)&&this.onLoop(),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const r=[];for(let i=0;i<t.length;++i)r.push(ne.from(t[i]));return new Ta(r)}static fromImages(t){const r=[];for(let i=0;i<t.length;++i)r.push(ne.from(t[i]));return new Ta(r)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof ne)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let r=0;r<t.length;r++)this._textures.push(t[r].texture),this._durations.push(t[r].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const r=this.currentFrame;this._currentTime=t,r!==this.currentFrame&&this.updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?($r.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&($r.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const oo=new Ze;class su extends us{constructor(t,r=100,i=100){super(t),this.tileTransform=new rn,this._width=r,this._height=i,this.uvMatrix=this.texture.uvMatrix||new ea(t),this.pluginName="tilingSprite",this.uvRespectAnchor=!1}get clampMargin(){return this.uvMatrix.clampMargin}set clampMargin(t){this.uvMatrix.clampMargin=t,this.uvMatrix.update(!0)}get tileScale(){return this.tileTransform.scale}set tileScale(t){this.tileTransform.scale.copyFrom(t)}get tilePosition(){return this.tileTransform.position}set tilePosition(t){this.tileTransform.position.copyFrom(t)}_onTextureUpdate(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215}_render(t){const r=this._texture;!r||!r.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this))}_calculateBounds(){const t=this._width*-this._anchor._x,r=this._height*-this._anchor._y,i=this._width*(1-this._anchor._x),n=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,r,i,n)}getLocalBounds(t){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,oo);const r=this._width,i=this._height,n=-r*this.anchor._x;if(oo.x>=n&&oo.x<n+r){const o=-i*this.anchor._y;if(oo.y>=o&&oo.y<o+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,r){const i=t instanceof ne?t:ne.from(t,r);return new su(i,r.width,r.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var lm=`#version 300 es
1010
+ `;class Jl extends Nn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new nr,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Pe.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Mi.from(qg,jg,{}),this.state=Pi.for2d()}render(t){const r=t.children,i=t._maxSize,n=t._batchSize,o=this.renderer;let h=r.length;if(h===0)return;h>i&&!t.autoResize&&(h=i);let f=t._buffers;f||(f=t._buffers=this.generateBuffers(t));const A=r[0]._texture.baseTexture,T=A.alphaMode>0;this.state.blendMode=kh(t.blendMode,T),o.state.set(this.state);const C=o.gl,x=t.worldTransform.copyTo(this.tempMatrix);x.prepend(o.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=x.toArray(!0),this.shader.uniforms.uColor=rr.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,T).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=A,this.renderer.shader.bind(this.shader);let M=!1;for(let D=0,k=0;D<h;D+=n,k+=1){let U=h-D;U>n&&(U=n),k>=f.length&&f.push(this._generateOneMoreBuffer(t));const G=f[k];G.uploadDynamic(r,D,U);const X=t._bufferUpdateIDs[k]||0;M=M||G._updateID<X,M&&(G._updateID=t._updateID,G.uploadStatic(r,D,U)),o.geometry.bind(G.geometry),C.drawElements(C.TRIANGLES,U*6,C.UNSIGNED_SHORT,0)}}generateBuffers(t){const r=[],i=t._maxSize,n=t._batchSize,o=t._properties;for(let h=0;h<i;h+=n)r.push(new ad(this.properties,o,n));return r}_generateOneMoreBuffer(t){const r=t._batchSize,i=t._properties;return new ad(this.properties,i,r)}uploadVertices(t,r,i,n,o,h){let f=0,A=0,T=0,C=0;for(let x=0;x<i;++x){const M=t[r+x],D=M._texture,k=M.scale.x,U=M.scale.y,G=D.trim,X=D.orig;G?(A=G.x-M.anchor.x*X.width,f=A+G.width,C=G.y-M.anchor.y*X.height,T=C+G.height):(f=X.width*(1-M.anchor.x),A=X.width*-M.anchor.x,T=X.height*(1-M.anchor.y),C=X.height*-M.anchor.y),n[h]=A*k,n[h+1]=C*U,n[h+o]=f*k,n[h+o+1]=C*U,n[h+o*2]=f*k,n[h+o*2+1]=T*U,n[h+o*3]=A*k,n[h+o*3+1]=T*U,h+=o*4}}uploadPosition(t,r,i,n,o,h){for(let f=0;f<i;f++){const A=t[r+f].position;n[h]=A.x,n[h+1]=A.y,n[h+o]=A.x,n[h+o+1]=A.y,n[h+o*2]=A.x,n[h+o*2+1]=A.y,n[h+o*3]=A.x,n[h+o*3+1]=A.y,h+=o*4}}uploadRotation(t,r,i,n,o,h){for(let f=0;f<i;f++){const A=t[r+f].rotation;n[h]=A,n[h+o]=A,n[h+o*2]=A,n[h+o*3]=A,h+=o*4}}uploadUvs(t,r,i,n,o,h){for(let f=0;f<i;++f){const A=t[r+f]._texture._uvs;A?(n[h]=A.x0,n[h+1]=A.y0,n[h+o]=A.x1,n[h+o+1]=A.y1,n[h+o*2]=A.x2,n[h+o*2+1]=A.y2,n[h+o*3]=A.x3,n[h+o*3+1]=A.y3,h+=o*4):(n[h]=0,n[h+1]=0,n[h+o]=0,n[h+o+1]=0,n[h+o*2]=0,n[h+o*2+1]=0,n[h+o*3]=0,n[h+o*3+1]=0,h+=o*4)}}uploadTint(t,r,i,n,o,h){for(let f=0;f<i;++f){const A=t[r+f],T=rr.shared.setValue(A._tintRGB).toPremultiplied(A.alpha,A.texture.baseTexture.alphaMode>0);n[h]=T,n[h+o]=T,n[h+o*2]=T,n[h+o*3]=T,h+=o*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Jl.extension={name:"particle",type:ee.RendererPlugin},Te.add(Jl);var no=(s=>(s[s.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",s[s.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",s))(no||{});const ba={willReadFrequently:!0},ji=class Se{static get experimentalLetterSpacingSupported(){let t=Se._experimentalLetterSpacingSupported;if(t!==void 0){const r=ue.ADAPTER.getCanvasRenderingContext2D().prototype;t=Se._experimentalLetterSpacingSupported="letterSpacing"in r||"textLetterSpacing"in r}return t}constructor(t,r,i,n,o,h,f,A,T){this.text=t,this.style=r,this.width=i,this.height=n,this.lines=o,this.lineWidths=h,this.lineHeight=f,this.maxLineWidth=A,this.fontProperties=T}static measureText(t,r,i,n=Se._canvas){i=i??r.wordWrap;const o=r.toFontString(),h=Se.measureFont(o);h.fontSize===0&&(h.fontSize=r.fontSize,h.ascent=r.fontSize);const f=n.getContext("2d",ba);f.font=o;const A=(i?Se.wordWrap(t,r,n):t).split(/(?:\r\n|\r|\n)/),T=new Array(A.length);let C=0;for(let k=0;k<A.length;k++){const U=Se._measureText(A[k],r.letterSpacing,f);T[k]=U,C=Math.max(C,U)}let x=C+r.strokeThickness;r.dropShadow&&(x+=r.dropShadowDistance);const M=r.lineHeight||h.fontSize+r.strokeThickness;let D=Math.max(M,h.fontSize+r.strokeThickness*2)+r.leading+(A.length-1)*(M+r.leading);return r.dropShadow&&(D+=r.dropShadowDistance),new Se(t,r,x,D,A,T,M+r.leading,C,h)}static _measureText(t,r,i){let n=!1;Se.experimentalLetterSpacingSupported&&(Se.experimentalLetterSpacing?(i.letterSpacing=`${r}px`,i.textLetterSpacing=`${r}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let o=i.measureText(t).width;return o>0&&(n?o-=r:o+=(Se.graphemeSegmenter(t).length-1)*r),o}static wordWrap(t,r,i=Se._canvas){const n=i.getContext("2d",ba);let o=0,h="",f="";const A=Object.create(null),{letterSpacing:T,whiteSpace:C}=r,x=Se.collapseSpaces(C),M=Se.collapseNewlines(C);let D=!x;const k=r.wordWrapWidth+T,U=Se.tokenize(t);for(let G=0;G<U.length;G++){let X=U[G];if(Se.isNewline(X)){if(!M){f+=Se.addLine(h),D=!x,h="",o=0;continue}X=" "}if(x){const Z=Se.isBreakingSpace(X),it=Se.isBreakingSpace(h[h.length-1]);if(Z&&it)continue}const J=Se.getFromCache(X,T,A,n);if(J>k)if(h!==""&&(f+=Se.addLine(h),h="",o=0),Se.canBreakWords(X,r.breakWords)){const Z=Se.wordWrapSplit(X);for(let it=0;it<Z.length;it++){let Q=Z[it],_t=Q,et=1;for(;Z[it+et];){const wt=Z[it+et];if(!Se.canBreakChars(_t,wt,X,it,r.breakWords))Q+=wt;else break;_t=wt,et++}it+=et-1;const ft=Se.getFromCache(Q,T,A,n);ft+o>k&&(f+=Se.addLine(h),D=!1,h="",o=0),h+=Q,o+=ft}}else{h.length>0&&(f+=Se.addLine(h),h="",o=0);const Z=G===U.length-1;f+=Se.addLine(X,!Z),D=!1,h="",o=0}else J+o>k&&(D=!1,f+=Se.addLine(h),h="",o=0),(h.length>0||!Se.isBreakingSpace(X)||D)&&(h+=X,o+=J)}return f+=Se.addLine(h,!1),f}static addLine(t,r=!0){return t=Se.trimRight(t),t=r?`${t}
1011
+ `:t,t}static getFromCache(t,r,i,n){let o=i[t];return typeof o!="number"&&(o=Se._measureText(t,r,n)+r,i[t]=o),o}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let r=t.length-1;r>=0;r--){const i=t[r];if(!Se.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:Se._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,r){return typeof t!="string"?!1:Se._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const r=[];let i="";if(typeof t!="string")return r;for(let n=0;n<t.length;n++){const o=t[n],h=t[n+1];if(Se.isBreakingSpace(o,h)||Se.isNewline(o)){i!==""&&(r.push(i),i=""),r.push(o);continue}i+=o}return i!==""&&r.push(i),r}static canBreakWords(t,r){return r}static canBreakChars(t,r,i,n,o){return!0}static wordWrapSplit(t){return Se.graphemeSegmenter(t)}static measureFont(t){if(Se._fonts[t])return Se._fonts[t];const r={ascent:0,descent:0,fontSize:0},i=Se._canvas,n=Se._context;n.font=t;const o=Se.METRICS_STRING+Se.BASELINE_SYMBOL,h=Math.ceil(n.measureText(o).width);let f=Math.ceil(n.measureText(Se.BASELINE_SYMBOL).width);const A=Math.ceil(Se.HEIGHT_MULTIPLIER*f);if(f=f*Se.BASELINE_MULTIPLIER|0,h===0||A===0)return Se._fonts[t]=r,r;i.width=h,i.height=A,n.fillStyle="#f00",n.fillRect(0,0,h,A),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(o,0,f);const T=n.getImageData(0,0,h,A).data,C=T.length,x=h*4;let M=0,D=0,k=!1;for(M=0;M<f;++M){for(let U=0;U<x;U+=4)if(T[D+U]!==255){k=!0;break}if(!k)D+=x;else break}for(r.ascent=f-M,D=C-x,k=!1,M=A;M>f;--M){for(let U=0;U<x;U+=4)if(T[D+U]!==255){k=!0;break}if(!k)D-=x;else break}return r.descent=M-f,r.fontSize=r.ascent+r.descent,Se._fonts[t]=r,r}static clearMetrics(t=""){t?delete Se._fonts[t]:Se._fonts={}}static get _canvas(){var t;if(!Se.__canvas){let r;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",ba))!=null&&t.measureText)return Se.__canvas=i,i;r=ue.ADAPTER.createCanvas()}catch{r=ue.ADAPTER.createCanvas()}r.width=r.height=10,Se.__canvas=r}return Se.__canvas}static get _context(){return Se.__context||(Se.__context=Se._canvas.getContext("2d",ba)),Se.__context}};ji.METRICS_STRING="|ÉqÅ",ji.BASELINE_SYMBOL="M",ji.BASELINE_MULTIPLIER=1.4,ji.HEIGHT_MULTIPLIER=2,ji.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(r=>r.segment)}return s=>[...s]})(),ji.experimentalLetterSpacing=!1,ji._fonts={},ji._newlines=[10,13],ji._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let ds=ji;const Zg=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],hd=class Do{constructor(t){this.styleID=0,this.reset(),eu(this,t,t)}clone(){const t={};return eu(t,this,Do.defaultStyle),new Do(t)}reset(){eu(this,Do.defaultStyle,Do.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const r=tu(t);this._dropShadowColor!==r&&(this._dropShadowColor=r,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const r=tu(t);this._fill!==r&&(this._fill=r,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Qg(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const r=tu(t);this._stroke!==r&&(this._stroke=r,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let r=this.fontFamily;Array.isArray(this.fontFamily)||(r=this.fontFamily.split(","));for(let i=r.length-1;i>=0;i--){let n=r[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!Zg.includes(n)&&(n=`"${n}"`),r[i]=n}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${r.join(",")}`}};hd.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:no.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let ps=hd;function tu(s){const t=rr.shared,r=i=>{const n=t.setValue(i);return n.alpha===1?n.toHex():n.toRgbaString()};return Array.isArray(s)?s.map(r):r(s)}function Qg(s,t){if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let r=0;r<s.length;++r)if(s[r]!==t[r])return!1;return!0}function eu(s,t,r){for(const i in r)Array.isArray(t[i])?s[i]=t[i].slice():s[i]=t[i]}const Kg={texture:!0,children:!1,baseTexture:!0},ld=class Mu extends us{constructor(t,r,i){let n=!1;i||(i=ue.ADAPTER.createCanvas(),n=!0),i.width=3,i.height=3;const o=ne.from(i);o.orig=new Ve,o.trim=new Ve,super(o),this._ownCanvas=n,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Mu.defaultResolution??ue.RESOLUTION,this._autoResolution=Mu.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=r,this.localStyleID=-1}static get experimentalLetterSpacing(){return ds.experimentalLetterSpacing}static set experimentalLetterSpacing(t){Oe("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),ds.experimentalLetterSpacing=t}updateText(t){const r=this._style;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,n=ds.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),o=n.width,h=n.height,f=n.lines,A=n.lineHeight,T=n.lineWidths,C=n.maxLineWidth,x=n.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,o)+r.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,h)+r.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=r.strokeThickness,i.textBaseline=r.textBaseline,i.lineJoin=r.lineJoin,i.miterLimit=r.miterLimit;let M,D;const k=r.dropShadow?2:1;for(let U=0;U<k;++U){const G=r.dropShadow&&U===0,X=G?Math.ceil(Math.max(1,h)+r.padding*2):0,J=X*this._resolution;if(G){i.fillStyle="black",i.strokeStyle="black";const it=r.dropShadowColor,Q=r.dropShadowBlur*this._resolution,_t=r.dropShadowDistance*this._resolution;i.shadowColor=rr.shared.setValue(it).setAlpha(r.dropShadowAlpha).toRgbaString(),i.shadowBlur=Q,i.shadowOffsetX=Math.cos(r.dropShadowAngle)*_t,i.shadowOffsetY=Math.sin(r.dropShadowAngle)*_t+J}else i.fillStyle=this._generateFillStyle(r,f,n),i.strokeStyle=r.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let Z=(A-x.fontSize)/2;A-x.fontSize<0&&(Z=0);for(let it=0;it<f.length;it++)M=r.strokeThickness/2,D=r.strokeThickness/2+it*A+x.ascent+Z,r.align==="right"?M+=C-T[it]:r.align==="center"&&(M+=(C-T[it])/2),r.stroke&&r.strokeThickness&&this.drawLetterSpacing(f[it],M+r.padding,D+r.padding-X,!0),r.fill&&this.drawLetterSpacing(f[it],M+r.padding,D+r.padding-X)}this.updateTexture()}drawLetterSpacing(t,r,i,n=!1){const o=this._style.letterSpacing;let h=!1;if(ds.experimentalLetterSpacingSupported&&(ds.experimentalLetterSpacing?(this.context.letterSpacing=`${o}px`,this.context.textLetterSpacing=`${o}px`,h=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),o===0||h){n?this.context.strokeText(t,r,i):this.context.fillText(t,r,i);return}let f=r;const A=ds.graphemeSegmenter(t);let T=this.context.measureText(t).width,C=0;for(let x=0;x<A.length;++x){const M=A[x];n?this.context.strokeText(M,f,i):this.context.fillText(M,f,i);let D="";for(let k=x+1;k<A.length;++k)D+=A[k];C=this.context.measureText(D).width,f+=T-C+o,T=C}}updateTexture(){const t=this.canvas;if(this._style.trim){const h=Q0(t);h.data&&(t.width=h.width,t.height=h.height,this.context.putImageData(h.data,0,0))}const r=this._texture,i=this._style,n=i.trim?0:i.padding,o=r.baseTexture;r.trim.width=r._frame.width=t.width/this._resolution,r.trim.height=r._frame.height=t.height/this._resolution,r.trim.x=-n,r.trim.y=-n,r.orig.width=r._frame.width-n*2,r.orig.height=r._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(t.width,t.height,this._resolution),r.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,r){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,r)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,r,i){const n=t.fill;if(Array.isArray(n)){if(n.length===1)return n[0]}else return n;let o;const h=t.dropShadow?t.dropShadowDistance:0,f=t.padding||0,A=this.canvas.width/this._resolution-h-f*2,T=this.canvas.height/this._resolution-h-f*2,C=n.slice(),x=t.fillGradientStops.slice();if(!x.length){const M=C.length+1;for(let D=1;D<M;++D)x.push(D/M)}if(C.unshift(n[0]),x.unshift(0),C.push(n[n.length-1]),x.push(1),t.fillGradientType===no.LINEAR_VERTICAL){o=this.context.createLinearGradient(A/2,f,A/2,T+f);const M=i.fontProperties.fontSize+t.strokeThickness;for(let D=0;D<r.length;D++){const k=i.lineHeight*(D-1)+M,U=i.lineHeight*D;let G=U;D>0&&k>U&&(G=(U+k)/2);const X=U+M,J=i.lineHeight*(D+1);let Z=X;D+1<r.length&&J<X&&(Z=(X+J)/2);const it=(Z-G)/T;for(let Q=0;Q<C.length;Q++){let _t=0;typeof x[Q]=="number"?_t=x[Q]:_t=Q/C.length;let et=Math.min(1,Math.max(0,G/T+_t*it));et=Number(et.toFixed(5)),o.addColorStop(et,C[Q])}}}else{o=this.context.createLinearGradient(f,T/2,A+f,T/2);const M=C.length+1;let D=1;for(let k=0;k<C.length;k++){let U;typeof x[k]=="number"?U=x[k]:U=D/M,o.addColorStop(U,C[k]),D++}}return o}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Kg,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const r=as(this.scale.x)||1;this.scale.x=r*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const r=as(this.scale.y)||1;this.scale.y=r*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof ps?this._style=t:this._style=new ps(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};ld.defaultAutoResolution=!0;let ru=ld;class ud{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Jg(s,t){var i;let r=!1;if((i=s==null?void 0:s._textures)!=null&&i.length){for(let n=0;n<s._textures.length;n++)if(s._textures[n]instanceof ne){const o=s._textures[n].baseTexture;t.includes(o)||(t.push(o),r=!0)}}return r}function tm(s,t){if(s.baseTexture instanceof Ge){const r=s.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function em(s,t){if(s._texture&&s._texture instanceof ne){const r=s._texture.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function rm(s,t){return t instanceof ru?(t.updateText(!0),!0):!1}function im(s,t){if(t instanceof ps){const r=t.toFontString();return ds.measureFont(r),!0}return!1}function sm(s,t){if(s instanceof ru){t.includes(s.style)||t.push(s.style),t.includes(s)||t.push(s);const r=s._texture.baseTexture;return t.includes(r)||t.push(r),!0}return!1}function nm(s,t){return s instanceof ps?(t.includes(s)||t.push(s),!0):!1}const cd=class m2{constructor(t){this.limiter=new ud(m2.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(sm),this.registerFindHook(nm),this.registerFindHook(Jg),this.registerFindHook(tm),this.registerFindHook(em),this.registerUploadHook(rm),this.registerUploadHook(im)}upload(t){return new Promise(r=>{t&&this.add(t),this.queue.length?(this.completes.push(r),this.ticking||(this.ticking=!0,$r.system.addOnce(this.tick,this,ls.UTILITY))):r()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let r=!1;if(t&&!t._destroyed){for(let i=0,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),r=!0;break}}r||this.queue.shift()}if(this.queue.length)$r.system.addOnce(this.tick,this,ls.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let r=0,i=t.length;r<i;r++)t[r]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let r=0,i=this.addHooks.length;r<i&&!this.addHooks[r](t,this.queue);r++);if(t instanceof Zr)for(let r=t.children.length-1;r>=0;r--)this.add(t.children[r]);return this}destroy(){this.ticking&&$r.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};cd.uploadsPerFrame=4;let Aa=cd;Object.defineProperties(ue,{UPLOADS_PER_FRAME:{get(){return Aa.uploadsPerFrame},set(s){Oe("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Aa.uploadsPerFrame=s}}});function fd(s,t){return t instanceof Ge?(t._glTextures[s.CONTEXT_UID]||s.texture.bind(t),!0):!1}function om(s,t){if(!(t instanceof Ql))return!1;const{geometry:r}=t;t.finishPoly(),r.updateBatches();const{batches:i}=r;for(let n=0;n<i.length;n++){const{texture:o}=i[n].style;o&&fd(s,o.baseTexture)}return r.batchable||s.geometry.bind(r,t._resolveDirectShader(s)),!0}function am(s,t){return s instanceof Ql?(t.push(s),!0):!1}class iu extends Aa{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(am),this.registerUploadHook(fd),this.registerUploadHook(om)}}iu.extension={name:"prepare",type:ee.RendererSystem},Te.add(iu);class hm{constructor(t){this.maxMilliseconds=t,this.frameStart=0}beginFrame(){this.frameStart=Date.now()}allowedToUpload(){return Date.now()-this.frameStart<this.maxMilliseconds}}class wa extends us{constructor(t,r=!0){super(t[0]instanceof ne?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=r,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&($r.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&($r.shared.add(this.update,this,ls.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const r=this.animationSpeed*t,i=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=r/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=r;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i||this.animationSpeed<0&&this.currentFrame>i)&&this.onLoop(),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const r=[];for(let i=0;i<t.length;++i)r.push(ne.from(t[i]));return new wa(r)}static fromImages(t){const r=[];for(let i=0;i<t.length;++i)r.push(ne.from(t[i]));return new wa(r)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof ne)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let r=0;r<t.length;r++)this._textures.push(t[r].texture),this._durations.push(t[r].time)}this._previousFrame=null,this.gotoAndStop(0),this.updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const r=this.currentFrame;this._currentTime=t,r!==this.currentFrame&&this.updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?($r.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&($r.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const oo=new Ze;class su extends us{constructor(t,r=100,i=100){super(t),this.tileTransform=new rn,this._width=r,this._height=i,this.uvMatrix=this.texture.uvMatrix||new ea(t),this.pluginName="tilingSprite",this.uvRespectAnchor=!1}get clampMargin(){return this.uvMatrix.clampMargin}set clampMargin(t){this.uvMatrix.clampMargin=t,this.uvMatrix.update(!0)}get tileScale(){return this.tileTransform.scale}set tileScale(t){this.tileTransform.scale.copyFrom(t)}get tilePosition(){return this.tileTransform.position}set tilePosition(t){this.tileTransform.position.copyFrom(t)}_onTextureUpdate(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215}_render(t){const r=this._texture;!r||!r.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this))}_calculateBounds(){const t=this._width*-this._anchor._x,r=this._height*-this._anchor._y,i=this._width*(1-this._anchor._x),n=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,r,i,n)}getLocalBounds(t){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new Ve),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,oo);const r=this._width,i=this._height,n=-r*this.anchor._x;if(oo.x>=n&&oo.x<n+r){const o=-i*this.anchor._y;if(oo.y>=o&&oo.y<o+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,r){const i=t instanceof ne?t:ne.from(t,r);return new su(i,r.width,r.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var lm=`#version 300 es
1012
1012
  #define SHADER_NAME Tiling-Sprite-100
1013
1013
 
1014
1014
  precision lowp float;
@@ -1087,7 +1087,7 @@ void main(void)
1087
1087
 
1088
1088
  gl_FragColor = texSample * uColor;
1089
1089
  }
1090
- `,pd=`#version 100
1090
+ `,dd=`#version 100
1091
1091
  #define SHADER_NAME Tiling-Sprite-100
1092
1092
 
1093
1093
  precision lowp float;
@@ -1122,7 +1122,7 @@ void main(void)
1122
1122
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1123
1123
  gl_FragColor = texSample * uColor;
1124
1124
  }
1125
- `;const Ea=new nr;class nu extends Nn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new ll,this.state=Pi.for2d()}contextChange(){const t=this.renderer,r={globals:t.globalUniforms};this.simpleShader=Mi.from(pd,fm,r),this.shader=t.context.webGLVersion>1?Mi.from(um,lm,r):Mi.from(pd,cm,r)}render(t){const r=this.renderer,i=this.quad;let n=i.vertices;n[0]=n[6]=t._width*-t.anchor.x,n[1]=n[3]=t._height*-t.anchor.y,n[2]=n[4]=t._width*(1-t.anchor.x),n[5]=n[7]=t._height*(1-t.anchor.y);const o=t.uvRespectAnchor?t.anchor.x:0,h=t.uvRespectAnchor?t.anchor.y:0;n=i.uvs,n[0]=n[6]=-o,n[1]=n[3]=-h,n[2]=n[4]=1-o,n[5]=n[7]=1-h,i.invalidate();const f=t._texture,A=f.baseTexture,T=A.alphaMode>0,C=t.tileTransform.localTransform,x=t.uvMatrix;let M=A.isPowerOfTwo&&f.frame.width===A.width&&f.frame.height===A.height;M&&(A._glTextures[r.CONTEXT_UID]?M=A.wrapMode!==Vi.CLAMP:A.wrapMode===Vi.CLAMP&&(A.wrapMode=Vi.REPEAT));const D=M?this.simpleShader:this.shader,k=f.width,U=f.height,G=t._width,X=t._height;Ea.set(C.a*k/G,C.b*k/X,C.c*U/G,C.d*U/X,C.tx/G,C.ty/X),Ea.invert(),M?Ea.prepend(x.mapCoord):(D.uniforms.uMapCoord=x.mapCoord.toArray(!0),D.uniforms.uClampFrame=x.uClampFrame,D.uniforms.uClampOffset=x.uClampOffset),D.uniforms.uTransform=Ea.toArray(!0),D.uniforms.uColor=rr.shared.setValue(t.tint).premultiply(t.worldAlpha,T).toArray(D.uniforms.uColor),D.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),D.uniforms.uSampler=f,r.shader.bind(D),r.geometry.bind(i),this.state.blendMode=Oh(t.blendMode,T),r.state.set(this.state),r.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}nu.extension={name:"tilingSprite",type:ee.RendererPlugin},be.add(nu);const _d=class Fo{constructor(t,r,i){this.linkedSheets=[],(t instanceof Ge||t instanceof ne)&&(t={texture:t,data:r,resolutionFilename:i});const{texture:n,data:o,resolutionFilename:h=null,cachePrefix:f=""}=t;this.cachePrefix=f,this._texture=n instanceof ne?n:null,this.baseTexture=n instanceof Ge?n:this._texture.baseTexture,this.textures={},this.animations={},this.data=o;const A=this.baseTexture.resource;this.resolution=this._updateResolution(h||(A?A.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:r}=this.data.meta;let i=Xi(t,null);return i===null&&(i=typeof r=="number"?r:parseFloat(r??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Fo.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let r=t;const i=Fo.BATCH_SIZE;for(;r-t<i&&r<this._frameKeys.length;){const n=this._frameKeys[r],o=this._frames[n],h=o.frame;if(h){let f=null,A=null;const T=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,C=new Ve(0,0,Math.floor(T.w)/this.resolution,Math.floor(T.h)/this.resolution);o.rotated?f=new Ve(Math.floor(h.x)/this.resolution,Math.floor(h.y)/this.resolution,Math.floor(h.h)/this.resolution,Math.floor(h.w)/this.resolution):f=new Ve(Math.floor(h.x)/this.resolution,Math.floor(h.y)/this.resolution,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(A=new Ve(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution)),this.textures[n]=new ne(this.baseTexture,f,C,A,o.rotated?2:0,o.anchor,o.borders),ne.addToCache(this.textures[n],this.cachePrefix+n.toString())}r++}}_processAnimations(){const t=this.data.animations||{};for(const r in t){this.animations[r]=[];for(let i=0;i<t[r].length;i++){const n=t[r][i];this.animations[r].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Fo.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Fo.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var r;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((r=this._texture)==null||r.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};_d.BATCH_SIZE=1e3;let ou=_d;const dm=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function gd(s,t,r){const i={};if(s.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!r){const n=Pr.dirname(s[0]);t.linkedSheets.forEach((o,h)=>{Object.assign(i,gd([`${n}/${t.data.meta.related_multi_packs[h]}`],o,!0))})}return i}const md={extension:ee.Asset,cache:{test:s=>s instanceof ou,getCacheableAssets:(s,t)=>gd(s,t,!1)},resolver:{test:s=>{const t=s.split("?")[0].split("."),r=t.pop(),i=t.pop();return r==="json"&&dm.includes(i)},parse:s=>{var r;const t=s.split(".");return{resolution:parseFloat(((r=ue.RETINA_PREFIX.exec(s))==null?void 0:r[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:ee.LoadParser,priority:_i.Normal},async testParse(s,t){return Pr.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,r){var C,x;const{texture:i,imageFilename:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let h=Pr.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let f;if(i&&i.baseTexture)f=i;else{const M=fa(h+(n??s.meta.image),t.src);f=(await r.load([M]))[M]}const A=new ou({texture:f.baseTexture,data:s,resolutionFilename:t.src,cachePrefix:o});await A.parse();const T=(C=s==null?void 0:s.meta)==null?void 0:C.related_multi_packs;if(Array.isArray(T)){const M=[];for(const k of T){if(typeof k!="string")continue;let U=h+k;(x=t.data)!=null&&x.ignoreMultiPack||(U=fa(U,t.src),M.push(r.load({src:U,data:{ignoreMultiPack:!0}})))}const D=await Promise.all(M);A.linkedSheets=D,D.forEach(k=>{k.linkedSheets=[A].concat(A.linkedSheets.filter(U=>U!==k))})}return A},unload(s){s.destroy(!0)}}};be.add(md);class ao{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class ho{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const r=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const o in r){const h=r[o].match(/^[a-z]+/gm)[0],f=r[o].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),A={};for(const T in f){const C=f[T].split("="),x=C[0],M=C[1].replace(/"/gm,""),D=parseFloat(M),k=isNaN(D)?M:D;A[x]=k}i[h].push(A)}const n=new ao;return i.info.forEach(o=>n.info.push({face:o.face,size:parseInt(o.size,10)})),i.common.forEach(o=>n.common.push({lineHeight:parseInt(o.lineHeight,10)})),i.page.forEach(o=>n.page.push({id:parseInt(o.id,10),file:o.file})),i.char.forEach(o=>n.char.push({id:parseInt(o.id,10),page:parseInt(o.page,10),x:parseInt(o.x,10),y:parseInt(o.y,10),width:parseInt(o.width,10),height:parseInt(o.height,10),xoffset:parseInt(o.xoffset,10),yoffset:parseInt(o.yoffset,10),xadvance:parseInt(o.xadvance,10)})),i.kerning.forEach(o=>n.kerning.push({first:parseInt(o.first,10),second:parseInt(o.second,10),amount:parseInt(o.amount,10)})),i.distanceField.forEach(o=>n.distanceField.push({distanceRange:parseInt(o.distanceRange,10),fieldType:o.fieldType})),n}}class Ca{static test(t){const r=t;return typeof t!="string"&&"getElementsByTagName"in t&&r.getElementsByTagName("page").length&&r.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const r=new ao,i=t.getElementsByTagName("info"),n=t.getElementsByTagName("common"),o=t.getElementsByTagName("page"),h=t.getElementsByTagName("char"),f=t.getElementsByTagName("kerning"),A=t.getElementsByTagName("distanceField");for(let T=0;T<i.length;T++)r.info.push({face:i[T].getAttribute("face"),size:parseInt(i[T].getAttribute("size"),10)});for(let T=0;T<n.length;T++)r.common.push({lineHeight:parseInt(n[T].getAttribute("lineHeight"),10)});for(let T=0;T<o.length;T++)r.page.push({id:parseInt(o[T].getAttribute("id"),10)||0,file:o[T].getAttribute("file")});for(let T=0;T<h.length;T++){const C=h[T];r.char.push({id:parseInt(C.getAttribute("id"),10),page:parseInt(C.getAttribute("page"),10)||0,x:parseInt(C.getAttribute("x"),10),y:parseInt(C.getAttribute("y"),10),width:parseInt(C.getAttribute("width"),10),height:parseInt(C.getAttribute("height"),10),xoffset:parseInt(C.getAttribute("xoffset"),10),yoffset:parseInt(C.getAttribute("yoffset"),10),xadvance:parseInt(C.getAttribute("xadvance"),10)})}for(let T=0;T<f.length;T++)r.kerning.push({first:parseInt(f[T].getAttribute("first"),10),second:parseInt(f[T].getAttribute("second"),10),amount:parseInt(f[T].getAttribute("amount"),10)});for(let T=0;T<A.length;T++)r.distanceField.push({fieldType:A[T].getAttribute("fieldType"),distanceRange:parseInt(A[T].getAttribute("distanceRange"),10)});return r}}class Sa{static test(t){return typeof t=="string"&&t.includes("<font>")?Ca.test(ue.ADAPTER.parseXML(t)):!1}static parse(t){return Ca.parse(ue.ADAPTER.parseXML(t))}}const au=[ho,Ca,Sa];function yd(s){for(let t=0;t<au.length;t++)if(au[t].test(s))return au[t];return null}function pm(s,t,r,i,n,o){const h=r.fill;if(Array.isArray(h)){if(h.length===1)return h[0]}else return h;let f;const A=r.dropShadow?r.dropShadowDistance:0,T=r.padding||0,C=s.width/i-A-T*2,x=s.height/i-A-T*2,M=h.slice(),D=r.fillGradientStops.slice();if(!D.length){const k=M.length+1;for(let U=1;U<k;++U)D.push(U/k)}if(M.unshift(h[0]),D.unshift(0),M.push(h[h.length-1]),D.push(1),r.fillGradientType===no.LINEAR_VERTICAL){f=t.createLinearGradient(C/2,T,C/2,x+T);let k=0;const U=(o.fontProperties.fontSize+r.strokeThickness)/x;for(let G=0;G<n.length;G++){const X=o.lineHeight*G;for(let J=0;J<M.length;J++){let Z=0;typeof D[J]=="number"?Z=D[J]:Z=J/M.length;const it=X/x+Z*U;let Q=Math.max(k,it);Q=Math.min(Q,1),f.addColorStop(Q,M[J]),k=Q}}}else{f=t.createLinearGradient(T,x/2,C+T,x/2);const k=M.length+1;let U=1;for(let G=0;G<M.length;G++){let X;typeof D[G]=="number"?X=D[G]:X=U/k,f.addColorStop(X,M[G]),U++}}return f}function _m(s,t,r,i,n,o,h){const f=r.text,A=r.fontProperties;t.translate(i,n),t.scale(o,o);const T=h.strokeThickness/2,C=-(h.strokeThickness/2);if(t.font=h.toFontString(),t.lineWidth=h.strokeThickness,t.textBaseline=h.textBaseline,t.lineJoin=h.lineJoin,t.miterLimit=h.miterLimit,t.fillStyle=pm(s,t,h,o,[f],r),t.strokeStyle=h.stroke,h.dropShadow){const x=h.dropShadowColor,M=h.dropShadowBlur*o,D=h.dropShadowDistance*o;t.shadowColor=rr.shared.setValue(x).setAlpha(h.dropShadowAlpha).toRgbaString(),t.shadowBlur=M,t.shadowOffsetX=Math.cos(h.dropShadowAngle)*D,t.shadowOffsetY=Math.sin(h.dropShadowAngle)*D}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;h.stroke&&h.strokeThickness&&t.strokeText(f,T,C+r.lineHeight-A.descent),h.fill&&t.fillText(f,T,C+r.lineHeight-A.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Pa(s){return s.codePointAt?s.codePointAt(0):s.charCodeAt(0)}function vd(s){return Array.from?Array.from(s):s.split("")}function gm(s){typeof s=="string"&&(s=[s]);const t=[];for(let r=0,i=s.length;r<i;r++){const n=s[r];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);const o=n[0].charCodeAt(0),h=n[1].charCodeAt(0);if(h<o)throw new Error("[BitmapFont]: Invalid character range.");for(let f=o,A=h;f<=A;f++)t.push(String.fromCharCode(f))}else t.push(...vd(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Ps=class is{constructor(t,r,i){var C;const[n]=t.info,[o]=t.common,[h]=t.page,[f]=t.distanceField,A=Xi(h.file),T={};this._ownsTextures=i,this.font=n.face,this.size=n.size,this.lineHeight=o.lineHeight/A,this.chars={},this.pageTextures=T;for(let x=0;x<t.page.length;x++){const{id:M,file:D}=t.page[x];T[M]=r instanceof Array?r[x]:r[D],f!=null&&f.fieldType&&f.fieldType!=="none"&&(T[M].baseTexture.alphaMode=Vr.NO_PREMULTIPLIED_ALPHA,T[M].baseTexture.mipmap=wi.OFF)}for(let x=0;x<t.char.length;x++){const{id:M,page:D}=t.char[x];let{x:k,y:U,width:G,height:X,xoffset:J,yoffset:Z,xadvance:it}=t.char[x];k/=A,U/=A,G/=A,X/=A,J/=A,Z/=A,it/=A;const Q=new Ve(k+T[D].frame.x/A,U+T[D].frame.y/A,G,X);this.chars[M]={xOffset:J,yOffset:Z,xAdvance:it,kerning:{},texture:new ne(T[D].baseTexture,Q),page:D}}for(let x=0;x<t.kerning.length;x++){let{first:M,second:D,amount:k}=t.kerning[x];M/=A,D/=A,k/=A,this.chars[D]&&(this.chars[D].kerning[M]=k)}this.distanceFieldRange=f==null?void 0:f.distanceRange,this.distanceFieldType=((C=f==null?void 0:f.fieldType)==null?void 0:C.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,r,i){let n;if(t instanceof ao)n=t;else{const h=yd(t);if(!h)throw new Error("Unrecognized data format for font.");n=h.parse(t)}r instanceof ne&&(r=[r]);const o=new is(n,r,i);return is.available[o.font]=o,o}static uninstall(t){const r=is.available[t];if(!r)throw new Error(`No font found named '${t}'`);r.destroy(),delete is.available[t]}static from(t,r,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:n,padding:o,resolution:h,textureWidth:f,textureHeight:A,...T}=Object.assign({},is.defaultOptions,i),C=gm(n),x=r instanceof ps?r:new ps(r),M=f,D=new ao;D.info[0]={face:x.fontFamily,size:x.fontSize},D.common[0]={lineHeight:x.fontSize};let k=0,U=0,G,X,J,Z=0;const it=[];for(let _t=0;_t<C.length;_t++){G||(G=ue.ADAPTER.createCanvas(),G.width=f,G.height=A,X=G.getContext("2d"),J=new Ge(G,{resolution:h,...T}),it.push(new ne(J)),D.page.push({id:it.length-1,file:""}));const et=C[_t],ft=ds.measureText(et,x,!1,G),wt=ft.width,Rt=Math.ceil(ft.height),It=Math.ceil((x.fontStyle==="italic"?2:1)*wt);if(U>=A-Rt*h){if(U===0)throw new Error(`[BitmapFont] textureHeight ${A}px is too small (fontFamily: '${x.fontFamily}', fontSize: ${x.fontSize}px, char: '${et}')`);--_t,G=null,X=null,J=null,U=0,k=0,Z=0;continue}if(Z=Math.max(Rt+ft.fontProperties.descent,Z),It*h+k>=M){if(k===0)throw new Error(`[BitmapFont] textureWidth ${f}px is too small (fontFamily: '${x.fontFamily}', fontSize: ${x.fontSize}px, char: '${et}')`);--_t,U+=Z*h,U=Math.ceil(U),k=0,Z=0;continue}_m(G,X,ft,k,U,h,x);const pt=Pa(ft.text);D.char.push({id:pt,page:it.length-1,x:k/h,y:U/h,width:It,height:Rt,xoffset:0,yoffset:0,xadvance:wt-(x.dropShadow?x.dropShadowDistance:0)-(x.stroke?x.strokeThickness:0)}),k+=(It+2*o)*h,k=Math.ceil(k)}if(!(i!=null&&i.skipKerning))for(let _t=0,et=C.length;_t<et;_t++){const ft=C[_t];for(let wt=0;wt<et;wt++){const Rt=C[wt],It=X.measureText(ft).width,pt=X.measureText(Rt).width,xt=X.measureText(ft+Rt).width-(It+pt);xt&&D.kerning.push({first:Pa(ft),second:Pa(Rt),amount:xt})}}const Q=new is(D,it,!0);return is.available[t]!==void 0&&is.uninstall(t),is.available[t]=Q,Q}};Ps.ALPHA=[["a","z"],["A","Z"]," "],Ps.NUMERIC=[["0","9"]],Ps.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Ps.ASCII=[[" ","~"]],Ps.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Ps.ALPHANUMERIC},Ps.available={};let _s=Ps;var mm=`// Pixi texture info\r
1125
+ `;const Ta=new nr;class nu extends Nn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new hl,this.state=Pi.for2d()}contextChange(){const t=this.renderer,r={globals:t.globalUniforms};this.simpleShader=Mi.from(dd,fm,r),this.shader=t.context.webGLVersion>1?Mi.from(um,lm,r):Mi.from(dd,cm,r)}render(t){const r=this.renderer,i=this.quad;let n=i.vertices;n[0]=n[6]=t._width*-t.anchor.x,n[1]=n[3]=t._height*-t.anchor.y,n[2]=n[4]=t._width*(1-t.anchor.x),n[5]=n[7]=t._height*(1-t.anchor.y);const o=t.uvRespectAnchor?t.anchor.x:0,h=t.uvRespectAnchor?t.anchor.y:0;n=i.uvs,n[0]=n[6]=-o,n[1]=n[3]=-h,n[2]=n[4]=1-o,n[5]=n[7]=1-h,i.invalidate();const f=t._texture,A=f.baseTexture,T=A.alphaMode>0,C=t.tileTransform.localTransform,x=t.uvMatrix;let M=A.isPowerOfTwo&&f.frame.width===A.width&&f.frame.height===A.height;M&&(A._glTextures[r.CONTEXT_UID]?M=A.wrapMode!==Vi.CLAMP:A.wrapMode===Vi.CLAMP&&(A.wrapMode=Vi.REPEAT));const D=M?this.simpleShader:this.shader,k=f.width,U=f.height,G=t._width,X=t._height;Ta.set(C.a*k/G,C.b*k/X,C.c*U/G,C.d*U/X,C.tx/G,C.ty/X),Ta.invert(),M?Ta.prepend(x.mapCoord):(D.uniforms.uMapCoord=x.mapCoord.toArray(!0),D.uniforms.uClampFrame=x.uClampFrame,D.uniforms.uClampOffset=x.uClampOffset),D.uniforms.uTransform=Ta.toArray(!0),D.uniforms.uColor=rr.shared.setValue(t.tint).premultiply(t.worldAlpha,T).toArray(D.uniforms.uColor),D.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),D.uniforms.uSampler=f,r.shader.bind(D),r.geometry.bind(i),this.state.blendMode=kh(t.blendMode,T),r.state.set(this.state),r.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}nu.extension={name:"tilingSprite",type:ee.RendererPlugin},Te.add(nu);const pd=class Fo{constructor(t,r,i){this.linkedSheets=[],(t instanceof Ge||t instanceof ne)&&(t={texture:t,data:r,resolutionFilename:i});const{texture:n,data:o,resolutionFilename:h=null,cachePrefix:f=""}=t;this.cachePrefix=f,this._texture=n instanceof ne?n:null,this.baseTexture=n instanceof Ge?n:this._texture.baseTexture,this.textures={},this.animations={},this.data=o;const A=this.baseTexture.resource;this.resolution=this._updateResolution(h||(A?A.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:r}=this.data.meta;let i=Xi(t,null);return i===null&&(i=typeof r=="number"?r:parseFloat(r??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Fo.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let r=t;const i=Fo.BATCH_SIZE;for(;r-t<i&&r<this._frameKeys.length;){const n=this._frameKeys[r],o=this._frames[n],h=o.frame;if(h){let f=null,A=null;const T=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,C=new Ve(0,0,Math.floor(T.w)/this.resolution,Math.floor(T.h)/this.resolution);o.rotated?f=new Ve(Math.floor(h.x)/this.resolution,Math.floor(h.y)/this.resolution,Math.floor(h.h)/this.resolution,Math.floor(h.w)/this.resolution):f=new Ve(Math.floor(h.x)/this.resolution,Math.floor(h.y)/this.resolution,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(A=new Ve(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution)),this.textures[n]=new ne(this.baseTexture,f,C,A,o.rotated?2:0,o.anchor,o.borders),ne.addToCache(this.textures[n],this.cachePrefix+n.toString())}r++}}_processAnimations(){const t=this.data.animations||{};for(const r in t){this.animations[r]=[];for(let i=0;i<t[r].length;i++){const n=t[r][i];this.animations[r].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Fo.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Fo.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var r;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((r=this._texture)==null||r.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};pd.BATCH_SIZE=1e3;let ou=pd;const dm=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function _d(s,t,r){const i={};if(s.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!r){const n=Pr.dirname(s[0]);t.linkedSheets.forEach((o,h)=>{Object.assign(i,_d([`${n}/${t.data.meta.related_multi_packs[h]}`],o,!0))})}return i}const gd={extension:ee.Asset,cache:{test:s=>s instanceof ou,getCacheableAssets:(s,t)=>_d(s,t,!1)},resolver:{test:s=>{const t=s.split("?")[0].split("."),r=t.pop(),i=t.pop();return r==="json"&&dm.includes(i)},parse:s=>{var r;const t=s.split(".");return{resolution:parseFloat(((r=ue.RETINA_PREFIX.exec(s))==null?void 0:r[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:ee.LoadParser,priority:_i.Normal},async testParse(s,t){return Pr.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,r){var C,x;const{texture:i,imageFilename:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let h=Pr.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let f;if(i&&i.baseTexture)f=i;else{const M=ca(h+(n??s.meta.image),t.src);f=(await r.load([M]))[M]}const A=new ou({texture:f.baseTexture,data:s,resolutionFilename:t.src,cachePrefix:o});await A.parse();const T=(C=s==null?void 0:s.meta)==null?void 0:C.related_multi_packs;if(Array.isArray(T)){const M=[];for(const k of T){if(typeof k!="string")continue;let U=h+k;(x=t.data)!=null&&x.ignoreMultiPack||(U=ca(U,t.src),M.push(r.load({src:U,data:{ignoreMultiPack:!0}})))}const D=await Promise.all(M);A.linkedSheets=D,D.forEach(k=>{k.linkedSheets=[A].concat(A.linkedSheets.filter(U=>U!==k))})}return A},unload(s){s.destroy(!0)}}};Te.add(gd);class ao{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class ho{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const r=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const o in r){const h=r[o].match(/^[a-z]+/gm)[0],f=r[o].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),A={};for(const T in f){const C=f[T].split("="),x=C[0],M=C[1].replace(/"/gm,""),D=parseFloat(M),k=isNaN(D)?M:D;A[x]=k}i[h].push(A)}const n=new ao;return i.info.forEach(o=>n.info.push({face:o.face,size:parseInt(o.size,10)})),i.common.forEach(o=>n.common.push({lineHeight:parseInt(o.lineHeight,10)})),i.page.forEach(o=>n.page.push({id:parseInt(o.id,10),file:o.file})),i.char.forEach(o=>n.char.push({id:parseInt(o.id,10),page:parseInt(o.page,10),x:parseInt(o.x,10),y:parseInt(o.y,10),width:parseInt(o.width,10),height:parseInt(o.height,10),xoffset:parseInt(o.xoffset,10),yoffset:parseInt(o.yoffset,10),xadvance:parseInt(o.xadvance,10)})),i.kerning.forEach(o=>n.kerning.push({first:parseInt(o.first,10),second:parseInt(o.second,10),amount:parseInt(o.amount,10)})),i.distanceField.forEach(o=>n.distanceField.push({distanceRange:parseInt(o.distanceRange,10),fieldType:o.fieldType})),n}}class Ea{static test(t){const r=t;return typeof t!="string"&&"getElementsByTagName"in t&&r.getElementsByTagName("page").length&&r.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const r=new ao,i=t.getElementsByTagName("info"),n=t.getElementsByTagName("common"),o=t.getElementsByTagName("page"),h=t.getElementsByTagName("char"),f=t.getElementsByTagName("kerning"),A=t.getElementsByTagName("distanceField");for(let T=0;T<i.length;T++)r.info.push({face:i[T].getAttribute("face"),size:parseInt(i[T].getAttribute("size"),10)});for(let T=0;T<n.length;T++)r.common.push({lineHeight:parseInt(n[T].getAttribute("lineHeight"),10)});for(let T=0;T<o.length;T++)r.page.push({id:parseInt(o[T].getAttribute("id"),10)||0,file:o[T].getAttribute("file")});for(let T=0;T<h.length;T++){const C=h[T];r.char.push({id:parseInt(C.getAttribute("id"),10),page:parseInt(C.getAttribute("page"),10)||0,x:parseInt(C.getAttribute("x"),10),y:parseInt(C.getAttribute("y"),10),width:parseInt(C.getAttribute("width"),10),height:parseInt(C.getAttribute("height"),10),xoffset:parseInt(C.getAttribute("xoffset"),10),yoffset:parseInt(C.getAttribute("yoffset"),10),xadvance:parseInt(C.getAttribute("xadvance"),10)})}for(let T=0;T<f.length;T++)r.kerning.push({first:parseInt(f[T].getAttribute("first"),10),second:parseInt(f[T].getAttribute("second"),10),amount:parseInt(f[T].getAttribute("amount"),10)});for(let T=0;T<A.length;T++)r.distanceField.push({fieldType:A[T].getAttribute("fieldType"),distanceRange:parseInt(A[T].getAttribute("distanceRange"),10)});return r}}class Ca{static test(t){return typeof t=="string"&&t.includes("<font>")?Ea.test(ue.ADAPTER.parseXML(t)):!1}static parse(t){return Ea.parse(ue.ADAPTER.parseXML(t))}}const au=[ho,Ea,Ca];function md(s){for(let t=0;t<au.length;t++)if(au[t].test(s))return au[t];return null}function pm(s,t,r,i,n,o){const h=r.fill;if(Array.isArray(h)){if(h.length===1)return h[0]}else return h;let f;const A=r.dropShadow?r.dropShadowDistance:0,T=r.padding||0,C=s.width/i-A-T*2,x=s.height/i-A-T*2,M=h.slice(),D=r.fillGradientStops.slice();if(!D.length){const k=M.length+1;for(let U=1;U<k;++U)D.push(U/k)}if(M.unshift(h[0]),D.unshift(0),M.push(h[h.length-1]),D.push(1),r.fillGradientType===no.LINEAR_VERTICAL){f=t.createLinearGradient(C/2,T,C/2,x+T);let k=0;const U=(o.fontProperties.fontSize+r.strokeThickness)/x;for(let G=0;G<n.length;G++){const X=o.lineHeight*G;for(let J=0;J<M.length;J++){let Z=0;typeof D[J]=="number"?Z=D[J]:Z=J/M.length;const it=X/x+Z*U;let Q=Math.max(k,it);Q=Math.min(Q,1),f.addColorStop(Q,M[J]),k=Q}}}else{f=t.createLinearGradient(T,x/2,C+T,x/2);const k=M.length+1;let U=1;for(let G=0;G<M.length;G++){let X;typeof D[G]=="number"?X=D[G]:X=U/k,f.addColorStop(X,M[G]),U++}}return f}function _m(s,t,r,i,n,o,h){const f=r.text,A=r.fontProperties;t.translate(i,n),t.scale(o,o);const T=h.strokeThickness/2,C=-(h.strokeThickness/2);if(t.font=h.toFontString(),t.lineWidth=h.strokeThickness,t.textBaseline=h.textBaseline,t.lineJoin=h.lineJoin,t.miterLimit=h.miterLimit,t.fillStyle=pm(s,t,h,o,[f],r),t.strokeStyle=h.stroke,h.dropShadow){const x=h.dropShadowColor,M=h.dropShadowBlur*o,D=h.dropShadowDistance*o;t.shadowColor=rr.shared.setValue(x).setAlpha(h.dropShadowAlpha).toRgbaString(),t.shadowBlur=M,t.shadowOffsetX=Math.cos(h.dropShadowAngle)*D,t.shadowOffsetY=Math.sin(h.dropShadowAngle)*D}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;h.stroke&&h.strokeThickness&&t.strokeText(f,T,C+r.lineHeight-A.descent),h.fill&&t.fillText(f,T,C+r.lineHeight-A.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Sa(s){return s.codePointAt?s.codePointAt(0):s.charCodeAt(0)}function yd(s){return Array.from?Array.from(s):s.split("")}function gm(s){typeof s=="string"&&(s=[s]);const t=[];for(let r=0,i=s.length;r<i;r++){const n=s[r];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);const o=n[0].charCodeAt(0),h=n[1].charCodeAt(0);if(h<o)throw new Error("[BitmapFont]: Invalid character range.");for(let f=o,A=h;f<=A;f++)t.push(String.fromCharCode(f))}else t.push(...yd(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Ps=class is{constructor(t,r,i){var C;const[n]=t.info,[o]=t.common,[h]=t.page,[f]=t.distanceField,A=Xi(h.file),T={};this._ownsTextures=i,this.font=n.face,this.size=n.size,this.lineHeight=o.lineHeight/A,this.chars={},this.pageTextures=T;for(let x=0;x<t.page.length;x++){const{id:M,file:D}=t.page[x];T[M]=r instanceof Array?r[x]:r[D],f!=null&&f.fieldType&&f.fieldType!=="none"&&(T[M].baseTexture.alphaMode=Vr.NO_PREMULTIPLIED_ALPHA,T[M].baseTexture.mipmap=wi.OFF)}for(let x=0;x<t.char.length;x++){const{id:M,page:D}=t.char[x];let{x:k,y:U,width:G,height:X,xoffset:J,yoffset:Z,xadvance:it}=t.char[x];k/=A,U/=A,G/=A,X/=A,J/=A,Z/=A,it/=A;const Q=new Ve(k+T[D].frame.x/A,U+T[D].frame.y/A,G,X);this.chars[M]={xOffset:J,yOffset:Z,xAdvance:it,kerning:{},texture:new ne(T[D].baseTexture,Q),page:D}}for(let x=0;x<t.kerning.length;x++){let{first:M,second:D,amount:k}=t.kerning[x];M/=A,D/=A,k/=A,this.chars[D]&&(this.chars[D].kerning[M]=k)}this.distanceFieldRange=f==null?void 0:f.distanceRange,this.distanceFieldType=((C=f==null?void 0:f.fieldType)==null?void 0:C.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,r,i){let n;if(t instanceof ao)n=t;else{const h=md(t);if(!h)throw new Error("Unrecognized data format for font.");n=h.parse(t)}r instanceof ne&&(r=[r]);const o=new is(n,r,i);return is.available[o.font]=o,o}static uninstall(t){const r=is.available[t];if(!r)throw new Error(`No font found named '${t}'`);r.destroy(),delete is.available[t]}static from(t,r,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:n,padding:o,resolution:h,textureWidth:f,textureHeight:A,...T}=Object.assign({},is.defaultOptions,i),C=gm(n),x=r instanceof ps?r:new ps(r),M=f,D=new ao;D.info[0]={face:x.fontFamily,size:x.fontSize},D.common[0]={lineHeight:x.fontSize};let k=0,U=0,G,X,J,Z=0;const it=[];for(let _t=0;_t<C.length;_t++){G||(G=ue.ADAPTER.createCanvas(),G.width=f,G.height=A,X=G.getContext("2d"),J=new Ge(G,{resolution:h,...T}),it.push(new ne(J)),D.page.push({id:it.length-1,file:""}));const et=C[_t],ft=ds.measureText(et,x,!1,G),wt=ft.width,Rt=Math.ceil(ft.height),It=Math.ceil((x.fontStyle==="italic"?2:1)*wt);if(U>=A-Rt*h){if(U===0)throw new Error(`[BitmapFont] textureHeight ${A}px is too small (fontFamily: '${x.fontFamily}', fontSize: ${x.fontSize}px, char: '${et}')`);--_t,G=null,X=null,J=null,U=0,k=0,Z=0;continue}if(Z=Math.max(Rt+ft.fontProperties.descent,Z),It*h+k>=M){if(k===0)throw new Error(`[BitmapFont] textureWidth ${f}px is too small (fontFamily: '${x.fontFamily}', fontSize: ${x.fontSize}px, char: '${et}')`);--_t,U+=Z*h,U=Math.ceil(U),k=0,Z=0;continue}_m(G,X,ft,k,U,h,x);const pt=Sa(ft.text);D.char.push({id:pt,page:it.length-1,x:k/h,y:U/h,width:It,height:Rt,xoffset:0,yoffset:0,xadvance:wt-(x.dropShadow?x.dropShadowDistance:0)-(x.stroke?x.strokeThickness:0)}),k+=(It+2*o)*h,k=Math.ceil(k)}if(!(i!=null&&i.skipKerning))for(let _t=0,et=C.length;_t<et;_t++){const ft=C[_t];for(let wt=0;wt<et;wt++){const Rt=C[wt],It=X.measureText(ft).width,pt=X.measureText(Rt).width,xt=X.measureText(ft+Rt).width-(It+pt);xt&&D.kerning.push({first:Sa(ft),second:Sa(Rt),amount:xt})}}const Q=new is(D,it,!0);return is.available[t]!==void 0&&is.uninstall(t),is.available[t]=Q,Q}};Ps.ALPHA=[["a","z"],["A","Z"]," "],Ps.NUMERIC=[["0","9"]],Ps.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Ps.ASCII=[[" ","~"]],Ps.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Ps.ALPHANUMERIC},Ps.available={};let _s=Ps;var mm=`// Pixi texture info\r
1126
1126
  varying vec2 vTextureCoord;\r
1127
1127
  uniform sampler2D uSampler;\r
1128
1128
  \r
@@ -1176,33 +1176,33 @@ void main(void)\r
1176
1176
  \r
1177
1177
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1178
1178
  }\r
1179
- `;const xd=[],bd=[],Ad=[],wd=class y2 extends Zr{constructor(t,r={}){super();const{align:i,tint:n,maxWidth:o,letterSpacing:h,fontName:f,fontSize:A}=Object.assign({},y2.styleDefaults,r);if(!_s.available[f])throw new Error(`Missing BitmapFont "${f}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new rr(n),this._font=void 0,this._fontName=f,this._fontSize=A,this.text=t,this._maxWidth=o,this._maxLineHeight=0,this._letterSpacing=h,this._anchor=new $i(()=>{this.dirty=!0},this,0,0),this._roundPixels=ue.ROUND_PIXELS,this.dirty=!0,this._resolution=ue.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var It;const t=_s.available[this._fontName],r=this.fontSize,i=r/t.size,n=new Ze,o=[],h=[],f=[],A=this._text.replace(/(?:\r\n|\r)/g,`
1180
- `)||" ",T=vd(A),C=this._maxWidth*t.size/r,x=t.distanceFieldType==="none"?xd:bd;let M=null,D=0,k=0,U=0,G=-1,X=0,J=0,Z=0,it=0;for(let pt=0;pt<T.length;pt++){const xt=T[pt],Ct=Pa(xt);if(/(?:\s)/.test(xt)&&(G=pt,X=D,it++),xt==="\r"||xt===`
1181
- `){h.push(D),f.push(-1),k=Math.max(k,D),++U,++J,n.x=0,n.y+=t.lineHeight,M=null,it=0;continue}const Gt=t.chars[Ct];if(!Gt)continue;M&&Gt.kerning[M]&&(n.x+=Gt.kerning[M]);const st=Ad.pop()||{texture:ne.EMPTY,line:0,charCode:0,prevSpaces:0,position:new Ze};st.texture=Gt.texture,st.line=U,st.charCode=Ct,st.position.x=Math.round(n.x+Gt.xOffset+this._letterSpacing/2),st.position.y=Math.round(n.y+Gt.yOffset),st.prevSpaces=it,o.push(st),D=st.position.x+Math.max(Gt.xAdvance-Gt.xOffset,Gt.texture.orig.width),n.x+=Gt.xAdvance+this._letterSpacing,Z=Math.max(Z,Gt.yOffset+Gt.texture.height),M=Ct,G!==-1&&C>0&&n.x>C&&(++J,Bs(o,1+G-J,1+pt-G),pt=G,G=-1,h.push(X),f.push(o.length>0?o[o.length-1].prevSpaces:0),k=Math.max(k,X),U++,n.x=0,n.y+=t.lineHeight,M=null,it=0)}const Q=T[T.length-1];Q!=="\r"&&Q!==`
1182
- `&&(/(?:\s)/.test(Q)&&(D=X),h.push(D),k=Math.max(k,D),f.push(-1));const _t=[];for(let pt=0;pt<=U;pt++){let xt=0;this._align==="right"?xt=k-h[pt]:this._align==="center"?xt=(k-h[pt])/2:this._align==="justify"&&(xt=f[pt]<0?0:(k-h[pt])/f[pt]),_t.push(xt)}const et=o.length,ft={},wt=[],Rt=this._activePagesMeshData;x.push(...Rt);for(let pt=0;pt<et;pt++){const xt=o[pt].texture,Ct=xt.baseTexture.uid;if(!ft[Ct]){let Gt=x.pop();if(!Gt){const nt=new so;let Y,gt;t.distanceFieldType==="none"?(Y=new fn(ne.EMPTY),gt=Re.NORMAL):(Y=new fn(ne.EMPTY,{program:Wi.from(ym,mm),uniforms:{uFWidth:0}}),gt=Re.NORMAL_NPM);const ot=new cn(nt,Y);ot.blendMode=gt,Gt={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:ot,vertices:null,uvs:null,indices:null}}Gt.index=0,Gt.indexCount=0,Gt.vertexCount=0,Gt.uvsCount=0,Gt.total=0;const{_textureCache:st}=this;st[Ct]=st[Ct]||new ne(xt.baseTexture),Gt.mesh.texture=st[Ct],Gt.mesh.tint=this._tintColor.value,wt.push(Gt),ft[Ct]=Gt}ft[Ct].total++}for(let pt=0;pt<Rt.length;pt++)wt.includes(Rt[pt])||this.removeChild(Rt[pt].mesh);for(let pt=0;pt<wt.length;pt++)wt[pt].mesh.parent!==this&&this.addChild(wt[pt].mesh);this._activePagesMeshData=wt;for(const pt in ft){const xt=ft[pt],Ct=xt.total;if(!(((It=xt.indices)==null?void 0:It.length)>6*Ct)||xt.vertices.length<cn.BATCHABLE_SIZE*2)xt.vertices=new Float32Array(4*2*Ct),xt.uvs=new Float32Array(4*2*Ct),xt.indices=new Uint16Array(6*Ct);else{const Gt=xt.total,st=xt.vertices;for(let nt=Gt*4*2;nt<st.length;nt++)st[nt]=0}xt.mesh.size=6*Ct}for(let pt=0;pt<et;pt++){const xt=o[pt];let Ct=xt.position.x+_t[xt.line]*(this._align==="justify"?xt.prevSpaces:1);this._roundPixels&&(Ct=Math.round(Ct));const Gt=Ct*i,st=xt.position.y*i,nt=xt.texture,Y=ft[nt.baseTexture.uid],gt=nt.frame,ot=nt._uvs,ht=Y.index++;Y.indices[ht*6+0]=0+ht*4,Y.indices[ht*6+1]=1+ht*4,Y.indices[ht*6+2]=2+ht*4,Y.indices[ht*6+3]=0+ht*4,Y.indices[ht*6+4]=2+ht*4,Y.indices[ht*6+5]=3+ht*4,Y.vertices[ht*8+0]=Gt,Y.vertices[ht*8+1]=st,Y.vertices[ht*8+2]=Gt+gt.width*i,Y.vertices[ht*8+3]=st,Y.vertices[ht*8+4]=Gt+gt.width*i,Y.vertices[ht*8+5]=st+gt.height*i,Y.vertices[ht*8+6]=Gt,Y.vertices[ht*8+7]=st+gt.height*i,Y.uvs[ht*8+0]=ot.x0,Y.uvs[ht*8+1]=ot.y0,Y.uvs[ht*8+2]=ot.x1,Y.uvs[ht*8+3]=ot.y1,Y.uvs[ht*8+4]=ot.x2,Y.uvs[ht*8+5]=ot.y2,Y.uvs[ht*8+6]=ot.x3,Y.uvs[ht*8+7]=ot.y3}this._textWidth=k*i,this._textHeight=(n.y+t.lineHeight)*i;for(const pt in ft){const xt=ft[pt];if(this.anchor.x!==0||this.anchor.y!==0){let nt=0;const Y=this._textWidth*this.anchor.x,gt=this._textHeight*this.anchor.y;for(let ot=0;ot<xt.total;ot++)xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt}this._maxLineHeight=Z*i;const Ct=xt.mesh.geometry.getBuffer("aVertexPosition"),Gt=xt.mesh.geometry.getBuffer("aTextureCoord"),st=xt.mesh.geometry.getIndex();Ct.data=xt.vertices,Gt.data=xt.uvs,st.data=xt.indices,Ct.update(),Gt.update(),st.update()}for(let pt=0;pt<o.length;pt++)Ad.push(o[pt]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:r,distanceFieldType:i,size:n}=_s.available[this._fontName];if(i!=="none"){const{a:o,b:h,c:f,d:A}=this.worldTransform,T=Math.sqrt(o*o+h*h),C=Math.sqrt(f*f+A*A),x=(Math.abs(T)+Math.abs(C))/2,M=this.fontSize/n,D=t._view.resolution;for(const k of this._activePagesMeshData)k.mesh.shader.uniforms.uFWidth=x*r*M*D}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=_s.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let r=0;r<this._activePagesMeshData.length;r++)this._activePagesMeshData[r].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!_s.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??_s.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:r}=this,i=_s.available[this._fontName].distanceFieldType==="none"?xd:bd;i.push(...this._activePagesMeshData);for(const n of this._activePagesMeshData)this.removeChild(n.mesh);this._activePagesMeshData=[],i.filter(n=>r[n.mesh.texture.baseTexture.uid]).forEach(n=>{n.mesh.texture=ne.EMPTY});for(const n in r)r[n].destroy(),delete r[n];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};wd.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let vm=wd;const xm=[".xml",".fnt"],Td={extension:{type:ee.LoadParser,priority:_i.Normal},name:"loadBitmapFont",test(s){return xm.includes(Pr.extname(s).toLowerCase())},async testParse(s){return ho.test(s)||Sa.test(s)},async parse(s,t,r){const i=ho.test(s)?ho.parse(s):Sa.parse(s),{src:n}=t,{page:o}=i,h=[];for(let T=0;T<o.length;++T){const C=o[T].file;let x=Pr.join(Pr.dirname(n),C);x=fa(x,n),h.push(x)}const f=await r.load(h),A=h.map(T=>f[T]);return _s.install(i,A,!0)},async load(s,t){return(await ue.ADAPTER.fetch(s)).text()},unload(s){s.destroy()}};be.add(Td);const hu=class Tn extends ps{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Tn(Object.keys(Tn.defaultOptions).reduce((r,i)=>({...r,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete Tn.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,r={}){const{availableFonts:i}=Tn;if(i[t]){const n=i[t];return this._fonts.push(n),n.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return ue.ADAPTER.fetch(t).then(n=>n.blob()).then(async n=>new Promise((o,h)=>{const f=URL.createObjectURL(n),A=new FileReader;A.onload=()=>o([f,A.result]),A.onerror=h,A.readAsDataURL(n)})).then(async([n,o])=>{const h=Object.assign({family:Pr.basename(t,Pr.extname(t)),weight:"normal",style:"normal",display:"auto",src:n,dataSrc:o,refs:1,originalUrl:t,fontFace:null},r);i[t]=h,this._fonts.push(h),this.styleID++;const f=new FontFace(h.family,`url(${h.src})`,{weight:h.weight,style:h.style,display:h.display});h.fontFace=f,await f.load(),document.fonts.add(f),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const r=t.filter(i=>!this._overrides.includes(i));r.length>0&&(this._overrides.push(...r),this.styleID++)}removeOverride(...t){const r=t.filter(i=>this._overrides.includes(i));r.length>0&&(this._overrides=this._overrides.filter(i=>!r.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,r)=>`${t}
1179
+ `;const vd=[],xd=[],bd=[],Ad=class y2 extends Zr{constructor(t,r={}){super();const{align:i,tint:n,maxWidth:o,letterSpacing:h,fontName:f,fontSize:A}=Object.assign({},y2.styleDefaults,r);if(!_s.available[f])throw new Error(`Missing BitmapFont "${f}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new rr(n),this._font=void 0,this._fontName=f,this._fontSize=A,this.text=t,this._maxWidth=o,this._maxLineHeight=0,this._letterSpacing=h,this._anchor=new $i(()=>{this.dirty=!0},this,0,0),this._roundPixels=ue.ROUND_PIXELS,this.dirty=!0,this._resolution=ue.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var It;const t=_s.available[this._fontName],r=this.fontSize,i=r/t.size,n=new Ze,o=[],h=[],f=[],A=this._text.replace(/(?:\r\n|\r)/g,`
1180
+ `)||" ",T=yd(A),C=this._maxWidth*t.size/r,x=t.distanceFieldType==="none"?vd:xd;let M=null,D=0,k=0,U=0,G=-1,X=0,J=0,Z=0,it=0;for(let pt=0;pt<T.length;pt++){const xt=T[pt],Ct=Sa(xt);if(/(?:\s)/.test(xt)&&(G=pt,X=D,it++),xt==="\r"||xt===`
1181
+ `){h.push(D),f.push(-1),k=Math.max(k,D),++U,++J,n.x=0,n.y+=t.lineHeight,M=null,it=0;continue}const Gt=t.chars[Ct];if(!Gt)continue;M&&Gt.kerning[M]&&(n.x+=Gt.kerning[M]);const st=bd.pop()||{texture:ne.EMPTY,line:0,charCode:0,prevSpaces:0,position:new Ze};st.texture=Gt.texture,st.line=U,st.charCode=Ct,st.position.x=Math.round(n.x+Gt.xOffset+this._letterSpacing/2),st.position.y=Math.round(n.y+Gt.yOffset),st.prevSpaces=it,o.push(st),D=st.position.x+Math.max(Gt.xAdvance-Gt.xOffset,Gt.texture.orig.width),n.x+=Gt.xAdvance+this._letterSpacing,Z=Math.max(Z,Gt.yOffset+Gt.texture.height),M=Ct,G!==-1&&C>0&&n.x>C&&(++J,Bs(o,1+G-J,1+pt-G),pt=G,G=-1,h.push(X),f.push(o.length>0?o[o.length-1].prevSpaces:0),k=Math.max(k,X),U++,n.x=0,n.y+=t.lineHeight,M=null,it=0)}const Q=T[T.length-1];Q!=="\r"&&Q!==`
1182
+ `&&(/(?:\s)/.test(Q)&&(D=X),h.push(D),k=Math.max(k,D),f.push(-1));const _t=[];for(let pt=0;pt<=U;pt++){let xt=0;this._align==="right"?xt=k-h[pt]:this._align==="center"?xt=(k-h[pt])/2:this._align==="justify"&&(xt=f[pt]<0?0:(k-h[pt])/f[pt]),_t.push(xt)}const et=o.length,ft={},wt=[],Rt=this._activePagesMeshData;x.push(...Rt);for(let pt=0;pt<et;pt++){const xt=o[pt].texture,Ct=xt.baseTexture.uid;if(!ft[Ct]){let Gt=x.pop();if(!Gt){const nt=new so;let Y,gt;t.distanceFieldType==="none"?(Y=new fn(ne.EMPTY),gt=Re.NORMAL):(Y=new fn(ne.EMPTY,{program:Wi.from(ym,mm),uniforms:{uFWidth:0}}),gt=Re.NORMAL_NPM);const ot=new cn(nt,Y);ot.blendMode=gt,Gt={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:ot,vertices:null,uvs:null,indices:null}}Gt.index=0,Gt.indexCount=0,Gt.vertexCount=0,Gt.uvsCount=0,Gt.total=0;const{_textureCache:st}=this;st[Ct]=st[Ct]||new ne(xt.baseTexture),Gt.mesh.texture=st[Ct],Gt.mesh.tint=this._tintColor.value,wt.push(Gt),ft[Ct]=Gt}ft[Ct].total++}for(let pt=0;pt<Rt.length;pt++)wt.includes(Rt[pt])||this.removeChild(Rt[pt].mesh);for(let pt=0;pt<wt.length;pt++)wt[pt].mesh.parent!==this&&this.addChild(wt[pt].mesh);this._activePagesMeshData=wt;for(const pt in ft){const xt=ft[pt],Ct=xt.total;if(!(((It=xt.indices)==null?void 0:It.length)>6*Ct)||xt.vertices.length<cn.BATCHABLE_SIZE*2)xt.vertices=new Float32Array(4*2*Ct),xt.uvs=new Float32Array(4*2*Ct),xt.indices=new Uint16Array(6*Ct);else{const Gt=xt.total,st=xt.vertices;for(let nt=Gt*4*2;nt<st.length;nt++)st[nt]=0}xt.mesh.size=6*Ct}for(let pt=0;pt<et;pt++){const xt=o[pt];let Ct=xt.position.x+_t[xt.line]*(this._align==="justify"?xt.prevSpaces:1);this._roundPixels&&(Ct=Math.round(Ct));const Gt=Ct*i,st=xt.position.y*i,nt=xt.texture,Y=ft[nt.baseTexture.uid],gt=nt.frame,ot=nt._uvs,ht=Y.index++;Y.indices[ht*6+0]=0+ht*4,Y.indices[ht*6+1]=1+ht*4,Y.indices[ht*6+2]=2+ht*4,Y.indices[ht*6+3]=0+ht*4,Y.indices[ht*6+4]=2+ht*4,Y.indices[ht*6+5]=3+ht*4,Y.vertices[ht*8+0]=Gt,Y.vertices[ht*8+1]=st,Y.vertices[ht*8+2]=Gt+gt.width*i,Y.vertices[ht*8+3]=st,Y.vertices[ht*8+4]=Gt+gt.width*i,Y.vertices[ht*8+5]=st+gt.height*i,Y.vertices[ht*8+6]=Gt,Y.vertices[ht*8+7]=st+gt.height*i,Y.uvs[ht*8+0]=ot.x0,Y.uvs[ht*8+1]=ot.y0,Y.uvs[ht*8+2]=ot.x1,Y.uvs[ht*8+3]=ot.y1,Y.uvs[ht*8+4]=ot.x2,Y.uvs[ht*8+5]=ot.y2,Y.uvs[ht*8+6]=ot.x3,Y.uvs[ht*8+7]=ot.y3}this._textWidth=k*i,this._textHeight=(n.y+t.lineHeight)*i;for(const pt in ft){const xt=ft[pt];if(this.anchor.x!==0||this.anchor.y!==0){let nt=0;const Y=this._textWidth*this.anchor.x,gt=this._textHeight*this.anchor.y;for(let ot=0;ot<xt.total;ot++)xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt,xt.vertices[nt++]-=Y,xt.vertices[nt++]-=gt}this._maxLineHeight=Z*i;const Ct=xt.mesh.geometry.getBuffer("aVertexPosition"),Gt=xt.mesh.geometry.getBuffer("aTextureCoord"),st=xt.mesh.geometry.getIndex();Ct.data=xt.vertices,Gt.data=xt.uvs,st.data=xt.indices,Ct.update(),Gt.update(),st.update()}for(let pt=0;pt<o.length;pt++)bd.push(o[pt]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:r,distanceFieldType:i,size:n}=_s.available[this._fontName];if(i!=="none"){const{a:o,b:h,c:f,d:A}=this.worldTransform,T=Math.sqrt(o*o+h*h),C=Math.sqrt(f*f+A*A),x=(Math.abs(T)+Math.abs(C))/2,M=this.fontSize/n,D=t._view.resolution;for(const k of this._activePagesMeshData)k.mesh.shader.uniforms.uFWidth=x*r*M*D}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=_s.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let r=0;r<this._activePagesMeshData.length;r++)this._activePagesMeshData[r].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!_s.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??_s.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:r}=this,i=_s.available[this._fontName].distanceFieldType==="none"?vd:xd;i.push(...this._activePagesMeshData);for(const n of this._activePagesMeshData)this.removeChild(n.mesh);this._activePagesMeshData=[],i.filter(n=>r[n.mesh.texture.baseTexture.uid]).forEach(n=>{n.mesh.texture=ne.EMPTY});for(const n in r)r[n].destroy(),delete r[n];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Ad.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let vm=Ad;const xm=[".xml",".fnt"],wd={extension:{type:ee.LoadParser,priority:_i.Normal},name:"loadBitmapFont",test(s){return xm.includes(Pr.extname(s).toLowerCase())},async testParse(s){return ho.test(s)||Ca.test(s)},async parse(s,t,r){const i=ho.test(s)?ho.parse(s):Ca.parse(s),{src:n}=t,{page:o}=i,h=[];for(let T=0;T<o.length;++T){const C=o[T].file;let x=Pr.join(Pr.dirname(n),C);x=ca(x,n),h.push(x)}const f=await r.load(h),A=h.map(T=>f[T]);return _s.install(i,A,!0)},async load(s,t){return(await ue.ADAPTER.fetch(s)).text()},unload(s){s.destroy()}};Te.add(wd);const hu=class Tn extends ps{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Tn(Object.keys(Tn.defaultOptions).reduce((r,i)=>({...r,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete Tn.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,r={}){const{availableFonts:i}=Tn;if(i[t]){const n=i[t];return this._fonts.push(n),n.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return ue.ADAPTER.fetch(t).then(n=>n.blob()).then(async n=>new Promise((o,h)=>{const f=URL.createObjectURL(n),A=new FileReader;A.onload=()=>o([f,A.result]),A.onerror=h,A.readAsDataURL(n)})).then(async([n,o])=>{const h=Object.assign({family:Pr.basename(t,Pr.extname(t)),weight:"normal",style:"normal",display:"auto",src:n,dataSrc:o,refs:1,originalUrl:t,fontFace:null},r);i[t]=h,this._fonts.push(h),this.styleID++;const f=new FontFace(h.family,`url(${h.src})`,{weight:h.weight,style:h.style,display:h.display});h.fontFace=f,await f.load(),document.fonts.add(f),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const r=t.filter(i=>!this._overrides.includes(i));r.length>0&&(this._overrides.push(...r),this.styleID++)}removeOverride(...t){const r=t.filter(i=>this._overrides.includes(i));r.length>0&&(this._overrides=this._overrides.filter(i=>!r.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,r)=>`${t}
1183
1183
  @font-face {
1184
1184
  font-family: "${r.family}";
1185
1185
  src: url('${r.dataSrc}');
1186
1186
  font-weight: ${r.weight};
1187
1187
  font-style: ${r.style};
1188
1188
  font-display: ${r.display};
1189
- }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=W0(t)),typeof t=="number"?X0(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const r=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&r<1&&(t+=(r*255|0).toString(16).padStart(2,"0"));const o=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${o} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${o} ${t}`}reset(){Object.assign(this,Tn.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(r=>setTimeout(r,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=ue.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};hu.availableFonts={},hu.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let $a=hu;const lo=class En extends us{constructor(t="",r={}){super(ne.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,n=ne.from(i,{scaleMode:ue.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new Ve,n.trim=new Ve,this.texture=n;const o="http://www.w3.org/2000/svg",h="http://www.w3.org/1999/xhtml",f=document.createElementNS(o,"svg"),A=document.createElementNS(o,"foreignObject"),T=document.createElementNS(h,"div"),C=document.createElementNS(h,"style");A.setAttribute("width","10000"),A.setAttribute("height","10000"),A.style.overflow="hidden",f.appendChild(A),this.maxWidth=En.defaultMaxWidth,this.maxHeight=En.defaultMaxHeight,this._domElement=T,this._styleElement=C,this._svgRoot=f,this._foreignObject=A,this._foreignObject.appendChild(C),this._foreignObject.appendChild(T),this._image=i,this._loadImage=new Image,this._autoResolution=En.defaultAutoResolution,this._resolution=En.defaultResolution??ue.RESOLUTION,this.text=t,this.style=r}measureText(t){var C,x;const{text:r,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:r,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const o=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:h,height:f}=o;(h>this.maxWidth||f>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const A=Math.min(this.maxWidth,Math.ceil(h)),T=Math.min(this.maxHeight,Math.ceil(f));return this._svgRoot.setAttribute("width",A.toString()),this._svgRoot.setAttribute("height",T.toString()),r!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(C=this._style)==null?void 0:C.toCSS(n)}),this._styleElement.textContent=(x=this._style)==null?void 0:x.toGlobalCSS()),{width:A+i.padding*2,height:T+i.padding*2}}async updateText(t=!0){const{style:r,_image:i,_loadImage:n}=this;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!this.dirty&&t)return;const{width:o,height:h}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,o)),i.height=n.height=Math.ceil(Math.max(1,h)),this._updateID++;const f=this._updateID;await new Promise(A=>{n.onload=async()=>{if(f<this._updateID){A();return}await r.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),A()};const T=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(T)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:r,_image:i,resolution:n}=this,{padding:o}=t,{baseTexture:h}=r;r.trim.width=r._frame.width=i.width/n,r.trim.height=r._frame.height=i.height/n,r.trim.x=-o,r.trim.y=-o,r.orig.width=r._frame.width-o*2,r.orig.height=r._frame.height-o*2,this._onTextureUpdate(),h.setRealSize(i.width,i.height,n),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,n,o,h,f;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},En.defaultDestroyOptions,t),super.destroy(t);const r=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=r,(n=this._svgRoot)==null||n.remove(),this._svgRoot=r,(o=this._domElement)==null||o.remove(),this._domElement=r,(h=this._foreignObject)==null||h.remove(),this._foreignObject=r,(f=this._styleElement)==null||f.remove(),this._styleElement=r,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=r,this._image.src="",this._image=r}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const r=as(this.scale.x)||1;this.scale.x=r*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const r=as(this.scale.y)||1;this.scale.y=r*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof $a?(this.ownsStyle=!1,this._style=t):t instanceof ps?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=$a.from(t)):(this.ownsStyle=!0,this._style=new $a(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};lo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},lo.defaultMaxWidth=2024,lo.defaultMaxHeight=2024,lo.defaultAutoResolution=!0;const bm=Object.freeze(Object.defineProperty({__proto__:null,ALPHA_MODES:Vr,AbstractMultiResource:$l,AccessibilityManager:Bl,AlphaFilter:Qc,AnimatedSprite:Ta,Application:kl,ArrayResource:Xc,Assets:Kn,AssetsClass:wf,Attribute:Dn,BLEND_MODES:Re,BUFFER_BITS:Lo,BUFFER_TYPE:Ei,BackgroundSystem:Gn,BaseImageResource:Hi,BasePrepare:wa,BaseRenderTexture:ol,BaseTexture:Ge,BatchDrawCall:Xo,BatchGeometry:Jh,BatchRenderer:bs,BatchShaderGenerator:gc,BatchSystem:nl,BatchTextureArray:Zo,BitmapFont:_s,BitmapFontData:ao,BitmapText:vm,BlobResource:Bf,BlurFilter:Kc,BlurFilterPass:ha,Bounds:Yn,BrowserAdapter:Lu,Buffer:br,BufferResource:In,BufferSystem:Sl,CLEAR_MODES:Ti,COLOR_MASK_BITS:Fu,Cache:Es,CanvasResource:Wc,Circle:Ln,Color:rr,ColorMatrixFilter:la,CompressedTextureResource:Cs,Container:Zr,ContextSystem:Vn,CountLimiter:cd,CubeResource:Yc,DEG_TO_RAD:sc,DRAW_MODES:Ai,DisplacementFilter:Jc,DisplayObject:pr,ENV:ys,Ellipse:Bn,EventBoundary:rf,EventSystem:ua,ExtensionType:ee,Extract:Yf,FORMATS:qt,FORMATS_TO_COMPONENTS:Uf,FXAAFilter:tf,FederatedDisplayObject:nf,FederatedEvent:nn,FederatedMouseEvent:qn,FederatedPointerEvent:di,FederatedWheelEvent:Xs,FillStyle:io,Filter:Gr,FilterState:xc,FilterSystem:cl,Framebuffer:Qo,FramebufferSystem:fl,GC_MODES:Bo,GLFramebuffer:bc,GLProgram:Rc,GLTexture:ia,GRAPHICS_CURVES:Og,GenerateTextureSystem:vl,Geometry:hs,GeometrySystem:pl,Graphics:Ql,GraphicsData:ro,GraphicsGeometry:td,HTMLText:lo,HTMLTextStyle:$a,IGLUniformData:Kp,INSTALLED:zo,INTERNAL_FORMATS:Fr,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:Jn,ImageBitmapResource:zs,ImageResource:al,LINE_CAP:fs,LINE_JOIN:ni,LineStyle:xa,LoaderParserPriority:_i,MASK_TYPES:xr,MIPMAP_MODES:wi,MSAA_QUALITY:yr,MaskData:Tc,MaskSystem:_l,Matrix:nr,Mesh:cn,MeshBatchUvs:ed,MeshGeometry:so,MeshMaterial:fn,MultisampleSystem:Cl,NineSlicePlane:Xg,NoiseFilter:ef,ObjectRenderer:Nn,ObjectRendererSystem:Pl,ObservablePoint:$i,PI_2:Fn,PRECISION:ri,ParticleContainer:Yg,ParticleRenderer:Jl,PlaneGeometry:nd,PluginSystem:ml,Point:Ze,Polygon:xs,Prepare:iu,Program:Wi,ProjectionSystem:yl,Quad:vc,QuadUv:ll,RAD_TO_DEG:ic,RENDERER_TYPE:Ya,Rectangle:Ve,RenderTexture:As,RenderTexturePool:hl,RenderTextureSystem:xl,Renderer:oa,ResizePlugin:Ol,Resource:en,RopeGeometry:od,RoundedRectangle:kn,Runner:si,SAMPLER_TYPES:le,SCALE_MODES:Gi,SHAPES:Dr,SVGResource:aa,ScissorSystem:$c,Shader:Mi,ShaderSystem:bl,SimpleMesh:Wg,SimplePlane:ad,SimpleRope:Hg,Sprite:us,SpriteMaskFilter:wc,Spritesheet:ou,StartupSystem:Xn,State:Pi,StateSystem:Oc,StencilSystem:gl,SystemManager:Nc,TARGETS:Fs,TEXT_GRADIENT:no,TYPES:Pe,TYPES_TO_BYTES_PER_COMPONENT:Xl,TYPES_TO_BYTES_PER_PIXEL:Gf,TemporaryDisplayObject:jc,Text:ru,TextFormat:ho,TextMetrics:ds,TextStyle:ps,Texture:ne,TextureGCSystem:ws,TextureMatrix:ea,TextureSystem:Al,TextureUvs:Ko,Ticker:$r,TickerPlugin:sa,TilingSprite:su,TilingSpriteRenderer:nu,TimeLimiter:hm,Transform:rn,TransformFeedback:m_,TransformFeedbackSystem:wl,UPDATE_PRIORITY:ls,UniformGroup:fi,VERSION:y_,VideoResource:Il,ViewSystem:Hn,ViewableBuffer:Vo,WRAP_MODES:Vi,XMLFormat:Ca,XMLStringFormat:Sa,accessibleTarget:of,autoDetectFormat:yd,autoDetectRenderer:Vc,autoDetectResource:Qh,cacheTextureArray:Tf,checkDataUrl:Ws,checkExtension:cs,checkMaxIfStatementsInShader:ec,convertToList:pi,copySearchParams:fa,createStringVariations:ff,createTexture:hn,createUBOElements:Fc,curves:Ss,defaultFilterVertex:El,defaultVertex:zc,detectAvif:Cf,detectCompressedTextures:Lf,detectDefaults:$f,detectMp4:Rf,detectOgv:If,detectWebm:Mf,detectWebp:Sf,extensions:be,filters:Dl,generateProgram:Ic,generateUniformBufferSync:Bc,getFontFamilyName:_f,getTestContext:lc,getUBOData:Lc,graphicsUtils:Gg,groupD8:dr,isMobile:Ci,isSingleItem:Zn,loadBitmapFont:Td,loadDDS:zf,loadImageBitmap:xf,loadJson:df,loadKTX:Xf,loadSVG:bf,loadTextures:Qn,loadTxt:pf,loadVideo:Af,loadWebFont:gf,parseDDS:Of,parseKTX:Vf,resolveCompressedTextureUrl:Wf,resolveTextureUrl:Df,settings:ue,spritesheetAsset:md,uniformParsers:Gs,unsafeEvalSupported:_c,utils:Ap},Symbol.toStringTag,{value:"Module"}));var Am=Object.defineProperty,Ys=Math.pow,wm=(s,t,r)=>t in s?Am(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,bt=(s,t,r)=>(wm(s,typeof t!="symbol"?t+"":t,r),r),_r=(s,t,r)=>new Promise((i,n)=>{var o=A=>{try{f(r.next(A))}catch(T){n(T)}},h=A=>{try{f(r.throw(A))}catch(T){n(T)}},f=A=>A.done?i(A.value):Promise.resolve(A.value).then(o,h);f((r=r.apply(s,t)).next())});const Ed=2,Cd=2;var Ma;(s=>{s.supportMoreMaskDivisions=!0,s.setOpacityFromMotion=!1})(Ma||(Ma={}));const dn={motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500},or={log(s,...t){},warn(s,...t){console.warn(`[${s}]`,...t)},error(s,...t){console.error(`[${s}]`,...t)}};function pn(s,t,r){return s<t?t:s>r?r:s}function Tm(s,t){return Math.random()*(t-s)+s}function uo(s,t,r,i,n){const o=t[i];o!==null&&typeof o===s&&(r[n]=o)}function co(s,t,r,i,n){const o=t[i];Array.isArray(o)&&(r[n]=o.filter(h=>h!==null&&typeof h===s))}function Em(s,t){t.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(r.prototype,i))})})}function Cm(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function Sm(s,t){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}class lu extends ns{constructor(t,r){super(),bt(this,"tag"),bt(this,"settings"),bt(this,"expressions",[]),bt(this,"defaultExpression"),bt(this,"currentExpression"),bt(this,"reserveExpressionIndex",-1),bt(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return _r(this,null,function*(){if(!this.definitions[t]){or.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){or.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];const r=yield this._loadExpression(t);return this.expressions[t]=r,r})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return _r(this,null,function*(){if(this.definitions.length){const t=[];for(let r=0;r<this.definitions.length;r++)this.expressions[r]!==null&&this.expressions[r]!==this.currentExpression&&r!==this.reserveExpressionIndex&&t.push(r);if(t.length){const r=Math.floor(Math.random()*t.length);return this.setExpression(r)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return _r(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const r=yield this.loadExpression(t);return!r||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=r,this._setExpression(r),!0)})}update(t,r){return this.isFinished()?!1:this.updateParameters(t,r)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const Sd=.01,Pm=40/7.5,$m=1/(.15*1e3);class Mm{constructor(){bt(this,"targetX",0),bt(this,"targetY",0),bt(this,"x",0),bt(this,"y",0),bt(this,"vx",0),bt(this,"vy",0)}focus(t,r,i=!1){this.targetX=pn(t,-1,1),this.targetY=pn(r,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const r=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(r)<Sd&&Math.abs(i)<Sd)return;const n=Math.sqrt(Ys(r,2)+Ys(i,2)),o=Pm/(1e3/t);let h=o*(r/n)-this.vx,f=o*(i/n)-this.vy;const A=Math.sqrt(Ys(h,2)+Ys(f,2)),T=o*$m*t;A>T&&(h*=T/A,f*=T/A),this.vx+=h,this.vy+=f;const C=Math.sqrt(Ys(this.vx,2)+Ys(this.vy,2)),x=.5*(Math.sqrt(Ys(T,2)+8*T*n)-T);C>x&&(this.vx*=x/C,this.vy*=x/C),this.x+=this.vx,this.y+=this.vy}}class Ra{constructor(t){bt(this,"json"),bt(this,"name"),bt(this,"url"),bt(this,"pose"),bt(this,"physics"),this.json=t;const r=t.url;if(typeof r!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=r,this.name=Cm(this.url)}resolveURL(t){return No.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let r=0;r<this.textures.length;r++)this.textures[r]=t(this.textures[r],`textures[${r}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(r=>(t.push(r),r)),t}validateFiles(t){const r=(o,h)=>{const f=this.resolveURL(o);if(!t.includes(f)){if(h)throw new Error(`File "${o}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(o=>r(o,!0)),this.getDefinedFiles().filter(o=>r(o,!1))}}var Ia=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(Ia||{});class Rm{constructor(){bt(this,"tag"),bt(this,"debug",!1),bt(this,"currentPriority",0),bt(this,"reservePriority",0),bt(this,"currentGroup"),bt(this,"currentIndex"),bt(this,"reservedGroup"),bt(this,"reservedIndex"),bt(this,"reservedIdleGroup"),bt(this,"reservedIdleIndex")}reserve(t,r,i){if(i<=0)return or.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&r===this.currentIndex)return or.log(this.tag,"Motion is already playing.",this.dump(t,r)),!1;if(t===this.reservedGroup&&r===this.reservedIndex||t===this.reservedIdleGroup&&r===this.reservedIdleIndex)return or.log(this.tag,"Motion is already reserved.",this.dump(t,r)),!1;if(i===1){if(this.currentPriority!==0)return or.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,r)),!1;if(this.reservedIdleGroup!==void 0)return or.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,r)),!1;this.setReservedIdle(t,r)}else{if(i<3){if(i<=this.currentPriority)return or.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,r)),!1;if(i<=this.reservePriority)return or.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,r)),!1}this.setReserved(t,r,i)}return!0}start(t,r,i,n){if(n===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return or.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(r,i)),!1}else{if(r!==this.reservedGroup||i!==this.reservedIndex)return or.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(r,i)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(r,i,n),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,r,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=r}setReserved(t,r,i){this.reservePriority=i,this.reservedGroup=t,this.reservedIndex=r}setReservedIdle(t,r){this.reservedIdleGroup=t,this.reservedIdleIndex=r}isActive(t,r){return t===this.currentGroup&&r===this.currentIndex||t===this.reservedGroup&&r===this.reservedIndex||t===this.reservedIdleGroup&&r===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!1}dump(t,r){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
1189
+ }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=X0(t)),typeof t=="number"?z0(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const r=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&r<1&&(t+=(r*255|0).toString(16).padStart(2,"0"));const o=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${o} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${o} ${t}`}reset(){Object.assign(this,Tn.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(r=>setTimeout(r,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=ue.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};hu.availableFonts={},hu.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Pa=hu;const lo=class En extends us{constructor(t="",r={}){super(ne.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,n=ne.from(i,{scaleMode:ue.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new Ve,n.trim=new Ve,this.texture=n;const o="http://www.w3.org/2000/svg",h="http://www.w3.org/1999/xhtml",f=document.createElementNS(o,"svg"),A=document.createElementNS(o,"foreignObject"),T=document.createElementNS(h,"div"),C=document.createElementNS(h,"style");A.setAttribute("width","10000"),A.setAttribute("height","10000"),A.style.overflow="hidden",f.appendChild(A),this.maxWidth=En.defaultMaxWidth,this.maxHeight=En.defaultMaxHeight,this._domElement=T,this._styleElement=C,this._svgRoot=f,this._foreignObject=A,this._foreignObject.appendChild(C),this._foreignObject.appendChild(T),this._image=i,this._loadImage=new Image,this._autoResolution=En.defaultAutoResolution,this._resolution=En.defaultResolution??ue.RESOLUTION,this.text=t,this.style=r}measureText(t){var C,x;const{text:r,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:r,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const o=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:h,height:f}=o;(h>this.maxWidth||f>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const A=Math.min(this.maxWidth,Math.ceil(h)),T=Math.min(this.maxHeight,Math.ceil(f));return this._svgRoot.setAttribute("width",A.toString()),this._svgRoot.setAttribute("height",T.toString()),r!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(C=this._style)==null?void 0:C.toCSS(n)}),this._styleElement.textContent=(x=this._style)==null?void 0:x.toGlobalCSS()),{width:A+i.padding*2,height:T+i.padding*2}}async updateText(t=!0){const{style:r,_image:i,_loadImage:n}=this;if(this.localStyleID!==r.styleID&&(this.dirty=!0,this.localStyleID=r.styleID),!this.dirty&&t)return;const{width:o,height:h}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,o)),i.height=n.height=Math.ceil(Math.max(1,h)),this._updateID++;const f=this._updateID;await new Promise(A=>{n.onload=async()=>{if(f<this._updateID){A();return}await r.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),A()};const T=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(T)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:r,_image:i,resolution:n}=this,{padding:o}=t,{baseTexture:h}=r;r.trim.width=r._frame.width=i.width/n,r.trim.height=r._frame.height=i.height/n,r.trim.x=-o,r.trim.y=-o,r.orig.width=r._frame.width-o*2,r.orig.height=r._frame.height-o*2,this._onTextureUpdate(),h.setRealSize(i.width,i.height,n),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,n,o,h,f;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},En.defaultDestroyOptions,t),super.destroy(t);const r=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=r,(n=this._svgRoot)==null||n.remove(),this._svgRoot=r,(o=this._domElement)==null||o.remove(),this._domElement=r,(h=this._foreignObject)==null||h.remove(),this._foreignObject=r,(f=this._styleElement)==null||f.remove(),this._styleElement=r,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=r,this._image.src="",this._image=r}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const r=as(this.scale.x)||1;this.scale.x=r*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const r=as(this.scale.y)||1;this.scale.y=r*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Pa?(this.ownsStyle=!1,this._style=t):t instanceof ps?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Pa.from(t)):(this.ownsStyle=!0,this._style=new Pa(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};lo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},lo.defaultMaxWidth=2024,lo.defaultMaxHeight=2024,lo.defaultAutoResolution=!0;const bm=Object.freeze(Object.defineProperty({__proto__:null,ALPHA_MODES:Vr,AbstractMultiResource:$l,AccessibilityManager:Bl,AlphaFilter:Zc,AnimatedSprite:wa,Application:kl,ArrayResource:zc,Assets:Kn,AssetsClass:Af,Attribute:Dn,BLEND_MODES:Re,BUFFER_BITS:Lo,BUFFER_TYPE:Ei,BackgroundSystem:Gn,BaseImageResource:Hi,BasePrepare:Aa,BaseRenderTexture:nl,BaseTexture:Ge,BatchDrawCall:Xo,BatchGeometry:Kh,BatchRenderer:bs,BatchShaderGenerator:_c,BatchSystem:sl,BatchTextureArray:Zo,BitmapFont:_s,BitmapFontData:ao,BitmapText:vm,BlobResource:Lf,BlurFilter:Qc,BlurFilterPass:aa,Bounds:Yn,BrowserAdapter:Fu,Buffer:br,BufferResource:In,BufferSystem:Sl,CLEAR_MODES:Ti,COLOR_MASK_BITS:Du,Cache:Es,CanvasResource:Xc,Circle:Ln,Color:rr,ColorMatrixFilter:ha,CompressedTextureResource:Cs,Container:Zr,ContextSystem:Vn,CountLimiter:ud,CubeResource:Hc,DEG_TO_RAD:ic,DRAW_MODES:Ai,DisplacementFilter:Kc,DisplayObject:pr,ENV:ys,Ellipse:Bn,EventBoundary:ef,EventSystem:la,ExtensionType:ee,Extract:Hf,FORMATS:qt,FORMATS_TO_COMPONENTS:Nf,FXAAFilter:Jc,FederatedDisplayObject:sf,FederatedEvent:nn,FederatedMouseEvent:qn,FederatedPointerEvent:di,FederatedWheelEvent:Xs,FillStyle:io,Filter:Gr,FilterState:vc,FilterSystem:ul,Framebuffer:Qo,FramebufferSystem:cl,GC_MODES:Bo,GLFramebuffer:xc,GLProgram:Mc,GLTexture:ia,GRAPHICS_CURVES:Og,GenerateTextureSystem:yl,Geometry:hs,GeometrySystem:dl,Graphics:Ql,GraphicsData:ro,GraphicsGeometry:Jf,HTMLText:lo,HTMLTextStyle:Pa,IGLUniformData:Kp,INSTALLED:zo,INTERNAL_FORMATS:Fr,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:Jn,ImageBitmapResource:zs,ImageResource:ol,LINE_CAP:fs,LINE_JOIN:ni,LineStyle:va,LoaderParserPriority:_i,MASK_TYPES:xr,MIPMAP_MODES:wi,MSAA_QUALITY:yr,MaskData:wc,MaskSystem:pl,Matrix:nr,Mesh:cn,MeshBatchUvs:td,MeshGeometry:so,MeshMaterial:fn,MultisampleSystem:Cl,NineSlicePlane:Xg,NoiseFilter:tf,ObjectRenderer:Nn,ObjectRendererSystem:Pl,ObservablePoint:$i,PI_2:Fn,PRECISION:ri,ParticleContainer:Yg,ParticleRenderer:Jl,PlaneGeometry:sd,PluginSystem:gl,Point:Ze,Polygon:xs,Prepare:iu,Program:Wi,ProjectionSystem:ml,Quad:yc,QuadUv:hl,RAD_TO_DEG:rc,RENDERER_TYPE:Ha,Rectangle:Ve,RenderTexture:As,RenderTexturePool:al,RenderTextureSystem:vl,Renderer:na,ResizePlugin:Ol,Resource:en,RopeGeometry:nd,RoundedRectangle:kn,Runner:si,SAMPLER_TYPES:le,SCALE_MODES:Gi,SHAPES:Dr,SVGResource:oa,ScissorSystem:Pc,Shader:Mi,ShaderSystem:xl,SimpleMesh:Wg,SimplePlane:od,SimpleRope:Hg,Sprite:us,SpriteMaskFilter:Ac,Spritesheet:ou,StartupSystem:Xn,State:Pi,StateSystem:kc,StencilSystem:_l,SystemManager:Oc,TARGETS:Fs,TEXT_GRADIENT:no,TYPES:Pe,TYPES_TO_BYTES_PER_COMPONENT:Xl,TYPES_TO_BYTES_PER_PIXEL:Uf,TemporaryDisplayObject:Yc,Text:ru,TextFormat:ho,TextMetrics:ds,TextStyle:ps,Texture:ne,TextureGCSystem:ws,TextureMatrix:ea,TextureSystem:bl,TextureUvs:Ko,Ticker:$r,TickerPlugin:Tl,TilingSprite:su,TilingSpriteRenderer:nu,TimeLimiter:hm,Transform:rn,TransformFeedback:m_,TransformFeedbackSystem:Al,UPDATE_PRIORITY:ls,UniformGroup:fi,VERSION:y_,VideoResource:Il,ViewSystem:Hn,ViewableBuffer:Vo,WRAP_MODES:Vi,XMLFormat:Ea,XMLStringFormat:Ca,accessibleTarget:nf,autoDetectFormat:md,autoDetectRenderer:Gc,autoDetectResource:Zh,cacheTextureArray:wf,checkDataUrl:Ws,checkExtension:cs,checkMaxIfStatementsInShader:tc,convertToList:pi,copySearchParams:ca,createStringVariations:cf,createTexture:hn,createUBOElements:Dc,curves:Ss,defaultFilterVertex:El,defaultVertex:Vc,detectAvif:Ef,detectCompressedTextures:Ff,detectDefaults:Pf,detectMp4:Mf,detectOgv:Rf,detectWebm:$f,detectWebp:Cf,extensions:Te,filters:Dl,generateProgram:Rc,generateUniformBufferSync:Lc,getFontFamilyName:pf,getTestContext:hc,getUBOData:Fc,graphicsUtils:Gg,groupD8:dr,isMobile:Ci,isSingleItem:Zn,loadBitmapFont:wd,loadDDS:Vf,loadImageBitmap:vf,loadJson:ff,loadKTX:zf,loadSVG:xf,loadTextures:Qn,loadTxt:df,loadVideo:bf,loadWebFont:_f,parseDDS:kf,parseKTX:Gf,resolveCompressedTextureUrl:Xf,resolveTextureUrl:If,settings:ue,spritesheetAsset:gd,uniformParsers:Gs,unsafeEvalSupported:pc,utils:Ap},Symbol.toStringTag,{value:"Module"}));var Am=Object.defineProperty,Ys=Math.pow,wm=(s,t,r)=>t in s?Am(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,bt=(s,t,r)=>(wm(s,typeof t!="symbol"?t+"":t,r),r),_r=(s,t,r)=>new Promise((i,n)=>{var o=A=>{try{f(r.next(A))}catch(T){n(T)}},h=A=>{try{f(r.throw(A))}catch(T){n(T)}},f=A=>A.done?i(A.value):Promise.resolve(A.value).then(o,h);f((r=r.apply(s,t)).next())});const Td=2,Ed=2;var $a;(s=>{s.supportMoreMaskDivisions=!0,s.setOpacityFromMotion=!1})($a||($a={}));const dn={motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500},or={log(s,...t){},warn(s,...t){console.warn(`[${s}]`,...t)},error(s,...t){console.error(`[${s}]`,...t)}};function pn(s,t,r){return s<t?t:s>r?r:s}function Tm(s,t){return Math.random()*(t-s)+s}function uo(s,t,r,i,n){const o=t[i];o!==null&&typeof o===s&&(r[n]=o)}function co(s,t,r,i,n){const o=t[i];Array.isArray(o)&&(r[n]=o.filter(h=>h!==null&&typeof h===s))}function Em(s,t){t.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(r.prototype,i))})})}function Cm(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function Sm(s,t){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}class lu extends ns{constructor(t,r){super(),bt(this,"tag"),bt(this,"settings"),bt(this,"expressions",[]),bt(this,"defaultExpression"),bt(this,"currentExpression"),bt(this,"reserveExpressionIndex",-1),bt(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return _r(this,null,function*(){if(!this.definitions[t]){or.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){or.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];const r=yield this._loadExpression(t);return this.expressions[t]=r,r})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return _r(this,null,function*(){if(this.definitions.length){const t=[];for(let r=0;r<this.definitions.length;r++)this.expressions[r]!==null&&this.expressions[r]!==this.currentExpression&&r!==this.reserveExpressionIndex&&t.push(r);if(t.length){const r=Math.floor(Math.random()*t.length);return this.setExpression(r)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return _r(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const r=yield this.loadExpression(t);return!r||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=r,this._setExpression(r),!0)})}update(t,r){return this.isFinished()?!1:this.updateParameters(t,r)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const Cd=.01,Pm=40/7.5,$m=1/(.15*1e3);class Mm{constructor(){bt(this,"targetX",0),bt(this,"targetY",0),bt(this,"x",0),bt(this,"y",0),bt(this,"vx",0),bt(this,"vy",0)}focus(t,r,i=!1){this.targetX=pn(t,-1,1),this.targetY=pn(r,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const r=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(r)<Cd&&Math.abs(i)<Cd)return;const n=Math.sqrt(Ys(r,2)+Ys(i,2)),o=Pm/(1e3/t);let h=o*(r/n)-this.vx,f=o*(i/n)-this.vy;const A=Math.sqrt(Ys(h,2)+Ys(f,2)),T=o*$m*t;A>T&&(h*=T/A,f*=T/A),this.vx+=h,this.vy+=f;const C=Math.sqrt(Ys(this.vx,2)+Ys(this.vy,2)),x=.5*(Math.sqrt(Ys(T,2)+8*T*n)-T);C>x&&(this.vx*=x/C,this.vy*=x/C),this.x+=this.vx,this.y+=this.vy}}class Ma{constructor(t){bt(this,"json"),bt(this,"name"),bt(this,"url"),bt(this,"pose"),bt(this,"physics"),this.json=t;const r=t.url;if(typeof r!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=r,this.name=Cm(this.url)}resolveURL(t){return No.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let r=0;r<this.textures.length;r++)this.textures[r]=t(this.textures[r],`textures[${r}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(r=>(t.push(r),r)),t}validateFiles(t){const r=(o,h)=>{const f=this.resolveURL(o);if(!t.includes(f)){if(h)throw new Error(`File "${o}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(o=>r(o,!0)),this.getDefinedFiles().filter(o=>r(o,!1))}}var Ra=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(Ra||{});class Rm{constructor(){bt(this,"tag"),bt(this,"debug",!1),bt(this,"currentPriority",0),bt(this,"reservePriority",0),bt(this,"currentGroup"),bt(this,"currentIndex"),bt(this,"reservedGroup"),bt(this,"reservedIndex"),bt(this,"reservedIdleGroup"),bt(this,"reservedIdleIndex")}reserve(t,r,i){if(i<=0)return or.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&r===this.currentIndex)return or.log(this.tag,"Motion is already playing.",this.dump(t,r)),!1;if(t===this.reservedGroup&&r===this.reservedIndex||t===this.reservedIdleGroup&&r===this.reservedIdleIndex)return or.log(this.tag,"Motion is already reserved.",this.dump(t,r)),!1;if(i===1){if(this.currentPriority!==0)return or.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,r)),!1;if(this.reservedIdleGroup!==void 0)return or.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,r)),!1;this.setReservedIdle(t,r)}else{if(i<3){if(i<=this.currentPriority)return or.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,r)),!1;if(i<=this.reservePriority)return or.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,r)),!1}this.setReserved(t,r,i)}return!0}start(t,r,i,n){if(n===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return or.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(r,i)),!1}else{if(r!==this.reservedGroup||i!==this.reservedIndex)return or.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(r,i)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(r,i,n),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,r,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=r}setReserved(t,r,i){this.reservePriority=i,this.reservedGroup=t,this.reservedIndex=r}setReservedIdle(t,r){this.reservedIdleGroup=t,this.reservedIdleIndex=r}isActive(t,r){return t===this.currentGroup&&r===this.currentIndex||t===this.reservedGroup&&r===this.reservedIndex||t===this.reservedIdleGroup&&r===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!1}dump(t,r){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
1190
1190
  <Requested> group = "${t}", index = ${r}
1191
1191
  `+i.map(n=>"["+n+"] "+this[n]).join(`
1192
- `)}return""}}const Im="SoundManager",_n=.5;class Mr{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(r=>r.volume=this._volume)}static add(t,r,i,n){const o=new Audio(t);return o.volume=this._volume,o.preload="auto",o.crossOrigin=n,o.addEventListener("ended",()=>{this.dispose(o),r==null||r()}),o.addEventListener("error",h=>{this.dispose(o),or.warn(Im,`Error occurred on "${t}"`,h.error),i==null||i(h.error)}),this.audios.push(o),o}static play(t){return new Promise((r,i)=>{var n;(n=t.play())==null||n.catch(o=>{t.dispatchEvent(new ErrorEvent("error",{error:o})),i(o)}),t.readyState===t.HAVE_ENOUGH_DATA?r():t.addEventListener("canplaythrough",r)})}static addContext(t){const r=new AudioContext;return this.contexts.push(r),r}static addAnalyzer(t,r){const i=r.createMediaElementSource(t),n=r.createAnalyser();return n.fftSize=256,n.minDecibels=-90,n.maxDecibels=-10,n.smoothingTimeConstant=.85,i.connect(n),n.connect(r.destination),this.analysers.push(n),n}static analyze(t){if(t!=null){const r=new Float32Array(t.fftSize);let i=0;t.getFloatTimeDomainData(r);for(const n of r)i+=n*n;return parseFloat(Math.sqrt(i/r.length*20).toFixed(1))}else return parseFloat(Math.random().toFixed(1))}static dispose(t){t.pause(),t.removeAttribute("src"),Sm(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)this.contexts[t].close();for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}bt(Mr,"audios",[]),bt(Mr,"analysers",[]),bt(Mr,"contexts",[]),bt(Mr,"_volume",_n);class fo extends ns{constructor(t,r){super(),bt(this,"tag"),bt(this,"settings"),bt(this,"motionGroups",{}),bt(this,"state",new Rm),bt(this,"currentAudio"),bt(this,"currentAnalyzer"),bt(this,"currentContext"),bt(this,"playing",!1),bt(this,"destroyed",!1),this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let r;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":r=Object.keys(this.definitions);break;case"IDLE":default:r=[this.groups.idle];break}for(const i of r)if(this.definitions[i])for(let n=0;n<this.definitions[i].length;n++)this.loadMotion(i,n).then()}loadMotion(t,r){return _r(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[r])){or.warn(this.tag,`Undefined motion at "${t}"[${r}]`);return}if(this.motionGroups[t][r]===null){or.warn(this.tag,`Cannot start motion at "${t}"[${r}] because it's already failed in loading.`);return}if(this.motionGroups[t][r])return this.motionGroups[t][r];const n=yield this._loadMotion(t,r);if(!this.destroyed)return this.motionGroups[t][r]=n??null,n})}_loadMotion(t,r){throw new Error("Not implemented.")}speak(t){return _r(this,arguments,function*(r,{volume:i=_n,expression:n,resetExpression:o=!0,crossOrigin:h,onFinish:f,onError:A}={}){let T,C,x;if(this.currentAudio&&!this.currentAudio.ended)return!1;let M;const D=r&&r.startsWith("data:");if(console.log(f),r&&!D){const U=document.createElement("a");U.href=r,r=U.href,M=r}else M="data:audio/";const k=r;if(k)try{T=Mr.add(k,(U=this)=>{console.log("Audio finished playing"),f==null||f(),o&&n&&U.expressionManager&&U.expressionManager.resetExpression(),U.currentAudio=void 0},(U,G=this)=>{console.log("Error during audio playback:",U),A==null||A(U),o&&n&&G.expressionManager&&G.expressionManager.resetExpression(),G.currentAudio=void 0},h),this.currentAudio=T,Mr.volume=i,x=Mr.addContext(this.currentAudio),this.currentContext=x,C=Mr.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=C}catch(U){return or.warn(this.tag,"Failed to create audio",M,U),!1}if(T){let U=!0;if(yield Mr.play(T).catch(X=>{or.warn(this.tag,"Failed to play audio",T.src,X),U=!1}),!U)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),n&&this.expressionManager&&this.expressionManager.setExpression(n),this.playing=!0,!0})}startMotion(t,r){return _r(this,arguments,function*(i,n,o=Ia.NORMAL,{sound:h=void 0,volume:f=_n,expression:A=void 0,resetExpression:T=!0,crossOrigin:C,onFinish:x,onError:M}={}){var D;if(!this.state.reserve(i,n,o)||this.currentAudio&&!this.currentAudio.ended&&o!=Ia.FORCE)return!1;const k=(D=this.definitions[i])==null?void 0:D[n];if(!k)return!1;this.currentAudio&&Mr.dispose(this.currentAudio);let U,G,X,J;const Z=h&&h.startsWith("data:");if(h&&!Z){const _t=document.createElement("a");_t.href=h,h=_t.href,J=h}else J=this.getSoundFile(k),J&&(J=this.settings.resolveURL(J));const it=J;if(it)try{U=Mr.add(it,(_t=this)=>{console.log("Audio finished playing"),x==null||x(),console.log(x),T&&A&&_t.expressionManager&&_t.expressionManager.resetExpression(),_t.currentAudio=void 0},(_t,et=this)=>{console.log("Error during audio playback:",_t),M==null||M(_t),T&&A&&et.expressionManager&&et.expressionManager.resetExpression(),et.currentAudio=void 0},C),this.currentAudio=U,Mr.volume=f,X=Mr.addContext(this.currentAudio),this.currentContext=X,G=Mr.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=G}catch(_t){or.warn(this.tag,"Failed to create audio",J,_t)}const Q=yield this.loadMotion(i,n);return U&&(yield Mr.play(U).catch(et=>or.warn(this.tag,"Failed to play audio",U.src,et))),this.state.start(Q,i,n,o)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),or.log(this.tag,"Start motion:",this.getMotionName(k)),this.emit("motionStart",i,n,U),A&&this.expressionManager&&this.state.shouldOverrideExpression()&&this.expressionManager.setExpression(A),this.playing=!0,this._startMotion(Q),!0):(U&&(Mr.dispose(U),this.currentAudio=void 0),!1)})}startRandomMotion(t,r){return _r(this,arguments,function*(i,n,{sound:o,volume:h=_n,expression:f,resetExpression:A=!0,crossOrigin:T,onFinish:C,onError:x}={}){const M=this.definitions[i];if(M!=null&&M.length){const D=[];for(let k=0;k<M.length;k++)this.motionGroups[i][k]!==null&&!this.state.isActive(i,k)&&D.push(k);if(D.length){const k=D[Math.floor(Math.random()*D.length)];return this.startMotion(i,k,n,{sound:o,volume:h,expression:f,resetExpression:A,crossOrigin:T,onFinish:C,onError:x})}}return!1})}stopSpeaking(){this.currentAudio&&(Mr.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,r){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Ia.IDLE)),this.updateParameters(t,r)}mouthSync(){return this.currentAnalyzer?Mr.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const r=this;r.definitions=void 0,r.motionGroups=void 0}}const Dm={x:0,y:0,width:0,height:0};class Pd extends ns{constructor(){super(...arguments),bt(this,"focusController",new Mm),bt(this,"pose"),bt(this,"physics"),bt(this,"originalWidth",0),bt(this,"originalHeight",0),bt(this,"width",0),bt(this,"height",0),bt(this,"localTransform",new nr),bt(this,"drawingMatrix",new nr),bt(this,"hitAreas",{}),bt(this,"textureFlipY",!1),bt(this,"viewport",[0,0,0,0]),bt(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,r=this.getSize();t.originalWidth=r[0],t.originalHeight=r[1];const i=Object.assign({width:Ed,height:Cd},this.getLayout());this.localTransform.scale(i.width/Ed,i.height/Cd),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const n=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,o=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*n,-this.height*o)}setupHitAreas(){const t=this.getHitAreaDefs().filter(r=>r.index>=0);for(const r of t)this.hitAreas[r.name]=r}hitTest(t,r){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,r))}isHit(t,r,i){if(!this.hitAreas[t])return!1;const n=this.hitAreas[t].index,o=this.getDrawableBounds(n,Dm);return o.x<=r&&r<=o.x+o.width&&o.y<=i&&i<=o.y+o.height}getDrawableBounds(t,r){const i=this.getDrawableVertices(t);let n=i[0],o=i[0],h=i[1],f=i[1];for(let A=0;A<i.length;A+=2){const T=i[A],C=i[A+1];n=Math.min(T,n),o=Math.max(T,o),h=Math.min(C,h),f=Math.max(C,f)}return r??(r={}),r.x=n,r.y=h,r.width=o-n,r.height=f-h,r}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,r){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const Fm="XHRLoader";class $d extends Error{constructor(t,r,i,n=!1){super(t),this.url=r,this.status=i,this.aborted=n}}const po=class ei{static createXHR(t,r,i,n,o){const h=new XMLHttpRequest;if(ei.allXhrSet.add(h),t){let f=ei.xhrMap.get(t);f?f.add(h):(f=new Set([h]),ei.xhrMap.set(t,f)),t.listeners("destroy").includes(ei.cancelXHRs)||t.once("destroy",ei.cancelXHRs)}return h.open("GET",r),h.responseType=i,h.onload=()=>{(h.status===200||h.status===0)&&h.response?n(h.response):h.onerror()},h.onerror=()=>{or.warn(Fm,`Failed to load resource as ${h.responseType} (Status ${h.status}): ${r}`),o(new $d("Network error.",r,h.status))},h.onabort=()=>o(new $d("Aborted.",r,h.status,!0)),h.onloadend=()=>{var f;ei.allXhrSet.delete(h),t&&((f=ei.xhrMap.get(t))==null||f.delete(h))},h}static cancelXHRs(){var t;(t=ei.xhrMap.get(this))==null||t.forEach(r=>{r.abort(),ei.allXhrSet.delete(r)}),ei.xhrMap.delete(this)}static release(){ei.allXhrSet.forEach(t=>t.abort()),ei.allXhrSet.clear(),ei.xhrMap=new WeakMap}};bt(po,"xhrMap",new WeakMap),bt(po,"allXhrSet",new Set),bt(po,"loader",(s,t)=>new Promise((r,i)=>{po.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,o=>{s.result=o,r()},i).send()}));let Lm=po;function Md(s,t){let r=-1;return i(0);function i(n,o){if(o)return Promise.reject(o);if(n<=r)return Promise.reject(new Error("next() called multiple times"));r=n;const h=s[n];if(!h)return Promise.resolve();try{return Promise.resolve(h(t,i.bind(null,n+1)))}catch(f){return Promise.reject(f)}}}class $s{static load(t){return Md(this.middlewares,t).then(()=>t.result)}}bt($s,"middlewares",[Lm.loader]);function Bm(s,t={}){var r;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(ne.fromURL)return ne.fromURL(s,i).catch(h=>{if(h instanceof Error)throw h;const f=new Error("Texture loading error");throw f.event=h,f});i.resourceOptions.autoLoad=!1;const n=ne.from(s,i);if(n.baseTexture.valid)return Promise.resolve(n);const o=n.baseTexture.resource;return(r=o._live2d_load)!=null||(o._live2d_load=new Promise((h,f)=>{const A=T=>{o.source.removeEventListener("error",A);const C=new Error("Texture loading error");C.event=T,f(C)};o.source.addEventListener("error",A),o.load().then(()=>h(n)).catch(A)})),o._live2d_load}function km(){}const Rd="Live2DFactory",Id=(s,t)=>_r(void 0,null,function*(){if(typeof s.source=="string"){const r=yield $s.load({url:s.source,type:"json",target:s.live2dModel});r.url=s.source,s.source=r,s.live2dModel.emit("settingsJSONLoaded",r)}return t()}),Dd=(s,t)=>_r(void 0,null,function*(){if(s.source instanceof Ra)return s.settings=s.source,t();if(typeof s.source=="object"){const r=oi.findRuntime(s.source);if(r){const i=r.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),Fd=(s,t)=>{if(s.settings){const r=oi.findRuntime(s.settings);if(r)return r.ready().then(t)}return t()},Ld=(s,t)=>_r(void 0,null,function*(){yield t();const r=s.internalModel;if(r){const i=s.settings,n=oi.findRuntime(i);if(n){const o=[];i.pose&&o.push($s.load({settings:i,url:i.pose,type:"json",target:r}).then(h=>{r.pose=n.createPose(r.coreModel,h),s.live2dModel.emit("poseLoaded",r.pose)}).catch(h=>{s.live2dModel.emit("poseLoadError",h),or.warn(Rd,"Failed to load pose.",h)})),i.physics&&o.push($s.load({settings:i,url:i.physics,type:"json",target:r}).then(h=>{r.physics=n.createPhysics(r.coreModel,h),s.live2dModel.emit("physicsLoaded",r.physics)}).catch(h=>{s.live2dModel.emit("physicsLoadError",h),or.warn(Rd,"Failed to load physics.",h)})),o.length&&(yield Promise.all(o))}}}),Bd=(s,t)=>_r(void 0,null,function*(){if(s.settings){const r=s.live2dModel,i=Promise.all(s.settings.textures.map(n=>{const o=s.settings.resolveURL(n);return Bm(o,{crossOrigin:s.options.crossOrigin})}));if(i.catch(km),yield t(),s.internalModel)r.internalModel=s.internalModel,r.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");r.textures=yield i,r.emit("textureLoaded",r.textures)}else throw new TypeError("Missing settings.")}),kd=(s,t)=>_r(void 0,null,function*(){const r=s.settings;if(r instanceof Ra){const i=oi.findRuntime(r);if(!i)throw new TypeError("Unknown model settings.");const n=yield $s.load({settings:r,url:r.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(n))throw new Error("Invalid moc data");const o=i.createCoreModel(n);return s.internalModel=i.createInternalModel(o,r,s.options),t()}throw new TypeError("Missing settings.")}),Xr=class Cn{static unzip(t,r){return _r(this,null,function*(){const i=yield Cn.getFilePaths(t),n=[];for(const h of r.getDefinedFiles()){const f=decodeURI(No.resolve(r.url,h));i.includes(f)&&n.push(f)}const o=yield Cn.getFiles(t,n);for(let h=0;h<o.length;h++){const f=n[h],A=o[h];Object.defineProperty(A,"webkitRelativePath",{value:f})}return o})}static createSettings(t){return _r(this,null,function*(){const i=(yield Cn.getFilePaths(t)).find(f=>f.endsWith("model.json")||f.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const n=yield Cn.readText(t,i);if(!n)throw new Error("Empty settings file: "+i);const o=JSON.parse(n);o.url=i;const h=Cn.live2dFactory.findRuntime(o);if(!h)throw new Error("Unknown settings JSON");return h.createModelSettings(o)})}static zipReader(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(t){return _r(this,null,function*(){throw new Error("Not implemented")})}static getFiles(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static readText(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(t){}};bt(Xr,"live2dFactory"),bt(Xr,"ZIP_PROTOCOL","zip://"),bt(Xr,"uid",0),bt(Xr,"factory",(s,t)=>_r(Xr,null,function*(){const r=s.source;let i,n,o;if(typeof r=="string"&&(r.endsWith(".zip")||r.startsWith(Xr.ZIP_PROTOCOL))?(r.startsWith(Xr.ZIP_PROTOCOL)?i=r.slice(Xr.ZIP_PROTOCOL.length):i=r,n=yield $s.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(r)&&r.length===1&&r[0]instanceof File&&r[0].name.endsWith(".zip")&&(n=r[0],i=URL.createObjectURL(n),o=r.settings),n){if(!n.size)throw new Error("Empty zip file");const h=yield Xr.zipReader(n,i);o||(o=yield Xr.createSettings(h)),o._objectURL=Xr.ZIP_PROTOCOL+Xr.uid+"/"+o.url;const f=yield Xr.unzip(h,o);f.settings=o,s.source=f,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",A=>{A.once("destroy",function(){URL.revokeObjectURL(i)})}),Xr.releaseReader(h)}return t()}));let Od=Xr;const Ii=class Wa{static resolveURL(t,r){var i;const n=(i=Wa.filesMap[t])==null?void 0:i[r];if(n===void 0)throw new Error("Cannot find this file from uploaded files: "+r);return n}static upload(t,r){return _r(this,null,function*(){const i={};for(const n of r.getDefinedFiles()){const o=decodeURI(No.resolve(r.url,n)),h=t.find(f=>f.webkitRelativePath===o);h&&(i[n]=URL.createObjectURL(h))}Wa.filesMap[r._objectURL]=i})}static createSettings(t){return _r(this,null,function*(){const r=t.find(f=>f.name.endsWith("model.json")||f.name.endsWith("model3.json"));if(!r)throw new TypeError("Settings file not found");const i=yield Wa.readText(r),n=JSON.parse(i);n.url=r.webkitRelativePath;const o=oi.findRuntime(n);if(!o)throw new Error("Unknown settings JSON");const h=o.createModelSettings(n);return h._objectURL=URL.createObjectURL(r),h})}static readText(t){return _r(this,null,function*(){return new Promise((r,i)=>{const n=new FileReader;n.onload=()=>r(n.result),n.onerror=i,n.readAsText(t,"utf8")})})}};bt(Ii,"live2dFactory"),bt(Ii,"filesMap",{}),bt(Ii,"factory",(s,t)=>_r(Ii,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const r=s.source;let i=r.settings;if(!i)i=yield Ii.createSettings(r);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(r.map(n=>encodeURI(n.webkitRelativePath))),yield Ii.upload(r,i),i.resolveURL=function(n){return Ii.resolveURL(this._objectURL,n)},s.source=i,s.live2dModel.once("modelLoaded",n=>{n.once("destroy",function(){const o=this.settings._objectURL;if(URL.revokeObjectURL(o),Ii.filesMap[o])for(const h of Object.values(Ii.filesMap[o]))URL.revokeObjectURL(h);delete Ii.filesMap[o]})})}return t()}));let Nd=Ii;const Di=class Ur{static registerRuntime(t){Ur.runtimes.push(t),Ur.runtimes.sort((r,i)=>i.version-r.version)}static findRuntime(t){for(const r of Ur.runtimes)if(r.test(t))return r}static setupLive2DModel(t,r,i){return _r(this,null,function*(){const n=new Promise(f=>t.once("textureLoaded",f)),o=new Promise(f=>t.once("modelLoaded",f)),h=Promise.all([n,o]).then(()=>t.emit("ready"));yield Md(Ur.live2DModelMiddlewares,{live2dModel:t,source:r,options:i||{}}),yield h,t.emit("load")})}static loadMotion(t,r,i){var n,o;const h=f=>t.emit("motionLoadError",r,i,f);try{const f=(n=t.definitions[r])==null?void 0:n[i];if(!f)return Promise.resolve(void 0);t.listeners("destroy").includes(Ur.releaseTasks)||t.once("destroy",Ur.releaseTasks);let A=Ur.motionTasksMap.get(t);A||(A={},Ur.motionTasksMap.set(t,A));let T=A[r];T||(T=[],A[r]=T);const C=t.getMotionFile(f);return(o=T[i])!=null||(T[i]=$s.load({url:C,settings:t.settings,type:t.motionDataType,target:t}).then(x=>{var M;const D=(M=Ur.motionTasksMap.get(t))==null?void 0:M[r];D&&delete D[i];const k=t.createMotion(x,r,f);return t.emit("motionLoaded",r,i,k),k}).catch(x=>{or.warn(t.tag,`Failed to load motion: ${C}
1192
+ `)}return""}}const Im="SoundManager",_n=.5;class Mr{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(r=>r.volume=this._volume)}static add(t,r,i,n){const o=new Audio(t);return o.volume=this._volume,o.preload="auto",o.crossOrigin=n,o.addEventListener("ended",()=>{this.dispose(o),r==null||r()}),o.addEventListener("error",h=>{this.dispose(o),or.warn(Im,`Error occurred on "${t}"`,h.error),i==null||i(h.error)}),this.audios.push(o),o}static play(t){return new Promise((r,i)=>{var n;(n=t.play())==null||n.catch(o=>{t.dispatchEvent(new ErrorEvent("error",{error:o})),i(o)}),t.readyState===t.HAVE_ENOUGH_DATA?r():t.addEventListener("canplaythrough",r)})}static addContext(t){const r=new AudioContext;return this.contexts.push(r),r}static addAnalyzer(t,r){const i=r.createMediaElementSource(t),n=r.createAnalyser();return n.fftSize=256,n.minDecibels=-90,n.maxDecibels=-10,n.smoothingTimeConstant=.85,i.connect(n),n.connect(r.destination),this.analysers.push(n),n}static analyze(t){if(t!=null){const r=new Float32Array(t.fftSize);let i=0;t.getFloatTimeDomainData(r);for(const n of r)i+=n*n;return parseFloat(Math.sqrt(i/r.length*20).toFixed(1))}else return parseFloat(Math.random().toFixed(1))}static dispose(t){t.pause(),t.removeAttribute("src"),Sm(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)this.contexts[t].close();for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}bt(Mr,"audios",[]),bt(Mr,"analysers",[]),bt(Mr,"contexts",[]),bt(Mr,"_volume",_n);class fo extends ns{constructor(t,r){super(),bt(this,"tag"),bt(this,"settings"),bt(this,"motionGroups",{}),bt(this,"state",new Rm),bt(this,"currentAudio"),bt(this,"currentAnalyzer"),bt(this,"currentContext"),bt(this,"playing",!1),bt(this,"destroyed",!1),this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let r;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":r=Object.keys(this.definitions);break;case"IDLE":default:r=[this.groups.idle];break}for(const i of r)if(this.definitions[i])for(let n=0;n<this.definitions[i].length;n++)this.loadMotion(i,n).then()}loadMotion(t,r){return _r(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[r])){or.warn(this.tag,`Undefined motion at "${t}"[${r}]`);return}if(this.motionGroups[t][r]===null){or.warn(this.tag,`Cannot start motion at "${t}"[${r}] because it's already failed in loading.`);return}if(this.motionGroups[t][r])return this.motionGroups[t][r];const n=yield this._loadMotion(t,r);if(!this.destroyed)return this.motionGroups[t][r]=n??null,n})}_loadMotion(t,r){throw new Error("Not implemented.")}speak(t){return _r(this,arguments,function*(r,{volume:i=_n,expression:n,resetExpression:o=!0,crossOrigin:h,onFinish:f,onError:A}={}){let T,C,x;if(this.currentAudio&&!this.currentAudio.ended)return!1;let M;const D=r&&r.startsWith("data:");if(console.log(f),r&&!D){const U=document.createElement("a");U.href=r,r=U.href,M=r}else M="data:audio/";const k=r;if(k)try{T=Mr.add(k,(U=this)=>{console.log("Audio finished playing"),f==null||f(),o&&n&&U.expressionManager&&U.expressionManager.resetExpression(),U.currentAudio=void 0},(U,G=this)=>{console.log("Error during audio playback:",U),A==null||A(U),o&&n&&G.expressionManager&&G.expressionManager.resetExpression(),G.currentAudio=void 0},h),this.currentAudio=T,Mr.volume=i,x=Mr.addContext(this.currentAudio),this.currentContext=x,C=Mr.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=C}catch(U){return or.warn(this.tag,"Failed to create audio",M,U),!1}if(T){let U=!0;if(yield Mr.play(T).catch(X=>{or.warn(this.tag,"Failed to play audio",T.src,X),U=!1}),!U)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),n&&this.expressionManager&&this.expressionManager.setExpression(n),this.playing=!0,!0})}startMotion(t,r){return _r(this,arguments,function*(i,n,o=Ra.NORMAL,{sound:h=void 0,volume:f=_n,expression:A=void 0,resetExpression:T=!0,crossOrigin:C,onFinish:x,onError:M}={}){var D;if(!this.state.reserve(i,n,o)||this.currentAudio&&!this.currentAudio.ended&&o!=Ra.FORCE)return!1;const k=(D=this.definitions[i])==null?void 0:D[n];if(!k)return!1;this.currentAudio&&Mr.dispose(this.currentAudio);let U,G,X,J;const Z=h&&h.startsWith("data:");if(h&&!Z){const _t=document.createElement("a");_t.href=h,h=_t.href,J=h}else J=this.getSoundFile(k),J&&(J=this.settings.resolveURL(J));const it=J;if(it)try{U=Mr.add(it,(_t=this)=>{console.log("Audio finished playing"),x==null||x(),console.log(x),T&&A&&_t.expressionManager&&_t.expressionManager.resetExpression(),_t.currentAudio=void 0},(_t,et=this)=>{console.log("Error during audio playback:",_t),M==null||M(_t),T&&A&&et.expressionManager&&et.expressionManager.resetExpression(),et.currentAudio=void 0},C),this.currentAudio=U,Mr.volume=f,X=Mr.addContext(this.currentAudio),this.currentContext=X,G=Mr.addAnalyzer(this.currentAudio,this.currentContext),this.currentAnalyzer=G}catch(_t){or.warn(this.tag,"Failed to create audio",J,_t)}const Q=yield this.loadMotion(i,n);return U&&(yield Mr.play(U).catch(et=>or.warn(this.tag,"Failed to play audio",U.src,et))),this.state.start(Q,i,n,o)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),or.log(this.tag,"Start motion:",this.getMotionName(k)),this.emit("motionStart",i,n,U),A&&this.expressionManager&&this.state.shouldOverrideExpression()&&this.expressionManager.setExpression(A),this.playing=!0,this._startMotion(Q),!0):(U&&(Mr.dispose(U),this.currentAudio=void 0),!1)})}startRandomMotion(t,r){return _r(this,arguments,function*(i,n,{sound:o,volume:h=_n,expression:f,resetExpression:A=!0,crossOrigin:T,onFinish:C,onError:x}={}){const M=this.definitions[i];if(M!=null&&M.length){const D=[];for(let k=0;k<M.length;k++)this.motionGroups[i][k]!==null&&!this.state.isActive(i,k)&&D.push(k);if(D.length){const k=D[Math.floor(Math.random()*D.length)];return this.startMotion(i,k,n,{sound:o,volume:h,expression:f,resetExpression:A,crossOrigin:T,onFinish:C,onError:x})}}return!1})}stopSpeaking(){this.currentAudio&&(Mr.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,r){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Ra.IDLE)),this.updateParameters(t,r)}mouthSync(){return this.currentAnalyzer?Mr.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const r=this;r.definitions=void 0,r.motionGroups=void 0}}const Dm={x:0,y:0,width:0,height:0};class Sd extends ns{constructor(){super(...arguments),bt(this,"focusController",new Mm),bt(this,"pose"),bt(this,"physics"),bt(this,"originalWidth",0),bt(this,"originalHeight",0),bt(this,"width",0),bt(this,"height",0),bt(this,"localTransform",new nr),bt(this,"drawingMatrix",new nr),bt(this,"hitAreas",{}),bt(this,"textureFlipY",!1),bt(this,"viewport",[0,0,0,0]),bt(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,r=this.getSize();t.originalWidth=r[0],t.originalHeight=r[1];const i=Object.assign({width:Td,height:Ed},this.getLayout());this.localTransform.scale(i.width/Td,i.height/Ed),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const n=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,o=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*n,-this.height*o)}setupHitAreas(){const t=this.getHitAreaDefs().filter(r=>r.index>=0);for(const r of t)this.hitAreas[r.name]=r}hitTest(t,r){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,r))}isHit(t,r,i){if(!this.hitAreas[t])return!1;const n=this.hitAreas[t].index,o=this.getDrawableBounds(n,Dm);return o.x<=r&&r<=o.x+o.width&&o.y<=i&&i<=o.y+o.height}getDrawableBounds(t,r){const i=this.getDrawableVertices(t);let n=i[0],o=i[0],h=i[1],f=i[1];for(let A=0;A<i.length;A+=2){const T=i[A],C=i[A+1];n=Math.min(T,n),o=Math.max(T,o),h=Math.min(C,h),f=Math.max(C,f)}return r??(r={}),r.x=n,r.y=h,r.width=o-n,r.height=f-h,r}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,r){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const Fm="XHRLoader";class Pd extends Error{constructor(t,r,i,n=!1){super(t),this.url=r,this.status=i,this.aborted=n}}const po=class ei{static createXHR(t,r,i,n,o){const h=new XMLHttpRequest;if(ei.allXhrSet.add(h),t){let f=ei.xhrMap.get(t);f?f.add(h):(f=new Set([h]),ei.xhrMap.set(t,f)),t.listeners("destroy").includes(ei.cancelXHRs)||t.once("destroy",ei.cancelXHRs)}return h.open("GET",r),h.responseType=i,h.onload=()=>{(h.status===200||h.status===0)&&h.response?n(h.response):h.onerror()},h.onerror=()=>{or.warn(Fm,`Failed to load resource as ${h.responseType} (Status ${h.status}): ${r}`),o(new Pd("Network error.",r,h.status))},h.onabort=()=>o(new Pd("Aborted.",r,h.status,!0)),h.onloadend=()=>{var f;ei.allXhrSet.delete(h),t&&((f=ei.xhrMap.get(t))==null||f.delete(h))},h}static cancelXHRs(){var t;(t=ei.xhrMap.get(this))==null||t.forEach(r=>{r.abort(),ei.allXhrSet.delete(r)}),ei.xhrMap.delete(this)}static release(){ei.allXhrSet.forEach(t=>t.abort()),ei.allXhrSet.clear(),ei.xhrMap=new WeakMap}};bt(po,"xhrMap",new WeakMap),bt(po,"allXhrSet",new Set),bt(po,"loader",(s,t)=>new Promise((r,i)=>{po.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,o=>{s.result=o,r()},i).send()}));let Lm=po;function $d(s,t){let r=-1;return i(0);function i(n,o){if(o)return Promise.reject(o);if(n<=r)return Promise.reject(new Error("next() called multiple times"));r=n;const h=s[n];if(!h)return Promise.resolve();try{return Promise.resolve(h(t,i.bind(null,n+1)))}catch(f){return Promise.reject(f)}}}class $s{static load(t){return $d(this.middlewares,t).then(()=>t.result)}}bt($s,"middlewares",[Lm.loader]);function Bm(s,t={}){var r;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(ne.fromURL)return ne.fromURL(s,i).catch(h=>{if(h instanceof Error)throw h;const f=new Error("Texture loading error");throw f.event=h,f});i.resourceOptions.autoLoad=!1;const n=ne.from(s,i);if(n.baseTexture.valid)return Promise.resolve(n);const o=n.baseTexture.resource;return(r=o._live2d_load)!=null||(o._live2d_load=new Promise((h,f)=>{const A=T=>{o.source.removeEventListener("error",A);const C=new Error("Texture loading error");C.event=T,f(C)};o.source.addEventListener("error",A),o.load().then(()=>h(n)).catch(A)})),o._live2d_load}function km(){}const Md="Live2DFactory",Rd=(s,t)=>_r(void 0,null,function*(){if(typeof s.source=="string"){const r=yield $s.load({url:s.source,type:"json",target:s.live2dModel});r.url=s.source,s.source=r,s.live2dModel.emit("settingsJSONLoaded",r)}return t()}),Id=(s,t)=>_r(void 0,null,function*(){if(s.source instanceof Ma)return s.settings=s.source,t();if(typeof s.source=="object"){const r=oi.findRuntime(s.source);if(r){const i=r.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),Dd=(s,t)=>{if(s.settings){const r=oi.findRuntime(s.settings);if(r)return r.ready().then(t)}return t()},Fd=(s,t)=>_r(void 0,null,function*(){yield t();const r=s.internalModel;if(r){const i=s.settings,n=oi.findRuntime(i);if(n){const o=[];i.pose&&o.push($s.load({settings:i,url:i.pose,type:"json",target:r}).then(h=>{r.pose=n.createPose(r.coreModel,h),s.live2dModel.emit("poseLoaded",r.pose)}).catch(h=>{s.live2dModel.emit("poseLoadError",h),or.warn(Md,"Failed to load pose.",h)})),i.physics&&o.push($s.load({settings:i,url:i.physics,type:"json",target:r}).then(h=>{r.physics=n.createPhysics(r.coreModel,h),s.live2dModel.emit("physicsLoaded",r.physics)}).catch(h=>{s.live2dModel.emit("physicsLoadError",h),or.warn(Md,"Failed to load physics.",h)})),o.length&&(yield Promise.all(o))}}}),Ld=(s,t)=>_r(void 0,null,function*(){if(s.settings){const r=s.live2dModel,i=Promise.all(s.settings.textures.map(n=>{const o=s.settings.resolveURL(n);return Bm(o,{crossOrigin:s.options.crossOrigin})}));if(i.catch(km),yield t(),s.internalModel)r.internalModel=s.internalModel,r.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");r.textures=yield i,r.emit("textureLoaded",r.textures)}else throw new TypeError("Missing settings.")}),Bd=(s,t)=>_r(void 0,null,function*(){const r=s.settings;if(r instanceof Ma){const i=oi.findRuntime(r);if(!i)throw new TypeError("Unknown model settings.");const n=yield $s.load({settings:r,url:r.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(n))throw new Error("Invalid moc data");const o=i.createCoreModel(n);return s.internalModel=i.createInternalModel(o,r,s.options),t()}throw new TypeError("Missing settings.")}),Xr=class Cn{static unzip(t,r){return _r(this,null,function*(){const i=yield Cn.getFilePaths(t),n=[];for(const h of r.getDefinedFiles()){const f=decodeURI(No.resolve(r.url,h));i.includes(f)&&n.push(f)}const o=yield Cn.getFiles(t,n);for(let h=0;h<o.length;h++){const f=n[h],A=o[h];Object.defineProperty(A,"webkitRelativePath",{value:f})}return o})}static createSettings(t){return _r(this,null,function*(){const i=(yield Cn.getFilePaths(t)).find(f=>f.endsWith("model.json")||f.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const n=yield Cn.readText(t,i);if(!n)throw new Error("Empty settings file: "+i);const o=JSON.parse(n);o.url=i;const h=Cn.live2dFactory.findRuntime(o);if(!h)throw new Error("Unknown settings JSON");return h.createModelSettings(o)})}static zipReader(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(t){return _r(this,null,function*(){throw new Error("Not implemented")})}static getFiles(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static readText(t,r){return _r(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(t){}};bt(Xr,"live2dFactory"),bt(Xr,"ZIP_PROTOCOL","zip://"),bt(Xr,"uid",0),bt(Xr,"factory",(s,t)=>_r(Xr,null,function*(){const r=s.source;let i,n,o;if(typeof r=="string"&&(r.endsWith(".zip")||r.startsWith(Xr.ZIP_PROTOCOL))?(r.startsWith(Xr.ZIP_PROTOCOL)?i=r.slice(Xr.ZIP_PROTOCOL.length):i=r,n=yield $s.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(r)&&r.length===1&&r[0]instanceof File&&r[0].name.endsWith(".zip")&&(n=r[0],i=URL.createObjectURL(n),o=r.settings),n){if(!n.size)throw new Error("Empty zip file");const h=yield Xr.zipReader(n,i);o||(o=yield Xr.createSettings(h)),o._objectURL=Xr.ZIP_PROTOCOL+Xr.uid+"/"+o.url;const f=yield Xr.unzip(h,o);f.settings=o,s.source=f,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",A=>{A.once("destroy",function(){URL.revokeObjectURL(i)})}),Xr.releaseReader(h)}return t()}));let kd=Xr;const Ii=class Xa{static resolveURL(t,r){var i;const n=(i=Xa.filesMap[t])==null?void 0:i[r];if(n===void 0)throw new Error("Cannot find this file from uploaded files: "+r);return n}static upload(t,r){return _r(this,null,function*(){const i={};for(const n of r.getDefinedFiles()){const o=decodeURI(No.resolve(r.url,n)),h=t.find(f=>f.webkitRelativePath===o);h&&(i[n]=URL.createObjectURL(h))}Xa.filesMap[r._objectURL]=i})}static createSettings(t){return _r(this,null,function*(){const r=t.find(f=>f.name.endsWith("model.json")||f.name.endsWith("model3.json"));if(!r)throw new TypeError("Settings file not found");const i=yield Xa.readText(r),n=JSON.parse(i);n.url=r.webkitRelativePath;const o=oi.findRuntime(n);if(!o)throw new Error("Unknown settings JSON");const h=o.createModelSettings(n);return h._objectURL=URL.createObjectURL(r),h})}static readText(t){return _r(this,null,function*(){return new Promise((r,i)=>{const n=new FileReader;n.onload=()=>r(n.result),n.onerror=i,n.readAsText(t,"utf8")})})}};bt(Ii,"live2dFactory"),bt(Ii,"filesMap",{}),bt(Ii,"factory",(s,t)=>_r(Ii,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const r=s.source;let i=r.settings;if(!i)i=yield Ii.createSettings(r);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(r.map(n=>encodeURI(n.webkitRelativePath))),yield Ii.upload(r,i),i.resolveURL=function(n){return Ii.resolveURL(this._objectURL,n)},s.source=i,s.live2dModel.once("modelLoaded",n=>{n.once("destroy",function(){const o=this.settings._objectURL;if(URL.revokeObjectURL(o),Ii.filesMap[o])for(const h of Object.values(Ii.filesMap[o]))URL.revokeObjectURL(h);delete Ii.filesMap[o]})})}return t()}));let Od=Ii;const Di=class Ur{static registerRuntime(t){Ur.runtimes.push(t),Ur.runtimes.sort((r,i)=>i.version-r.version)}static findRuntime(t){for(const r of Ur.runtimes)if(r.test(t))return r}static setupLive2DModel(t,r,i){return _r(this,null,function*(){const n=new Promise(f=>t.once("textureLoaded",f)),o=new Promise(f=>t.once("modelLoaded",f)),h=Promise.all([n,o]).then(()=>t.emit("ready"));yield $d(Ur.live2DModelMiddlewares,{live2dModel:t,source:r,options:i||{}}),yield h,t.emit("load")})}static loadMotion(t,r,i){var n,o;const h=f=>t.emit("motionLoadError",r,i,f);try{const f=(n=t.definitions[r])==null?void 0:n[i];if(!f)return Promise.resolve(void 0);t.listeners("destroy").includes(Ur.releaseTasks)||t.once("destroy",Ur.releaseTasks);let A=Ur.motionTasksMap.get(t);A||(A={},Ur.motionTasksMap.set(t,A));let T=A[r];T||(T=[],A[r]=T);const C=t.getMotionFile(f);return(o=T[i])!=null||(T[i]=$s.load({url:C,settings:t.settings,type:t.motionDataType,target:t}).then(x=>{var M;const D=(M=Ur.motionTasksMap.get(t))==null?void 0:M[r];D&&delete D[i];const k=t.createMotion(x,r,f);return t.emit("motionLoaded",r,i,k),k}).catch(x=>{or.warn(t.tag,`Failed to load motion: ${C}
1193
1193
  `,x),h(x)})),T[i]}catch(f){or.warn(t.tag,`Failed to load motion at "${r}"[${i}]
1194
1194
  `,f),h(f)}return Promise.resolve(void 0)}static loadExpression(t,r){var i;const n=o=>t.emit("expressionLoadError",r,o);try{const o=t.definitions[r];if(!o)return Promise.resolve(void 0);t.listeners("destroy").includes(Ur.releaseTasks)||t.once("destroy",Ur.releaseTasks);let h=Ur.expressionTasksMap.get(t);h||(h=[],Ur.expressionTasksMap.set(t,h));const f=t.getExpressionFile(o);return(i=h[r])!=null||(h[r]=$s.load({url:f,settings:t.settings,type:"json",target:t}).then(A=>{const T=Ur.expressionTasksMap.get(t);T&&delete T[r];const C=t.createExpression(A,o);return t.emit("expressionLoaded",r,C),C}).catch(A=>{or.warn(t.tag,`Failed to load expression: ${f}
1195
1195
  `,A),n(A)})),h[r]}catch(o){or.warn(t.tag,`Failed to load expression at [${r}]
1196
- `,o),n(o)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof fo?Ur.motionTasksMap.delete(this):Ur.expressionTasksMap.delete(this)}};bt(Di,"runtimes",[]),bt(Di,"urlToJSON",Id),bt(Di,"jsonToSettings",Dd),bt(Di,"waitUntilReady",Fd),bt(Di,"setupOptionals",Ld),bt(Di,"setupEssentials",Bd),bt(Di,"createInternalModel",kd),bt(Di,"live2DModelMiddlewares",[Od.factory,Nd.factory,Id,Dd,Fd,Ld,Bd,kd]),bt(Di,"motionTasksMap",new WeakMap),bt(Di,"expressionTasksMap",new WeakMap);let oi=Di;fo.prototype._loadMotion=function(s,t){return oi.loadMotion(this,s,t)},lu.prototype._loadExpression=function(s){return oi.loadExpression(this,s)},Nd.live2dFactory=oi,Od.live2dFactory=oi;const Ud=class Iu{constructor(t,{autoUpdate:r=!0,autoHitTest:i=!0,autoFocus:n=!0,autoInteract:o,ticker:h}={}){bt(this,"model"),bt(this,"destroyed",!1),bt(this,"_ticker"),bt(this,"_autoUpdate",!1),bt(this,"_autoHitTest",!1),bt(this,"_autoFocus",!1),h||(Iu.defaultTicker?h=Iu.defaultTicker:typeof PIXI<"u"&&(h=PIXI.Ticker.shared)),o!==void 0&&(i=o,n=o,or.warn(t.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=t,this.ticker=h,this.autoUpdate=r,this.autoHitTest=i,this.autoFocus=n,(i||n)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var r;this._ticker&&this._ticker.remove(Da,this),this._ticker=t,this._autoUpdate&&((r=this._ticker)==null||r.add(Da,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var r;this.destroyed||(t?this._ticker?(this._ticker.add(Da,this),this._autoUpdate=!0):or.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):((r=this._ticker)==null||r.remove(Da,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",Vd,this):this.model.off("pointertap",Vd,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",zd,this):this.model.off("globalpointermove",zd,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};bt(Ud,"defaultTicker");let Gd=Ud;function Da(){this.onTickerUpdate()}function Vd(s){this.onTap(s)}function zd(s){this.onPointerMove(s)}class Om extends rn{}const gi=new Ze,Nm=new nr;class uu extends Zr{constructor(t){super(),bt(this,"tag","Live2DModel(uninitialized)"),bt(this,"internalModel"),bt(this,"textures",[]),bt(this,"transform",new Om),bt(this,"anchor",new $i(this.onAnchorChange,this,0,0)),bt(this,"glContextID",-1),bt(this,"elapsedTime",0),bt(this,"deltaTime",0),bt(this,"automator"),this.automator=new Gd(this,t),this.once("modelLoaded",()=>this.init(t))}static from(t,r){const i=new this(r);return oi.setupLive2DModel(i,t,r).then(()=>i)}static fromSync(t,r){const i=new this(r);return oi.setupLive2DModel(i,t,r).then(r==null?void 0:r.onLoad).catch(r==null?void 0:r.onError),i}static registerTicker(t){Gd.defaultTicker=t.shared}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,r,i,{sound:n=void 0,volume:o=_n,expression:h=void 0,resetExpression:f=!0,crossOrigin:A,onFinish:T,onError:C}={}){return r===void 0?this.internalModel.motionManager.startRandomMotion(t,i,{sound:n,volume:o,expression:h,resetExpression:f,crossOrigin:A,onFinish:T,onError:C}):this.internalModel.motionManager.startMotion(t,r,i,{sound:n,volume:o,expression:h,resetExpression:f,crossOrigin:A,onFinish:T,onError:C})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:r=_n,expression:i,resetExpression:n=!0,crossOrigin:o,onFinish:h,onError:f}={}){return this.internalModel.motionManager.speak(t,{volume:r,expression:i,resetExpression:n,crossOrigin:o,onFinish:h,onError:f})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,r,i=!1){gi.x=t,gi.y=r,this.toModelPosition(gi,gi,!0);const n=gi.x/this.internalModel.originalWidth*2-1,o=gi.y/this.internalModel.originalHeight*2-1,h=Math.atan2(o,n);this.internalModel.focusController.focus(Math.cos(h),-Math.sin(h),i)}tap(t,r){const i=this.hitTest(t,r);i.length&&(or.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,r){return gi.x=t,gi.y=r,this.toModelPosition(gi,gi),this.internalModel.hitTest(gi.x,gi.y)}toModelPosition(t,r=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,r),this.internalModel.localTransform.applyInverse(r,r),r}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let r=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),r=!0);for(let o=0;o<this.textures.length;o++){const h=this.textures[o];h.valid&&((r||!h.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(h.baseTexture,0)),this.internalModel.bindTexture(o,h.baseTexture._glTextures[this.glContextID].texture),h.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const n=Nm.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(n),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),t!=null&&t.texture&&this.textures.forEach(r=>r.destroy(t.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const Um=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){Um.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class Gm extends AMotion{constructor(t){super(),bt(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:dn.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:dn.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(r=>{const i=r.calc||"add";if(i==="add"){const n=r.def||0;r.val-=n}else if(i==="mult"){const n=r.def||1;r.val/=n}this.params.push({calc:i,val:r.val,id:r.id})})}updateParamExe(t,r,i,n){this.params.forEach(o=>{t.setParamFloat(o.id,o.val*i)})}}class Vm extends lu{constructor(t,r){var i;super(t,r),bt(this,"queueManager",new MotionQueueManager),bt(this,"definitions"),this.definitions=(i=this.settings.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(r=>r.name===t)}getExpressionFile(t){return t.file}createExpression(t,r){return new Gm(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.updateParam(t)}}class zm extends fo{constructor(t,r){super(t,r),bt(this,"definitions"),bt(this,"groups",{idle:"idle"}),bt(this,"motionDataType","arraybuffer"),bt(this,"queueManager",new MotionQueueManager),bt(this,"lipSyncIds"),bt(this,"expressionManager"),this.definitions=this.settings.motions,this.init(r),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Vm(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,r,i){const n=Live2DMotion.loadMotion(t),o=r===this.groups.idle?dn.idleMotionFadingDuration:dn.motionFadingDuration;return n.setFadeIn(i.fade_in>0?i.fade_in:o),n.setFadeOut(i.fade_out>0?i.fade_out:o),n}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,r){return t.onFinishHandler=r,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class Xm{constructor(t){bt(this,"leftParam"),bt(this,"rightParam"),bt(this,"blinkInterval",4e3),bt(this,"closingDuration",100),bt(this,"closedDuration",50),bt(this,"openingDuration",150),bt(this,"eyeState",0),bt(this,"eyeParamValue",1),bt(this,"closedTimer",0),bt(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=pn(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+Tm(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const js=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Wm extends Pd{constructor(t,r,i){super(),bt(this,"settings"),bt(this,"coreModel"),bt(this,"motionManager"),bt(this,"eyeBlink"),bt(this,"eyeballXParamIndex"),bt(this,"eyeballYParamIndex"),bt(this,"angleXParamIndex"),bt(this,"angleYParamIndex"),bt(this,"angleZParamIndex"),bt(this,"bodyAngleXParamIndex"),bt(this,"breathParamIndex"),bt(this,"textureFlipY",!0),bt(this,"lipSync",!0),bt(this,"drawDataCount",0),bt(this,"disableCulling",!1),bt(this,"hasDrawn",!1),this.coreModel=t,this.settings=r,this.motionManager=new zm(r,i),this.eyeBlink=new Xm(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:o,value:h})=>this.coreModel.setParamFloat(o,h)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:o,value:h})=>this.coreModel.setPartsOpacity(o,h)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let r=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:o=>r=o,get:()=>this.disableCulling?!1:r});const i=this.coreModel.getModelContext().clipManager,n=i.setupClip;i.setupClip=(o,h)=>{n.call(i,o,h),h.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[r,i]of Object.entries(this.settings.layout)){let n=r;r==="center_x"?n="centerX":r==="center_y"&&(n="centerY"),t[n]=i}return t}updateWebGLContext(t,r){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=r;for(const[h,f]of Object.entries(i))f instanceof WebGLBuffer&&(i[h]=null);const n=this.coreModel.getModelContext().clipManager;n.curFrameNo=r;const o=t.getParameter(t.FRAMEBUFFER_BINDING);n.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,o)}bindTexture(t,r){this.coreModel.setTexture(t,r)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(r=>({id:r.id,name:r.name,index:this.coreModel.getDrawDataIndex(r.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),r=[];for(let i=0;i<this.drawDataCount;i++){const n=t.getDrawData(i);n&&r.push(n.getDrawDataID().id)}return r}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,r){return this.hasDrawn||or.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,r)}update(t,r){var i,n,o,h;super.update(t,r);const f=this.coreModel;this.emit("beforeMotionUpdate");const A=this.motionManager.update(this.coreModel,r);if(this.emit("afterMotionUpdate"),f.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(f,r),A||(n=this.eyeBlink)==null||n.update(t),this.updateFocus(),this.updateNaturalMovements(t,r),this.lipSync&&this.motionManager.currentAudio){let T=this.motionManager.mouthSync(),C=0;const x=1,M=1.2,D=.7;T>0&&(C=.4),T=Math.pow(T,D),T=pn(T*M,C,x);for(let k=0;k<this.motionManager.lipSyncIds.length;++k)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[k]),T)}(o=this.physics)==null||o.update(r),(h=this.pose)==null||h.update(t),this.emit("beforeModelUpdate"),f.update(),f.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,r){const i=r/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*Math.sin(i/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*Math.sin(i/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*Math.sin(i/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*Math.sin(i/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const r=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;js[0]=i.a,js[1]=i.b,js[4]=i.c,js[5]=i.d,js[12]=i.tx,js[13]=i.ty,this.coreModel.setMatrix(js),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=r}destroy(){super.destroy(),this.coreModel=void 0}}class _o extends Ra{constructor(t){if(super(t),bt(this,"moc"),bt(this,"textures"),bt(this,"layout"),bt(this,"hitAreas"),bt(this,"initParams"),bt(this,"initOpacities"),bt(this,"expressions"),bt(this,"motions",{}),!_o.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,co("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var r;return!!t&&typeof t.model=="string"&&((r=t.textures)==null?void 0:r.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){uo("string",t,this,"name","name"),uo("string",t,this,"pose","pose"),uo("string",t,this,"physics","physics"),uo("object",t,this,"layout","layout"),uo("object",t,this,"motions","motions"),co("object",t,this,"hit_areas","hitAreas"),co("object",t,this,"expressions","expressions"),co("object",t,this,"init_params","initParams"),co("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[r,i]of Object.entries(this.motions))for(let n=0;n<i.length;n++)i[n].file=t(i[n].file,`motions.${r}[${n}].file`),i[n].sound!==void 0&&(i[n].sound=t(i[n].sound,`motions.${r}[${n}].sound`));if(this.expressions)for(let r=0;r<this.expressions.length;r++)this.expressions[r].file=t(this.expressions[r].file,`expressions[${r}].file`)}}const Hm={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},Ym={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class jm{constructor(t,r){bt(this,"physicsHairs",[]),this.coreModel=t,r.physics_hair&&(this.physicsHairs=r.physics_hair.map(i=>{const n=new PhysicsHair;return n.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:o,ptype:h,scale:f,weight:A})=>{const T=Hm[h];T&&n.addSrcParam(T,o,f,A)}),i.targets.forEach(({id:o,ptype:h,scale:f,weight:A})=>{const T=Ym[h];T&&n.addTargetParam(T,o,f,A)}),n}))}update(t){this.physicsHairs.forEach(r=>r.update(this.coreModel,t))}}class Xd{constructor(t){bt(this,"paramIndex",-1),bt(this,"partsIndex",-1),bt(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class qm{constructor(t,r){bt(this,"opacityAnimDuration",500),bt(this,"partsGroups",[]),this.coreModel=t,r.parts_visible&&(this.partsGroups=r.parts_visible.map(({group:i})=>i.map(({id:n,link:o})=>{const h=new Xd(n);return o&&(h.link=o.map(f=>new Xd(f))),h})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(r=>{if(r.initIndex(this.coreModel),r.paramIndex>=0){const i=this.coreModel.getParamFloat(r.paramIndex)!==0;this.coreModel.setPartsOpacity(r.partsIndex,i?1:0),this.coreModel.setParamFloat(r.paramIndex,i?1:0),r.link.length>0&&r.link.forEach(n=>n.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,r){const i=this.coreModel,n=.5,o=.15;let h=1,f=t.findIndex(({paramIndex:A,partsIndex:T})=>T>=0&&i.getParamFloat(A)!==0);if(f>=0){const A=i.getPartsOpacity(t[f].partsIndex);h=pn(A+r/this.opacityAnimDuration,0,1)}else f=0,h=1;t.forEach(({partsIndex:A},T)=>{if(A>=0)if(f==T)i.setPartsOpacity(A,h);else{let C=i.getPartsOpacity(A),x;h<n?x=h*(n-1)/n+1:x=(1-h)*n/(1-n),(1-x)*(1-h)>o&&(x=1-o/(1-h)),C>x&&(C=x),i.setPartsOpacity(A,C)}})}copyOpacity(t){const r=this.coreModel;t.forEach(({partsIndex:i,link:n})=>{if(i>=0&&n){const o=r.getPartsOpacity(i);n.forEach(({partsIndex:h})=>{h>=0&&r.setPartsOpacity(h,o)})}})}update(t){this.partsGroups.forEach(r=>{this.normalizePartsOpacityGroup(r,t),this.copyOpacity(r)})}}if(oi.registerRuntime({version:2,test(s){return s instanceof _o||_o.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new _o(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),r=Live2D.getError();if(r)throw r;return t},createInternalModel(s,t,r){return new Wm(s,t,r)},createPose(s,t){return new qm(s,t)},createPhysics(s,t){return new jm(s,t)}}),!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class Ie{constructor(t,r){this.x=t||0,this.y=r||0}add(t){const r=new Ie(0,0);return r.x=this.x+t.x,r.y=this.y+t.y,r}substract(t){const r=new Ie(0,0);return r.x=this.x-t.x,r.y=this.y-t.y,r}multiply(t){const r=new Ie(0,0);return r.x=this.x*t.x,r.y=this.y*t.y,r}multiplyByScaler(t){return this.multiply(new Ie(t,t))}division(t){const r=new Ie(0,0);return r.x=this.x/t.x,r.y=this.y/t.y,r}divisionByScalar(t){return this.division(new Ie(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const Wd=class Ha{static range(t,r,i){return t<r?t=r:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let r=t;const i=r<0;i&&(r=-r);let n;return r===1/0?n=1/0:(n=Math.exp(Math.log(r)/3),n=(r/(n*n)+2*n)/3),i?-n:n}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,r){return t>r?t:r}static min(t,r){return t>r?r:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,r){const i=Math.atan2(r.y,r.x),n=Math.atan2(t.y,t.x);let o=i-n;for(;o<-Math.PI;)o+=Math.PI*2;for(;o>Math.PI;)o-=Math.PI*2;return o}static directionToDegrees(t,r){const i=this.directionToRadian(t,r);let n=this.radianToDegrees(i);return r.x-t.x>0&&(n=-n),n}static radianToDirection(t){const r=new Ie;return r.x=this.sin(t),r.y=this.cos(t),r}static quadraticEquation(t,r,i){return this.abs(t)<Ha.Epsilon?this.abs(r)<Ha.Epsilon?-i:-i/r:-(r+this.sqrt(r*r-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,r,i,n){if(this.sqrt(t)<Ha.Epsilon)return this.range(this.quadraticEquation(r,i,n),0,1);const o=r/t,h=i/t,f=n/t,A=(3*h-o*o)/3,T=A/3,C=(2*o*o*o-9*o*h+27*f)/27,x=C/2,M=x*x+T*T*T,D=.5,k=D+.01;if(M<0){const Z=-A/3,it=Z*Z*Z,Q=this.sqrt(it),_t=-C/(2*Q),et=this.range(_t,-1,1),ft=Math.acos(et),Rt=2*this.cbrt(Q),It=Rt*this.cos(ft/3)-o/3;if(this.abs(It-D)<k)return this.range(It,0,1);const pt=Rt*this.cos((ft+2*Math.PI)/3)-o/3;if(this.abs(pt-D)<k)return this.range(pt,0,1);const xt=Rt*this.cos((ft+4*Math.PI)/3)-o/3;return this.range(xt,0,1)}if(M==0){let Z;x<0?Z=this.cbrt(-x):Z=-this.cbrt(x);const it=2*Z-o/3;if(this.abs(it-D)<k)return this.range(it,0,1);const Q=-Z-o/3;return this.range(Q,0,1)}const U=this.sqrt(M),G=this.cbrt(U-x),X=this.cbrt(U+x),J=G-X-o/3;return this.range(J,0,1)}constructor(){}};Wd.Epsilon=1e-5;let Ke=Wd;class mi{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,r,i){const n=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=4;for(let h=0;h<o;++h)for(let f=0;f<o;++f)for(let A=0;A<o;++A)n[f+h*4]+=t[A+h*4]*r[f+A*4];for(let h=0;h<16;++h)i[h]=n[h]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let r=0;r<16;++r)this._tr[r]=t[r]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,r){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,r,0,1]);mi.multiply(i,this._tr,this._tr)}translate(t,r){this._tr[12]=t,this._tr[13]=r}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,r){const i=new Float32Array([t,0,0,0,0,r,0,0,0,0,1,0,0,0,0,1]);mi.multiply(i,this._tr,this._tr)}scale(t,r){this._tr[0]=t,this._tr[5]=r}multiplyByMatrix(t){mi.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new mi;for(let r=0;r<this._tr.length;r++)t._tr[r]=this._tr[r];return t}}class cu{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,r,i,n){t<0?t=0:t>1&&(t=1),r<0?r=0:r>1&&(r=1),i<0?i=0:i>1&&(i=1),n<0?n=0:n>1&&(n=1),this._modelColor.R=t,this._modelColor.G=r,this._modelColor.B=i,this._modelColor.A=n}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._modelColor=new ai,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new mi,this._mvpMatrix4x4.loadIdentity()}}var gs=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))(gs||{});class ai{constructor(t=1,r=1,i=1,n=1){this.R=t,this.G=r,this.B=i,this.A=n}}let qi=!1,gn=!1,mn;const fu={vertexOffset:0,vertexStep:2};class go{static startUp(t){if(qi)return mo("CubismFramework.startUp() is already done."),qi;if(Live2DCubismCore._isStarted)return qi=!0,!0;if(Live2DCubismCore._isStarted=!0,mn=t,mn&&Live2DCubismCore.Logging.csmSetLogFunction(mn.logFunction),qi=!0,qi){const r=Live2DCubismCore.Version.csmGetVersion(),i=(r&4278190080)>>24,n=(r&16711680)>>16,o=r&65535,h=r;mo("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+n).slice(-2),("0000"+o).slice(-4),h)}return mo("CubismFramework.startUp() is complete."),qi}static cleanUp(){qi=!1,gn=!1,mn=void 0}static initialize(t=0){if(!qi){qs("CubismFramework is not started.");return}if(gn){qs("CubismFramework.initialize() skipped, already initialized.");return}Live2DCubismCore.Memory.initializeAmountOfMemory(t),gn=!0,mo("CubismFramework.initialize() is complete.")}static dispose(){if(!qi){qs("CubismFramework is not started.");return}if(!gn){qs("CubismFramework.dispose() skipped, not initialized.");return}cu.staticRelease(),gn=!1,mo("CubismFramework.dispose() is complete.")}static isStarted(){return qi}static isInitialized(){return gn}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return mn!=null?mn.loggingLevel:5}constructor(){}}var yn=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(yn||{});const vn=typeof process<"u"&&process.env.NODE_ENV==="production"?()=>{}:s=>console.assert(s);function Hd(s,...t){Fa.print(yn.LogLevel_Debug,"[CSM][D]"+s+`
1197
- `,t)}function mo(s,...t){Fa.print(yn.LogLevel_Info,"[CSM][I]"+s+`
1198
- `,t)}function qs(s,...t){Fa.print(yn.LogLevel_Warning,"[CSM][W]"+s+`
1199
- `,t)}function Zi(s,...t){Fa.print(yn.LogLevel_Error,"[CSM][E]"+s+`
1200
- `,t)}class Fa{static print(t,r,i){if(t<go.getLoggingLevel())return;const n=go.coreLogFunction;if(!n)return;const o=r.replace(/{(\d+)}/g,(h,f)=>i[f]);n(o)}static dumpBytes(t,r,i){for(let n=0;n<i;n++)n%16==0&&n>0?this.print(t,`
1196
+ `,o),n(o)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof fo?Ur.motionTasksMap.delete(this):Ur.expressionTasksMap.delete(this)}};bt(Di,"runtimes",[]),bt(Di,"urlToJSON",Rd),bt(Di,"jsonToSettings",Id),bt(Di,"waitUntilReady",Dd),bt(Di,"setupOptionals",Fd),bt(Di,"setupEssentials",Ld),bt(Di,"createInternalModel",Bd),bt(Di,"live2DModelMiddlewares",[kd.factory,Od.factory,Rd,Id,Dd,Fd,Ld,Bd]),bt(Di,"motionTasksMap",new WeakMap),bt(Di,"expressionTasksMap",new WeakMap);let oi=Di;fo.prototype._loadMotion=function(s,t){return oi.loadMotion(this,s,t)},lu.prototype._loadExpression=function(s){return oi.loadExpression(this,s)},Od.live2dFactory=oi,kd.live2dFactory=oi;const Nd=class Ru{constructor(t,{autoUpdate:r=!0,autoHitTest:i=!0,autoFocus:n=!0,autoInteract:o,ticker:h}={}){bt(this,"model"),bt(this,"destroyed",!1),bt(this,"_ticker"),bt(this,"_autoUpdate",!1),bt(this,"_autoHitTest",!1),bt(this,"_autoFocus",!1),h||(Ru.defaultTicker?h=Ru.defaultTicker:typeof PIXI<"u"&&(h=PIXI.Ticker.shared)),o!==void 0&&(i=o,n=o,or.warn(t.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=t,this.ticker=h,this.autoUpdate=r,this.autoHitTest=i,this.autoFocus=n,(i||n)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var r;this._ticker&&this._ticker.remove(Ia,this),this._ticker=t,this._autoUpdate&&((r=this._ticker)==null||r.add(Ia,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var r;this.destroyed||(t?this._ticker?(this._ticker.add(Ia,this),this._autoUpdate=!0):or.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):((r=this._ticker)==null||r.remove(Ia,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",Gd,this):this.model.off("pointertap",Gd,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",Vd,this):this.model.off("globalpointermove",Vd,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};bt(Nd,"defaultTicker");let Ud=Nd;function Ia(){this.onTickerUpdate()}function Gd(s){this.onTap(s)}function Vd(s){this.onPointerMove(s)}class Om extends rn{}const gi=new Ze,Nm=new nr;class zd extends Zr{constructor(t){super(),bt(this,"tag","Live2DModel(uninitialized)"),bt(this,"internalModel"),bt(this,"textures",[]),bt(this,"transform",new Om),bt(this,"anchor",new $i(this.onAnchorChange,this,0,0)),bt(this,"glContextID",-1),bt(this,"elapsedTime",0),bt(this,"deltaTime",0),bt(this,"automator"),this.automator=new Ud(this,t),this.once("modelLoaded",()=>this.init(t))}static from(t,r){const i=new this(r);return oi.setupLive2DModel(i,t,r).then(()=>i)}static fromSync(t,r){const i=new this(r);return oi.setupLive2DModel(i,t,r).then(r==null?void 0:r.onLoad).catch(r==null?void 0:r.onError),i}static registerTicker(t){Ud.defaultTicker=t.shared}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,r,i,{sound:n=void 0,volume:o=_n,expression:h=void 0,resetExpression:f=!0,crossOrigin:A,onFinish:T,onError:C}={}){return r===void 0?this.internalModel.motionManager.startRandomMotion(t,i,{sound:n,volume:o,expression:h,resetExpression:f,crossOrigin:A,onFinish:T,onError:C}):this.internalModel.motionManager.startMotion(t,r,i,{sound:n,volume:o,expression:h,resetExpression:f,crossOrigin:A,onFinish:T,onError:C})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:r=_n,expression:i,resetExpression:n=!0,crossOrigin:o,onFinish:h,onError:f}={}){return this.internalModel.motionManager.speak(t,{volume:r,expression:i,resetExpression:n,crossOrigin:o,onFinish:h,onError:f})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,r,i=!1){gi.x=t,gi.y=r,this.toModelPosition(gi,gi,!0);const n=gi.x/this.internalModel.originalWidth*2-1,o=gi.y/this.internalModel.originalHeight*2-1,h=Math.atan2(o,n);this.internalModel.focusController.focus(Math.cos(h),-Math.sin(h),i)}tap(t,r){const i=this.hitTest(t,r);i.length&&(or.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,r){return gi.x=t,gi.y=r,this.toModelPosition(gi,gi),this.internalModel.hitTest(gi.x,gi.y)}toModelPosition(t,r=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,r),this.internalModel.localTransform.applyInverse(r,r),r}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let r=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),r=!0);for(let o=0;o<this.textures.length;o++){const h=this.textures[o];h.valid&&((r||!h.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(h.baseTexture,0)),this.internalModel.bindTexture(o,h.baseTexture._glTextures[this.glContextID].texture),h.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const n=Nm.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(n),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),t!=null&&t.texture&&this.textures.forEach(r=>r.destroy(t.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const Um=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){Um.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class Gm extends AMotion{constructor(t){super(),bt(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:dn.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:dn.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(r=>{const i=r.calc||"add";if(i==="add"){const n=r.def||0;r.val-=n}else if(i==="mult"){const n=r.def||1;r.val/=n}this.params.push({calc:i,val:r.val,id:r.id})})}updateParamExe(t,r,i,n){this.params.forEach(o=>{t.setParamFloat(o.id,o.val*i)})}}class Vm extends lu{constructor(t,r){var i;super(t,r),bt(this,"queueManager",new MotionQueueManager),bt(this,"definitions"),this.definitions=(i=this.settings.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(r=>r.name===t)}getExpressionFile(t){return t.file}createExpression(t,r){return new Gm(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.updateParam(t)}}class zm extends fo{constructor(t,r){super(t,r),bt(this,"definitions"),bt(this,"groups",{idle:"idle"}),bt(this,"motionDataType","arraybuffer"),bt(this,"queueManager",new MotionQueueManager),bt(this,"lipSyncIds"),bt(this,"expressionManager"),this.definitions=this.settings.motions,this.init(r),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Vm(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,r,i){const n=Live2DMotion.loadMotion(t),o=r===this.groups.idle?dn.idleMotionFadingDuration:dn.motionFadingDuration;return n.setFadeIn(i.fade_in>0?i.fade_in:o),n.setFadeOut(i.fade_out>0?i.fade_out:o),n}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,r){return t.onFinishHandler=r,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class Xm{constructor(t){bt(this,"leftParam"),bt(this,"rightParam"),bt(this,"blinkInterval",4e3),bt(this,"closingDuration",100),bt(this,"closedDuration",50),bt(this,"openingDuration",150),bt(this,"eyeState",0),bt(this,"eyeParamValue",1),bt(this,"closedTimer",0),bt(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=pn(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+Tm(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const js=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Wm extends Sd{constructor(t,r,i){super(),bt(this,"settings"),bt(this,"coreModel"),bt(this,"motionManager"),bt(this,"eyeBlink"),bt(this,"eyeballXParamIndex"),bt(this,"eyeballYParamIndex"),bt(this,"angleXParamIndex"),bt(this,"angleYParamIndex"),bt(this,"angleZParamIndex"),bt(this,"bodyAngleXParamIndex"),bt(this,"breathParamIndex"),bt(this,"textureFlipY",!0),bt(this,"lipSync",!0),bt(this,"drawDataCount",0),bt(this,"disableCulling",!1),bt(this,"hasDrawn",!1),this.coreModel=t,this.settings=r,this.motionManager=new zm(r,i),this.eyeBlink=new Xm(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:o,value:h})=>this.coreModel.setParamFloat(o,h)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:o,value:h})=>this.coreModel.setPartsOpacity(o,h)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let r=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:o=>r=o,get:()=>this.disableCulling?!1:r});const i=this.coreModel.getModelContext().clipManager,n=i.setupClip;i.setupClip=(o,h)=>{n.call(i,o,h),h.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[r,i]of Object.entries(this.settings.layout)){let n=r;r==="center_x"?n="centerX":r==="center_y"&&(n="centerY"),t[n]=i}return t}updateWebGLContext(t,r){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=r;for(const[h,f]of Object.entries(i))f instanceof WebGLBuffer&&(i[h]=null);const n=this.coreModel.getModelContext().clipManager;n.curFrameNo=r;const o=t.getParameter(t.FRAMEBUFFER_BINDING);n.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,o)}bindTexture(t,r){this.coreModel.setTexture(t,r)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(r=>({id:r.id,name:r.name,index:this.coreModel.getDrawDataIndex(r.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),r=[];for(let i=0;i<this.drawDataCount;i++){const n=t.getDrawData(i);n&&r.push(n.getDrawDataID().id)}return r}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,r){return this.hasDrawn||or.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,r)}update(t,r){var i,n,o,h;super.update(t,r);const f=this.coreModel;this.emit("beforeMotionUpdate");const A=this.motionManager.update(this.coreModel,r);if(this.emit("afterMotionUpdate"),f.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(f,r),A||(n=this.eyeBlink)==null||n.update(t),this.updateFocus(),this.updateNaturalMovements(t,r),this.lipSync&&this.motionManager.currentAudio){let T=this.motionManager.mouthSync(),C=0;const x=1,M=1.2,D=.7;T>0&&(C=.4),T=Math.pow(T,D),T=pn(T*M,C,x);for(let k=0;k<this.motionManager.lipSyncIds.length;++k)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[k]),T)}(o=this.physics)==null||o.update(r),(h=this.pose)==null||h.update(t),this.emit("beforeModelUpdate"),f.update(),f.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,r){const i=r/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*Math.sin(i/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*Math.sin(i/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*Math.sin(i/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*Math.sin(i/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const r=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;js[0]=i.a,js[1]=i.b,js[4]=i.c,js[5]=i.d,js[12]=i.tx,js[13]=i.ty,this.coreModel.setMatrix(js),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=r}destroy(){super.destroy(),this.coreModel=void 0}}class _o extends Ma{constructor(t){if(super(t),bt(this,"moc"),bt(this,"textures"),bt(this,"layout"),bt(this,"hitAreas"),bt(this,"initParams"),bt(this,"initOpacities"),bt(this,"expressions"),bt(this,"motions",{}),!_o.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,co("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var r;return!!t&&typeof t.model=="string"&&((r=t.textures)==null?void 0:r.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){uo("string",t,this,"name","name"),uo("string",t,this,"pose","pose"),uo("string",t,this,"physics","physics"),uo("object",t,this,"layout","layout"),uo("object",t,this,"motions","motions"),co("object",t,this,"hit_areas","hitAreas"),co("object",t,this,"expressions","expressions"),co("object",t,this,"init_params","initParams"),co("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[r,i]of Object.entries(this.motions))for(let n=0;n<i.length;n++)i[n].file=t(i[n].file,`motions.${r}[${n}].file`),i[n].sound!==void 0&&(i[n].sound=t(i[n].sound,`motions.${r}[${n}].sound`));if(this.expressions)for(let r=0;r<this.expressions.length;r++)this.expressions[r].file=t(this.expressions[r].file,`expressions[${r}].file`)}}const Hm={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},Ym={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class jm{constructor(t,r){bt(this,"physicsHairs",[]),this.coreModel=t,r.physics_hair&&(this.physicsHairs=r.physics_hair.map(i=>{const n=new PhysicsHair;return n.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:o,ptype:h,scale:f,weight:A})=>{const T=Hm[h];T&&n.addSrcParam(T,o,f,A)}),i.targets.forEach(({id:o,ptype:h,scale:f,weight:A})=>{const T=Ym[h];T&&n.addTargetParam(T,o,f,A)}),n}))}update(t){this.physicsHairs.forEach(r=>r.update(this.coreModel,t))}}class Xd{constructor(t){bt(this,"paramIndex",-1),bt(this,"partsIndex",-1),bt(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class qm{constructor(t,r){bt(this,"opacityAnimDuration",500),bt(this,"partsGroups",[]),this.coreModel=t,r.parts_visible&&(this.partsGroups=r.parts_visible.map(({group:i})=>i.map(({id:n,link:o})=>{const h=new Xd(n);return o&&(h.link=o.map(f=>new Xd(f))),h})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(r=>{if(r.initIndex(this.coreModel),r.paramIndex>=0){const i=this.coreModel.getParamFloat(r.paramIndex)!==0;this.coreModel.setPartsOpacity(r.partsIndex,i?1:0),this.coreModel.setParamFloat(r.paramIndex,i?1:0),r.link.length>0&&r.link.forEach(n=>n.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,r){const i=this.coreModel,n=.5,o=.15;let h=1,f=t.findIndex(({paramIndex:A,partsIndex:T})=>T>=0&&i.getParamFloat(A)!==0);if(f>=0){const A=i.getPartsOpacity(t[f].partsIndex);h=pn(A+r/this.opacityAnimDuration,0,1)}else f=0,h=1;t.forEach(({partsIndex:A},T)=>{if(A>=0)if(f==T)i.setPartsOpacity(A,h);else{let C=i.getPartsOpacity(A),x;h<n?x=h*(n-1)/n+1:x=(1-h)*n/(1-n),(1-x)*(1-h)>o&&(x=1-o/(1-h)),C>x&&(C=x),i.setPartsOpacity(A,C)}})}copyOpacity(t){const r=this.coreModel;t.forEach(({partsIndex:i,link:n})=>{if(i>=0&&n){const o=r.getPartsOpacity(i);n.forEach(({partsIndex:h})=>{h>=0&&r.setPartsOpacity(h,o)})}})}update(t){this.partsGroups.forEach(r=>{this.normalizePartsOpacityGroup(r,t),this.copyOpacity(r)})}}if(oi.registerRuntime({version:2,test(s){return s instanceof _o||_o.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new _o(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),r=Live2D.getError();if(r)throw r;return t},createInternalModel(s,t,r){return new Wm(s,t,r)},createPose(s,t){return new qm(s,t)},createPhysics(s,t){return new jm(s,t)}}),!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class Ie{constructor(t,r){this.x=t||0,this.y=r||0}add(t){const r=new Ie(0,0);return r.x=this.x+t.x,r.y=this.y+t.y,r}substract(t){const r=new Ie(0,0);return r.x=this.x-t.x,r.y=this.y-t.y,r}multiply(t){const r=new Ie(0,0);return r.x=this.x*t.x,r.y=this.y*t.y,r}multiplyByScaler(t){return this.multiply(new Ie(t,t))}division(t){const r=new Ie(0,0);return r.x=this.x/t.x,r.y=this.y/t.y,r}divisionByScalar(t){return this.division(new Ie(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const Wd=class Wa{static range(t,r,i){return t<r?t=r:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let r=t;const i=r<0;i&&(r=-r);let n;return r===1/0?n=1/0:(n=Math.exp(Math.log(r)/3),n=(r/(n*n)+2*n)/3),i?-n:n}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,r){return t>r?t:r}static min(t,r){return t>r?r:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,r){const i=Math.atan2(r.y,r.x),n=Math.atan2(t.y,t.x);let o=i-n;for(;o<-Math.PI;)o+=Math.PI*2;for(;o>Math.PI;)o-=Math.PI*2;return o}static directionToDegrees(t,r){const i=this.directionToRadian(t,r);let n=this.radianToDegrees(i);return r.x-t.x>0&&(n=-n),n}static radianToDirection(t){const r=new Ie;return r.x=this.sin(t),r.y=this.cos(t),r}static quadraticEquation(t,r,i){return this.abs(t)<Wa.Epsilon?this.abs(r)<Wa.Epsilon?-i:-i/r:-(r+this.sqrt(r*r-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,r,i,n){if(this.sqrt(t)<Wa.Epsilon)return this.range(this.quadraticEquation(r,i,n),0,1);const o=r/t,h=i/t,f=n/t,A=(3*h-o*o)/3,T=A/3,C=(2*o*o*o-9*o*h+27*f)/27,x=C/2,M=x*x+T*T*T,D=.5,k=D+.01;if(M<0){const Z=-A/3,it=Z*Z*Z,Q=this.sqrt(it),_t=-C/(2*Q),et=this.range(_t,-1,1),ft=Math.acos(et),Rt=2*this.cbrt(Q),It=Rt*this.cos(ft/3)-o/3;if(this.abs(It-D)<k)return this.range(It,0,1);const pt=Rt*this.cos((ft+2*Math.PI)/3)-o/3;if(this.abs(pt-D)<k)return this.range(pt,0,1);const xt=Rt*this.cos((ft+4*Math.PI)/3)-o/3;return this.range(xt,0,1)}if(M==0){let Z;x<0?Z=this.cbrt(-x):Z=-this.cbrt(x);const it=2*Z-o/3;if(this.abs(it-D)<k)return this.range(it,0,1);const Q=-Z-o/3;return this.range(Q,0,1)}const U=this.sqrt(M),G=this.cbrt(U-x),X=this.cbrt(U+x),J=G-X-o/3;return this.range(J,0,1)}constructor(){}};Wd.Epsilon=1e-5;let Ke=Wd;class mi{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,r,i){const n=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=4;for(let h=0;h<o;++h)for(let f=0;f<o;++f)for(let A=0;A<o;++A)n[f+h*4]+=t[A+h*4]*r[f+A*4];for(let h=0;h<16;++h)i[h]=n[h]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let r=0;r<16;++r)this._tr[r]=t[r]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,r){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,r,0,1]);mi.multiply(i,this._tr,this._tr)}translate(t,r){this._tr[12]=t,this._tr[13]=r}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,r){const i=new Float32Array([t,0,0,0,0,r,0,0,0,0,1,0,0,0,0,1]);mi.multiply(i,this._tr,this._tr)}scale(t,r){this._tr[0]=t,this._tr[5]=r}multiplyByMatrix(t){mi.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new mi;for(let r=0;r<this._tr.length;r++)t._tr[r]=this._tr[r];return t}}class uu{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,r,i,n){t<0?t=0:t>1&&(t=1),r<0?r=0:r>1&&(r=1),i<0?i=0:i>1&&(i=1),n<0?n=0:n>1&&(n=1),this._modelColor.R=t,this._modelColor.G=r,this._modelColor.B=i,this._modelColor.A=n}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._modelColor=new ai,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new mi,this._mvpMatrix4x4.loadIdentity()}}var gs=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))(gs||{});class ai{constructor(t=1,r=1,i=1,n=1){this.R=t,this.G=r,this.B=i,this.A=n}}let qi=!1,gn=!1,mn;const cu={vertexOffset:0,vertexStep:2};class go{static startUp(t){if(qi)return mo("CubismFramework.startUp() is already done."),qi;if(Live2DCubismCore._isStarted)return qi=!0,!0;if(Live2DCubismCore._isStarted=!0,mn=t,mn&&Live2DCubismCore.Logging.csmSetLogFunction(mn.logFunction),qi=!0,qi){const r=Live2DCubismCore.Version.csmGetVersion(),i=(r&4278190080)>>24,n=(r&16711680)>>16,o=r&65535,h=r;mo("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+n).slice(-2),("0000"+o).slice(-4),h)}return mo("CubismFramework.startUp() is complete."),qi}static cleanUp(){qi=!1,gn=!1,mn=void 0}static initialize(t=0){if(!qi){qs("CubismFramework is not started.");return}if(gn){qs("CubismFramework.initialize() skipped, already initialized.");return}Live2DCubismCore.Memory.initializeAmountOfMemory(t),gn=!0,mo("CubismFramework.initialize() is complete.")}static dispose(){if(!qi){qs("CubismFramework is not started.");return}if(!gn){qs("CubismFramework.dispose() skipped, not initialized.");return}uu.staticRelease(),gn=!1,mo("CubismFramework.dispose() is complete.")}static isStarted(){return qi}static isInitialized(){return gn}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return mn!=null?mn.loggingLevel:5}constructor(){}}var yn=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(yn||{});const vn=typeof process<"u"&&process.env.NODE_ENV==="production"?()=>{}:s=>console.assert(s);function Hd(s,...t){Da.print(yn.LogLevel_Debug,"[CSM][D]"+s+`
1197
+ `,t)}function mo(s,...t){Da.print(yn.LogLevel_Info,"[CSM][I]"+s+`
1198
+ `,t)}function qs(s,...t){Da.print(yn.LogLevel_Warning,"[CSM][W]"+s+`
1199
+ `,t)}function Zi(s,...t){Da.print(yn.LogLevel_Error,"[CSM][E]"+s+`
1200
+ `,t)}class Da{static print(t,r,i){if(t<go.getLoggingLevel())return;const n=go.coreLogFunction;if(!n)return;const o=r.replace(/{(\d+)}/g,(h,f)=>i[f]);n(o)}static dumpBytes(t,r,i){for(let n=0;n<i;n++)n%16==0&&n>0?this.print(t,`
1201
1201
  `):n%8==0&&n>0&&this.print(t," "),this.print(t,"{0} ",[r[n]&255]);this.print(t,`
1202
- `)}constructor(){}}class Yd{constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=[]}release(){this._weight=0}updateParameters(t,r,i){if(!r.isAvailable()||r.isFinished())return;if(!r.isStarted()){r.setIsStarted(!0),r.setStartTime(i-this._offsetSeconds),r.setFadeInStartTime(i);const f=this.getDuration();r.getEndTime()<0&&r.setEndTime(f<=0?-1:r.getStartTime()+f)}let n=this._weight;const o=this._fadeInSeconds==0?1:Ke.getEasingSine((i-r.getFadeInStartTime())/this._fadeInSeconds),h=this._fadeOutSeconds==0||r.getEndTime()<0?1:Ke.getEasingSine((r.getEndTime()-i)/this._fadeOutSeconds);n=n*o*h,r.setState(i,n),vn(0<=n&&n<=1),this.doUpdateParameters(t,i,n,r),r.getEndTime()>0&&r.getEndTime()<i&&r.setIsFinished(!0)}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}getFiredEvent(t,r){return this._firedEventValues}setFinishedMotionHandler(t){this._onFinishedMotion=t}getFinishedMotionHandler(){return this._onFinishedMotion}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){}getModelOpacityValue(){return 1}}const jd=1;class du extends Yd{static create(t){const r=new du;return r.parse(t),r}doUpdateParameters(t,r,i,n){for(let o=0;o<this._parameters.length;++o){const h=this._parameters[o];switch(h.blendType){case 0:{t.addParameterValueById(h.parameterId,h.value,i);break}case 1:{t.multiplyParameterValueById(h.parameterId,h.value,i);break}case 2:{t.setParameterValueById(h.parameterId,h.value,i);break}}}}parse(t){this.setFadeInTime(t.FadeInTime!=null?t.FadeInTime:jd),this.setFadeOutTime(t.FadeOutTime!=null?t.FadeOutTime:jd);const r=(t.Parameters||[]).length;for(let i=0;i<r;++i){const n=t.Parameters[i],o=n.Id,h=n.Value;let f;!n.Blend||n.Blend==="Add"?f=0:n.Blend==="Multiply"?f=1:n.Blend==="Overwrite"?f=2:f=0;const A={parameterId:o,blendType:f,value:h};this._parameters.push(A)}}constructor(){super(),this._parameters=[]}}class Zm{constructor(){this._autoDelete=!1,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&this._motion.release()}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,r){const i=r+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,r){this._stateTimeSeconds=t,this._stateWeight=r}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}}class qd{constructor(){this._userTimeSeconds=0,this._eventCustomData=null,this._motions=[]}release(){for(let t=0;t<this._motions.length;++t)this._motions[t]&&this._motions[t].release();this._motions=void 0}startMotion(t,r,i){if(t==null)return Qm;let n;for(let o=0;o<this._motions.length;++o)n=this._motions[o],n!=null&&n.setFadeOut(n._motion.getFadeOutTime());return n=new Zm,n._autoDelete=r,n._motion=t,this._motions.push(n),n._motionQueueEntryHandle}isFinished(){let t=0;for(;t<this._motions.length;){const r=this._motions[t];if(r==null){this._motions.splice(t,1);continue}if(r._motion==null){r.release(),this._motions.splice(t,1);continue}if(!r.isFinished())return!1;t++}return!0}isFinishedByHandle(t){for(let r=0;r<this._motions.length;r++){const i=this._motions[r];if(i!=null&&i._motionQueueEntryHandle==t&&!i.isFinished())return!1}return!0}stopAllMotions(){for(let t=0;t<this._motions.length;t++){const r=this._motions[t];r!=null&&r.release()}this._motions=[]}getCubismMotionQueueEntry(t){return this._motions.find(r=>r!=null&&r._motionQueueEntryHandle==t)}setEventCallback(t,r=null){this._eventCallBack=t,this._eventCustomData=r}doUpdateMotion(t,r){let i=!1,n=0;for(;n<this._motions.length;){const o=this._motions[n];if(o==null){this._motions.splice(n,1);continue}const h=o._motion;if(h==null){o.release(),this._motions.splice(n,1);continue}h.updateParameters(t,o,r),i=!0;const f=h.getFiredEvent(o.getLastCheckEventSeconds()-o.getStartTime(),r-o.getStartTime());for(let A=0;A<f.length;++A)this._eventCallBack(this,f[A],this._eventCustomData);o.setLastCheckEventSeconds(r),o.isFinished()?(o.release(),this._motions.splice(n,1)):(o.isTriggeredFadeOut()&&o.startFadeOut(o.getFadeOutSeconds(),r),n++)}return i}}const Qm=-1;class Km extends lu{constructor(t,r){var i;super(t,r),bt(this,"queueManager",new qd),bt(this,"definitions"),this.definitions=(i=t.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(r=>r.Name===t)}getExpressionFile(t){return t.File}createExpression(t,r){return du.create(t)}_setExpression(t){return this.queueManager.startMotion(t,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.doUpdateMotion(t,r)}}var Qi=(s=>(s[s.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",s[s.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",s[s.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",s))(Qi||{}),Ki=(s=>(s[s.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",s[s.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",s[s.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",s[s.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",s))(Ki||{});class Ms{constructor(t=0,r=0){this.time=t,this.value=r}}class Jm{constructor(){this.basePointIndex=0,this.segmentType=0}}class t1{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class e1{constructor(){this.fireTime=0,this.value=""}}class r1{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class Zd{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return t==0?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,r){return this._json.Curves[t].Segments[r]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var Qd=(s=>(s[s.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",s))(Qd||{});const i1="EyeBlink",s1="LipSync",n1="Model",o1="Parameter",a1="PartOpacity",La="Opacity",h1=!1;function yi(s,t,r){const i=new Ms;return i.time=s.time+(t.time-s.time)*r,i.value=s.value+(t.value-s.value)*r,i}function l1(s,t){let r=(t-s[0].time)/(s[1].time-s[0].time);return r<0&&(r=0),s[0].value+(s[1].value-s[0].value)*r}function u1(s,t){let r=(t-s[0].time)/(s[3].time-s[0].time);r<0&&(r=0);const i=yi(s[0],s[1],r),n=yi(s[1],s[2],r),o=yi(s[2],s[3],r),h=yi(i,n,r),f=yi(n,o,r);return yi(h,f,r).value}function c1(s,t){const r=t,i=s[0].time,n=s[3].time,o=s[1].time,h=s[2].time,f=n-3*h+3*o-i,A=3*h-6*o+3*i,T=3*o-3*i,C=i-r,x=Ke.cardanoAlgorithmForBezier(f,A,T,C),M=yi(s[0],s[1],x),D=yi(s[1],s[2],x),k=yi(s[2],s[3],x),U=yi(M,D,x),G=yi(D,k,x);return yi(U,G,x).value}function f1(s,t){return s[0].value}function d1(s,t){return s[1].value}function pu(s,t,r){const i=s.curves[t];let n=-1;const o=i.baseSegmentIndex+i.segmentCount;let h=0;for(let A=i.baseSegmentIndex;A<o;++A)if(h=s.segments[A].basePointIndex+(s.segments[A].segmentType==Ki.CubismMotionSegmentType_Bezier?3:1),s.points[h].time>r){n=A;break}if(n==-1)return s.points[h].value;const f=s.segments[n];return f.evaluate(s.points.slice(f.basePointIndex),r)}class _u extends Yd{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._modelOpacity=1}static create(t,r){const i=new _u;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=r,i}doUpdateParameters(t,r,i,n){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=i1),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=s1),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=La);let o=r-n.getStartTime();o<0&&(o=0);let h=Number.MAX_VALUE,f=Number.MAX_VALUE;const A=64;let T=0,C=0;this._eyeBlinkParameterIds.length>A&&Hd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>A&&Hd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const x=this._fadeInSeconds<=0?1:Ke.getEasingSine((r-n.getFadeInStartTime())/this._fadeInSeconds),M=this._fadeOutSeconds<=0||n.getEndTime()<0?1:Ke.getEasingSine((n.getEndTime()-r)/this._fadeOutSeconds);let D,k,U,G=o;if(this._isLoop)for(;G>this._motionData.duration;)G-=this._motionData.duration;const X=this._motionData.curves;for(k=0;k<this._motionData.curveCount&&X[k].type==Qi.CubismMotionCurveTarget_Model;++k)D=pu(this._motionData,k,G),X[k].id==this._modelCurveIdEyeBlink?f=D:X[k].id==this._modelCurveIdLipSync?h=D:X[k].id==this._modelCurveIdOpacity&&(this._modelOpacity=D,t.setModelOapcity(this.getModelOpacityValue()));for(;k<this._motionData.curveCount&&X[k].type==Qi.CubismMotionCurveTarget_Parameter;++k){if(U=t.getParameterIndex(X[k].id),U==-1)continue;const J=t.getParameterValueByIndex(U);if(D=pu(this._motionData,k,G),f!=Number.MAX_VALUE){for(let it=0;it<this._eyeBlinkParameterIds.length&&it<A;++it)if(this._eyeBlinkParameterIds[it]==X[k].id){D*=f,C|=1<<it;break}}if(h!=Number.MAX_VALUE){for(let it=0;it<this._lipSyncParameterIds.length&&it<A;++it)if(this._lipSyncParameterIds[it]==X[k].id){D+=h,T|=1<<it;break}}let Z;if(X[k].fadeInTime<0&&X[k].fadeOutTime<0)Z=J+(D-J)*i;else{let it,Q;X[k].fadeInTime<0?it=x:it=X[k].fadeInTime==0?1:Ke.getEasingSine((r-n.getFadeInStartTime())/X[k].fadeInTime),X[k].fadeOutTime<0?Q=M:Q=X[k].fadeOutTime==0||n.getEndTime()<0?1:Ke.getEasingSine((n.getEndTime()-r)/X[k].fadeOutTime);const _t=this._weight*it*Q;Z=J+(D-J)*_t}t.setParameterValueByIndex(U,Z,1)}{if(f!=Number.MAX_VALUE)for(let J=0;J<this._eyeBlinkParameterIds.length&&J<A;++J){const Z=t.getParameterValueById(this._eyeBlinkParameterIds[J]);if(C>>J&1)continue;const it=Z+(f-Z)*i;t.setParameterValueById(this._eyeBlinkParameterIds[J],it)}if(h!=Number.MAX_VALUE)for(let J=0;J<this._lipSyncParameterIds.length&&J<A;++J){const Z=t.getParameterValueById(this._lipSyncParameterIds[J]);if(T>>J&1)continue;const it=Z+(h-Z)*i;t.setParameterValueById(this._lipSyncParameterIds[J],it)}}for(;k<this._motionData.curveCount&&X[k].type==Qi.CubismMotionCurveTarget_PartOpacity;++k)if(D=pu(this._motionData,k,G),Ma.setOpacityFromMotion)t.setPartOpacityById(X[k].id,D);else{if(U=t.getParameterIndex(X[k].id),U==-1)continue;t.setParameterValueByIndex(U,D)}o>=this._motionData.duration&&(this._isLoop?(n.setStartTime(r),this._isLoopFadeIn&&n.setFadeInStartTime(r)):(this._onFinishedMotion&&this._onFinishedMotion(this),n.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){this._isLoop=t}isLoop(){return this._isLoop}setIsLoopFadeIn(t){this._isLoopFadeIn=t}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,r){const i=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==i[n].id){i[n].fadeInTime=r;return}}setParameterFadeOutTime(t,r){const i=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==i[n].id){i[n].fadeOutTime=r;return}}getParameterFadeInTime(t){const r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeInTime;return-1}getParameterFadeOutTime(t){const r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeOutTime;return-1}setEffectIds(t,r){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=r}release(){this._motionData=void 0}parse(t){this._motionData=new r1;const r=new Zd(t);this._motionData.duration=r.getMotionDuration(),this._motionData.loop=r.isMotionLoop(),this._motionData.curveCount=r.getMotionCurveCount(),this._motionData.fps=r.getMotionFps(),this._motionData.eventCount=r.getEventCount();const i=r.getEvaluationOptionFlag(Qd.EvaluationOptionFlag_AreBeziersRistricted),n=r.getMotionFadeInTime(),o=r.getMotionFadeOutTime();n!==void 0?this._fadeInSeconds=n<0?1:n:this._fadeInSeconds=1,o!==void 0?this._fadeOutSeconds=o<0?1:o:this._fadeOutSeconds=1,this._motionData.curves=Array.from({length:this._motionData.curveCount}).map(()=>new t1),this._motionData.segments=Array.from({length:r.getMotionTotalSegmentCount()}).map(()=>new Jm),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new e1),this._motionData.points=[];let h=0,f=0;for(let A=0;A<this._motionData.curveCount;++A){const T=this._motionData.curves[A];switch(r.getMotionCurveTarget(A)){case n1:T.type=Qi.CubismMotionCurveTarget_Model;break;case o1:T.type=Qi.CubismMotionCurveTarget_Parameter;break;case a1:T.type=Qi.CubismMotionCurveTarget_PartOpacity;break;default:qs('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!')}T.id=r.getMotionCurveId(A),T.baseSegmentIndex=f;const C=r.getMotionCurveFadeInTime(A),x=r.getMotionCurveFadeOutTime(A);T.fadeInTime=C!==void 0?C:-1,T.fadeOutTime=x!==void 0?x:-1;for(let M=0;M<r.getMotionCurveSegmentCount(A);){switch(M==0?(this._motionData.segments[f].basePointIndex=h,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M),r.getMotionCurveSegment(A,M+1)),h+=1,M+=2):this._motionData.segments[f].basePointIndex=h-1,r.getMotionCurveSegment(A,M)){case Ki.CubismMotionSegmentType_Linear:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_Linear,this._motionData.segments[f].evaluate=l1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),h+=1,M+=3;break}case Ki.CubismMotionSegmentType_Bezier:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_Bezier,i||h1?this._motionData.segments[f].evaluate=u1:this._motionData.segments[f].evaluate=c1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),this._motionData.points[h+1]=new Ms(r.getMotionCurveSegment(A,M+3),r.getMotionCurveSegment(A,M+4)),this._motionData.points[h+2]=new Ms(r.getMotionCurveSegment(A,M+5),r.getMotionCurveSegment(A,M+6)),h+=3,M+=7;break}case Ki.CubismMotionSegmentType_Stepped:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_Stepped,this._motionData.segments[f].evaluate=f1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),h+=1,M+=3;break}case Ki.CubismMotionSegmentType_InverseStepped:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_InverseStepped,this._motionData.segments[f].evaluate=d1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),h+=1,M+=3;break}default:{vn(0);break}}++T.segmentCount,++f}this._motionData.curves.push(T)}for(let A=0;A<r.getEventCount();++A)this._motionData.events[A].fireTime=r.getEventTime(A),this._motionData.events[A].value=r.getEventValue(A);r.release()}getFiredEvent(t,r){this._firedEventValues.length=0;for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=r&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const r=this._motionData.curves[t];if(r.type==Qi.CubismMotionCurveTarget_Model&&r.id===La)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const r=this._motionData.curves[t];if(r.type==Qi.CubismMotionCurveTarget_Model&&r.id===La)return t}return-1}getModelOpacityId(t){if(t!=-1){const r=this._motionData.curves[t];if(r.type==Qi.CubismMotionCurveTarget_Model&&r.id===La)return r.id}}getModelOpacityValue(){return this._modelOpacity}}class p1 extends fo{constructor(t,r){var i;super(t,r),bt(this,"definitions"),bt(this,"groups",{idle:"Idle"}),bt(this,"motionDataType","json"),bt(this,"queueManager",new qd),bt(this,"expressionManager"),bt(this,"eyeBlinkIds"),bt(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=(i=t.motions)!=null?i:{},this.eyeBlinkIds=t.getEyeBlinkParameters()||[];const n=t.getLipSyncParameters();n!=null&&n.length&&(this.lipSyncIds=n),this.init(r)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Km(this.settings,t)),this.queueManager.setEventCallback((r,i,n)=>{this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,r){return t.setFinishedMotionHandler(r),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,r,i){const n=_u.create(t),o=new Zd(t),h=(r===this.groups.idle?dn.idleMotionFadingDuration:dn.motionFadingDuration)/1e3;return o.getMotionFadeInTime()===void 0&&n.setFadeInTime(i.FadeInTime>0?i.FadeInTime:h),o.getMotionFadeOutTime()===void 0&&n.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:h),n.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),n}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,r){return this.queueManager.doUpdateMotion(t,r)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}}const _1="ParamAngleX",g1="ParamAngleY",m1="ParamAngleZ",y1="ParamEyeBallX",v1="ParamEyeBallY",x1="ParamMouthForm",b1="ParamBodyAngleX",A1="ParamBreath";class gu{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new gu}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,r){this._currentTime+=r;const i=this._currentTime*2*3.14159;for(let n=0;n<this._breathParameters.length;++n){const o=this._breathParameters[n];t.addParameterValueById(o.parameterId,o.offset+o.peak*Math.sin(i/o.cycle),o.weight)}}}class yo{constructor(t,r,i,n,o){this.parameterId=t??void 0,this.offset=r??0,this.peak=i??0,this.cycle=n??0,this.weight=o??0}}const Kd=class Du{static create(t){return new Du(t)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,r,i){this._closingSeconds=t,this._closedSeconds=r,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,r){this._userTimeSeconds+=r;let i,n=0;switch(this._blinkingState){case 2:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,n>=1&&(n=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-n;break;case 3:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,n>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,n>=1&&(n=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=n;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case 0:default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}Du.CloseIfZero||(i=-i);for(let o=0;o<this._parameterIds.length;++o)t.setParameterValueById(this._parameterIds[o],i)}constructor(t){var r,i;this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=[],t!=null&&(this._parameterIds=(i=(r=t.getEyeBlinkParameters())==null?void 0:r.slice())!=null?i:this._parameterIds)}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};Kd.CloseIfZero=!0;let w1=Kd;class mu{constructor(t=0,r=0,i=0,n=0){this.x=t,this.y=r,this.width=i,this.height=n}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,r){this.x-=t,this.y-=r,this.width+=t*2,this.height+=r*2}}const Ba=4,T1=36,E1=32,C1=10;let Zs,ms,ka;class Jd{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures=[],this._maskColorBuffers=[];const t=this._clippingMaskBufferSize;for(let r=0;r<this._renderTextureCount;r++)this._maskColorBuffers.push(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers[r]),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.push(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures[r]),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers[r],0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ka),this._maskTexture=new S1(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,r){let i=Number.MAX_VALUE,n=Number.MAX_VALUE,o=Number.MIN_VALUE,h=Number.MIN_VALUE;const f=r._clippedDrawableIndexList.length;for(let A=0;A<f;A++){const T=r._clippedDrawableIndexList[A],C=t.getDrawableVertexCount(T),x=t.getDrawableVertices(T);let M=Number.MAX_VALUE,D=Number.MAX_VALUE,k=-Number.MAX_VALUE,U=-Number.MAX_VALUE;const G=C*fu.vertexStep;for(let X=fu.vertexOffset;X<G;X+=fu.vertexStep){const J=x[X],Z=x[X+1];J<M&&(M=J),J>k&&(k=J),Z<D&&(D=Z),Z>U&&(U=Z)}if(M!=Number.MAX_VALUE)if(M<i&&(i=M),D<n&&(n=D),k>o&&(o=k),U>h&&(h=U),i==Number.MAX_VALUE)r._allClippedDrawRect.x=0,r._allClippedDrawRect.y=0,r._allClippedDrawRect.width=0,r._allClippedDrawRect.height=0,r._isUsing=!1;else{r._isUsing=!0;const X=o-i,J=h-n;r._allClippedDrawRect.x=i,r._allClippedDrawRect.y=n,r._allClippedDrawRect.width=X,r._allClippedDrawRect.height=J}}}constructor(){this._currentMaskRenderTexture=null,this._currentFrameNo=0,this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new mu,this._tmpMatrix=new mi,this._tmpMatrixForMask=new mi,this._tmpMatrixForDraw=new mi;let t=new ai;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t;const r=this;for(let i=0;i<this._clippingContextListForMask.length;i++)this._clippingContextListForMask[i]&&((t=this._clippingContextListForMask[i])==null||t.release());if(r._clippingContextListForMask=void 0,r._clippingContextListForDraw=void 0,this._maskTexture){for(let i=0;i<this._maskTexture.textures.length;i++)this.gl.deleteFramebuffer(this._maskTexture.textures[i]);this._maskTexture=void 0}if(r._channelColors=void 0,this._maskColorBuffers)for(let i=0;i<this._maskColorBuffers.length;i++)this.gl.deleteTexture(this._maskColorBuffers[i]);this._maskColorBuffers=void 0,this._maskRenderTextures=void 0,this._clearedFrameBufferflags=void 0}initialize(t,r,i,n,o){o%1!=0&&(qs("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),o=~~o),o<1&&qs("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=o<1?1:o,this._clearedFrameBufferflags=[];for(let h=0;h<r;h++){if(n[h]<=0){this._clippingContextListForDraw.push(null);continue}let f=this.findSameClip(i[h],n[h]);f==null&&(f=new P1(this,i[h],n[h]),this._clippingContextListForMask.push(f)),f.addClippedDrawable(h),this._clippingContextListForDraw.push(f)}}setupClippingContext(t,r){this._currentFrameNo++;let i=0;for(let n=0;n<this._clippingContextListForMask.length;n++){const o=this._clippingContextListForMask[n];this.calcClippedDrawTotalBounds(t,o),o._isUsing&&i++}if(i>0){this.setupLayoutBounds(r.isUsingHighPrecisionMask()?0:i),r.isUsingHighPrecisionMask()||(this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture()[0],r.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._clearedFrameBufferflags||(this._clearedFrameBufferflags=[]);for(let n=0;n<this._renderTextureCount;n++)this._clearedFrameBufferflags[n]=!1;for(let n=0;n<this._clippingContextListForMask.length;n++){const o=this._clippingContextListForMask[n],h=o._allClippedDrawRect,f=o._layoutBounds,A=.05;let T=0,C=0;const x=this.getMaskRenderTexture()[o._bufferIndex];if(this._currentMaskRenderTexture!=x&&!r.isUsingHighPrecisionMask()&&(this._currentMaskRenderTexture=x,r.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),r.isUsingHighPrecisionMask()){const M=t.getPixelsPerUnit(),D=o.getClippingManager()._clippingMaskBufferSize,k=f.width*D,U=f.height*D;this._tmpBoundsOnModel.setRect(h),this._tmpBoundsOnModel.width*M>k?(this._tmpBoundsOnModel.expand(h.width*A,0),T=f.width/this._tmpBoundsOnModel.width):T=M/k,this._tmpBoundsOnModel.height*M>U?(this._tmpBoundsOnModel.expand(0,h.height*A),C=f.height/this._tmpBoundsOnModel.height):C=M/U}else this._tmpBoundsOnModel.setRect(h),this._tmpBoundsOnModel.expand(h.width*A,h.height*A),T=f.width/this._tmpBoundsOnModel.width,C=f.height/this._tmpBoundsOnModel.height;if(this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(f.x,f.y),this._tmpMatrix.scaleRelative(T,C),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(f.x,f.y),this._tmpMatrix.scaleRelative(T,C),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),o._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),o._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray()),!r.isUsingHighPrecisionMask()){const M=o._clippingIdCount;for(let D=0;D<M;D++){const k=o._clippingIdList[D];t.getDrawableDynamicFlagVertexPositionsDidChange(k)&&(r.setIsCulling(t.getDrawableCulling(k)!=!1),this._clearedFrameBufferflags[o._bufferIndex]||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferflags[o._bufferIndex]=!0),r.setClippingContextBufferForMask(o),r.drawMesh(t.getDrawableTextureIndex(k),t.getDrawableVertexIndexCount(k),t.getDrawableVertexCount(k),t.getDrawableVertexIndices(k),t.getDrawableVertices(k),t.getDrawableVertexUvs(k),t.getMultiplyColor(k),t.getScreenColor(k),t.getDrawableOpacity(k),gs.CubismBlendMode_Normal,!1))}}}r.isUsingHighPrecisionMask()||(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ka),r.setClippingContextBufferForMask(null),this.gl.viewport(ms[0],ms[1],ms[2],ms[3]))}}findSameClip(t,r){for(let i=0;i<this._clippingContextListForMask.length;i++){const n=this._clippingContextListForMask[i],o=n._clippingIdCount;if(o!=r)continue;let h=0;for(let f=0;f<o;f++){const A=n._clippingIdList[f];for(let T=0;T<o;T++)if(t[T]==A){h++;break}}if(h==o)return n}return null}setupLayoutBounds(t){const r=this._renderTextureCount<=1?T1:E1*this._renderTextureCount;if(t<=0||t>r){t>r&&Zi(`not supported mask count : {0}
1203
- [Details] render texture count : {1}, mask count : {2}`,t-r,this._renderTextureCount,t);for(let T=0;T<this._clippingContextListForMask.length;T++){const C=this._clippingContextListForMask[T];C._layoutChannelNo=0,C._layoutBounds.x=0,C._layoutBounds.y=0,C._layoutBounds.width=1,C._layoutBounds.height=1,C._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let n=t/this._renderTextureCount,o=t%this._renderTextureCount;n=~~n,o=~~o;let h=n/Ba,f=n%Ba;h=~~h,f=~~f;let A=0;for(let T=0;T<this._renderTextureCount;T++)for(let C=0;C<Ba;C++){let x=h+(C<f?1:0);const M=f+1>=Ba?0:f+1;if(x<i&&C==M&&(x+=T<o?1:0),x!=0)if(x==1){const D=this._clippingContextListForMask[A++];D._layoutChannelNo=C,D._layoutBounds.x=0,D._layoutBounds.y=0,D._layoutBounds.width=1,D._layoutBounds.height=1,D._bufferIndex=T}else if(x==2)for(let D=0;D<x;D++){let k=D%2;k=~~k;const U=this._clippingContextListForMask[A++];U._layoutChannelNo=C,U._layoutBounds.x=k*.5,U._layoutBounds.y=0,U._layoutBounds.width=.5,U._layoutBounds.height=1,U._bufferIndex=T}else if(x<=4)for(let D=0;D<x;D++){let k=D%2,U=D/2;k=~~k,U=~~U;const G=this._clippingContextListForMask[A++];G._layoutChannelNo=C,G._layoutBounds.x=k*.5,G._layoutBounds.y=U*.5,G._layoutBounds.width=.5,G._layoutBounds.height=.5,G._bufferIndex=T}else if(x<=i)for(let D=0;D<x;D++){let k=D%3,U=D/3;k=~~k,U=~~U;const G=this._clippingContextListForMask[A++];G._layoutChannelNo=C,G._layoutBounds.x=k/3,G._layoutBounds.y=U/3,G._layoutBounds.width=1/3,G._layoutBounds.height=1/3,G._bufferIndex=T}else if(Ma.supportMoreMaskDivisions&&x<=16)for(let D=0;D<x;D++){let k=D%4,U=D/4;k=~~k,U=~~U;const G=this._clippingContextListForMask[A++];G._layoutChannelNo=C,G._layoutBounds.x=k/4,G._layoutBounds.y=U/4,G._layoutBounds.width=1/4,G._layoutBounds.height=1/4,G._bufferIndex=T}else{Zi(`not supported mask count : {0}
1204
- [Details] render texture count : {1}, mask count : {2}`,t-r,this._renderTextureCount,t);for(let D=0;D<x;D++){const k=this._clippingContextListForMask[A++];k._layoutChannelNo=0,k._layoutBounds.x=0,k._layoutBounds.y=0,k._layoutBounds.width=1,k._layoutBounds.height=1,k._bufferIndex=0}}}}getColorBuffer(){return this._maskColorBuffers}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskCount(){return this._clippingContextListForMask.length}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}}class S1{constructor(t,r){this.frameNo=t,this.textures=r}}class P1{constructor(t,r,i){this._isUsing=!1,this._owner=t,this._clippingIdList=r,this._clippingIdCount=i,this._allClippedDrawRect=new mu,this._layoutBounds=new mu,this._clippedDrawableIndexList=[],this._matrixForMask=new mi,this._matrixForDraw=new mi,this._bufferIndex=0}release(){const t=this;t._layoutBounds=void 0,t._allClippedDrawRect=void 0,t._clippedDrawableIndexList=void 0}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class $1{setGlEnable(t,r){r?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,r){r?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){if(this.gl==null){Zi(`'gl' is null. WebGLRenderingContext is required.
1202
+ `)}constructor(){}}class Yd{constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=[]}release(){this._weight=0}updateParameters(t,r,i){if(!r.isAvailable()||r.isFinished())return;if(!r.isStarted()){r.setIsStarted(!0),r.setStartTime(i-this._offsetSeconds),r.setFadeInStartTime(i);const f=this.getDuration();r.getEndTime()<0&&r.setEndTime(f<=0?-1:r.getStartTime()+f)}let n=this._weight;const o=this._fadeInSeconds==0?1:Ke.getEasingSine((i-r.getFadeInStartTime())/this._fadeInSeconds),h=this._fadeOutSeconds==0||r.getEndTime()<0?1:Ke.getEasingSine((r.getEndTime()-i)/this._fadeOutSeconds);n=n*o*h,r.setState(i,n),vn(0<=n&&n<=1),this.doUpdateParameters(t,i,n,r),r.getEndTime()>0&&r.getEndTime()<i&&r.setIsFinished(!0)}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}getFiredEvent(t,r){return this._firedEventValues}setFinishedMotionHandler(t){this._onFinishedMotion=t}getFinishedMotionHandler(){return this._onFinishedMotion}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){}getModelOpacityValue(){return 1}}const jd=1;class fu extends Yd{static create(t){const r=new fu;return r.parse(t),r}doUpdateParameters(t,r,i,n){for(let o=0;o<this._parameters.length;++o){const h=this._parameters[o];switch(h.blendType){case 0:{t.addParameterValueById(h.parameterId,h.value,i);break}case 1:{t.multiplyParameterValueById(h.parameterId,h.value,i);break}case 2:{t.setParameterValueById(h.parameterId,h.value,i);break}}}}parse(t){this.setFadeInTime(t.FadeInTime!=null?t.FadeInTime:jd),this.setFadeOutTime(t.FadeOutTime!=null?t.FadeOutTime:jd);const r=(t.Parameters||[]).length;for(let i=0;i<r;++i){const n=t.Parameters[i],o=n.Id,h=n.Value;let f;!n.Blend||n.Blend==="Add"?f=0:n.Blend==="Multiply"?f=1:n.Blend==="Overwrite"?f=2:f=0;const A={parameterId:o,blendType:f,value:h};this._parameters.push(A)}}constructor(){super(),this._parameters=[]}}class Zm{constructor(){this._autoDelete=!1,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&this._motion.release()}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,r){const i=r+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,r){this._stateTimeSeconds=t,this._stateWeight=r}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}}class qd{constructor(){this._userTimeSeconds=0,this._eventCustomData=null,this._motions=[]}release(){for(let t=0;t<this._motions.length;++t)this._motions[t]&&this._motions[t].release();this._motions=void 0}startMotion(t,r,i){if(t==null)return Qm;let n;for(let o=0;o<this._motions.length;++o)n=this._motions[o],n!=null&&n.setFadeOut(n._motion.getFadeOutTime());return n=new Zm,n._autoDelete=r,n._motion=t,this._motions.push(n),n._motionQueueEntryHandle}isFinished(){let t=0;for(;t<this._motions.length;){const r=this._motions[t];if(r==null){this._motions.splice(t,1);continue}if(r._motion==null){r.release(),this._motions.splice(t,1);continue}if(!r.isFinished())return!1;t++}return!0}isFinishedByHandle(t){for(let r=0;r<this._motions.length;r++){const i=this._motions[r];if(i!=null&&i._motionQueueEntryHandle==t&&!i.isFinished())return!1}return!0}stopAllMotions(){for(let t=0;t<this._motions.length;t++){const r=this._motions[t];r!=null&&r.release()}this._motions=[]}getCubismMotionQueueEntry(t){return this._motions.find(r=>r!=null&&r._motionQueueEntryHandle==t)}setEventCallback(t,r=null){this._eventCallBack=t,this._eventCustomData=r}doUpdateMotion(t,r){let i=!1,n=0;for(;n<this._motions.length;){const o=this._motions[n];if(o==null){this._motions.splice(n,1);continue}const h=o._motion;if(h==null){o.release(),this._motions.splice(n,1);continue}h.updateParameters(t,o,r),i=!0;const f=h.getFiredEvent(o.getLastCheckEventSeconds()-o.getStartTime(),r-o.getStartTime());for(let A=0;A<f.length;++A)this._eventCallBack(this,f[A],this._eventCustomData);o.setLastCheckEventSeconds(r),o.isFinished()?(o.release(),this._motions.splice(n,1)):(o.isTriggeredFadeOut()&&o.startFadeOut(o.getFadeOutSeconds(),r),n++)}return i}}const Qm=-1;class Km extends lu{constructor(t,r){var i;super(t,r),bt(this,"queueManager",new qd),bt(this,"definitions"),this.definitions=(i=t.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(r=>r.Name===t)}getExpressionFile(t){return t.File}createExpression(t,r){return fu.create(t)}_setExpression(t){return this.queueManager.startMotion(t,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,r){return this.queueManager.doUpdateMotion(t,r)}}var Qi=(s=>(s[s.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",s[s.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",s[s.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",s))(Qi||{}),Ki=(s=>(s[s.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",s[s.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",s[s.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",s[s.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",s))(Ki||{});class Ms{constructor(t=0,r=0){this.time=t,this.value=r}}class Jm{constructor(){this.basePointIndex=0,this.segmentType=0}}class t1{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class e1{constructor(){this.fireTime=0,this.value=""}}class r1{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class Zd{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return t==0?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,r){return this._json.Curves[t].Segments[r]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var Qd=(s=>(s[s.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",s))(Qd||{});const i1="EyeBlink",s1="LipSync",n1="Model",o1="Parameter",a1="PartOpacity",Fa="Opacity",h1=!1;function yi(s,t,r){const i=new Ms;return i.time=s.time+(t.time-s.time)*r,i.value=s.value+(t.value-s.value)*r,i}function l1(s,t){let r=(t-s[0].time)/(s[1].time-s[0].time);return r<0&&(r=0),s[0].value+(s[1].value-s[0].value)*r}function u1(s,t){let r=(t-s[0].time)/(s[3].time-s[0].time);r<0&&(r=0);const i=yi(s[0],s[1],r),n=yi(s[1],s[2],r),o=yi(s[2],s[3],r),h=yi(i,n,r),f=yi(n,o,r);return yi(h,f,r).value}function c1(s,t){const r=t,i=s[0].time,n=s[3].time,o=s[1].time,h=s[2].time,f=n-3*h+3*o-i,A=3*h-6*o+3*i,T=3*o-3*i,C=i-r,x=Ke.cardanoAlgorithmForBezier(f,A,T,C),M=yi(s[0],s[1],x),D=yi(s[1],s[2],x),k=yi(s[2],s[3],x),U=yi(M,D,x),G=yi(D,k,x);return yi(U,G,x).value}function f1(s,t){return s[0].value}function d1(s,t){return s[1].value}function du(s,t,r){const i=s.curves[t];let n=-1;const o=i.baseSegmentIndex+i.segmentCount;let h=0;for(let A=i.baseSegmentIndex;A<o;++A)if(h=s.segments[A].basePointIndex+(s.segments[A].segmentType==Ki.CubismMotionSegmentType_Bezier?3:1),s.points[h].time>r){n=A;break}if(n==-1)return s.points[h].value;const f=s.segments[n];return f.evaluate(s.points.slice(f.basePointIndex),r)}class pu extends Yd{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._modelOpacity=1}static create(t,r){const i=new pu;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=r,i}doUpdateParameters(t,r,i,n){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=i1),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=s1),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=Fa);let o=r-n.getStartTime();o<0&&(o=0);let h=Number.MAX_VALUE,f=Number.MAX_VALUE;const A=64;let T=0,C=0;this._eyeBlinkParameterIds.length>A&&Hd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>A&&Hd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const x=this._fadeInSeconds<=0?1:Ke.getEasingSine((r-n.getFadeInStartTime())/this._fadeInSeconds),M=this._fadeOutSeconds<=0||n.getEndTime()<0?1:Ke.getEasingSine((n.getEndTime()-r)/this._fadeOutSeconds);let D,k,U,G=o;if(this._isLoop)for(;G>this._motionData.duration;)G-=this._motionData.duration;const X=this._motionData.curves;for(k=0;k<this._motionData.curveCount&&X[k].type==Qi.CubismMotionCurveTarget_Model;++k)D=du(this._motionData,k,G),X[k].id==this._modelCurveIdEyeBlink?f=D:X[k].id==this._modelCurveIdLipSync?h=D:X[k].id==this._modelCurveIdOpacity&&(this._modelOpacity=D,t.setModelOapcity(this.getModelOpacityValue()));for(;k<this._motionData.curveCount&&X[k].type==Qi.CubismMotionCurveTarget_Parameter;++k){if(U=t.getParameterIndex(X[k].id),U==-1)continue;const J=t.getParameterValueByIndex(U);if(D=du(this._motionData,k,G),f!=Number.MAX_VALUE){for(let it=0;it<this._eyeBlinkParameterIds.length&&it<A;++it)if(this._eyeBlinkParameterIds[it]==X[k].id){D*=f,C|=1<<it;break}}if(h!=Number.MAX_VALUE){for(let it=0;it<this._lipSyncParameterIds.length&&it<A;++it)if(this._lipSyncParameterIds[it]==X[k].id){D+=h,T|=1<<it;break}}let Z;if(X[k].fadeInTime<0&&X[k].fadeOutTime<0)Z=J+(D-J)*i;else{let it,Q;X[k].fadeInTime<0?it=x:it=X[k].fadeInTime==0?1:Ke.getEasingSine((r-n.getFadeInStartTime())/X[k].fadeInTime),X[k].fadeOutTime<0?Q=M:Q=X[k].fadeOutTime==0||n.getEndTime()<0?1:Ke.getEasingSine((n.getEndTime()-r)/X[k].fadeOutTime);const _t=this._weight*it*Q;Z=J+(D-J)*_t}t.setParameterValueByIndex(U,Z,1)}{if(f!=Number.MAX_VALUE)for(let J=0;J<this._eyeBlinkParameterIds.length&&J<A;++J){const Z=t.getParameterValueById(this._eyeBlinkParameterIds[J]);if(C>>J&1)continue;const it=Z+(f-Z)*i;t.setParameterValueById(this._eyeBlinkParameterIds[J],it)}if(h!=Number.MAX_VALUE)for(let J=0;J<this._lipSyncParameterIds.length&&J<A;++J){const Z=t.getParameterValueById(this._lipSyncParameterIds[J]);if(T>>J&1)continue;const it=Z+(h-Z)*i;t.setParameterValueById(this._lipSyncParameterIds[J],it)}}for(;k<this._motionData.curveCount&&X[k].type==Qi.CubismMotionCurveTarget_PartOpacity;++k)if(D=du(this._motionData,k,G),$a.setOpacityFromMotion)t.setPartOpacityById(X[k].id,D);else{if(U=t.getParameterIndex(X[k].id),U==-1)continue;t.setParameterValueByIndex(U,D)}o>=this._motionData.duration&&(this._isLoop?(n.setStartTime(r),this._isLoopFadeIn&&n.setFadeInStartTime(r)):(this._onFinishedMotion&&this._onFinishedMotion(this),n.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){this._isLoop=t}isLoop(){return this._isLoop}setIsLoopFadeIn(t){this._isLoopFadeIn=t}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,r){const i=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==i[n].id){i[n].fadeInTime=r;return}}setParameterFadeOutTime(t,r){const i=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(t==i[n].id){i[n].fadeOutTime=r;return}}getParameterFadeInTime(t){const r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeInTime;return-1}getParameterFadeOutTime(t){const r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeOutTime;return-1}setEffectIds(t,r){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=r}release(){this._motionData=void 0}parse(t){this._motionData=new r1;const r=new Zd(t);this._motionData.duration=r.getMotionDuration(),this._motionData.loop=r.isMotionLoop(),this._motionData.curveCount=r.getMotionCurveCount(),this._motionData.fps=r.getMotionFps(),this._motionData.eventCount=r.getEventCount();const i=r.getEvaluationOptionFlag(Qd.EvaluationOptionFlag_AreBeziersRistricted),n=r.getMotionFadeInTime(),o=r.getMotionFadeOutTime();n!==void 0?this._fadeInSeconds=n<0?1:n:this._fadeInSeconds=1,o!==void 0?this._fadeOutSeconds=o<0?1:o:this._fadeOutSeconds=1,this._motionData.curves=Array.from({length:this._motionData.curveCount}).map(()=>new t1),this._motionData.segments=Array.from({length:r.getMotionTotalSegmentCount()}).map(()=>new Jm),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new e1),this._motionData.points=[];let h=0,f=0;for(let A=0;A<this._motionData.curveCount;++A){const T=this._motionData.curves[A];switch(r.getMotionCurveTarget(A)){case n1:T.type=Qi.CubismMotionCurveTarget_Model;break;case o1:T.type=Qi.CubismMotionCurveTarget_Parameter;break;case a1:T.type=Qi.CubismMotionCurveTarget_PartOpacity;break;default:qs('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!')}T.id=r.getMotionCurveId(A),T.baseSegmentIndex=f;const C=r.getMotionCurveFadeInTime(A),x=r.getMotionCurveFadeOutTime(A);T.fadeInTime=C!==void 0?C:-1,T.fadeOutTime=x!==void 0?x:-1;for(let M=0;M<r.getMotionCurveSegmentCount(A);){switch(M==0?(this._motionData.segments[f].basePointIndex=h,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M),r.getMotionCurveSegment(A,M+1)),h+=1,M+=2):this._motionData.segments[f].basePointIndex=h-1,r.getMotionCurveSegment(A,M)){case Ki.CubismMotionSegmentType_Linear:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_Linear,this._motionData.segments[f].evaluate=l1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),h+=1,M+=3;break}case Ki.CubismMotionSegmentType_Bezier:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_Bezier,i||h1?this._motionData.segments[f].evaluate=u1:this._motionData.segments[f].evaluate=c1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),this._motionData.points[h+1]=new Ms(r.getMotionCurveSegment(A,M+3),r.getMotionCurveSegment(A,M+4)),this._motionData.points[h+2]=new Ms(r.getMotionCurveSegment(A,M+5),r.getMotionCurveSegment(A,M+6)),h+=3,M+=7;break}case Ki.CubismMotionSegmentType_Stepped:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_Stepped,this._motionData.segments[f].evaluate=f1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),h+=1,M+=3;break}case Ki.CubismMotionSegmentType_InverseStepped:{this._motionData.segments[f].segmentType=Ki.CubismMotionSegmentType_InverseStepped,this._motionData.segments[f].evaluate=d1,this._motionData.points[h]=new Ms(r.getMotionCurveSegment(A,M+1),r.getMotionCurveSegment(A,M+2)),h+=1,M+=3;break}default:{vn(0);break}}++T.segmentCount,++f}this._motionData.curves.push(T)}for(let A=0;A<r.getEventCount();++A)this._motionData.events[A].fireTime=r.getEventTime(A),this._motionData.events[A].value=r.getEventValue(A);r.release()}getFiredEvent(t,r){this._firedEventValues.length=0;for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=r&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const r=this._motionData.curves[t];if(r.type==Qi.CubismMotionCurveTarget_Model&&r.id===Fa)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const r=this._motionData.curves[t];if(r.type==Qi.CubismMotionCurveTarget_Model&&r.id===Fa)return t}return-1}getModelOpacityId(t){if(t!=-1){const r=this._motionData.curves[t];if(r.type==Qi.CubismMotionCurveTarget_Model&&r.id===Fa)return r.id}}getModelOpacityValue(){return this._modelOpacity}}class p1 extends fo{constructor(t,r){var i;super(t,r),bt(this,"definitions"),bt(this,"groups",{idle:"Idle"}),bt(this,"motionDataType","json"),bt(this,"queueManager",new qd),bt(this,"expressionManager"),bt(this,"eyeBlinkIds"),bt(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=(i=t.motions)!=null?i:{},this.eyeBlinkIds=t.getEyeBlinkParameters()||[];const n=t.getLipSyncParameters();n!=null&&n.length&&(this.lipSyncIds=n),this.init(r)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Km(this.settings,t)),this.queueManager.setEventCallback((r,i,n)=>{this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,r){return t.setFinishedMotionHandler(r),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,r,i){const n=pu.create(t),o=new Zd(t),h=(r===this.groups.idle?dn.idleMotionFadingDuration:dn.motionFadingDuration)/1e3;return o.getMotionFadeInTime()===void 0&&n.setFadeInTime(i.FadeInTime>0?i.FadeInTime:h),o.getMotionFadeOutTime()===void 0&&n.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:h),n.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),n}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,r){return this.queueManager.doUpdateMotion(t,r)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}}const _1="ParamAngleX",g1="ParamAngleY",m1="ParamAngleZ",y1="ParamEyeBallX",v1="ParamEyeBallY",x1="ParamMouthForm",b1="ParamBodyAngleX",A1="ParamBreath";class _u{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new _u}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,r){this._currentTime+=r;const i=this._currentTime*2*3.14159;for(let n=0;n<this._breathParameters.length;++n){const o=this._breathParameters[n];t.addParameterValueById(o.parameterId,o.offset+o.peak*Math.sin(i/o.cycle),o.weight)}}}class yo{constructor(t,r,i,n,o){this.parameterId=t??void 0,this.offset=r??0,this.peak=i??0,this.cycle=n??0,this.weight=o??0}}const Kd=class Iu{static create(t){return new Iu(t)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,r,i){this._closingSeconds=t,this._closedSeconds=r,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,r){this._userTimeSeconds+=r;let i,n=0;switch(this._blinkingState){case 2:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,n>=1&&(n=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-n;break;case 3:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,n>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:n=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,n>=1&&(n=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=n;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case 0:default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}Iu.CloseIfZero||(i=-i);for(let o=0;o<this._parameterIds.length;++o)t.setParameterValueById(this._parameterIds[o],i)}constructor(t){var r,i;this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=[],t!=null&&(this._parameterIds=(i=(r=t.getEyeBlinkParameters())==null?void 0:r.slice())!=null?i:this._parameterIds)}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};Kd.CloseIfZero=!0;let w1=Kd;class gu{constructor(t=0,r=0,i=0,n=0){this.x=t,this.y=r,this.width=i,this.height=n}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,r){this.x-=t,this.y-=r,this.width+=t*2,this.height+=r*2}}const La=4,T1=36,E1=32,C1=10;let Zs,ms,Ba;class Jd{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures=[],this._maskColorBuffers=[];const t=this._clippingMaskBufferSize;for(let r=0;r<this._renderTextureCount;r++)this._maskColorBuffers.push(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers[r]),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.push(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures[r]),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers[r],0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Ba),this._maskTexture=new S1(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,r){let i=Number.MAX_VALUE,n=Number.MAX_VALUE,o=Number.MIN_VALUE,h=Number.MIN_VALUE;const f=r._clippedDrawableIndexList.length;for(let A=0;A<f;A++){const T=r._clippedDrawableIndexList[A],C=t.getDrawableVertexCount(T),x=t.getDrawableVertices(T);let M=Number.MAX_VALUE,D=Number.MAX_VALUE,k=-Number.MAX_VALUE,U=-Number.MAX_VALUE;const G=C*cu.vertexStep;for(let X=cu.vertexOffset;X<G;X+=cu.vertexStep){const J=x[X],Z=x[X+1];J<M&&(M=J),J>k&&(k=J),Z<D&&(D=Z),Z>U&&(U=Z)}if(M!=Number.MAX_VALUE)if(M<i&&(i=M),D<n&&(n=D),k>o&&(o=k),U>h&&(h=U),i==Number.MAX_VALUE)r._allClippedDrawRect.x=0,r._allClippedDrawRect.y=0,r._allClippedDrawRect.width=0,r._allClippedDrawRect.height=0,r._isUsing=!1;else{r._isUsing=!0;const X=o-i,J=h-n;r._allClippedDrawRect.x=i,r._allClippedDrawRect.y=n,r._allClippedDrawRect.width=X,r._allClippedDrawRect.height=J}}}constructor(){this._currentMaskRenderTexture=null,this._currentFrameNo=0,this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new gu,this._tmpMatrix=new mi,this._tmpMatrixForMask=new mi,this._tmpMatrixForDraw=new mi;let t=new ai;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new ai,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t;const r=this;for(let i=0;i<this._clippingContextListForMask.length;i++)this._clippingContextListForMask[i]&&((t=this._clippingContextListForMask[i])==null||t.release());if(r._clippingContextListForMask=void 0,r._clippingContextListForDraw=void 0,this._maskTexture){for(let i=0;i<this._maskTexture.textures.length;i++)this.gl.deleteFramebuffer(this._maskTexture.textures[i]);this._maskTexture=void 0}if(r._channelColors=void 0,this._maskColorBuffers)for(let i=0;i<this._maskColorBuffers.length;i++)this.gl.deleteTexture(this._maskColorBuffers[i]);this._maskColorBuffers=void 0,this._maskRenderTextures=void 0,this._clearedFrameBufferflags=void 0}initialize(t,r,i,n,o){o%1!=0&&(qs("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),o=~~o),o<1&&qs("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=o<1?1:o,this._clearedFrameBufferflags=[];for(let h=0;h<r;h++){if(n[h]<=0){this._clippingContextListForDraw.push(null);continue}let f=this.findSameClip(i[h],n[h]);f==null&&(f=new P1(this,i[h],n[h]),this._clippingContextListForMask.push(f)),f.addClippedDrawable(h),this._clippingContextListForDraw.push(f)}}setupClippingContext(t,r){this._currentFrameNo++;let i=0;for(let n=0;n<this._clippingContextListForMask.length;n++){const o=this._clippingContextListForMask[n];this.calcClippedDrawTotalBounds(t,o),o._isUsing&&i++}if(i>0){this.setupLayoutBounds(r.isUsingHighPrecisionMask()?0:i),r.isUsingHighPrecisionMask()||(this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture()[0],r.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._clearedFrameBufferflags||(this._clearedFrameBufferflags=[]);for(let n=0;n<this._renderTextureCount;n++)this._clearedFrameBufferflags[n]=!1;for(let n=0;n<this._clippingContextListForMask.length;n++){const o=this._clippingContextListForMask[n],h=o._allClippedDrawRect,f=o._layoutBounds,A=.05;let T=0,C=0;const x=this.getMaskRenderTexture()[o._bufferIndex];if(this._currentMaskRenderTexture!=x&&!r.isUsingHighPrecisionMask()&&(this._currentMaskRenderTexture=x,r.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),r.isUsingHighPrecisionMask()){const M=t.getPixelsPerUnit(),D=o.getClippingManager()._clippingMaskBufferSize,k=f.width*D,U=f.height*D;this._tmpBoundsOnModel.setRect(h),this._tmpBoundsOnModel.width*M>k?(this._tmpBoundsOnModel.expand(h.width*A,0),T=f.width/this._tmpBoundsOnModel.width):T=M/k,this._tmpBoundsOnModel.height*M>U?(this._tmpBoundsOnModel.expand(0,h.height*A),C=f.height/this._tmpBoundsOnModel.height):C=M/U}else this._tmpBoundsOnModel.setRect(h),this._tmpBoundsOnModel.expand(h.width*A,h.height*A),T=f.width/this._tmpBoundsOnModel.width,C=f.height/this._tmpBoundsOnModel.height;if(this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(f.x,f.y),this._tmpMatrix.scaleRelative(T,C),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(f.x,f.y),this._tmpMatrix.scaleRelative(T,C),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),o._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),o._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray()),!r.isUsingHighPrecisionMask()){const M=o._clippingIdCount;for(let D=0;D<M;D++){const k=o._clippingIdList[D];t.getDrawableDynamicFlagVertexPositionsDidChange(k)&&(r.setIsCulling(t.getDrawableCulling(k)!=!1),this._clearedFrameBufferflags[o._bufferIndex]||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferflags[o._bufferIndex]=!0),r.setClippingContextBufferForMask(o),r.drawMesh(t.getDrawableTextureIndex(k),t.getDrawableVertexIndexCount(k),t.getDrawableVertexCount(k),t.getDrawableVertexIndices(k),t.getDrawableVertices(k),t.getDrawableVertexUvs(k),t.getMultiplyColor(k),t.getScreenColor(k),t.getDrawableOpacity(k),gs.CubismBlendMode_Normal,!1))}}}r.isUsingHighPrecisionMask()||(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Ba),r.setClippingContextBufferForMask(null),this.gl.viewport(ms[0],ms[1],ms[2],ms[3]))}}findSameClip(t,r){for(let i=0;i<this._clippingContextListForMask.length;i++){const n=this._clippingContextListForMask[i],o=n._clippingIdCount;if(o!=r)continue;let h=0;for(let f=0;f<o;f++){const A=n._clippingIdList[f];for(let T=0;T<o;T++)if(t[T]==A){h++;break}}if(h==o)return n}return null}setupLayoutBounds(t){const r=this._renderTextureCount<=1?T1:E1*this._renderTextureCount;if(t<=0||t>r){t>r&&Zi(`not supported mask count : {0}
1203
+ [Details] render texture count : {1}, mask count : {2}`,t-r,this._renderTextureCount,t);for(let T=0;T<this._clippingContextListForMask.length;T++){const C=this._clippingContextListForMask[T];C._layoutChannelNo=0,C._layoutBounds.x=0,C._layoutBounds.y=0,C._layoutBounds.width=1,C._layoutBounds.height=1,C._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let n=t/this._renderTextureCount,o=t%this._renderTextureCount;n=~~n,o=~~o;let h=n/La,f=n%La;h=~~h,f=~~f;let A=0;for(let T=0;T<this._renderTextureCount;T++)for(let C=0;C<La;C++){let x=h+(C<f?1:0);const M=f+1>=La?0:f+1;if(x<i&&C==M&&(x+=T<o?1:0),x!=0)if(x==1){const D=this._clippingContextListForMask[A++];D._layoutChannelNo=C,D._layoutBounds.x=0,D._layoutBounds.y=0,D._layoutBounds.width=1,D._layoutBounds.height=1,D._bufferIndex=T}else if(x==2)for(let D=0;D<x;D++){let k=D%2;k=~~k;const U=this._clippingContextListForMask[A++];U._layoutChannelNo=C,U._layoutBounds.x=k*.5,U._layoutBounds.y=0,U._layoutBounds.width=.5,U._layoutBounds.height=1,U._bufferIndex=T}else if(x<=4)for(let D=0;D<x;D++){let k=D%2,U=D/2;k=~~k,U=~~U;const G=this._clippingContextListForMask[A++];G._layoutChannelNo=C,G._layoutBounds.x=k*.5,G._layoutBounds.y=U*.5,G._layoutBounds.width=.5,G._layoutBounds.height=.5,G._bufferIndex=T}else if(x<=i)for(let D=0;D<x;D++){let k=D%3,U=D/3;k=~~k,U=~~U;const G=this._clippingContextListForMask[A++];G._layoutChannelNo=C,G._layoutBounds.x=k/3,G._layoutBounds.y=U/3,G._layoutBounds.width=1/3,G._layoutBounds.height=1/3,G._bufferIndex=T}else if($a.supportMoreMaskDivisions&&x<=16)for(let D=0;D<x;D++){let k=D%4,U=D/4;k=~~k,U=~~U;const G=this._clippingContextListForMask[A++];G._layoutChannelNo=C,G._layoutBounds.x=k/4,G._layoutBounds.y=U/4,G._layoutBounds.width=1/4,G._layoutBounds.height=1/4,G._bufferIndex=T}else{Zi(`not supported mask count : {0}
1204
+ [Details] render texture count : {1}, mask count : {2}`,t-r,this._renderTextureCount,t);for(let D=0;D<x;D++){const k=this._clippingContextListForMask[A++];k._layoutChannelNo=0,k._layoutBounds.x=0,k._layoutBounds.y=0,k._layoutBounds.width=1,k._layoutBounds.height=1,k._bufferIndex=0}}}}getColorBuffer(){return this._maskColorBuffers}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskCount(){return this._clippingContextListForMask.length}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}}class S1{constructor(t,r){this.frameNo=t,this.textures=r}}class P1{constructor(t,r,i){this._isUsing=!1,this._owner=t,this._clippingIdList=r,this._clippingIdCount=i,this._allClippedDrawRect=new gu,this._layoutBounds=new gu,this._clippedDrawableIndexList=[],this._matrixForMask=new mi,this._matrixForDraw=new mi,this._bufferIndex=0}release(){const t=this;t._layoutBounds=void 0,t._allClippedDrawRect=void 0,t._clippedDrawableIndexList=void 0}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class $1{setGlEnable(t,r){r?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,r){r?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){if(this.gl==null){Zi(`'gl' is null. WebGLRenderingContext is required.
1205
1205
  Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)}restore(){if(this.gl==null){Zi(`'gl' is null. WebGLRenderingContext is required.
1206
- Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class xn{static getInstance(){return Zs==null&&(Zs=new xn),Zs}static deleteInstance(){Zs&&(Zs.release(),Zs=void 0)}constructor(){this._shaderSets=[]}release(){this.releaseShaderProgram()}setupShaderProgram(t,r,i,n,o,h,f,A,T,C,x,M,D,k,U){D||Zi("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders();let G,X,J,Z;const it=t.getClippingContextBufferForMask();if(it!=null){const Q=this._shaderSets[0];this.gl.useProgram(Q.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(Q.samplerTexture0Location,0),f.vertex==null&&(f.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(Q.attributePositionLocation),this.gl.vertexAttribPointer(Q.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),f.uv==null&&(f.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(Q.attributeTexCoordLocation),this.gl.vertexAttribPointer(Q.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);const _t=it._layoutChannelNo,et=it.getClippingManager().getChannelFlagAsColor(_t);this.gl.uniform4f(Q.uniformChannelFlagLocation,et.R,et.G,et.B,et.A),this.gl.uniformMatrix4fv(Q.uniformClipMatrixLocation,!1,it._matrixForMask.getArray());const ft=it._layoutBounds;this.gl.uniform4f(Q.uniformBaseColorLocation,ft.x*2-1,ft.y*2-1,ft.getRight()*2-1,ft.getBottom()*2-1),this.gl.uniform4f(Q.uniformMultiplyColorLocation,x.R,x.G,x.B,x.A),this.gl.uniform4f(Q.uniformScreenColorLocation,M.R,M.G,M.B,M.A),G=this.gl.ZERO,X=this.gl.ONE_MINUS_SRC_COLOR,J=this.gl.ZERO,Z=this.gl.ONE_MINUS_SRC_ALPHA}else{const Q=t.getClippingContextBufferForDraw(),et=Q!=null?U?2:1:0;let ft;switch(T){case gs.CubismBlendMode_Normal:default:ft=this._shaderSets[1+et],G=this.gl.ONE,X=this.gl.ONE_MINUS_SRC_ALPHA,J=this.gl.ONE,Z=this.gl.ONE_MINUS_SRC_ALPHA;break;case gs.CubismBlendMode_Additive:ft=this._shaderSets[4+et],G=this.gl.ONE,X=this.gl.ONE,J=this.gl.ZERO,Z=this.gl.ONE;break;case gs.CubismBlendMode_Multiplicative:ft=this._shaderSets[7+et],G=this.gl.DST_COLOR,X=this.gl.ONE_MINUS_SRC_ALPHA,J=this.gl.ZERO,Z=this.gl.ONE;break}if(this.gl.useProgram(ft.shaderProgram),f.vertex==null&&(f.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(ft.attributePositionLocation),this.gl.vertexAttribPointer(ft.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),f.uv==null&&(f.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(ft.attributeTexCoordLocation),this.gl.vertexAttribPointer(ft.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),Q!=null){this.gl.activeTexture(this.gl.TEXTURE1);const wt=Q.getClippingManager().getColorBuffer()[t.getClippingContextBufferForDraw()._bufferIndex];this.gl.bindTexture(this.gl.TEXTURE_2D,wt),this.gl.uniform1i(ft.samplerTexture1Location,1),this.gl.uniformMatrix4fv(ft.uniformClipMatrixLocation,!1,Q._matrixForDraw.getArray());const Rt=Q._layoutChannelNo,It=Q.getClippingManager().getChannelFlagAsColor(Rt);this.gl.uniform4f(ft.uniformChannelFlagLocation,It.R,It.G,It.B,It.A)}this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(ft.samplerTexture0Location,0),this.gl.uniformMatrix4fv(ft.uniformMatrixLocation,!1,k.getArray()),this.gl.uniform4f(ft.uniformBaseColorLocation,C.R,C.G,C.B,C.A),this.gl.uniform4f(ft.uniformMultiplyColorLocation,x.R,x.G,x.B,x.A),this.gl.uniform4f(ft.uniformScreenColorLocation,M.R,M.G,M.B,M.A)}f.index==null&&(f.index=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,f.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,o,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(G,X,J,Z)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.length;t++)this.gl.deleteProgram(this._shaderSets[t].shaderProgram),this._shaderSets[t].shaderProgram=0;this._shaderSets=[]}generateShaders(){for(let t=0;t<C1;t++)this._shaderSets.push({});this._shaderSets[0].shaderProgram=this.loadShaderProgram(M1,R1),this._shaderSets[1].shaderProgram=this.loadShaderProgram(I1,D1),this._shaderSets[2].shaderProgram=this.loadShaderProgram(t2,F1),this._shaderSets[3].shaderProgram=this.loadShaderProgram(t2,L1),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[0].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_multiplyColor"),this._shaderSets[0].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_screenColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}loadShaderProgram(t,r){const i=this.gl.createProgram(),n=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!n)return Zi("Vertex shader compile error!"),0;const o=this.compileShaderSource(this.gl.FRAGMENT_SHADER,r);return o?(this.gl.attachShader(i,n),this.gl.attachShader(i,o),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(n),this.gl.deleteShader(o),i):(Zi("Failed to link program: {0}",i),this.gl.deleteShader(n),this.gl.deleteShader(o),i&&this.gl.deleteProgram(i),0)):(Zi("Vertex shader compile error!"),0)}compileShaderSource(t,r){const i=r,n=this.gl.createShader(t);if(this.gl.shaderSource(n,i),this.gl.compileShader(n),!n){const h=this.gl.getShaderInfoLog(n);Zi("Shader compile log: {0} ",h)}return this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(this.gl.deleteShader(n),null)}setGl(t){this.gl=t}}const M1="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",R1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",I1="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",t2="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",D1="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",F1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",L1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}";class e2 extends cu{initialize(t,r=1){t.isUsingMasking()&&(this._clippingManager=new Jd,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts(),r));for(let i=t.getDrawableCount()-1;i>=0;i--)this._sortedDrawableIndexList[i]=0;super.initialize(t)}bindTexture(t,r){this._textures[t]=r}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const r=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=new Jd,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts(),r)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new $1,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}release(){var t,r,i;const n=this;this._clippingManager.release(),n._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(r=this.gl)==null||r.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,n._bufferData=void 0,n._textures=void 0}doDrawModel(){if(this.gl==null){Zi(`'gl' is null. WebGLRenderingContext is required.
1207
- Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),r=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const n=r[i];this._sortedDrawableIndexList[n]=i}for(let i=0;i<t;++i){const n=this._sortedDrawableIndexList[i];if(!this.getModel().getDrawableDynamicFlagIsVisible(n))continue;const o=this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw()[n]:null;if(o!=null&&this.isUsingHighPrecisionMask()){o._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,o.getClippingManager().getMaskRenderTexture()[o._bufferIndex]),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const h=o._clippingIdCount;for(let f=0;f<h;f++){const A=o._clippingIdList[f];this._model.getDrawableDynamicFlagVertexPositionsDidChange(A)&&(this.setIsCulling(this._model.getDrawableCulling(A)!=!1),this.setClippingContextBufferForMask(o),this.drawMesh(this.getModel().getDrawableTextureIndex(A),this.getModel().getDrawableVertexIndexCount(A),this.getModel().getDrawableVertexCount(A),this.getModel().getDrawableVertexIndices(A),this.getModel().getDrawableVertices(A),this.getModel().getDrawableVertexUvs(A),this.getModel().getMultiplyColor(A),this.getModel().getScreenColor(A),this.getModel().getDrawableOpacity(A),gs.CubismBlendMode_Normal,!1))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ka),this.setClippingContextBufferForMask(null),this.gl.viewport(ms[0],ms[1],ms[2],ms[3]),this.preDraw()}this.setClippingContextBufferForDraw(o),this.setIsCulling(this.getModel().getDrawableCulling(n)),this.drawMesh(this.getModel().getDrawableTextureIndex(n),this.getModel().getDrawableVertexIndexCount(n),this.getModel().getDrawableVertexCount(n),this.getModel().getDrawableVertexIndices(n),this.getModel().getDrawableVertices(n),this.getModel().getDrawableVertexUvs(n),this.getModel().getMultiplyColor(n),this.getModel().getScreenColor(n),this.getModel().getDrawableOpacity(n),this.getModel().getDrawableBlendMode(n),this.getModel().getDrawableInvertedMaskBit(n))}}drawMesh(t,r,i,n,o,h,f,A,T,C,x){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW);const M=this.getModelColor();this.getClippingContextBufferForMask()==null&&(M.A*=T,this.isPremultipliedAlpha()&&(M.R*=M.A,M.G*=M.A,M.B*=M.A));let D=null;this._textures[t]!=null&&(D=this._textures[t]),xn.getInstance().setupShaderProgram(this,D,i,o,n,h,this._bufferData,T,C,M,f,A,this.isPremultipliedAlpha(),this.getMvpMatrix(),x),this.gl.drawElements(this.gl.TRIANGLES,r,this.gl.UNSIGNED_SHORT,0),this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){xn.deleteInstance()}setRenderState(t,r){ka=t,ms=r}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(const t of Object.entries(this._textures))this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),xn.getInstance().setGl(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}cu.staticRelease=()=>{e2.doStaticRelease()};const r2=new mi;class B1 extends Pd{constructor(t,r,i){super(),bt(this,"settings"),bt(this,"coreModel"),bt(this,"motionManager"),bt(this,"lipSync",!0),bt(this,"breath",gu.create()),bt(this,"eyeBlink"),bt(this,"userData"),bt(this,"renderer",new e2),bt(this,"idParamAngleX",_1),bt(this,"idParamAngleY",g1),bt(this,"idParamAngleZ",m1),bt(this,"idParamEyeBallX",y1),bt(this,"idParamEyeBallY",v1),bt(this,"idParamBodyAngleX",b1),bt(this,"idParamBreath",A1),bt(this,"idParamMouthForm",x1),bt(this,"pixelsPerUnit",1),bt(this,"centeringTransform",new nr),this.coreModel=t,this.settings=r,this.motionManager=new p1(r,i),this.init()}init(){var t;super.init(),(t=this.settings.getEyeBlinkParameters())!=null&&t.length&&(this.eyeBlink=w1.create(this.settings)),this.breath.setParameters([new yo(this.idParamAngleX,0,15,6.5345,.5),new yo(this.idParamAngleY,0,8,3.5345,.5),new yo(this.idParamAngleZ,0,10,5.5345,.5),new yo(this.idParamBodyAngleX,0,4,15.5345,.5),new yo(this.idParamBreath,0,.5,3.2345,.5)]),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){const t={};if(this.settings.layout)for(const[r,i]of Object.entries(this.settings.layout)){const n=r.charAt(0).toLowerCase()+r.slice(1);t[n]=i}return t}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.centeringTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,r){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager._currentFrameNo=r,this.renderer._clippingManager._maskTexture=void 0,xn.getInstance()._shaderSets=[]}bindTexture(t,r){this.renderer.bindTexture(t,r)}getHitAreaDefs(){var t,r;return(r=(t=this.settings.hitAreas)==null?void 0:t.map(i=>({id:i.Id,name:i.Name,index:this.coreModel.getDrawableIndex(i.Id)})))!=null?r:[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(t){return this.coreModel.getDrawableIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawableIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);const r=this.coreModel.getDrawableVertices(t).slice();for(let i=0;i<r.length;i+=2)r[i]=r[i]*this.pixelsPerUnit+this.originalWidth/2,r[i+1]=-r[i+1]*this.pixelsPerUnit+this.originalHeight/2;return r}updateTransform(t){this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t)}update(t,r){var i,n,o,h;super.update(t,r),t/=1e3,r/=1e3;const f=this.coreModel;this.emit("beforeMotionUpdate");const A=this.motionManager.update(this.coreModel,r);if(this.emit("afterMotionUpdate"),f.saveParameters(),(i=this.motionManager.expressionManager)==null||i.update(f,r),A||(n=this.eyeBlink)==null||n.updateParameters(f,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,r*1e3),this.lipSync&&this.motionManager.currentAudio){let T=this.motionManager.mouthSync(),C=0;const x=1,M=1.2;T>0&&(C=.4),T=pn(T*M,C,x);for(let D=0;D<this.motionManager.lipSyncIds.length;++D)f.addParameterValueById(this.motionManager.lipSyncIds[D],T,.8)}(o=this.physics)==null||o.evaluate(f,t),(h=this.pose)==null||h.updateParameters(f,t),this.emit("beforeModelUpdate"),f.update(),f.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,r){var i;(i=this.breath)==null||i.updateParameters(this.coreModel,t/1e3)}draw(t){const r=this.drawingMatrix,i=r2.getArray();i[0]=r.a,i[1]=r.b,i[4]=-r.c,i[5]=-r.d,i[12]=r.tx,i[13]=r.ty,this.renderer.setMvpMatrix(r2),this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING),this.viewport),this.renderer.drawModel()}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}}class i2{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,r;return(r=(t=this.groups)==null?void 0:t.find(i=>i.Name==="EyeBlink"))==null?void 0:r.Ids}getLipSyncParameters(){var t,r;return(r=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:r.Ids}}class bn extends Ra{constructor(t){if(super(t),bt(this,"moc"),bt(this,"textures"),!bn.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new i2(t))}static isValidJSON(t){var r;return!!(t!=null&&t.FileReferences)&&typeof t.FileReferences.Moc=="string"&&((r=t.FileReferences.Textures)==null?void 0:r.length)>0&&t.FileReferences.Textures.every(i=>typeof i=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[r,i]of Object.entries(this.motions))for(let n=0;n<i.length;n++)i[n].File=t(i[n].File,`motions.${r}[${n}].File`),i[n].Sound!==void 0&&(i[n].Sound=t(i[n].Sound,`motions.${r}[${n}].Sound`));if(this.expressions)for(let r=0;r<this.expressions.length;r++)this.expressions[r].File=t(this.expressions[r].File,`expressions[${r}].File`)}}Em(bn,[i2]);let Oa,s2=20;function k1(){return go.isStarted()?Promise.resolve():(Oa??(Oa=new Promise((s,t)=>{function r(){try{O1(),s()}catch(i){if(s2--,s2<0){const n=new Error("Failed to start up Cubism 4 framework.");n.cause=i,t(n);return}setTimeout(r,10)}}r()})),Oa)}function O1(s){s=Object.assign({logFunction:console.log,loggingLevel:yn.LogLevel_Verbose},s),go.startUp(s),go.initialize()}const N1=.001,n2=.5;class yu{static create(t){const r=new yu;typeof t.FadeInTime=="number"&&(r._fadeTimeSeconds=t.FadeInTime,r._fadeTimeSeconds<=0&&(r._fadeTimeSeconds=n2));const i=t.Groups,n=i.length;for(let o=0;o<n;++o){const h=i[o],f=h.length;let A=0;for(let T=0;T<f;++T){const C=h[T],x=new Na;x.partId=C.Id;const M=C.Link;if(M){const D=M.length;for(let k=0;k<D;++k){const U=new Na;U.partId=M[k],x.link.push(U)}}r._partGroups.push(x),++A}r._partGroupCounts.push(A)}return r}updateParameters(t,r){t!=this._lastModel&&this.reset(t),this._lastModel=t,r<0&&(r=0);let i=0;for(let n=0;n<this._partGroupCounts.length;n++){const o=this._partGroupCounts[n];this.doFade(t,r,i,o),i+=o}this.copyPartOpacities(t)}reset(t){let r=0;for(let i=0;i<this._partGroupCounts.length;++i){const n=this._partGroupCounts[i];for(let o=r;o<r+n;++o){this._partGroups[o].initialize(t);const h=this._partGroups[o].partIndex,f=this._partGroups[o].parameterIndex;if(!(h<0)){t.setPartOpacityByIndex(h,o==r?1:0),t.setParameterValueByIndex(f,o==r?1:0);for(let A=0;A<this._partGroups[o].link.length;++A)this._partGroups[o].link[A].initialize(t)}}r+=n}}copyPartOpacities(t){for(let r=0;r<this._partGroups.length;++r){const i=this._partGroups[r];if(i.link.length==0)continue;const n=this._partGroups[r].partIndex,o=t.getPartOpacityByIndex(n);for(let h=0;h<i.link.length;++h){const A=i.link[h].partIndex;A<0||t.setPartOpacityByIndex(A,o)}}}doFade(t,r,i,n){let o=-1,h=1;const f=.5,A=.15;for(let T=i;T<i+n;++T){const C=this._partGroups[T].partIndex,x=this._partGroups[T].parameterIndex;if(t.getParameterValueByIndex(x)>N1){if(o>=0)break;o=T,h=t.getPartOpacityByIndex(C),h+=r/this._fadeTimeSeconds,h>1&&(h=1)}}o<0&&(o=0,h=1);for(let T=i;T<i+n;++T){const C=this._partGroups[T].partIndex;if(o==T)t.setPartOpacityByIndex(C,h);else{let x=t.getPartOpacityByIndex(C),M;h<f?M=h*(f-1)/f+1:M=(1-h)*f/(1-f),(1-M)*(1-h)>A&&(M=1-A/(1-h)),x>M&&(x=M),t.setPartOpacityByIndex(C,x)}}}constructor(){this._fadeTimeSeconds=n2,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class Na{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(r=>r.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new Na;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(r=>r.clone()),t}}class o2{constructor(t=!1,r=new ai){this.isOverwritten=t,this.Color=r}}class a2{constructor(t=!1,r=new ai){this.isOverwritten=t,this.Color=r}}class U1{constructor(t=!1,r=!1){this.isOverwritten=t,this.isCulling=r}}class G1{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,r=this._savedParameters.length;for(let i=0;i<t;++i)i<r?this._savedParameters[i]=this._parameterValues[i]:this._savedParameters.push(this._parameterValues[i])}getMultiplyColor(t){return this.getOverwriteFlagForModelMultiplyColors()||this.getOverwriteFlagForDrawableMultiplyColors(t)?this._userMultiplyColors[t].Color:this.getDrawableMultiplyColor(t)}getScreenColor(t){return this.getOverwriteFlagForModelScreenColors()||this.getOverwriteFlagForDrawableScreenColors(t)?this._userScreenColors[t].Color:this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,r){this.setMultiplyColorByRGBA(t,r.R,r.G,r.B,r.A)}setMultiplyColorByRGBA(t,r,i,n,o=1){this._userMultiplyColors[t].Color.R=r,this._userMultiplyColors[t].Color.G=i,this._userMultiplyColors[t].Color.B=n,this._userMultiplyColors[t].Color.A=o}setScreenColorByTextureColor(t,r){this.setScreenColorByRGBA(t,r.R,r.G,r.B,r.A)}setScreenColorByRGBA(t,r,i,n,o=1){this._userScreenColors[t].Color.R=r,this._userScreenColors[t].Color.G=i,this._userScreenColors[t].Color.B=n,this._userScreenColors[t].Color.A=o}getPartMultiplyColor(t){return this._userPartMultiplyColors[t].Color}getPartScreenColor(t){return this._userPartScreenColors[t].Color}setPartColor(t,r,i,n,o,h,f){if(h[t].Color.R=r,h[t].Color.G=i,h[t].Color.B=n,h[t].Color.A=o,h[t].isOverwritten)for(let A=0;A<this._partChildDrawables[t].length;++A){const T=this._partChildDrawables[t][A];f[T].Color.R=r,f[T].Color.G=i,f[T].Color.B=n,f[T].Color.A=o}}setPartMultiplyColorByTextureColor(t,r){this.setPartMultiplyColorByRGBA(t,r.R,r.G,r.B,r.A)}setPartMultiplyColorByRGBA(t,r,i,n,o){this.setPartColor(t,r,i,n,o,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,r){this.setPartScreenColorByRGBA(t,r.R,r.G,r.B,r.A)}setPartScreenColorByRGBA(t,r,i,n,o){this.setPartColor(t,r,i,n,o,this._userPartScreenColors,this._userScreenColors)}getOverwriteFlagForModelMultiplyColors(){return this._isOverwrittenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return this._isOverwrittenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){this._isOverwrittenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){this._isOverwrittenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return this._userMultiplyColors[t].isOverwritten}getOverwriteFlagForDrawableScreenColors(t){return this._userScreenColors[t].isOverwritten}setOverwriteFlagForDrawableMultiplyColors(t,r){this._userMultiplyColors[t].isOverwritten=r}setOverwriteFlagForDrawableScreenColors(t,r){this._userScreenColors[t].isOverwritten=r}getOverwriteColorForPartMultiplyColors(t){return this._userPartMultiplyColors[t].isOverwritten}getOverwriteColorForPartScreenColors(t){return this._userPartScreenColors[t].isOverwritten}setOverwriteColorForPartColors(t,r,i,n){i[t].isOverwritten=r;for(let o=0;o<this._partChildDrawables[t].length;++o){const h=this._partChildDrawables[t][o];n[h].isOverwritten=r,r&&(n[h].Color.R=i[t].Color.R,n[h].Color.G=i[t].Color.G,n[h].Color.B=i[t].Color.B,n[h].Color.A=i[t].Color.A)}}setOverwriteColorForPartMultiplyColors(t,r){this._userPartMultiplyColors[t].isOverwritten=r,this.setOverwriteColorForPartColors(t,r,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,r){this._userPartScreenColors[t].isOverwritten=r,this.setOverwriteColorForPartColors(t,r,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverwriteFlagForModelCullings()||this.getOverwriteFlagForDrawableCullings(t))return this._userCullings[t].isCulling;const r=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(r[t])}setDrawableCulling(t,r){this._userCullings[t].isCulling=r}getOverwriteFlagForModelCullings(){return this._isOverwrittenCullings}setOverwriteFlagForModelCullings(t){this._isOverwrittenCullings=t}getOverwriteFlagForDrawableCullings(t){return this._userCullings[t].isOverwritten}setOverwriteFlagForDrawableCullings(t,r){this._userCullings[t].isOverwritten=r}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let r;const i=this._model.parts.count;for(r=0;r<i;++r)if(t==this._partIds[r])return r;return t in this._notExistPartId?this._notExistPartId[t]:(r=i+this._notExistPartId.length,this._notExistPartId[t]=r,this._notExistPartOpacities[r]=0,r)}getPartId(t){return this._model.parts.ids[t]}getPartCount(){return this._model.parts.count}setPartOpacityByIndex(t,r){if(t in this._notExistPartOpacities){this._notExistPartOpacities[t]=r;return}vn(0<=t&&t<this.getPartCount()),this._partOpacities[t]=r}setPartOpacityById(t,r){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,r)}getPartOpacityByIndex(t){return t in this._notExistPartOpacities?this._notExistPartOpacities[t]:(vn(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const r=this.getPartIndex(t);return r<0?0:this.getPartOpacityByIndex(r)}getParameterIndex(t){let r;const i=this._model.parameters.count;for(r=0;r<i;++r)if(t==this._parameterIds[r])return r;return t in this._notExistParameterId?this._notExistParameterId[t]:(r=this._model.parameters.count+Object.keys(this._notExistParameterId).length,this._notExistParameterId[t]=r,this._notExistParameterValues[r]=0,r)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterValueByIndex(t){return t in this._notExistParameterValues?this._notExistParameterValues[t]:(vn(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const r=this.getParameterIndex(t);return this.getParameterValueByIndex(r)}setParameterValueByIndex(t,r,i=1){if(t in this._notExistParameterValues){this._notExistParameterValues[t]=i==1?r:this._notExistParameterValues[t]*(1-i)+r*i;return}vn(0<=t&&t<this.getParameterCount()),this._model.parameters.maximumValues[t]<r&&(r=this._model.parameters.maximumValues[t]),this._model.parameters.minimumValues[t]>r&&(r=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?r:this._parameterValues[t]=this._parameterValues[t]*(1-i)+r*i}setParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.setParameterValueByIndex(n,r,i)}addParameterValueByIndex(t,r,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+r*i)}addParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.addParameterValueByIndex(n,r,i)}multiplyParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.multiplyParameterValueByIndex(n,r,i)}multiplyParameterValueByIndex(t,r,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(r-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const r=this._model.drawables.count;for(let i=0;i<r;++i)if(this._drawableIds[i]==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){return this._model.drawables.ids[t]}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(r[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const r=this._model.drawables.multiplyColors,i=t*4,n=new ai;return n.R=r[i],n.G=r[i+1],n.B=r[i+2],n.A=r[i+3],n}getDrawableScreenColor(t){const r=this._model.drawables.screenColors,i=t*4,n=new ai;return n.R=r[i],n.G=r[i+1],n.B=r[i+2],n.A=r[i+3],n}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const r=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(r[t])?gs.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(r[t])?gs.CubismBlendMode_Multiplicative:gs.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const r=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(r[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(r[t])}getDrawableDynamicFlagVisibilityDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(r[t])}getDrawableDynamicFlagOpacityDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(r[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(r[t])}getDrawableDynamicFlagBlendColorDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(r[t])}loadParameters(){let t=this._model.parameters.count;const r=this._savedParameters.length;t>r&&(t=r);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters[i]}initialize(){this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const r=this._model.parameters.ids,i=this._model.parameters.count;for(let n=0;n<i;++n)this._parameterIds.push(r[n])}const t=this._model.parts.count;{const r=this._model.parts.ids;for(let i=0;i<t;++i)this._partIds.push(r[i])}{const r=this._model.drawables.ids,i=this._model.drawables.count,n=new U1(!1,!1);for(let o=0;o<t;++o){const h=new ai(1,1,1,1),f=new ai(0,0,0,1),A=new a2(!1,h),T=new a2(!1,f);this._userPartMultiplyColors.push(A),this._userPartScreenColors.push(T),this._partChildDrawables.push([])}for(let o=0;o<i;++o){const h=new ai(1,1,1,1),f=new ai(0,0,0,1),A=new o2(!1,h),T=new o2(!1,f);this._drawableIds.push(r[o]),this._userMultiplyColors.push(A),this._userScreenColors.push(T),this._userCullings.push(n);const C=this.getDrawableParentPartIndex(o);C>=0&&this._partChildDrawables[C].push(o)}}}constructor(t){this._model=t,this._savedParameters=[],this._parameterIds=[],this._drawableIds=[],this._partIds=[],this._isOverwrittenModelMultiplyColors=!1,this._isOverwrittenModelScreenColors=!1,this._isOverwrittenCullings=!1,this._modelOpacity=1,this._userMultiplyColors=[],this._userScreenColors=[],this._userCullings=[],this._userPartMultiplyColors=[],this._userPartScreenColors=[],this._partChildDrawables=[],this._notExistPartId={},this._notExistParameterId={},this._notExistParameterValues={},this._notExistPartOpacities={},this.initialize()}release(){this._model.release(),this._model=void 0}}class vu{static create(t,r){if(r&&!this.hasMocConsistency(t))throw new Error("Inconsistent MOC3.");const i=Live2DCubismCore.Moc.fromArrayBuffer(t);if(i){const n=new vu(i);return n._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t),n}throw new Error("Failed to CubismMoc.create().")}createModel(){let t;const r=Live2DCubismCore.Model.fromMoc(this._moc);if(r)return t=new G1(r),++this._modelCount,t;throw new Error("Unknown error")}deleteModel(t){t!=null&&--this._modelCount}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){this._moc._release(),this._moc=void 0}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}}var xu=(s=>(s[s.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",s))(xu||{}),Qs=(s=>(s[s.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",s[s.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",s[s.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",s))(Qs||{});class V1{constructor(){this.initialPosition=new Ie(0,0),this.position=new Ie(0,0),this.lastPosition=new Ie(0,0),this.lastGravity=new Ie(0,0),this.force=new Ie(0,0),this.velocity=new Ie(0,0)}}class z1{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class X1{constructor(){this.source={}}}class W1{constructor(){this.destination={},this.translationScale=new Ie(0,0)}}class H1{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new Ie(0,0),this.wind=new Ie(0,0),this.fps=0}}class Y1{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new Ie(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new Ie(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getFps(){return this._json.Meta.Fps||0}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,r){return this._json.PhysicsSettings[t].Input[r].Weight}getInputReflect(t,r){return this._json.PhysicsSettings[t].Input[r].Reflect}getInputType(t,r){return this._json.PhysicsSettings[t].Input[r].Type}getInputSourceId(t,r){return this._json.PhysicsSettings[t].Input[r].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,r){return this._json.PhysicsSettings[t].Output[r].VertexIndex}getOutputAngleScale(t,r){return this._json.PhysicsSettings[t].Output[r].Scale}getOutputWeight(t,r){return this._json.PhysicsSettings[t].Output[r].Weight}getOutputDestinationId(t,r){return this._json.PhysicsSettings[t].Output[r].Destination.Id}getOutputType(t,r){return this._json.PhysicsSettings[t].Output[r].Type}getOutputReflect(t,r){return this._json.PhysicsSettings[t].Output[r].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,r){return this._json.PhysicsSettings[t].Vertices[r].Mobility}getParticleDelay(t,r){return this._json.PhysicsSettings[t].Vertices[r].Delay}getParticleAcceleration(t,r){return this._json.PhysicsSettings[t].Vertices[r].Acceleration}getParticleRadius(t,r){return this._json.PhysicsSettings[t].Vertices[r].Radius}getParticlePosition(t,r){const i=new Ie(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[r].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[r].Position.Y,i}}const h2="X",l2="Y",u2="Angle",j1=5,bu=100,c2=.001,q1=5;class Au{static create(t){const r=new Au;return r.parse(t),r._physicsRig.gravity.y=0,r}static delete(t){t!=null&&t.release()}parse(t){this._physicsRig=new H1;const r=new Y1(t);this._physicsRig.gravity=r.getGravity(),this._physicsRig.wind=r.getWind(),this._physicsRig.subRigCount=r.getSubRigCount(),this._physicsRig.fps=r.getFps(),this._currentRigOutputs=[],this._previousRigOutputs=[];let i=0,n=0,o=0;for(let h=0;h<this._physicsRig.subRigCount;++h){const f=new z1;f.normalizationPosition.minimum=r.getNormalizationPositionMinimumValue(h),f.normalizationPosition.maximum=r.getNormalizationPositionMaximumValue(h),f.normalizationPosition.defalut=r.getNormalizationPositionDefaultValue(h),f.normalizationAngle.minimum=r.getNormalizationAngleMinimumValue(h),f.normalizationAngle.maximum=r.getNormalizationAngleMaximumValue(h),f.normalizationAngle.defalut=r.getNormalizationAngleDefaultValue(h),f.inputCount=r.getInputCount(h),f.baseInputIndex=i,i+=f.inputCount;for(let C=0;C<f.inputCount;++C){const x=new X1;switch(x.sourceParameterIndex=-1,x.weight=r.getInputWeight(h,C),x.reflect=r.getInputReflect(h,C),r.getInputType(h,C)){case h2:x.type=Qs.CubismPhysicsSource_X,x.getNormalizedParameterValue=Q1;break;case l2:x.type=Qs.CubismPhysicsSource_Y,x.getNormalizedParameterValue=K1;break;case u2:x.type=Qs.CubismPhysicsSource_Angle,x.getNormalizedParameterValue=J1;break}x.source.targetType=xu.CubismPhysicsTargetType_Parameter,x.source.id=r.getInputSourceId(h,C),this._physicsRig.inputs.push(x)}f.outputCount=r.getOutputCount(h),f.baseOutputIndex=n;const A=new f2,T=new f2;for(let C=0;C<f.outputCount;++C){A.outputs[C]=0,T.outputs[C]=0;let x=this._physicsRig.outputs[n+C];switch(x||(x=new W1,this._physicsRig.outputs[n+C]=x),x.destinationParameterIndex=-1,x.vertexIndex=r.getOutputVertexIndex(h,C),x.angleScale=r.getOutputAngleScale(h,C),x.weight=r.getOutputWeight(h,C),x.destination.targetType=xu.CubismPhysicsTargetType_Parameter,x.destination.id=r.getOutputDestinationId(h,C),r.getOutputType(h,C)){case h2:x.type=Qs.CubismPhysicsSource_X,x.getValue=ty,x.getScale=ny;break;case l2:x.type=Qs.CubismPhysicsSource_Y,x.getValue=ey,x.getScale=oy;break;case u2:x.type=Qs.CubismPhysicsSource_Angle,x.getValue=ry,x.getScale=ay;break}x.reflect=r.getOutputReflect(h,C)}this._currentRigOutputs.push(A),this._previousRigOutputs.push(T),n+=f.outputCount,f.particleCount=r.getParticleCount(h),f.baseParticleIndex=o,o+=f.particleCount;for(let C=0;C<f.particleCount;++C){const x=new V1;x.mobility=r.getParticleMobility(h,C),x.delay=r.getParticleDelay(h,C),x.acceleration=r.getParticleAcceleration(h,C),x.radius=r.getParticleRadius(h,C),x.position=r.getParticlePosition(h,C),this._physicsRig.particles.push(x)}this._physicsRig.settings.push(f)}this.initialize(),r.release()}stabilization(t){var r,i,n,o;let h,f,A,T;const C=new Ie;let x,M,D,k,U,G,X,J;U=t.getModel().parameters.values,G=t.getModel().parameters.maximumValues,X=t.getModel().parameters.minimumValues,J=t.getModel().parameters.defaultValues,((i=(r=this._parameterCaches)==null?void 0:r.length)!=null?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((o=(n=this._parameterInputCaches)==null?void 0:n.length)!=null?o:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let Z=0;Z<t.getParameterCount();++Z)this._parameterCaches[Z]=U[Z],this._parameterInputCaches[Z]=U[Z];for(let Z=0;Z<this._physicsRig.subRigCount;++Z){h={angle:0},C.x=0,C.y=0,x=this._physicsRig.settings[Z],M=this._physicsRig.inputs.slice(x.baseInputIndex),D=this._physicsRig.outputs.slice(x.baseOutputIndex),k=this._physicsRig.particles.slice(x.baseParticleIndex);for(let it=0;it<x.inputCount;++it)f=M[it].weight/bu,M[it].sourceParameterIndex==-1&&(M[it].sourceParameterIndex=t.getParameterIndex(M[it].source.id)),M[it].getNormalizedParameterValue(C,h,U[M[it].sourceParameterIndex],X[M[it].sourceParameterIndex],G[M[it].sourceParameterIndex],J[M[it].sourceParameterIndex],x.normalizationPosition,x.normalizationAngle,M[it].reflect,f),this._parameterCaches[M[it].sourceParameterIndex]=U[M[it].sourceParameterIndex];A=Ke.degreesToRadian(-h.angle),C.x=C.x*Ke.cos(A)-C.y*Ke.sin(A),C.y=C.x*Ke.sin(A)+C.y*Ke.cos(A),ly(k,x.particleCount,C,h.angle,this._options.wind,c2*x.normalizationPosition.maximum);for(let it=0;it<x.outputCount;++it){const Q=D[it].vertexIndex;if(D[it].destinationParameterIndex==-1&&(D[it].destinationParameterIndex=t.getParameterIndex(D[it].destination.id)),Q<1||Q>=x.particleCount)continue;let _t=new Ie;_t=k[Q].position.substract(k[Q-1].position),T=D[it].getValue(_t,k,Q,D[it].reflect,this._options.gravity),this._currentRigOutputs[Z].outputs[it]=T,this._previousRigOutputs[Z].outputs[it]=T;const et=D[it].destinationParameterIndex,ft=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(U.subarray(et))):U.slice(et);wu(ft,X[et],G[et],T,D[it]);for(let wt=et,Rt=0;wt<this._parameterCaches.length;wt++,Rt++)U[wt]=this._parameterCaches[wt]=ft[Rt]}}}evaluate(t,r){var i,n,o,h;let f,A,T,C;const x=new Ie;let M,D,k,U;if(0>=r)return;let G,X,J,Z,it;if(this._currentRemainTime+=r,this._currentRemainTime>q1&&(this._currentRemainTime=0),G=t.getModel().parameters.values,X=t.getModel().parameters.maximumValues,J=t.getModel().parameters.minimumValues,Z=t.getModel().parameters.defaultValues,((n=(i=this._parameterCaches)==null?void 0:i.length)!=null?n:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((h=(o=this._parameterInputCaches)==null?void 0:o.length)!=null?h:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let _t=0;_t<t.getParameterCount();++_t)this._parameterInputCaches[_t]=G[_t]}for(this._physicsRig.fps>0?it=1/this._physicsRig.fps:it=r;this._currentRemainTime>=it;){for(let et=0;et<this._physicsRig.subRigCount;++et){M=this._physicsRig.settings[et],k=this._physicsRig.outputs.slice(M.baseOutputIndex);for(let ft=0;ft<M.outputCount;++ft)this._previousRigOutputs[et].outputs[ft]=this._currentRigOutputs[et].outputs[ft]}const _t=it/this._currentRemainTime;for(let et=0;et<t.getParameterCount();++et)this._parameterCaches[et]=this._parameterInputCaches[et]*(1-_t)+G[et]*_t,this._parameterInputCaches[et]=this._parameterCaches[et];for(let et=0;et<this._physicsRig.subRigCount;++et){f={angle:0},x.x=0,x.y=0,M=this._physicsRig.settings[et],D=this._physicsRig.inputs.slice(M.baseInputIndex),k=this._physicsRig.outputs.slice(M.baseOutputIndex),U=this._physicsRig.particles.slice(M.baseParticleIndex);for(let ft=0;ft<M.inputCount;++ft)A=D[ft].weight/bu,D[ft].sourceParameterIndex==-1&&(D[ft].sourceParameterIndex=t.getParameterIndex(D[ft].source.id)),D[ft].getNormalizedParameterValue(x,f,this._parameterCaches[D[ft].sourceParameterIndex],J[D[ft].sourceParameterIndex],X[D[ft].sourceParameterIndex],Z[D[ft].sourceParameterIndex],M.normalizationPosition,M.normalizationAngle,D[ft].reflect,A);T=Ke.degreesToRadian(-f.angle),x.x=x.x*Ke.cos(T)-x.y*Ke.sin(T),x.y=x.x*Ke.sin(T)+x.y*Ke.cos(T),hy(U,M.particleCount,x,f.angle,this._options.wind,c2*M.normalizationPosition.maximum,it,j1);for(let ft=0;ft<M.outputCount;++ft){const wt=k[ft].vertexIndex;if(k[ft].destinationParameterIndex==-1&&(k[ft].destinationParameterIndex=t.getParameterIndex(k[ft].destination.id)),wt<1||wt>=M.particleCount)continue;const Rt=new Ie;Rt.x=U[wt].position.x-U[wt-1].position.x,Rt.y=U[wt].position.y-U[wt-1].position.y,C=k[ft].getValue(Rt,U,wt,k[ft].reflect,this._options.gravity),this._currentRigOutputs[et].outputs[ft]=C;const It=k[ft].destinationParameterIndex,pt=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(It))):this._parameterCaches.slice(It);wu(pt,J[It],X[It],C,k[ft]);for(let xt=It,Ct=0;xt<this._parameterCaches.length;xt++,Ct++)this._parameterCaches[xt]=pt[Ct]}}this._currentRemainTime-=it}const Q=this._currentRemainTime/it;this.interpolate(t,Q)}interpolate(t,r){let i,n,o,h,f;o=t.getModel().parameters.values,h=t.getModel().parameters.maximumValues,f=t.getModel().parameters.minimumValues;for(let A=0;A<this._physicsRig.subRigCount;++A){n=this._physicsRig.settings[A],i=this._physicsRig.outputs.slice(n.baseOutputIndex);for(let T=0;T<n.outputCount;++T){if(i[T].destinationParameterIndex==-1)continue;const C=i[T].destinationParameterIndex,x=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(o.subarray(C))):o.slice(C);wu(x,f[C],h[C],this._previousRigOutputs[A].outputs[T]*(1-r)+this._currentRigOutputs[A].outputs[T]*r,i[T]);for(let M=C,D=0;M<o.length;M++,D++)o[M]=x[D]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._options=new Z1,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=[],this._previousRigOutputs=[],this._currentRemainTime=0}release(){this._physicsRig=void 0}initialize(){let t,r,i;for(let n=0;n<this._physicsRig.subRigCount;++n){r=this._physicsRig.settings[n],t=this._physicsRig.particles.slice(r.baseParticleIndex),t[0].initialPosition=new Ie(0,0),t[0].lastPosition=new Ie(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new Ie(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new Ie(0,0),t[0].force=new Ie(0,0);for(let o=1;o<r.particleCount;++o)i=new Ie(0,0),i.y=t[o].radius,t[o].initialPosition=new Ie(t[o-1].initialPosition.x+i.x,t[o-1].initialPosition.y+i.y),t[o].position=new Ie(t[o].initialPosition.x,t[o].initialPosition.y),t[o].lastPosition=new Ie(t[o].initialPosition.x,t[o].initialPosition.y),t[o].lastGravity=new Ie(0,-1),t[o].lastGravity.y*=-1,t[o].velocity=new Ie(0,0),t[o].force=new Ie(0,0)}}}class Z1{constructor(){this.gravity=new Ie(0,0),this.wind=new Ie(0,0)}}class f2{constructor(){this.outputs=[]}}function Q1(s,t,r,i,n,o,h,f,A,T){s.x+=Tu(r,i,n,o,h.minimum,h.maximum,h.defalut,A)*T}function K1(s,t,r,i,n,o,h,f,A,T){s.y+=Tu(r,i,n,o,h.minimum,h.maximum,h.defalut,A)*T}function J1(s,t,r,i,n,o,h,f,A,T){t.angle+=Tu(r,i,n,o,f.minimum,f.maximum,f.defalut,A)*T}function ty(s,t,r,i,n){let o=s.x;return i&&(o*=-1),o}function ey(s,t,r,i,n){let o=s.y;return i&&(o*=-1),o}function ry(s,t,r,i,n){let o;return r>=2?n=t[r-1].position.substract(t[r-2].position):n=n.multiplyByScaler(-1),o=Ke.directionToRadian(n,s),i&&(o*=-1),o}function iy(s,t){return Math.abs(Math.max(s,t)-Math.min(s,t))}function sy(s,t){return Math.min(s,t)+iy(s,t)/2}function ny(s,t){return s.x}function oy(s,t){return s.y}function ay(s,t){return t}function hy(s,t,r,i,n,o,h,f){let A,T,C,x,M=new Ie(0,0),D=new Ie(0,0),k=new Ie(0,0),U=new Ie(0,0);s[0].position=new Ie(r.x,r.y),A=Ke.degreesToRadian(i),x=Ke.radianToDirection(A),x.normalize();for(let G=1;G<t;++G)s[G].force=x.multiplyByScaler(s[G].acceleration).add(n),s[G].lastPosition=new Ie(s[G].position.x,s[G].position.y),T=s[G].delay*h*30,M=s[G].position.substract(s[G-1].position),C=Ke.directionToRadian(s[G].lastGravity,x)/f,M.x=Ke.cos(C)*M.x-M.y*Ke.sin(C),M.y=Ke.sin(C)*M.x+M.y*Ke.cos(C),s[G].position=s[G-1].position.add(M),D=s[G].velocity.multiplyByScaler(T),k=s[G].force.multiplyByScaler(T).multiplyByScaler(T),s[G].position=s[G].position.add(D).add(k),U=s[G].position.substract(s[G-1].position),U.normalize(),s[G].position=s[G-1].position.add(U.multiplyByScaler(s[G].radius)),Ke.abs(s[G].position.x)<o&&(s[G].position.x=0),T!=0&&(s[G].velocity=s[G].position.substract(s[G].lastPosition),s[G].velocity=s[G].velocity.divisionByScalar(T),s[G].velocity=s[G].velocity.multiplyByScaler(s[G].mobility)),s[G].force=new Ie(0,0),s[G].lastGravity=new Ie(x.x,x.y)}function ly(s,t,r,i,n,o){let h,f,A=new Ie(0,0);s[0].position=new Ie(r.x,r.y),h=Ke.degreesToRadian(i),f=Ke.radianToDirection(h),f.normalize();for(let T=1;T<t;++T)s[T].force=f.multiplyByScaler(s[T].acceleration).add(n),s[T].lastPosition=new Ie(s[T].position.x,s[T].position.y),s[T].velocity=new Ie(0,0),A=s[T].force,A.normalize(),A=A.multiplyByScaler(s[T].radius),s[T].position=s[T-1].position.add(A),Ke.abs(s[T].position.x)<o&&(s[T].position.x=0),s[T].force=new Ie(0,0),s[T].lastGravity=new Ie(f.x,f.y)}function wu(s,t,r,i,n){let o,h,f;o=n.getScale(n.translationScale,n.angleScale),h=i*o,h<t?(h<n.valueBelowMinimum&&(n.valueBelowMinimum=h),h=t):h>r&&(h>n.valueExceededMaximum&&(n.valueExceededMaximum=h),h=r),f=n.weight/bu,f>=1||(h=s[0]*(1-f)+h*f),s[0]=h}function Tu(s,t,r,i,n,o,h,f){let A=0;const T=Ke.max(r,t);T<s&&(s=T);const C=Ke.min(r,t);C>s&&(s=C);const x=Ke.min(n,o),M=Ke.max(n,o),D=h,k=sy(C,T),U=s-k;switch(Math.sign(U)){case 1:{const G=M-D,X=T-k;X!=0&&(A=U*(G/X),A+=D);break}case-1:{const G=x-D,X=C-k;X!=0&&(A=U*(G/X),A+=D);break}case 0:{A=D;break}}return f?A:A*-1}oi.registerRuntime({version:4,ready:k1,test(s){return s instanceof bn||bn.isValidJSON(s)},isValidMoc(s){if(s.byteLength<4)return!1;const t=new Int8Array(s,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(s){return new bn(s)},createCoreModel(s,t){const r=vu.create(s,!!(t!=null&&t.checkMocConsistency));try{const i=r.createModel();return i.__moc=r,i}catch(i){try{r.release()}catch{}throw i}},createInternalModel(s,t,r){const i=new B1(s,t,r),n=s;return n.__moc&&(i.__moc=n.__moc,delete n.__moc,i.once("destroy",uy)),i},createPhysics(s,t){return Au.create(t)},createPose(s,t){return yu.create(t)}});function uy(){var s;(s=this.__moc)==null||s.release()}async function cy(s){const{element_id:t="live2d-canvas",models:r,width:i=300,height:n=300,auto_fit:o=!0,auto_motion:h=!0,mouse_tracking:f=!0}=s;let A=fy(t,s);const T=new kl({view:A,width:i,height:n,backgroundAlpha:0,autoDensity:!0,antialias:!0,eventMode:"static",eventFeatures:{move:!0,globalMove:!0,click:!0,wheel:!0}}),C=await uu.from(r[0].model_url);if(T.stage.addChild(C),o){const x=Math.min(i/C.width,n/C.height);C.scale.set(x),C.x=(i-C.width*x)/2,C.y=(n-C.height*x)/2}return f&&dy(C,T.view),h&&await py(C),C}function fy(s,t){let r=document.getElementById(s);return r||(r=document.createElement("canvas"),r.id=s,document.body.appendChild(r),r.style.display="none",r.style.position="fixed",r.style.display="block",r.style.position="absolute",r.style.bottom=`${t.spacing_y||0}px`,r.style[t.position==="left"?"left":"right"]=`${t.spacing_x||0}px`,r.style.zIndex="9999"),r}function dy(s,t){document.addEventListener("mousemove",r=>{var A;const i=t.getBoundingClientRect(),n=i.left+i.width/2,o=i.top+i.height/2,h=(r.clientX-n)/i.width,f=-(r.clientY-o)/i.height;s.internalModel&&((A=s.internalModel.focusController)==null||A.focus(h,f))}),t.addEventListener("click",()=>{var r;try{const i=(r=s.internalModel)==null?void 0:r.motionManager.definitions;if(i)if(i.tap_body)s.motion("tap_body");else if(i.tap)s.motion("tap");else{const n=Object.keys(i)[0];n&&s.motion(n)}}catch(i){console.warn("Failed to play tap animation:",i)}})}async function py(s){var t;try{const r=(t=s.internalModel)==null?void 0:t.motionManager.definitions;if(r)if(r.idle)await s.motion("idle");else if(r.tap_body)await s.motion("tap_body");else{const i=Object.keys(r)[0];i&&await s.motion(i)}}catch(r){console.warn("Failed to start idle animation:",r)}}async function _y(){uu.registerTicker($r),be.add(sa)}qr.Live2DModel=uu,qr.MotionManager=fo,qr.PIXI=bm,qr.SoundManager=Mr,qr.createLive2D=cy,qr.initializeLive2D=_y,Object.defineProperty(qr,Symbol.toStringTag,{value:"Module"})});
1206
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class xn{static getInstance(){return Zs==null&&(Zs=new xn),Zs}static deleteInstance(){Zs&&(Zs.release(),Zs=void 0)}constructor(){this._shaderSets=[]}release(){this.releaseShaderProgram()}setupShaderProgram(t,r,i,n,o,h,f,A,T,C,x,M,D,k,U){D||Zi("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders();let G,X,J,Z;const it=t.getClippingContextBufferForMask();if(it!=null){const Q=this._shaderSets[0];this.gl.useProgram(Q.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(Q.samplerTexture0Location,0),f.vertex==null&&(f.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(Q.attributePositionLocation),this.gl.vertexAttribPointer(Q.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),f.uv==null&&(f.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(Q.attributeTexCoordLocation),this.gl.vertexAttribPointer(Q.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);const _t=it._layoutChannelNo,et=it.getClippingManager().getChannelFlagAsColor(_t);this.gl.uniform4f(Q.uniformChannelFlagLocation,et.R,et.G,et.B,et.A),this.gl.uniformMatrix4fv(Q.uniformClipMatrixLocation,!1,it._matrixForMask.getArray());const ft=it._layoutBounds;this.gl.uniform4f(Q.uniformBaseColorLocation,ft.x*2-1,ft.y*2-1,ft.getRight()*2-1,ft.getBottom()*2-1),this.gl.uniform4f(Q.uniformMultiplyColorLocation,x.R,x.G,x.B,x.A),this.gl.uniform4f(Q.uniformScreenColorLocation,M.R,M.G,M.B,M.A),G=this.gl.ZERO,X=this.gl.ONE_MINUS_SRC_COLOR,J=this.gl.ZERO,Z=this.gl.ONE_MINUS_SRC_ALPHA}else{const Q=t.getClippingContextBufferForDraw(),et=Q!=null?U?2:1:0;let ft;switch(T){case gs.CubismBlendMode_Normal:default:ft=this._shaderSets[1+et],G=this.gl.ONE,X=this.gl.ONE_MINUS_SRC_ALPHA,J=this.gl.ONE,Z=this.gl.ONE_MINUS_SRC_ALPHA;break;case gs.CubismBlendMode_Additive:ft=this._shaderSets[4+et],G=this.gl.ONE,X=this.gl.ONE,J=this.gl.ZERO,Z=this.gl.ONE;break;case gs.CubismBlendMode_Multiplicative:ft=this._shaderSets[7+et],G=this.gl.DST_COLOR,X=this.gl.ONE_MINUS_SRC_ALPHA,J=this.gl.ZERO,Z=this.gl.ONE;break}if(this.gl.useProgram(ft.shaderProgram),f.vertex==null&&(f.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(ft.attributePositionLocation),this.gl.vertexAttribPointer(ft.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),f.uv==null&&(f.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,f.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(ft.attributeTexCoordLocation),this.gl.vertexAttribPointer(ft.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),Q!=null){this.gl.activeTexture(this.gl.TEXTURE1);const wt=Q.getClippingManager().getColorBuffer()[t.getClippingContextBufferForDraw()._bufferIndex];this.gl.bindTexture(this.gl.TEXTURE_2D,wt),this.gl.uniform1i(ft.samplerTexture1Location,1),this.gl.uniformMatrix4fv(ft.uniformClipMatrixLocation,!1,Q._matrixForDraw.getArray());const Rt=Q._layoutChannelNo,It=Q.getClippingManager().getChannelFlagAsColor(Rt);this.gl.uniform4f(ft.uniformChannelFlagLocation,It.R,It.G,It.B,It.A)}this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(ft.samplerTexture0Location,0),this.gl.uniformMatrix4fv(ft.uniformMatrixLocation,!1,k.getArray()),this.gl.uniform4f(ft.uniformBaseColorLocation,C.R,C.G,C.B,C.A),this.gl.uniform4f(ft.uniformMultiplyColorLocation,x.R,x.G,x.B,x.A),this.gl.uniform4f(ft.uniformScreenColorLocation,M.R,M.G,M.B,M.A)}f.index==null&&(f.index=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,f.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,o,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(G,X,J,Z)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.length;t++)this.gl.deleteProgram(this._shaderSets[t].shaderProgram),this._shaderSets[t].shaderProgram=0;this._shaderSets=[]}generateShaders(){for(let t=0;t<C1;t++)this._shaderSets.push({});this._shaderSets[0].shaderProgram=this.loadShaderProgram(M1,R1),this._shaderSets[1].shaderProgram=this.loadShaderProgram(I1,D1),this._shaderSets[2].shaderProgram=this.loadShaderProgram(t2,F1),this._shaderSets[3].shaderProgram=this.loadShaderProgram(t2,L1),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[0].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_multiplyColor"),this._shaderSets[0].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_screenColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}loadShaderProgram(t,r){const i=this.gl.createProgram(),n=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!n)return Zi("Vertex shader compile error!"),0;const o=this.compileShaderSource(this.gl.FRAGMENT_SHADER,r);return o?(this.gl.attachShader(i,n),this.gl.attachShader(i,o),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(n),this.gl.deleteShader(o),i):(Zi("Failed to link program: {0}",i),this.gl.deleteShader(n),this.gl.deleteShader(o),i&&this.gl.deleteProgram(i),0)):(Zi("Vertex shader compile error!"),0)}compileShaderSource(t,r){const i=r,n=this.gl.createShader(t);if(this.gl.shaderSource(n,i),this.gl.compileShader(n),!n){const h=this.gl.getShaderInfoLog(n);Zi("Shader compile log: {0} ",h)}return this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(this.gl.deleteShader(n),null)}setGl(t){this.gl=t}}const M1="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",R1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",I1="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",t2="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",D1="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",F1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",L1="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}";class e2 extends uu{initialize(t,r=1){t.isUsingMasking()&&(this._clippingManager=new Jd,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts(),r));for(let i=t.getDrawableCount()-1;i>=0;i--)this._sortedDrawableIndexList[i]=0;super.initialize(t)}bindTexture(t,r){this._textures[t]=r}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const r=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=new Jd,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts(),r)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new $1,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}release(){var t,r,i;const n=this;this._clippingManager.release(),n._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(r=this.gl)==null||r.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,n._bufferData=void 0,n._textures=void 0}doDrawModel(){if(this.gl==null){Zi(`'gl' is null. WebGLRenderingContext is required.
1207
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),r=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const n=r[i];this._sortedDrawableIndexList[n]=i}for(let i=0;i<t;++i){const n=this._sortedDrawableIndexList[i];if(!this.getModel().getDrawableDynamicFlagIsVisible(n))continue;const o=this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw()[n]:null;if(o!=null&&this.isUsingHighPrecisionMask()){o._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,o.getClippingManager().getMaskRenderTexture()[o._bufferIndex]),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const h=o._clippingIdCount;for(let f=0;f<h;f++){const A=o._clippingIdList[f];this._model.getDrawableDynamicFlagVertexPositionsDidChange(A)&&(this.setIsCulling(this._model.getDrawableCulling(A)!=!1),this.setClippingContextBufferForMask(o),this.drawMesh(this.getModel().getDrawableTextureIndex(A),this.getModel().getDrawableVertexIndexCount(A),this.getModel().getDrawableVertexCount(A),this.getModel().getDrawableVertexIndices(A),this.getModel().getDrawableVertices(A),this.getModel().getDrawableVertexUvs(A),this.getModel().getMultiplyColor(A),this.getModel().getScreenColor(A),this.getModel().getDrawableOpacity(A),gs.CubismBlendMode_Normal,!1))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Ba),this.setClippingContextBufferForMask(null),this.gl.viewport(ms[0],ms[1],ms[2],ms[3]),this.preDraw()}this.setClippingContextBufferForDraw(o),this.setIsCulling(this.getModel().getDrawableCulling(n)),this.drawMesh(this.getModel().getDrawableTextureIndex(n),this.getModel().getDrawableVertexIndexCount(n),this.getModel().getDrawableVertexCount(n),this.getModel().getDrawableVertexIndices(n),this.getModel().getDrawableVertices(n),this.getModel().getDrawableVertexUvs(n),this.getModel().getMultiplyColor(n),this.getModel().getScreenColor(n),this.getModel().getDrawableOpacity(n),this.getModel().getDrawableBlendMode(n),this.getModel().getDrawableInvertedMaskBit(n))}}drawMesh(t,r,i,n,o,h,f,A,T,C,x){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW);const M=this.getModelColor();this.getClippingContextBufferForMask()==null&&(M.A*=T,this.isPremultipliedAlpha()&&(M.R*=M.A,M.G*=M.A,M.B*=M.A));let D=null;this._textures[t]!=null&&(D=this._textures[t]),xn.getInstance().setupShaderProgram(this,D,i,o,n,h,this._bufferData,T,C,M,f,A,this.isPremultipliedAlpha(),this.getMvpMatrix(),x),this.gl.drawElements(this.gl.TRIANGLES,r,this.gl.UNSIGNED_SHORT,0),this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){xn.deleteInstance()}setRenderState(t,r){Ba=t,ms=r}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(const t of Object.entries(this._textures))this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),xn.getInstance().setGl(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}uu.staticRelease=()=>{e2.doStaticRelease()};const r2=new mi;class B1 extends Sd{constructor(t,r,i){super(),bt(this,"settings"),bt(this,"coreModel"),bt(this,"motionManager"),bt(this,"lipSync",!0),bt(this,"breath",_u.create()),bt(this,"eyeBlink"),bt(this,"userData"),bt(this,"renderer",new e2),bt(this,"idParamAngleX",_1),bt(this,"idParamAngleY",g1),bt(this,"idParamAngleZ",m1),bt(this,"idParamEyeBallX",y1),bt(this,"idParamEyeBallY",v1),bt(this,"idParamBodyAngleX",b1),bt(this,"idParamBreath",A1),bt(this,"idParamMouthForm",x1),bt(this,"pixelsPerUnit",1),bt(this,"centeringTransform",new nr),this.coreModel=t,this.settings=r,this.motionManager=new p1(r,i),this.init()}init(){var t;super.init(),(t=this.settings.getEyeBlinkParameters())!=null&&t.length&&(this.eyeBlink=w1.create(this.settings)),this.breath.setParameters([new yo(this.idParamAngleX,0,15,6.5345,.5),new yo(this.idParamAngleY,0,8,3.5345,.5),new yo(this.idParamAngleZ,0,10,5.5345,.5),new yo(this.idParamBodyAngleX,0,4,15.5345,.5),new yo(this.idParamBreath,0,.5,3.2345,.5)]),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){const t={};if(this.settings.layout)for(const[r,i]of Object.entries(this.settings.layout)){const n=r.charAt(0).toLowerCase()+r.slice(1);t[n]=i}return t}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.centeringTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,r){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager._currentFrameNo=r,this.renderer._clippingManager._maskTexture=void 0,xn.getInstance()._shaderSets=[]}bindTexture(t,r){this.renderer.bindTexture(t,r)}getHitAreaDefs(){var t,r;return(r=(t=this.settings.hitAreas)==null?void 0:t.map(i=>({id:i.Id,name:i.Name,index:this.coreModel.getDrawableIndex(i.Id)})))!=null?r:[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(t){return this.coreModel.getDrawableIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawableIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);const r=this.coreModel.getDrawableVertices(t).slice();for(let i=0;i<r.length;i+=2)r[i]=r[i]*this.pixelsPerUnit+this.originalWidth/2,r[i+1]=-r[i+1]*this.pixelsPerUnit+this.originalHeight/2;return r}updateTransform(t){this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(t)}update(t,r){var i,n,o,h;super.update(t,r),t/=1e3,r/=1e3;const f=this.coreModel;this.emit("beforeMotionUpdate");const A=this.motionManager.update(this.coreModel,r);if(this.emit("afterMotionUpdate"),f.saveParameters(),(i=this.motionManager.expressionManager)==null||i.update(f,r),A||(n=this.eyeBlink)==null||n.updateParameters(f,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,r*1e3),this.lipSync&&this.motionManager.currentAudio){let T=this.motionManager.mouthSync(),C=0;const x=1,M=1.2;T>0&&(C=.4),T=pn(T*M,C,x);for(let D=0;D<this.motionManager.lipSyncIds.length;++D)f.addParameterValueById(this.motionManager.lipSyncIds[D],T,.8)}(o=this.physics)==null||o.evaluate(f,t),(h=this.pose)==null||h.updateParameters(f,t),this.emit("beforeModelUpdate"),f.update(),f.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,r){var i;(i=this.breath)==null||i.updateParameters(this.coreModel,t/1e3)}draw(t){const r=this.drawingMatrix,i=r2.getArray();i[0]=r.a,i[1]=r.b,i[4]=-r.c,i[5]=-r.d,i[12]=r.tx,i[13]=r.ty,this.renderer.setMvpMatrix(r2),this.renderer.setRenderState(t.getParameter(t.FRAMEBUFFER_BINDING),this.viewport),this.renderer.drawModel()}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}}class i2{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,r;return(r=(t=this.groups)==null?void 0:t.find(i=>i.Name==="EyeBlink"))==null?void 0:r.Ids}getLipSyncParameters(){var t,r;return(r=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:r.Ids}}class bn extends Ma{constructor(t){if(super(t),bt(this,"moc"),bt(this,"textures"),!bn.isValidJSON(t))throw new TypeError("Invalid JSON.");Object.assign(this,new i2(t))}static isValidJSON(t){var r;return!!(t!=null&&t.FileReferences)&&typeof t.FileReferences.Moc=="string"&&((r=t.FileReferences.Textures)==null?void 0:r.length)>0&&t.FileReferences.Textures.every(i=>typeof i=="string")}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[r,i]of Object.entries(this.motions))for(let n=0;n<i.length;n++)i[n].File=t(i[n].File,`motions.${r}[${n}].File`),i[n].Sound!==void 0&&(i[n].Sound=t(i[n].Sound,`motions.${r}[${n}].Sound`));if(this.expressions)for(let r=0;r<this.expressions.length;r++)this.expressions[r].File=t(this.expressions[r].File,`expressions[${r}].File`)}}Em(bn,[i2]);let ka,s2=20;function k1(){return go.isStarted()?Promise.resolve():(ka??(ka=new Promise((s,t)=>{function r(){try{O1(),s()}catch(i){if(s2--,s2<0){const n=new Error("Failed to start up Cubism 4 framework.");n.cause=i,t(n);return}setTimeout(r,10)}}r()})),ka)}function O1(s){s=Object.assign({logFunction:console.log,loggingLevel:yn.LogLevel_Verbose},s),go.startUp(s),go.initialize()}const N1=.001,n2=.5;class mu{static create(t){const r=new mu;typeof t.FadeInTime=="number"&&(r._fadeTimeSeconds=t.FadeInTime,r._fadeTimeSeconds<=0&&(r._fadeTimeSeconds=n2));const i=t.Groups,n=i.length;for(let o=0;o<n;++o){const h=i[o],f=h.length;let A=0;for(let T=0;T<f;++T){const C=h[T],x=new Oa;x.partId=C.Id;const M=C.Link;if(M){const D=M.length;for(let k=0;k<D;++k){const U=new Oa;U.partId=M[k],x.link.push(U)}}r._partGroups.push(x),++A}r._partGroupCounts.push(A)}return r}updateParameters(t,r){t!=this._lastModel&&this.reset(t),this._lastModel=t,r<0&&(r=0);let i=0;for(let n=0;n<this._partGroupCounts.length;n++){const o=this._partGroupCounts[n];this.doFade(t,r,i,o),i+=o}this.copyPartOpacities(t)}reset(t){let r=0;for(let i=0;i<this._partGroupCounts.length;++i){const n=this._partGroupCounts[i];for(let o=r;o<r+n;++o){this._partGroups[o].initialize(t);const h=this._partGroups[o].partIndex,f=this._partGroups[o].parameterIndex;if(!(h<0)){t.setPartOpacityByIndex(h,o==r?1:0),t.setParameterValueByIndex(f,o==r?1:0);for(let A=0;A<this._partGroups[o].link.length;++A)this._partGroups[o].link[A].initialize(t)}}r+=n}}copyPartOpacities(t){for(let r=0;r<this._partGroups.length;++r){const i=this._partGroups[r];if(i.link.length==0)continue;const n=this._partGroups[r].partIndex,o=t.getPartOpacityByIndex(n);for(let h=0;h<i.link.length;++h){const A=i.link[h].partIndex;A<0||t.setPartOpacityByIndex(A,o)}}}doFade(t,r,i,n){let o=-1,h=1;const f=.5,A=.15;for(let T=i;T<i+n;++T){const C=this._partGroups[T].partIndex,x=this._partGroups[T].parameterIndex;if(t.getParameterValueByIndex(x)>N1){if(o>=0)break;o=T,h=t.getPartOpacityByIndex(C),h+=r/this._fadeTimeSeconds,h>1&&(h=1)}}o<0&&(o=0,h=1);for(let T=i;T<i+n;++T){const C=this._partGroups[T].partIndex;if(o==T)t.setPartOpacityByIndex(C,h);else{let x=t.getPartOpacityByIndex(C),M;h<f?M=h*(f-1)/f+1:M=(1-h)*f/(1-f),(1-M)*(1-h)>A&&(M=1-A/(1-h)),x>M&&(x=M),t.setPartOpacityByIndex(C,x)}}}constructor(){this._fadeTimeSeconds=n2,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class Oa{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(r=>r.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new Oa;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(r=>r.clone()),t}}class o2{constructor(t=!1,r=new ai){this.isOverwritten=t,this.Color=r}}class a2{constructor(t=!1,r=new ai){this.isOverwritten=t,this.Color=r}}class U1{constructor(t=!1,r=!1){this.isOverwritten=t,this.isCulling=r}}class G1{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,r=this._savedParameters.length;for(let i=0;i<t;++i)i<r?this._savedParameters[i]=this._parameterValues[i]:this._savedParameters.push(this._parameterValues[i])}getMultiplyColor(t){return this.getOverwriteFlagForModelMultiplyColors()||this.getOverwriteFlagForDrawableMultiplyColors(t)?this._userMultiplyColors[t].Color:this.getDrawableMultiplyColor(t)}getScreenColor(t){return this.getOverwriteFlagForModelScreenColors()||this.getOverwriteFlagForDrawableScreenColors(t)?this._userScreenColors[t].Color:this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,r){this.setMultiplyColorByRGBA(t,r.R,r.G,r.B,r.A)}setMultiplyColorByRGBA(t,r,i,n,o=1){this._userMultiplyColors[t].Color.R=r,this._userMultiplyColors[t].Color.G=i,this._userMultiplyColors[t].Color.B=n,this._userMultiplyColors[t].Color.A=o}setScreenColorByTextureColor(t,r){this.setScreenColorByRGBA(t,r.R,r.G,r.B,r.A)}setScreenColorByRGBA(t,r,i,n,o=1){this._userScreenColors[t].Color.R=r,this._userScreenColors[t].Color.G=i,this._userScreenColors[t].Color.B=n,this._userScreenColors[t].Color.A=o}getPartMultiplyColor(t){return this._userPartMultiplyColors[t].Color}getPartScreenColor(t){return this._userPartScreenColors[t].Color}setPartColor(t,r,i,n,o,h,f){if(h[t].Color.R=r,h[t].Color.G=i,h[t].Color.B=n,h[t].Color.A=o,h[t].isOverwritten)for(let A=0;A<this._partChildDrawables[t].length;++A){const T=this._partChildDrawables[t][A];f[T].Color.R=r,f[T].Color.G=i,f[T].Color.B=n,f[T].Color.A=o}}setPartMultiplyColorByTextureColor(t,r){this.setPartMultiplyColorByRGBA(t,r.R,r.G,r.B,r.A)}setPartMultiplyColorByRGBA(t,r,i,n,o){this.setPartColor(t,r,i,n,o,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,r){this.setPartScreenColorByRGBA(t,r.R,r.G,r.B,r.A)}setPartScreenColorByRGBA(t,r,i,n,o){this.setPartColor(t,r,i,n,o,this._userPartScreenColors,this._userScreenColors)}getOverwriteFlagForModelMultiplyColors(){return this._isOverwrittenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return this._isOverwrittenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){this._isOverwrittenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){this._isOverwrittenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return this._userMultiplyColors[t].isOverwritten}getOverwriteFlagForDrawableScreenColors(t){return this._userScreenColors[t].isOverwritten}setOverwriteFlagForDrawableMultiplyColors(t,r){this._userMultiplyColors[t].isOverwritten=r}setOverwriteFlagForDrawableScreenColors(t,r){this._userScreenColors[t].isOverwritten=r}getOverwriteColorForPartMultiplyColors(t){return this._userPartMultiplyColors[t].isOverwritten}getOverwriteColorForPartScreenColors(t){return this._userPartScreenColors[t].isOverwritten}setOverwriteColorForPartColors(t,r,i,n){i[t].isOverwritten=r;for(let o=0;o<this._partChildDrawables[t].length;++o){const h=this._partChildDrawables[t][o];n[h].isOverwritten=r,r&&(n[h].Color.R=i[t].Color.R,n[h].Color.G=i[t].Color.G,n[h].Color.B=i[t].Color.B,n[h].Color.A=i[t].Color.A)}}setOverwriteColorForPartMultiplyColors(t,r){this._userPartMultiplyColors[t].isOverwritten=r,this.setOverwriteColorForPartColors(t,r,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,r){this._userPartScreenColors[t].isOverwritten=r,this.setOverwriteColorForPartColors(t,r,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverwriteFlagForModelCullings()||this.getOverwriteFlagForDrawableCullings(t))return this._userCullings[t].isCulling;const r=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(r[t])}setDrawableCulling(t,r){this._userCullings[t].isCulling=r}getOverwriteFlagForModelCullings(){return this._isOverwrittenCullings}setOverwriteFlagForModelCullings(t){this._isOverwrittenCullings=t}getOverwriteFlagForDrawableCullings(t){return this._userCullings[t].isOverwritten}setOverwriteFlagForDrawableCullings(t,r){this._userCullings[t].isOverwritten=r}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let r;const i=this._model.parts.count;for(r=0;r<i;++r)if(t==this._partIds[r])return r;return t in this._notExistPartId?this._notExistPartId[t]:(r=i+this._notExistPartId.length,this._notExistPartId[t]=r,this._notExistPartOpacities[r]=0,r)}getPartId(t){return this._model.parts.ids[t]}getPartCount(){return this._model.parts.count}setPartOpacityByIndex(t,r){if(t in this._notExistPartOpacities){this._notExistPartOpacities[t]=r;return}vn(0<=t&&t<this.getPartCount()),this._partOpacities[t]=r}setPartOpacityById(t,r){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,r)}getPartOpacityByIndex(t){return t in this._notExistPartOpacities?this._notExistPartOpacities[t]:(vn(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const r=this.getPartIndex(t);return r<0?0:this.getPartOpacityByIndex(r)}getParameterIndex(t){let r;const i=this._model.parameters.count;for(r=0;r<i;++r)if(t==this._parameterIds[r])return r;return t in this._notExistParameterId?this._notExistParameterId[t]:(r=this._model.parameters.count+Object.keys(this._notExistParameterId).length,this._notExistParameterId[t]=r,this._notExistParameterValues[r]=0,r)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterValueByIndex(t){return t in this._notExistParameterValues?this._notExistParameterValues[t]:(vn(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const r=this.getParameterIndex(t);return this.getParameterValueByIndex(r)}setParameterValueByIndex(t,r,i=1){if(t in this._notExistParameterValues){this._notExistParameterValues[t]=i==1?r:this._notExistParameterValues[t]*(1-i)+r*i;return}vn(0<=t&&t<this.getParameterCount()),this._model.parameters.maximumValues[t]<r&&(r=this._model.parameters.maximumValues[t]),this._model.parameters.minimumValues[t]>r&&(r=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?r:this._parameterValues[t]=this._parameterValues[t]*(1-i)+r*i}setParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.setParameterValueByIndex(n,r,i)}addParameterValueByIndex(t,r,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+r*i)}addParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.addParameterValueByIndex(n,r,i)}multiplyParameterValueById(t,r,i=1){const n=this.getParameterIndex(t);this.multiplyParameterValueByIndex(n,r,i)}multiplyParameterValueByIndex(t,r,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(r-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const r=this._model.drawables.count;for(let i=0;i<r;++i)if(this._drawableIds[i]==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){return this._model.drawables.ids[t]}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(r[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const r=this._model.drawables.multiplyColors,i=t*4,n=new ai;return n.R=r[i],n.G=r[i+1],n.B=r[i+2],n.A=r[i+3],n}getDrawableScreenColor(t){const r=this._model.drawables.screenColors,i=t*4,n=new ai;return n.R=r[i],n.G=r[i+1],n.B=r[i+2],n.A=r[i+3],n}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const r=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(r[t])?gs.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(r[t])?gs.CubismBlendMode_Multiplicative:gs.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const r=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(r[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(r[t])}getDrawableDynamicFlagVisibilityDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(r[t])}getDrawableDynamicFlagOpacityDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(r[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(r[t])}getDrawableDynamicFlagBlendColorDidChange(t){const r=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(r[t])}loadParameters(){let t=this._model.parameters.count;const r=this._savedParameters.length;t>r&&(t=r);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters[i]}initialize(){this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const r=this._model.parameters.ids,i=this._model.parameters.count;for(let n=0;n<i;++n)this._parameterIds.push(r[n])}const t=this._model.parts.count;{const r=this._model.parts.ids;for(let i=0;i<t;++i)this._partIds.push(r[i])}{const r=this._model.drawables.ids,i=this._model.drawables.count,n=new U1(!1,!1);for(let o=0;o<t;++o){const h=new ai(1,1,1,1),f=new ai(0,0,0,1),A=new a2(!1,h),T=new a2(!1,f);this._userPartMultiplyColors.push(A),this._userPartScreenColors.push(T),this._partChildDrawables.push([])}for(let o=0;o<i;++o){const h=new ai(1,1,1,1),f=new ai(0,0,0,1),A=new o2(!1,h),T=new o2(!1,f);this._drawableIds.push(r[o]),this._userMultiplyColors.push(A),this._userScreenColors.push(T),this._userCullings.push(n);const C=this.getDrawableParentPartIndex(o);C>=0&&this._partChildDrawables[C].push(o)}}}constructor(t){this._model=t,this._savedParameters=[],this._parameterIds=[],this._drawableIds=[],this._partIds=[],this._isOverwrittenModelMultiplyColors=!1,this._isOverwrittenModelScreenColors=!1,this._isOverwrittenCullings=!1,this._modelOpacity=1,this._userMultiplyColors=[],this._userScreenColors=[],this._userCullings=[],this._userPartMultiplyColors=[],this._userPartScreenColors=[],this._partChildDrawables=[],this._notExistPartId={},this._notExistParameterId={},this._notExistParameterValues={},this._notExistPartOpacities={},this.initialize()}release(){this._model.release(),this._model=void 0}}class yu{static create(t,r){if(r&&!this.hasMocConsistency(t))throw new Error("Inconsistent MOC3.");const i=Live2DCubismCore.Moc.fromArrayBuffer(t);if(i){const n=new yu(i);return n._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t),n}throw new Error("Failed to CubismMoc.create().")}createModel(){let t;const r=Live2DCubismCore.Model.fromMoc(this._moc);if(r)return t=new G1(r),++this._modelCount,t;throw new Error("Unknown error")}deleteModel(t){t!=null&&--this._modelCount}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){this._moc._release(),this._moc=void 0}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}}var vu=(s=>(s[s.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",s))(vu||{}),Qs=(s=>(s[s.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",s[s.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",s[s.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",s))(Qs||{});class V1{constructor(){this.initialPosition=new Ie(0,0),this.position=new Ie(0,0),this.lastPosition=new Ie(0,0),this.lastGravity=new Ie(0,0),this.force=new Ie(0,0),this.velocity=new Ie(0,0)}}class z1{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class X1{constructor(){this.source={}}}class W1{constructor(){this.destination={},this.translationScale=new Ie(0,0)}}class H1{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new Ie(0,0),this.wind=new Ie(0,0),this.fps=0}}class Y1{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new Ie(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new Ie(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getFps(){return this._json.Meta.Fps||0}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,r){return this._json.PhysicsSettings[t].Input[r].Weight}getInputReflect(t,r){return this._json.PhysicsSettings[t].Input[r].Reflect}getInputType(t,r){return this._json.PhysicsSettings[t].Input[r].Type}getInputSourceId(t,r){return this._json.PhysicsSettings[t].Input[r].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,r){return this._json.PhysicsSettings[t].Output[r].VertexIndex}getOutputAngleScale(t,r){return this._json.PhysicsSettings[t].Output[r].Scale}getOutputWeight(t,r){return this._json.PhysicsSettings[t].Output[r].Weight}getOutputDestinationId(t,r){return this._json.PhysicsSettings[t].Output[r].Destination.Id}getOutputType(t,r){return this._json.PhysicsSettings[t].Output[r].Type}getOutputReflect(t,r){return this._json.PhysicsSettings[t].Output[r].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,r){return this._json.PhysicsSettings[t].Vertices[r].Mobility}getParticleDelay(t,r){return this._json.PhysicsSettings[t].Vertices[r].Delay}getParticleAcceleration(t,r){return this._json.PhysicsSettings[t].Vertices[r].Acceleration}getParticleRadius(t,r){return this._json.PhysicsSettings[t].Vertices[r].Radius}getParticlePosition(t,r){const i=new Ie(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[r].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[r].Position.Y,i}}const h2="X",l2="Y",u2="Angle",j1=5,xu=100,c2=.001,q1=5;class bu{static create(t){const r=new bu;return r.parse(t),r._physicsRig.gravity.y=0,r}static delete(t){t!=null&&t.release()}parse(t){this._physicsRig=new H1;const r=new Y1(t);this._physicsRig.gravity=r.getGravity(),this._physicsRig.wind=r.getWind(),this._physicsRig.subRigCount=r.getSubRigCount(),this._physicsRig.fps=r.getFps(),this._currentRigOutputs=[],this._previousRigOutputs=[];let i=0,n=0,o=0;for(let h=0;h<this._physicsRig.subRigCount;++h){const f=new z1;f.normalizationPosition.minimum=r.getNormalizationPositionMinimumValue(h),f.normalizationPosition.maximum=r.getNormalizationPositionMaximumValue(h),f.normalizationPosition.defalut=r.getNormalizationPositionDefaultValue(h),f.normalizationAngle.minimum=r.getNormalizationAngleMinimumValue(h),f.normalizationAngle.maximum=r.getNormalizationAngleMaximumValue(h),f.normalizationAngle.defalut=r.getNormalizationAngleDefaultValue(h),f.inputCount=r.getInputCount(h),f.baseInputIndex=i,i+=f.inputCount;for(let C=0;C<f.inputCount;++C){const x=new X1;switch(x.sourceParameterIndex=-1,x.weight=r.getInputWeight(h,C),x.reflect=r.getInputReflect(h,C),r.getInputType(h,C)){case h2:x.type=Qs.CubismPhysicsSource_X,x.getNormalizedParameterValue=Q1;break;case l2:x.type=Qs.CubismPhysicsSource_Y,x.getNormalizedParameterValue=K1;break;case u2:x.type=Qs.CubismPhysicsSource_Angle,x.getNormalizedParameterValue=J1;break}x.source.targetType=vu.CubismPhysicsTargetType_Parameter,x.source.id=r.getInputSourceId(h,C),this._physicsRig.inputs.push(x)}f.outputCount=r.getOutputCount(h),f.baseOutputIndex=n;const A=new f2,T=new f2;for(let C=0;C<f.outputCount;++C){A.outputs[C]=0,T.outputs[C]=0;let x=this._physicsRig.outputs[n+C];switch(x||(x=new W1,this._physicsRig.outputs[n+C]=x),x.destinationParameterIndex=-1,x.vertexIndex=r.getOutputVertexIndex(h,C),x.angleScale=r.getOutputAngleScale(h,C),x.weight=r.getOutputWeight(h,C),x.destination.targetType=vu.CubismPhysicsTargetType_Parameter,x.destination.id=r.getOutputDestinationId(h,C),r.getOutputType(h,C)){case h2:x.type=Qs.CubismPhysicsSource_X,x.getValue=ty,x.getScale=ny;break;case l2:x.type=Qs.CubismPhysicsSource_Y,x.getValue=ey,x.getScale=oy;break;case u2:x.type=Qs.CubismPhysicsSource_Angle,x.getValue=ry,x.getScale=ay;break}x.reflect=r.getOutputReflect(h,C)}this._currentRigOutputs.push(A),this._previousRigOutputs.push(T),n+=f.outputCount,f.particleCount=r.getParticleCount(h),f.baseParticleIndex=o,o+=f.particleCount;for(let C=0;C<f.particleCount;++C){const x=new V1;x.mobility=r.getParticleMobility(h,C),x.delay=r.getParticleDelay(h,C),x.acceleration=r.getParticleAcceleration(h,C),x.radius=r.getParticleRadius(h,C),x.position=r.getParticlePosition(h,C),this._physicsRig.particles.push(x)}this._physicsRig.settings.push(f)}this.initialize(),r.release()}stabilization(t){var r,i,n,o;let h,f,A,T;const C=new Ie;let x,M,D,k,U,G,X,J;U=t.getModel().parameters.values,G=t.getModel().parameters.maximumValues,X=t.getModel().parameters.minimumValues,J=t.getModel().parameters.defaultValues,((i=(r=this._parameterCaches)==null?void 0:r.length)!=null?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((o=(n=this._parameterInputCaches)==null?void 0:n.length)!=null?o:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let Z=0;Z<t.getParameterCount();++Z)this._parameterCaches[Z]=U[Z],this._parameterInputCaches[Z]=U[Z];for(let Z=0;Z<this._physicsRig.subRigCount;++Z){h={angle:0},C.x=0,C.y=0,x=this._physicsRig.settings[Z],M=this._physicsRig.inputs.slice(x.baseInputIndex),D=this._physicsRig.outputs.slice(x.baseOutputIndex),k=this._physicsRig.particles.slice(x.baseParticleIndex);for(let it=0;it<x.inputCount;++it)f=M[it].weight/xu,M[it].sourceParameterIndex==-1&&(M[it].sourceParameterIndex=t.getParameterIndex(M[it].source.id)),M[it].getNormalizedParameterValue(C,h,U[M[it].sourceParameterIndex],X[M[it].sourceParameterIndex],G[M[it].sourceParameterIndex],J[M[it].sourceParameterIndex],x.normalizationPosition,x.normalizationAngle,M[it].reflect,f),this._parameterCaches[M[it].sourceParameterIndex]=U[M[it].sourceParameterIndex];A=Ke.degreesToRadian(-h.angle),C.x=C.x*Ke.cos(A)-C.y*Ke.sin(A),C.y=C.x*Ke.sin(A)+C.y*Ke.cos(A),ly(k,x.particleCount,C,h.angle,this._options.wind,c2*x.normalizationPosition.maximum);for(let it=0;it<x.outputCount;++it){const Q=D[it].vertexIndex;if(D[it].destinationParameterIndex==-1&&(D[it].destinationParameterIndex=t.getParameterIndex(D[it].destination.id)),Q<1||Q>=x.particleCount)continue;let _t=new Ie;_t=k[Q].position.substract(k[Q-1].position),T=D[it].getValue(_t,k,Q,D[it].reflect,this._options.gravity),this._currentRigOutputs[Z].outputs[it]=T,this._previousRigOutputs[Z].outputs[it]=T;const et=D[it].destinationParameterIndex,ft=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(U.subarray(et))):U.slice(et);Au(ft,X[et],G[et],T,D[it]);for(let wt=et,Rt=0;wt<this._parameterCaches.length;wt++,Rt++)U[wt]=this._parameterCaches[wt]=ft[Rt]}}}evaluate(t,r){var i,n,o,h;let f,A,T,C;const x=new Ie;let M,D,k,U;if(0>=r)return;let G,X,J,Z,it;if(this._currentRemainTime+=r,this._currentRemainTime>q1&&(this._currentRemainTime=0),G=t.getModel().parameters.values,X=t.getModel().parameters.maximumValues,J=t.getModel().parameters.minimumValues,Z=t.getModel().parameters.defaultValues,((n=(i=this._parameterCaches)==null?void 0:i.length)!=null?n:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((h=(o=this._parameterInputCaches)==null?void 0:o.length)!=null?h:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let _t=0;_t<t.getParameterCount();++_t)this._parameterInputCaches[_t]=G[_t]}for(this._physicsRig.fps>0?it=1/this._physicsRig.fps:it=r;this._currentRemainTime>=it;){for(let et=0;et<this._physicsRig.subRigCount;++et){M=this._physicsRig.settings[et],k=this._physicsRig.outputs.slice(M.baseOutputIndex);for(let ft=0;ft<M.outputCount;++ft)this._previousRigOutputs[et].outputs[ft]=this._currentRigOutputs[et].outputs[ft]}const _t=it/this._currentRemainTime;for(let et=0;et<t.getParameterCount();++et)this._parameterCaches[et]=this._parameterInputCaches[et]*(1-_t)+G[et]*_t,this._parameterInputCaches[et]=this._parameterCaches[et];for(let et=0;et<this._physicsRig.subRigCount;++et){f={angle:0},x.x=0,x.y=0,M=this._physicsRig.settings[et],D=this._physicsRig.inputs.slice(M.baseInputIndex),k=this._physicsRig.outputs.slice(M.baseOutputIndex),U=this._physicsRig.particles.slice(M.baseParticleIndex);for(let ft=0;ft<M.inputCount;++ft)A=D[ft].weight/xu,D[ft].sourceParameterIndex==-1&&(D[ft].sourceParameterIndex=t.getParameterIndex(D[ft].source.id)),D[ft].getNormalizedParameterValue(x,f,this._parameterCaches[D[ft].sourceParameterIndex],J[D[ft].sourceParameterIndex],X[D[ft].sourceParameterIndex],Z[D[ft].sourceParameterIndex],M.normalizationPosition,M.normalizationAngle,D[ft].reflect,A);T=Ke.degreesToRadian(-f.angle),x.x=x.x*Ke.cos(T)-x.y*Ke.sin(T),x.y=x.x*Ke.sin(T)+x.y*Ke.cos(T),hy(U,M.particleCount,x,f.angle,this._options.wind,c2*M.normalizationPosition.maximum,it,j1);for(let ft=0;ft<M.outputCount;++ft){const wt=k[ft].vertexIndex;if(k[ft].destinationParameterIndex==-1&&(k[ft].destinationParameterIndex=t.getParameterIndex(k[ft].destination.id)),wt<1||wt>=M.particleCount)continue;const Rt=new Ie;Rt.x=U[wt].position.x-U[wt-1].position.x,Rt.y=U[wt].position.y-U[wt-1].position.y,C=k[ft].getValue(Rt,U,wt,k[ft].reflect,this._options.gravity),this._currentRigOutputs[et].outputs[ft]=C;const It=k[ft].destinationParameterIndex,pt=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(It))):this._parameterCaches.slice(It);Au(pt,J[It],X[It],C,k[ft]);for(let xt=It,Ct=0;xt<this._parameterCaches.length;xt++,Ct++)this._parameterCaches[xt]=pt[Ct]}}this._currentRemainTime-=it}const Q=this._currentRemainTime/it;this.interpolate(t,Q)}interpolate(t,r){let i,n,o,h,f;o=t.getModel().parameters.values,h=t.getModel().parameters.maximumValues,f=t.getModel().parameters.minimumValues;for(let A=0;A<this._physicsRig.subRigCount;++A){n=this._physicsRig.settings[A],i=this._physicsRig.outputs.slice(n.baseOutputIndex);for(let T=0;T<n.outputCount;++T){if(i[T].destinationParameterIndex==-1)continue;const C=i[T].destinationParameterIndex,x=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(o.subarray(C))):o.slice(C);Au(x,f[C],h[C],this._previousRigOutputs[A].outputs[T]*(1-r)+this._currentRigOutputs[A].outputs[T]*r,i[T]);for(let M=C,D=0;M<o.length;M++,D++)o[M]=x[D]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._options=new Z1,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=[],this._previousRigOutputs=[],this._currentRemainTime=0}release(){this._physicsRig=void 0}initialize(){let t,r,i;for(let n=0;n<this._physicsRig.subRigCount;++n){r=this._physicsRig.settings[n],t=this._physicsRig.particles.slice(r.baseParticleIndex),t[0].initialPosition=new Ie(0,0),t[0].lastPosition=new Ie(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new Ie(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new Ie(0,0),t[0].force=new Ie(0,0);for(let o=1;o<r.particleCount;++o)i=new Ie(0,0),i.y=t[o].radius,t[o].initialPosition=new Ie(t[o-1].initialPosition.x+i.x,t[o-1].initialPosition.y+i.y),t[o].position=new Ie(t[o].initialPosition.x,t[o].initialPosition.y),t[o].lastPosition=new Ie(t[o].initialPosition.x,t[o].initialPosition.y),t[o].lastGravity=new Ie(0,-1),t[o].lastGravity.y*=-1,t[o].velocity=new Ie(0,0),t[o].force=new Ie(0,0)}}}class Z1{constructor(){this.gravity=new Ie(0,0),this.wind=new Ie(0,0)}}class f2{constructor(){this.outputs=[]}}function Q1(s,t,r,i,n,o,h,f,A,T){s.x+=wu(r,i,n,o,h.minimum,h.maximum,h.defalut,A)*T}function K1(s,t,r,i,n,o,h,f,A,T){s.y+=wu(r,i,n,o,h.minimum,h.maximum,h.defalut,A)*T}function J1(s,t,r,i,n,o,h,f,A,T){t.angle+=wu(r,i,n,o,f.minimum,f.maximum,f.defalut,A)*T}function ty(s,t,r,i,n){let o=s.x;return i&&(o*=-1),o}function ey(s,t,r,i,n){let o=s.y;return i&&(o*=-1),o}function ry(s,t,r,i,n){let o;return r>=2?n=t[r-1].position.substract(t[r-2].position):n=n.multiplyByScaler(-1),o=Ke.directionToRadian(n,s),i&&(o*=-1),o}function iy(s,t){return Math.abs(Math.max(s,t)-Math.min(s,t))}function sy(s,t){return Math.min(s,t)+iy(s,t)/2}function ny(s,t){return s.x}function oy(s,t){return s.y}function ay(s,t){return t}function hy(s,t,r,i,n,o,h,f){let A,T,C,x,M=new Ie(0,0),D=new Ie(0,0),k=new Ie(0,0),U=new Ie(0,0);s[0].position=new Ie(r.x,r.y),A=Ke.degreesToRadian(i),x=Ke.radianToDirection(A),x.normalize();for(let G=1;G<t;++G)s[G].force=x.multiplyByScaler(s[G].acceleration).add(n),s[G].lastPosition=new Ie(s[G].position.x,s[G].position.y),T=s[G].delay*h*30,M=s[G].position.substract(s[G-1].position),C=Ke.directionToRadian(s[G].lastGravity,x)/f,M.x=Ke.cos(C)*M.x-M.y*Ke.sin(C),M.y=Ke.sin(C)*M.x+M.y*Ke.cos(C),s[G].position=s[G-1].position.add(M),D=s[G].velocity.multiplyByScaler(T),k=s[G].force.multiplyByScaler(T).multiplyByScaler(T),s[G].position=s[G].position.add(D).add(k),U=s[G].position.substract(s[G-1].position),U.normalize(),s[G].position=s[G-1].position.add(U.multiplyByScaler(s[G].radius)),Ke.abs(s[G].position.x)<o&&(s[G].position.x=0),T!=0&&(s[G].velocity=s[G].position.substract(s[G].lastPosition),s[G].velocity=s[G].velocity.divisionByScalar(T),s[G].velocity=s[G].velocity.multiplyByScaler(s[G].mobility)),s[G].force=new Ie(0,0),s[G].lastGravity=new Ie(x.x,x.y)}function ly(s,t,r,i,n,o){let h,f,A=new Ie(0,0);s[0].position=new Ie(r.x,r.y),h=Ke.degreesToRadian(i),f=Ke.radianToDirection(h),f.normalize();for(let T=1;T<t;++T)s[T].force=f.multiplyByScaler(s[T].acceleration).add(n),s[T].lastPosition=new Ie(s[T].position.x,s[T].position.y),s[T].velocity=new Ie(0,0),A=s[T].force,A.normalize(),A=A.multiplyByScaler(s[T].radius),s[T].position=s[T-1].position.add(A),Ke.abs(s[T].position.x)<o&&(s[T].position.x=0),s[T].force=new Ie(0,0),s[T].lastGravity=new Ie(f.x,f.y)}function Au(s,t,r,i,n){let o,h,f;o=n.getScale(n.translationScale,n.angleScale),h=i*o,h<t?(h<n.valueBelowMinimum&&(n.valueBelowMinimum=h),h=t):h>r&&(h>n.valueExceededMaximum&&(n.valueExceededMaximum=h),h=r),f=n.weight/xu,f>=1||(h=s[0]*(1-f)+h*f),s[0]=h}function wu(s,t,r,i,n,o,h,f){let A=0;const T=Ke.max(r,t);T<s&&(s=T);const C=Ke.min(r,t);C>s&&(s=C);const x=Ke.min(n,o),M=Ke.max(n,o),D=h,k=sy(C,T),U=s-k;switch(Math.sign(U)){case 1:{const G=M-D,X=T-k;X!=0&&(A=U*(G/X),A+=D);break}case-1:{const G=x-D,X=C-k;X!=0&&(A=U*(G/X),A+=D);break}case 0:{A=D;break}}return f?A:A*-1}oi.registerRuntime({version:4,ready:k1,test(s){return s instanceof bn||bn.isValidJSON(s)},isValidMoc(s){if(s.byteLength<4)return!1;const t=new Int8Array(s,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(s){return new bn(s)},createCoreModel(s,t){const r=yu.create(s,!!(t!=null&&t.checkMocConsistency));try{const i=r.createModel();return i.__moc=r,i}catch(i){try{r.release()}catch{}throw i}},createInternalModel(s,t,r){const i=new B1(s,t,r),n=s;return n.__moc&&(i.__moc=n.__moc,delete n.__moc,i.once("destroy",uy)),i},createPhysics(s,t){return bu.create(t)},createPose(s,t){return mu.create(t)}});function uy(){var s;(s=this.__moc)==null||s.release()}async function cy(s){const{element_id:t="live2d-canvas",models:r,width:i=300,height:n=300,auto_fit:o=!0,auto_motion:h=!0,mouse_tracking:f=!0}=s;let A=fy(t,s);const T=new kl({view:A,width:i,height:n,backgroundAlpha:0,autoDensity:!0,antialias:!0,eventMode:"static",eventFeatures:{move:!0,globalMove:!0,click:!0,wheel:!0}}),C=await zd.from(r[0].model_url,{ticker:$r.system});if(T.stage.addChild(C),o){const x=Math.min(i/C.width,n/C.height);C.scale.set(x),C.x=(i-C.width*x)/2,C.y=(n-C.height*x)/2}return f&&dy(C,T.view),h&&await py(C),C}function fy(s,t){let r=document.getElementById(s);return r||(r=document.createElement("canvas"),r.id=s,document.body.appendChild(r),r.style.display="none",r.style.position="fixed",r.style.display="block",r.style.position="absolute",r.style.bottom=`${t.spacing_y||0}px`,r.style[t.position==="left"?"left":"right"]=`${t.spacing_x||0}px`,r.style.zIndex="9999"),r}function dy(s,t){document.addEventListener("mousemove",r=>{var A;const i=t.getBoundingClientRect(),n=i.left+i.width/2,o=i.top+i.height/2,h=(r.clientX-n)/i.width,f=-(r.clientY-o)/i.height;s.internalModel&&((A=s.internalModel.focusController)==null||A.focus(h,f))}),t.addEventListener("click",()=>{var r;try{const i=(r=s.internalModel)==null?void 0:r.motionManager.definitions;if(i)if(i.tap_body)s.motion("tap_body");else if(i.tap)s.motion("tap");else{const n=Object.keys(i)[0];n&&s.motion(n)}}catch(i){console.warn("Failed to play tap animation:",i)}})}async function py(s){var t;try{const r=(t=s.internalModel)==null?void 0:t.motionManager.definitions;if(r)if(r.idle)await s.motion("idle");else if(r.tap_body)await s.motion("tap_body");else{const i=Object.keys(r)[0];i&&await s.motion(i)}}catch(r){console.warn("Failed to start idle animation:",r)}}async function _y(){}qr.Live2DModel=zd,qr.MotionManager=fo,qr.PIXI=bm,qr.SoundManager=Mr,qr.createLive2D=cy,qr.initializeLive2D=_y,Object.defineProperty(qr,Symbol.toStringTag,{value:"Module"})});
1208
1208
  //# sourceMappingURL=l2d.umd.js.map