123 |
- System.register(["./ammo-instantiated-15f3deba.js","./_commonjsHelpers-364bf34e.js"],(function(t){"use strict";var e,i,r,n,s,a,o,l,h,u,c,_,f,p,d,m,y,g,v,b,S,A,C,x,T,w,E,B,D,M,P,R,I,O,F,L,V,k,N,G,z,U,H,j,W,X,Y,q,J,K,Z,Q,$,tt,et,it,rt,nt,st,at,ot,lt,ht,ut,ct,_t,ft,pt,dt,mt,yt,gt,vt,bt,St,At,Ct,xt,Tt,wt,Et,Bt,Dt,Mt,Pt,Rt,It,Ot,Ft,Lt,Vt,kt,Nt,Gt,zt,Ut,Ht,jt,Wt,Xt,Yt,qt,Jt,Kt,Zt,Qt,$t,te,ee,ie,re,ne,se,ae,oe,le,he,ue,ce,_e,fe,pe,de,me,ye,ge,ve,be,Se,Ae,Ce,xe,Te,we,Ee,Be,De,Me,Pe,Re,Ie,Oe,Fe,Le,Ve,ke,Ne,Ge,ze,Ue,He,je,We,Xe,Ye,qe,Je,Ke,Ze,Qe,$e,ti,ei,ii,ri,ni,si,ai,oi,li,hi,ui,ci,_i,fi,pi,di,mi,yi,gi,vi,bi,Si,Ai,Ci,xi,Ti,wi,Ei,Bi,Di,Mi,Pi,Ri,Ii,Oi,Fi,Li,Vi,ki,Ni,Gi,zi,Ui,Hi,ji,Wi,Xi,Yi,qi,Ji,Ki,Zi,Qi,$i,tr,er,ir,rr,nr,sr,ar,or,lr,hr,ur,cr,_r,fr,pr,dr,mr,yr,gr,vr,br,Sr,Ar,Cr,xr,Tr,wr,Er,Br,Dr,Mr,Pr,Rr,Ir,Or,Fr,Lr,Vr,kr,Nr,Gr,zr,Ur,Hr,jr,Wr,Xr,Yr,qr,Jr,Kr,Zr,Qr,$r,tn,en,rn,nn,sn,an,on,ln,hn,un,cn,_n,fn,pn,dn,mn,yn,gn,vn,bn,Sn,An,Cn,xn,Tn,wn,En,Bn,Dn,Mn,Pn,Rn,In,On,Fn,Ln,Vn,kn,Nn,Gn,zn,Un,Hn,jn,Wn,Xn,Yn,qn,Jn,Kn,Zn,Qn,$n,ts,es,is,rs,ns,ss,as,os,ls,hs,us,cs,_s,fs,ps,ds,ms,ys,gs,vs,bs,Ss,As;return{setters:[function(Ss){e=Ss.P,i=Ss.R,r=Ss.C,n=Ss.D,s=Ss.B,a=Ss.a,o=Ss.O,l=Ss.S,h=Ss.A,u=Ss.b,c=Ss.F,_=Ss.c,f=Ss.d,p=Ss.T,d=Ss.e,m=Ss.f,y=Ss.M,g=Ss.g,v=Ss.h,b=Ss.i,S=Ss.j,A=Ss.k,C=Ss.l,x=Ss.m,T=Ss.n,w=Ss.o,E=Ss.p,B=Ss.q,D=Ss.r,M=Ss.s,P=Ss.L,R=Ss.t,I=Ss.u,O=Ss.v,F=Ss.w,L=Ss.x,V=Ss.y,k=Ss.z,N=Ss.E,G=Ss.G,z=Ss.H,U=Ss.Q,H=Ss.I,j=Ss.J,W=Ss.K,X=Ss.N,Y=Ss.U,q=Ss.V,J=Ss.W,K=Ss.X,Z=Ss.Y,Q=Ss.Z,$=Ss._,tt=Ss.$,et=Ss.a0,it=Ss.a1,rt=Ss.a2,nt=Ss.a3,st=Ss.a4,at=Ss.a5,ot=Ss.a6,lt=Ss.a7,ht=Ss.a8,ut=Ss.a9,ct=Ss.aa,_t=Ss.ab,ft=Ss.ac,pt=Ss.ad,dt=Ss.ae,mt=Ss.af,yt=Ss.ag,gt=Ss.ah,vt=Ss.ai,bt=Ss.aj,St=Ss.ak,At=Ss.al,Ct=Ss.am,xt=Ss.an,Tt=Ss.ao,wt=Ss.ap,Et=Ss.aq,Bt=Ss.ar,Dt=Ss.as,Mt=Ss.at,Pt=Ss.au,Rt=Ss.av,It=Ss.aw,Ot=Ss.ax,Ft=Ss.ay,Lt=Ss.az,Vt=Ss.aA,kt=Ss.aB,Nt=Ss.aC,Gt=Ss.aD,zt=Ss.aE,Ut=Ss.aF,Ht=Ss.aG,jt=Ss.aH,Wt=Ss.aI,Xt=Ss.aJ,Yt=Ss.aK,qt=Ss.aL,Jt=Ss.aM,Kt=Ss.aN,Zt=Ss.aO,Qt=Ss.aP,$t=Ss.aQ,te=Ss.aR,ee=Ss.aS,ie=Ss.aT,re=Ss.aU,ne=Ss.aV,se=Ss.aW,ae=Ss.aX,oe=Ss.aY,le=Ss.aZ,he=Ss.a_,ue=Ss.a$,ce=Ss.b0,_e=Ss.b1,fe=Ss.b2,pe=Ss.b3,de=Ss.b4,me=Ss.b5,ye=Ss.b6,ge=Ss.b7,ve=Ss.b8,be=Ss.b9,Se=Ss.ba,Ae=Ss.bb,Ce=Ss.bc,xe=Ss.bd,Te=Ss.be,we=Ss.bf,Ee=Ss.bg,Be=Ss.bh,De=Ss.bi,Me=Ss.bj,Pe=Ss.bk,Re=Ss.bl,Ie=Ss.bm,Oe=Ss.bn,Fe=Ss.bo,Le=Ss.bp,Ve=Ss.bq,ke=Ss.br,Ne=Ss.bs,Ge=Ss.bt,ze=Ss.bu,Ue=Ss.bv,He=Ss.bw,je=Ss.bx,We=Ss.by,Xe=Ss.bz,Ye=Ss.bA,qe=Ss.bB,Je=Ss.bC,Ke=Ss.bD,Ze=Ss.bE,Qe=Ss.bF,$e=Ss.bG,ti=Ss.bH,ei=Ss.bI,ii=Ss.bJ,ri=Ss.bK,ni=Ss.bL,si=Ss.bM,ai=Ss.bN,oi=Ss.bO,li=Ss.bP,hi=Ss.bQ,ui=Ss.bR,ci=Ss.bS,_i=Ss.bT,fi=Ss.bU,pi=Ss.bV,di=Ss.bW,mi=Ss.bX,yi=Ss.bY,gi=Ss.bZ,vi=Ss.b_,bi=Ss.b$,Si=Ss.c0,Ai=Ss.c1,Ci=Ss.c2,xi=Ss.c3,Ti=Ss.c4,wi=Ss.c5,Ei=Ss.c6,Bi=Ss.c7,Di=Ss.c8,Mi=Ss.c9,Pi=Ss.ca,Ri=Ss.cb,Ii=Ss.cc,Oi=Ss.cd,Fi=Ss.ce,Li=Ss.cf,Vi=Ss.cg,ki=Ss.ch,Ni=Ss.ci,Gi=Ss.cj,zi=Ss.ck,Ui=Ss.cl,Hi=Ss.cm,ji=Ss.cn,Wi=Ss.co,Xi=Ss.cp,Yi=Ss.cq,qi=Ss.cr,Ji=Ss.cs,Ki=Ss.ct,Zi=Ss.cu,Qi=Ss.cv,$i=Ss.cw,tr=Ss.cx,er=Ss.cy,ir=Ss.cz,rr=Ss.cA,nr=Ss.cB,sr=Ss.cC,ar=Ss.cD,or=Ss.cE,lr=Ss.cF,hr=Ss.cG,ur=Ss.cH,cr=Ss.cI,_r=Ss.cJ,fr=Ss.cK,pr=Ss.cL,dr=Ss.cM,mr=Ss.cN,yr=Ss.cO,gr=Ss.cP,vr=Ss.cQ,br=Ss.cR,Sr=Ss.cS,Ar=Ss.cT,Cr=Ss.cU,xr=Ss.cV,Tr=Ss.cW,wr=Ss.cX,Er=Ss.cY,Br=Ss.cZ,Dr=Ss.c_,Mr=Ss.c$,Pr=Ss.d0,Rr=Ss.d1,Ir=Ss.d2,Or=Ss.d3,Fr=Ss.d4,Lr=Ss.d5,Vr=Ss.d6,kr=Ss.d7,Nr=Ss.d8,Gr=Ss.d9,zr=Ss.da,Ur=Ss.db,Hr=Ss.dc,jr=Ss.dd,Wr=Ss.de,Xr=Ss.df,Yr=Ss.dg,qr=Ss.dh,Jr=Ss.di,Kr=Ss.dj,Zr=Ss.dk,Qr=Ss.dl,$r=Ss.dm,tn=Ss.dn,en=Ss.dp,rn=Ss.dq,nn=Ss.dr,sn=Ss.ds,an=Ss.dt,on=Ss.du,ln=Ss.dv,hn=Ss.dw,un=Ss.dx,cn=Ss.dy,_n=Ss.dz,fn=Ss.dA,pn=Ss.dB,dn=Ss.dC,mn=Ss.dD,yn=Ss.dE,gn=Ss.dF,vn=Ss.dG,bn=Ss.dH,Sn=Ss.dI,An=Ss.dJ,Cn=Ss.dK,xn=Ss.dL,Tn=Ss.dM,wn=Ss.dN,En=Ss.dO,Bn=Ss.dP,Dn=Ss.dQ,Mn=Ss.dR,Pn=Ss.dS,Rn=Ss.dT,In=Ss.dU,On=Ss.dV,Fn=Ss.dW,Ln=Ss.dX,Vn=Ss.dY,kn=Ss.dZ,Nn=Ss.d_,Gn=Ss.d$,zn=Ss.e0,Un=Ss.e1,Hn=Ss.e2,jn=Ss.e3,Wn=Ss.e4,Xn=Ss.e5,Yn=Ss.e6,qn=Ss.e7,Jn=Ss.e8,Kn=Ss.e9,Zn=Ss.ea,Qn=Ss.eb,$n=Ss.ec,ts=Ss.ed,es=Ss.ee,is=Ss.ef,rs=Ss.eg,ns=Ss.eh,ss=Ss.ei,as=Ss.ej,os=Ss.ek,ls=Ss.el,hs=Ss.em,us=Ss.en,cs=Ss.eo,_s=Ss.ep,fs=Ss.eq,ps=Ss.er,ds=Ss.es,ms=Ss.et,ys=Ss.eu,gs=Ss.ev,vs=Ss.ew,bs=Ss.ex;var As={};As.AffineTransform=Ss.eH,As.AnimCurve=Ss.g2,As.Animation=Ss.cO,As.AnimationClip=Ss.g6,As.AnimationComponent=Ss.cO,As.AnimationManager=Ss.g7,As.AnimationState=Ss.cN,As.Asset=Ss.bN,As.AssetLibrary=Ss.fN,As.AssetManager=Ss.fJ,As.BaseNode=Ss.fP,As.BitMask=Ss.eS,As.BufferAsset=Ss.f5,As.CCBoolean=Ss.eq,As.CCClass=Ss.ev,As.CCFloat=Ss.f3,As.CCInteger=Ss.et,As.CCLoader=Ss.fL,As.CCObject=Ss.d5,As.CCString=Ss.ce,As.CachedArray=Ss.C,As.Camera=Ss.dc,As.CameraComponent=Ss.dc,As.Color=Ss.cl,As.CompactValueTypeArray=Ss.f4,As.Component=Ss.ck,As.ComponentModifier=Ss.fV,As.CubicSplineNumberValue=Ss.bi,As.CubicSplineQuatValue=Ss.bh,As.CubicSplineVec2Value=Ss.be,As.CubicSplineVec3Value=Ss.bf,As.CubicSplineVec4Value=Ss.bg,As.CurveValueAdapter=Ss.fW,As.DebugMode=Ss.fh,As.DeferredPipeline=Ss.fy,As.Details=Ss.f2,As.Director=Ss.cY,As.EPSILON=Ss.eL,As.EffectAsset=Ss.ep,As.Enum=Ss.bY,As.Event=Ss.dM,As.EventAcceleration=Ss.fn,As.EventHandler=Ss.dB,As.EventInfo=Ss.g3,As.EventKeyboard=Ss.fo,As.EventMouse=Ss.fm,As.EventTarget=Ss.ek,As.EventTouch=Ss.dL,As.Eventify=Ss.e6,As.ForwardFlow=Ss.fw,As.ForwardPipeline=Ss.fv,As.ForwardStage=Ss.fx,As.Game=Ss.d8,As.GbufferFlow=Ss.fz,As.GbufferStage=Ss.fA,As.HierachyModifier=Ss.fU,As.ImageAsset=Ss.bA,As.InstancedBuffer=Ss.fG,As.JavaScript=Ss.fb,As.JsonAsset=Ss.f8,As.Layers=Ss.dl,As.LightingFlow=Ss.fB,As.LightingStage=Ss.fC,As.Mat3=Ss.eG,As.Mat4=Ss.cb,As.Material=Ss.cI,As.MissingScript=Ss.fS,As.Node=Ss.cH,As.NodeActivator=Ss.fQ,As.NodePool=Ss.g9,As.PipelineStateManager=Ss.fH,As.Pool=Ss.P,As.PostprocessStage=Ss.fD,As.Prefab=Ss.f6,As.PrefabLink=Ss.eX,As.PrivateNode=Ss.fR,As.Quat=Ss.bM,As.RatioSampler=Ss.g1,As.Rect=Ss.cP,As.RecyclePool=Ss.R,As.RenderFlow=Ss.ft,As.RenderPipeline=Ss.fs,As.RenderStage=Ss.fu,As.RenderTexture=Ss.da,As.RenderableComponent=Ss.ca,As.RenderingSubMesh=Ss.bR,As.ResolutionPolicy=Ss.fi,As.Scene=Ss.dN,As.SceneAsset=Ss.f7,As.Scheduler=Ss.ew,As.Script=Ss.fa,As.ShadowFlow=Ss.fE,As.ShadowStage=Ss.fF,As.Size=Ss.cQ,As.SkelAnimDataHub=Ss.cu,As.System=Ss.e5,As.SystemEvent=Ss.fk,As.SystemEventType=Ss.c_,As.TextAsset=Ss.eu,As.Texture2D=Ss.bB,As.TextureCube=Ss.f9,As.Touch=Ss.fp,As.TypeScript=Ss.fc,As.UniformCurveValueAdapter=Ss.fX,As.VERSION=Ss.eo,As.ValueType=Ss.eT,As.Vec2=Ss.cM,As.Vec3=Ss.bJ,As.Vec4=Ss.c4,As.View=Ss.dQ,As.WorldNode3DToLocalNodeUI=Ss.eZ,As.WorldNode3DToWorldNodeUI=Ss.e_,As._decorator=Ss.f0,As.absMax=Ss.e9,As.absMaxComponent=Ss.eR,As.approx=Ss.eM,As.assert=Ss.fd,As.assertID=Ss.fe,As.assetManager=Ss.dh,As.bezier=Ss.f$,As.bezierByTime=Ss.g0,As.bits=Ss.eB,As.builtinResMgr=Ss.c2,As.ccenum=Ss.d0,As.cclegacy=Ss.bw,As.clamp=Ss.d9,As.clamp01=Ss.dK,As.color=Ss.eK,As.computeRatioByType=Ss.g5,As.convertUtils=Ss.e$,As.createDefaultPipeline=Ss.fr,As.deserialize=Ss.f1,As.director=Ss.cX,As.easing=Ss.en,As.effects=Ss.fT,As.equals=Ss.e4,As.error=Ss.bm,As.errorID=Ss.bl,As.eventManager=Ss.fj,As.find=Ss.bV,As.game=Ss.de,As.geometry=Ss.eA,As.getError=Ss.eh,As.getPathFromRoot=Ss.g8,As.getPhaseID=Ss.fI,As.getWorldTransformUntilRoot=Ss.ct,As.instantiate=Ss.e2,As.inverseLerp=Ss.eQ,As.isCustomTargetModifier=Ss.f_,As.isDisplayStats=Ss.ff,As.isElementModifier=Ss.fZ,As.isPropertyModifier=Ss.fY,As.isValid=Ss.er,As.js=Ss.eU,As.lerp=Ss.dC,As.loader=Ss.fM,As.log=Ss.el,As.logID=Ss.dt,As.macro=Ss.bn,As.markAsWarning=Ss.dg,As.mat4=Ss.em,As.math=Ss.ez,As.misc=Ss.eV,As.murmurhash2_32_gc=Ss.bS,As.nextPow2=Ss.eP,As.path=Ss.eW,As.pingPong=Ss.e0,As.pipeline=Ss.fq,As.pseudoRandom=Ss.dW,As.pseudoRandomRange=Ss.eN,As.pseudoRandomRangeInt=Ss.eO,As.quat=Ss.eF,As.random=Ss.dX,As.randomRange=Ss.dY,As.randomRangeInt=Ss.dZ,As.rect=Ss.eJ,As.removeProperty=Ss.cd,As.renderer=Ss.ey,As.repeat=Ss.dV,As.replaceProperty=Ss.cc,As.resources=Ss.fK,As.sampleAnimationCurve=Ss.g4,As.screen=Ss.dG,As.setDefaultLogTimes=Ss.eY,As.setDisplayStats=Ss.fg,As.size=Ss.eI,As.sys=Ss.br,As.systemEvent=Ss.fl,As.toDegree=Ss.dR,As.toRadian=Ss.cr,As.url=Ss.fO,As.v2=Ss.eC,As.v3=Ss.eD,As.v4=Ss.eE,As.view=Ss.df,As.warn=Ss.bv,As.warnID=Ss.bu,t(As)},function(t){Ss=t.c,As=t.u,t.a}],execute:function(){t({CacheMode:void 0,EAxisDirection:void 0,ECollider2DType:void 0,EJoint2DType:void 0,EPhysics2DDrawFlags:void 0,ERaycast2DType:void 0,ERigidBody2DType:void 0,ERigidBodyType:void 0,HorizontalTextAlignment:void 0,InstanceMaterialType:void 0,Overflow:void 0,Physics2DManifoldType:void 0,VerticalTextAlignment:void 0,earcut:cv,fragmentText:o_,getBaselineOffset:function(){return 0},isUnicodeCJK:r_,isUnicodeSpace:n_,safeMeasureText:s_,tween:Q8,tweenUtil:$8}),t("memop",Object.freeze({__proto__:null,Pool:e,RecyclePool:i,CachedArray:r})),t("gfx",Object.freeze({__proto__:null,DescriptorSet:n,Buffer:s,CommandBuffer:a,get ObjectType(){return o},get Status(){return l},get API(){return h},get SurfaceTransform(){return u},get Feature(){return c},get Format(){return _},get FormatType(){return f},get Type(){return p},get BufferUsageBit(){return d},get BufferFlagBit(){return m},get MemoryAccessBit(){return y},get MemoryUsageBit(){return g},get TextureType(){return v},get TextureUsageBit(){return b},get TextureFlagBit(){return S},get SampleCount(){return A},get Filter(){return C},get Address(){return x},get ComparisonFunc(){return T},get StencilOp(){return w},get BlendFactor(){return E},get BlendOp(){return B},get ColorMask(){return D},get ShaderStageFlagBit(){return M},get LoadOp(){return P},get StoreOp(){return R},get AccessType(){return I},get PipelineBindPoint(){return O},get PrimitiveMode(){return F},get PolygonMode(){return L},get ShadeModel(){return V},get CullMode(){return k},get DynamicStateFlagBit(){return N},get StencilFace(){return G},get DescriptorType(){return z},get QueueType(){return U},get CommandBufferType(){return H},get ClearFlagBit(){return j},Size:W,DeviceCaps:X,Offset:Y,Rect:q,Extent:J,TextureSubresLayers:K,TextureSubresRange:Z,TextureCopy:Q,TextureBlit:$,BufferTextureCopy:tt,Viewport:et,Color:it,BindingMappingInfo:rt,BufferInfo:nt,BufferViewInfo:st,DrawInfo:at,DispatchInfo:ot,IndirectBuffer:lt,TextureInfo:ht,TextureViewInfo:ut,SamplerInfo:ct,Uniform:_t,UniformBlock:ft,UniformSamplerTexture:pt,UniformSampler:dt,UniformTexture:mt,UniformStorageImage:yt,UniformStorageBuffer:gt,UniformInputAttachment:vt,ShaderStage:bt,Attribute:St,ShaderInfo:At,InputAssemblerInfo:Ct,ColorAttachment:xt,DepthStencilAttachment:Tt,SubpassInfo:wt,RenderPassInfo:Et,GlobalBarrierInfo:Bt,TextureBarrierInfo:Dt,FramebufferInfo:Mt,DescriptorSetLayoutBinding:Pt,DescriptorSetLayoutInfo:Rt,DescriptorSetInfo:It,PipelineLayoutInfo:Ot,InputState:Ft,CommandBufferInfo:Lt,QueueInfo:Vt,FormatInfo:kt,MemoryStatus:Nt,Obj:Gt,DeviceInfo:zt,get AttributeName(){return Ut},FormatInfos:Ht,DESCRIPTOR_BUFFER_TYPE:jt,DESCRIPTOR_SAMPLER_TYPE:Wt,DESCRIPTOR_DYNAMIC_TYPE:Xt,DRAW_INFO_SIZE:Yt,IsPowerOf2:qt,FormatSize:Jt,FormatSurfaceSize:Kt,GetTypeSize:Zt,getTypedArrayConstructor:Qt,Device:$t,Framebuffer:te,InputAssembler:ee,DescriptorSetLayout:ie,PipelineLayout:re,RasterizerState:ne,DepthStencilState:se,BlendTarget:ae,BlendState:oe,PipelineStateInfo:le,PipelineState:he,Queue:ue,RenderPass:ce,Sampler:_e,Shader:fe,Texture:pe,GlobalBarrier:de,TextureBarrier:me})),t("animation",Object.freeze({__proto__:null,UniformProxyFactory:ye,MorphWeightsValueProxy:ge,MorphWeightsAllValueProxy:ve,isPropertyPath:be,isCustomPath:Se,HierarchyPath:Ae,ComponentPath:Ce,evaluatePath:xe,CubicSplineVec2Value:Te,CubicSplineVec3Value:we,CubicSplineVec4Value:Ee,CubicSplineQuatValue:Be,CubicSplineNumberValue:De}));var Cs,xs=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuDescriptorSet=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._layout=t.layout;var e=t.layout.gpuDescriptorSetLayout,i=e.bindings,r=e.descriptorIndices,n=e.descriptorCount;this._buffers=Array(n).fill(null),this._textures=Array(n).fill(null),this._samplers=Array(n).fill(null);var s=[];this._gpuDescriptorSet={gpuDescriptors:s,descriptorIndices:r};for(var a=0;a<i.length;++a)for(var o=i[a],l=0;l<o.count;l++)s.push({type:o.descriptorType,gpuBuffer:null,gpuTexture:null,gpuSampler:null});return!0},i.destroy=function(){this._layout=null,this._gpuDescriptorSet=null},i.update=function(){if(this._isDirty&&this._gpuDescriptorSet){for(var t=this._gpuDescriptorSet.gpuDescriptors,e=0;e<t.length;++e)if(t[e].type&jt){var i=this._buffers[e];i&&(t[e].gpuBuffer=i.gpuBuffer||i.gpuBufferView)}else t[e].type&Wt&&(this._textures[e]&&(t[e].gpuTexture=this._textures[e].gpuTexture),this._samplers[e]&&(t[e].gpuSampler=this._samplers[e].gpuSampler));this._isDirty=!1}},Pe(e,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),e}(n);function Ts(t,e){switch(t){case _.R8:return e.UNSIGNED_BYTE;case _.R8SN:return e.BYTE;case _.R8UI:return e.UNSIGNED_BYTE;case _.R8I:return e.BYTE;case _.R16F:return Cs.HALF_FLOAT_OES;case _.R16UI:return e.UNSIGNED_SHORT;case _.R16I:return e.SHORT;case _.R32F:return e.FLOAT;case _.R32UI:return e.UNSIGNED_INT;case _.R32I:return e.INT;case _.RG8:return e.UNSIGNED_BYTE;case _.RG8SN:return e.BYTE;case _.RG8UI:return e.UNSIGNED_BYTE;case _.RG8I:return e.BYTE;case _.RG16F:return Cs.HALF_FLOAT_OES;case _.RG16UI:return e.UNSIGNED_SHORT;case _.RG16I:return e.SHORT;case _.RG32F:return e.FLOAT;case _.RG32UI:return e.UNSIGNED_INT;case _.RG32I:return e.INT;case _.RGB8:case _.SRGB8:return e.UNSIGNED_BYTE;case _.RGB8SN:return e.BYTE;case _.RGB8UI:return e.UNSIGNED_BYTE;case _.RGB8I:return e.BYTE;case _.RGB16F:return Cs.HALF_FLOAT_OES;case _.RGB16UI:return e.UNSIGNED_SHORT;case _.RGB16I:return e.SHORT;case _.RGB32F:return e.FLOAT;case _.RGB32UI:return e.UNSIGNED_INT;case _.RGB32I:return e.INT;case _.BGRA8:case _.RGBA8:case _.SRGB8_A8:return e.UNSIGNED_BYTE;case _.RGBA8SN:return e.BYTE;case _.RGBA8UI:return e.UNSIGNED_BYTE;case _.RGBA8I:return e.BYTE;case _.RGBA16F:return Cs.HALF_FLOAT_OES;case _.RGBA16UI:return e.UNSIGNED_SHORT;case _.RGBA16I:return e.SHORT;case _.RGBA32F:return e.FLOAT;case _.RGBA32UI:return e.UNSIGNED_INT;case _.RGBA32I:return e.INT;case _.R5G6B5:return e.UNSIGNED_SHORT_5_6_5;case _.R11G11B10F:return e.FLOAT;case _.RGB5A1:return e.UNSIGNED_SHORT_5_5_5_1;case _.RGBA4:return e.UNSIGNED_SHORT_4_4_4_4;case _.RGB10A2:return e.UNSIGNED_BYTE;case _.RGB10A2UI:return e.UNSIGNED_INT;case _.RGB9E5:return e.UNSIGNED_BYTE;case _.D16:return e.UNSIGNED_SHORT;case _.D16S8:return Cs.UNSIGNED_INT_24_8_WEBGL;case _.D24:return e.UNSIGNED_INT;case _.D24S8:return Cs.UNSIGNED_INT_24_8_WEBGL;case _.D32F:return e.UNSIGNED_INT;case _.D32F_S8:return Cs.UNSIGNED_INT_24_8_WEBGL;case _.BC1:case _.BC1_SRGB:case _.BC2:case _.BC2_SRGB:case _.BC3:case _.BC3_SRGB:case _.BC4:return e.UNSIGNED_BYTE;case _.BC4_SNORM:return e.BYTE;case _.BC5:return e.UNSIGNED_BYTE;case _.BC5_SNORM:return e.BYTE;case _.BC6H_SF16:case _.BC6H_UF16:return e.FLOAT;case _.BC7:case _.BC7_SRGB:case _.ETC_RGB8:case _.ETC2_RGB8:case _.ETC2_SRGB8:case _.ETC2_RGB8_A1:case _.ETC2_SRGB8_A1:case _.EAC_R11:return e.UNSIGNED_BYTE;case _.EAC_R11SN:return e.BYTE;case _.EAC_RG11:return e.UNSIGNED_BYTE;case _.EAC_RG11SN:return e.BYTE;case _.PVRTC_RGB2:case _.PVRTC_RGBA2:case _.PVRTC_RGB4:case _.PVRTC_RGBA4:case _.PVRTC2_2BPP:case _.PVRTC2_4BPP:return e.UNSIGNED_BYTE;case _.ASTC_RGBA_4x4:case _.ASTC_RGBA_5x4:case _.ASTC_RGBA_5x5:case _.ASTC_RGBA_6x5:case _.ASTC_RGBA_6x6:case _.ASTC_RGBA_8x5:case _.ASTC_RGBA_8x6:case _.ASTC_RGBA_8x8:case _.ASTC_RGBA_10x5:case _.ASTC_RGBA_10x6:case _.ASTC_RGBA_10x8:case _.ASTC_RGBA_10x10:case _.ASTC_RGBA_12x10:case _.ASTC_RGBA_12x12:case _.ASTC_SRGBA_4x4:case _.ASTC_SRGBA_5x4:case _.ASTC_SRGBA_5x5:case _.ASTC_SRGBA_6x5:case _.ASTC_SRGBA_6x6:case _.ASTC_SRGBA_8x5:case _.ASTC_SRGBA_8x6:case _.ASTC_SRGBA_8x8:case _.ASTC_SRGBA_10x5:case _.ASTC_SRGBA_10x6:case _.ASTC_SRGBA_10x8:case _.ASTC_SRGBA_10x10:case _.ASTC_SRGBA_12x10:case _.ASTC_SRGBA_12x12:default:return e.UNSIGNED_BYTE}}function ws(t,e){switch(t){case _.A8:return e.ALPHA;case _.L8:return e.LUMINANCE;case _.LA8:return e.LUMINANCE_ALPHA;case _.RGB8:case _.RGB16F:case _.RGB32F:return e.RGB;case _.BGRA8:case _.RGBA8:case _.RGBA16F:case _.RGBA32F:return e.RGBA;case _.R5G6B5:return e.RGB565;case _.RGB5A1:return e.RGB5_A1;case _.RGBA4:return e.RGBA4;case _.D16:return e.DEPTH_COMPONENT;case _.D16S8:return e.DEPTH_STENCIL;case _.D24:return e.DEPTH_COMPONENT;case _.D24S8:return e.DEPTH_STENCIL;case _.D32F:return e.DEPTH_COMPONENT;case _.D32F_S8:return e.DEPTH_STENCIL;case _.BC1:return Cs.COMPRESSED_RGB_S3TC_DXT1_EXT;case _.BC1_ALPHA:return Cs.COMPRESSED_RGBA_S3TC_DXT1_EXT;case _.BC1_SRGB:return Cs.COMPRESSED_SRGB_S3TC_DXT1_EXT;case _.BC1_SRGB_ALPHA:return Cs.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case _.BC2:return Cs.COMPRESSED_RGBA_S3TC_DXT3_EXT;case _.BC2_SRGB:return Cs.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case _.BC3:return Cs.COMPRESSED_RGBA_S3TC_DXT5_EXT;case _.BC3_SRGB:return Cs.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case _.ETC_RGB8:return Cs.COMPRESSED_RGB_ETC1_WEBGL;case _.ETC2_RGB8:return Cs.COMPRESSED_RGB8_ETC2;case _.ETC2_SRGB8:return Cs.COMPRESSED_SRGB8_ETC2;case _.ETC2_RGB8_A1:return Cs.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_SRGB8_A1:return Cs.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_RGBA8:return Cs.COMPRESSED_RGBA8_ETC2_EAC;case _.ETC2_SRGB8_A8:return Cs.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case _.EAC_R11:return Cs.COMPRESSED_R11_EAC;case _.EAC_R11SN:return Cs.COMPRESSED_SIGNED_R11_EAC;case _.EAC_RG11:return Cs.COMPRESSED_RG11_EAC;case _.EAC_RG11SN:return Cs.COMPRESSED_SIGNED_RG11_EAC;case _.PVRTC_RGB2:return Cs.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case _.PVRTC_RGBA2:return Cs.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case _.PVRTC_RGB4:return Cs.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case _.PVRTC_RGBA4:return Cs.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case _.ASTC_RGBA_4x4:return Cs.COMPRESSED_RGBA_ASTC_4x4_KHR;case _.ASTC_RGBA_5x4:return Cs.COMPRESSED_RGBA_ASTC_5x4_KHR;case _.ASTC_RGBA_5x5:return Cs.COMPRESSED_RGBA_ASTC_5x5_KHR;case _.ASTC_RGBA_6x5:return Cs.COMPRESSED_RGBA_ASTC_6x5_KHR;case _.ASTC_RGBA_6x6:return Cs.COMPRESSED_RGBA_ASTC_6x6_KHR;case _.ASTC_RGBA_8x5:return Cs.COMPRESSED_RGBA_ASTC_8x5_KHR;case _.ASTC_RGBA_8x6:return Cs.COMPRESSED_RGBA_ASTC_8x6_KHR;case _.ASTC_RGBA_8x8:return Cs.COMPRESSED_RGBA_ASTC_8x8_KHR;case _.ASTC_RGBA_10x5:return Cs.COMPRESSED_RGBA_ASTC_10x5_KHR;case _.ASTC_RGBA_10x6:return Cs.COMPRESSED_RGBA_ASTC_10x6_KHR;case _.ASTC_RGBA_10x8:return Cs.COMPRESSED_RGBA_ASTC_10x8_KHR;case _.ASTC_RGBA_10x10:return Cs.COMPRESSED_RGBA_ASTC_10x10_KHR;case _.ASTC_RGBA_12x10:return Cs.COMPRESSED_RGBA_ASTC_12x10_KHR;case _.ASTC_RGBA_12x12:return Cs.COMPRESSED_RGBA_ASTC_12x12_KHR;case _.ASTC_SRGBA_4x4:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case _.ASTC_SRGBA_5x4:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case _.ASTC_SRGBA_5x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case _.ASTC_SRGBA_6x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case _.ASTC_SRGBA_6x6:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case _.ASTC_SRGBA_8x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case _.ASTC_SRGBA_8x6:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case _.ASTC_SRGBA_8x8:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case _.ASTC_SRGBA_10x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case _.ASTC_SRGBA_10x6:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case _.ASTC_SRGBA_10x8:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case _.ASTC_SRGBA_10x10:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case _.ASTC_SRGBA_12x10:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case _.ASTC_SRGBA_12x12:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),e.RGBA}}function Es(t,e){switch(t){case _.A8:return e.ALPHA;case _.L8:return e.LUMINANCE;case _.LA8:return e.LUMINANCE_ALPHA;case _.RGB8:case _.RGB16F:case _.RGB32F:return e.RGB;case _.BGRA8:case _.RGBA8:case _.RGBA16F:case _.RGBA32F:return e.RGBA;case _.R5G6B5:return e.RGB;case _.RGB5A1:case _.RGBA4:return e.RGBA;case _.D16:return e.DEPTH_COMPONENT;case _.D16S8:return e.DEPTH_STENCIL;case _.D24:return e.DEPTH_COMPONENT;case _.D24S8:return e.DEPTH_STENCIL;case _.D32F:return e.DEPTH_COMPONENT;case _.D32F_S8:return e.DEPTH_STENCIL;case _.BC1:return Cs.COMPRESSED_RGB_S3TC_DXT1_EXT;case _.BC1_ALPHA:return Cs.COMPRESSED_RGBA_S3TC_DXT1_EXT;case _.BC1_SRGB:return Cs.COMPRESSED_SRGB_S3TC_DXT1_EXT;case _.BC1_SRGB_ALPHA:return Cs.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case _.BC2:return Cs.COMPRESSED_RGBA_S3TC_DXT3_EXT;case _.BC2_SRGB:return Cs.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case _.BC3:return Cs.COMPRESSED_RGBA_S3TC_DXT5_EXT;case _.BC3_SRGB:return Cs.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case _.ETC_RGB8:return Cs.COMPRESSED_RGB_ETC1_WEBGL;case _.ETC2_RGB8:return Cs.COMPRESSED_RGB8_ETC2;case _.ETC2_SRGB8:return Cs.COMPRESSED_SRGB8_ETC2;case _.ETC2_RGB8_A1:return Cs.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_SRGB8_A1:return Cs.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case _.ETC2_RGBA8:return Cs.COMPRESSED_RGBA8_ETC2_EAC;case _.ETC2_SRGB8_A8:return Cs.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case _.EAC_R11:return Cs.COMPRESSED_R11_EAC;case _.EAC_R11SN:return Cs.COMPRESSED_SIGNED_R11_EAC;case _.EAC_RG11:return Cs.COMPRESSED_RG11_EAC;case _.EAC_RG11SN:return Cs.COMPRESSED_SIGNED_RG11_EAC;case _.PVRTC_RGB2:return Cs.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case _.PVRTC_RGBA2:return Cs.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case _.PVRTC_RGB4:return Cs.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case _.PVRTC_RGBA4:return Cs.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case _.ASTC_RGBA_4x4:return Cs.COMPRESSED_RGBA_ASTC_4x4_KHR;case _.ASTC_RGBA_5x4:return Cs.COMPRESSED_RGBA_ASTC_5x4_KHR;case _.ASTC_RGBA_5x5:return Cs.COMPRESSED_RGBA_ASTC_5x5_KHR;case _.ASTC_RGBA_6x5:return Cs.COMPRESSED_RGBA_ASTC_6x5_KHR;case _.ASTC_RGBA_6x6:return Cs.COMPRESSED_RGBA_ASTC_6x6_KHR;case _.ASTC_RGBA_8x5:return Cs.COMPRESSED_RGBA_ASTC_8x5_KHR;case _.ASTC_RGBA_8x6:return Cs.COMPRESSED_RGBA_ASTC_8x6_KHR;case _.ASTC_RGBA_8x8:return Cs.COMPRESSED_RGBA_ASTC_8x8_KHR;case _.ASTC_RGBA_10x5:return Cs.COMPRESSED_RGBA_ASTC_10x5_KHR;case _.ASTC_RGBA_10x6:return Cs.COMPRESSED_RGBA_ASTC_10x6_KHR;case _.ASTC_RGBA_10x8:return Cs.COMPRESSED_RGBA_ASTC_10x8_KHR;case _.ASTC_RGBA_10x10:return Cs.COMPRESSED_RGBA_ASTC_10x10_KHR;case _.ASTC_RGBA_12x10:return Cs.COMPRESSED_RGBA_ASTC_12x10_KHR;case _.ASTC_RGBA_12x12:return Cs.COMPRESSED_RGBA_ASTC_12x12_KHR;case _.ASTC_SRGBA_4x4:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case _.ASTC_SRGBA_5x4:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case _.ASTC_SRGBA_5x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case _.ASTC_SRGBA_6x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case _.ASTC_SRGBA_6x6:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case _.ASTC_SRGBA_8x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case _.ASTC_SRGBA_8x6:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case _.ASTC_SRGBA_8x8:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case _.ASTC_SRGBA_10x5:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case _.ASTC_SRGBA_10x6:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case _.ASTC_SRGBA_10x8:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case _.ASTC_SRGBA_10x10:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case _.ASTC_SRGBA_12x10:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case _.ASTC_SRGBA_12x12:return Cs.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),e.RGBA}}function Bs(t,e){switch(t){case p.BOOL:return e.BOOL;case p.BOOL2:return e.BOOL_VEC2;case p.BOOL3:return e.BOOL_VEC3;case p.BOOL4:return e.BOOL_VEC4;case p.INT:return e.INT;case p.INT2:return e.INT_VEC2;case p.INT3:return e.INT_VEC3;case p.INT4:return e.INT_VEC4;case p.UINT:return e.UNSIGNED_INT;case p.FLOAT:return e.FLOAT;case p.FLOAT2:return e.FLOAT_VEC2;case p.FLOAT3:return e.FLOAT_VEC3;case p.FLOAT4:return e.FLOAT_VEC4;case p.MAT2:return e.FLOAT_MAT2;case p.MAT3:return e.FLOAT_MAT3;case p.MAT4:return e.FLOAT_MAT4;case p.SAMPLER2D:return e.SAMPLER_2D;case p.SAMPLER_CUBE:return e.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),p.UNKNOWN}}function Ds(t){switch(t){case p.BOOL:case p.BOOL2:case p.BOOL3:case p.BOOL4:case p.INT:case p.INT2:case p.INT3:case p.INT4:case p.UINT:return Int32Array;case p.FLOAT:case p.FLOAT2:case p.FLOAT3:case p.FLOAT4:case p.MAT2:case p.MAT3:case p.MAT4:return Float32Array;default:return console.error("Unsupported GLType, convert to TypedArrayConstructor failed."),Float32Array}}function Ms(t,e){switch(t){case e.BOOL:return p.BOOL;case e.BOOL_VEC2:return p.BOOL2;case e.BOOL_VEC3:return p.BOOL3;case e.BOOL_VEC4:return p.BOOL4;case e.INT:return p.INT;case e.INT_VEC2:return p.INT2;case e.INT_VEC3:return p.INT3;case e.INT_VEC4:return p.INT4;case e.UNSIGNED_INT:return p.UINT;case e.FLOAT:return p.FLOAT;case e.FLOAT_VEC2:return p.FLOAT2;case e.FLOAT_VEC3:return p.FLOAT3;case e.FLOAT_VEC4:return p.FLOAT4;case e.FLOAT_MAT2:return p.MAT2;case e.FLOAT_MAT3:return p.MAT3;case e.FLOAT_MAT4:return p.MAT4;case e.SAMPLER_2D:return p.SAMPLER2D;case e.SAMPLER_CUBE:return p.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),p.UNKNOWN}}function Ps(t,e){switch(t){case e.BOOL:return 4;case e.BOOL_VEC2:return 8;case e.BOOL_VEC3:return 12;case e.BOOL_VEC4:return 16;case e.INT:return 4;case e.INT_VEC2:return 8;case e.INT_VEC3:return 12;case e.INT_VEC4:return 16;case e.UNSIGNED_INT:case e.FLOAT:return 4;case e.FLOAT_VEC2:return 8;case e.FLOAT_VEC3:return 12;case e.FLOAT_VEC4:case e.FLOAT_MAT2:return 16;case e.FLOAT_MAT3:return 36;case e.FLOAT_MAT4:return 64;case e.SAMPLER_2D:case e.SAMPLER_CUBE:return 4;default:return console.error("Unsupported GLType, get type failed."),0}}function Rs(t,e){switch(t){case e.FLOAT_MAT2:return 2;case e.FLOAT_MAT3:return 3;case e.FLOAT_MAT4:return 4;default:return 1}}!function(t){t[t.RGBA16F_EXT=34842]="RGBA16F_EXT",t[t.RGB16F_EXT=34843]="RGB16F_EXT",t[t.RGBA32F_EXT=34836]="RGBA32F_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",t[t.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",t[t.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",t[t.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"}(Cs||(Cs={}));var Is,Os=[512,513,514,515,516,517,518,519],Fs=[0,7680,7681,7682,7683,5386,34055,34056],Ls=[32774,32778,32779,32775,32776],Vs=[0,1,770,772,771,773,768,774,769,775,776,32769,32770,32771,32772];!function(t){t[t.BEGIN_RENDER_PASS=0]="BEGIN_RENDER_PASS",t[t.END_RENDER_PASS=1]="END_RENDER_PASS",t[t.BIND_STATES=2]="BIND_STATES",t[t.DRAW=3]="DRAW",t[t.UPDATE_BUFFER=4]="UPDATE_BUFFER",t[t.COPY_BUFFER_TO_TEXTURE=5]="COPY_BUFFER_TO_TEXTURE",t[t.COUNT=6]="COUNT"}(Is||(Is={}));var ks=function(t){this.cmdType=void 0,this.refCount=0,this.cmdType=t},Ns=function(t){function e(){var e;return(e=t.call(this,Is.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,e.gpuFramebuffer=null,e.renderArea=new q,e.clearFlag=j.NONE,e.clearColors=[],e.clearDepth=1,e.clearStencil=0,e}return Me(e,t),e.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},e}(ks),Gs=function(t){function e(){var e;return(e=t.call(this,Is.BIND_STATES)||this).gpuPipelineState=null,e.gpuInputAssembler=null,e.gpuDescriptorSets=[],e.dynamicOffsets=[],e.viewport=null,e.scissor=null,e.lineWidth=null,e.depthBias=null,e.blendConstants=[],e.depthBounds=null,e.stencilWriteMask=null,e.stencilCompareMask=null,e}return Me(e,t),e.prototype.clear=function(){this.gpuPipelineState=null,this.gpuDescriptorSets.length=0,this.gpuInputAssembler=null,this.dynamicOffsets.length=0,this.viewport=null,this.scissor=null,this.lineWidth=null,this.depthBias=null,this.blendConstants.length=0,this.depthBounds=null,this.stencilWriteMask=null,this.stencilCompareMask=null},e}(ks),zs=function(t){function e(){var e;return(e=t.call(this,Is.DRAW)||this).drawInfo=new at,e}return Me(e,t),e.prototype.clear=function(){},e}(ks),Us=function(t){function e(){var e;return(e=t.call(this,Is.UPDATE_BUFFER)||this).gpuBuffer=null,e.buffer=null,e.offset=0,e.size=0,e}return Me(e,t),e.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},e}(ks),Hs=function(t){function e(){var e;return(e=t.call(this,Is.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,e.buffers=[],e.regions=[],e}return Me(e,t),e.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},e}(ks),js=function(){function t(){this.cmds=new r(1),this.beginRenderPassCmds=new r(1),this.bindStatesCmds=new r(1),this.drawCmds=new r(1),this.updateBufferCmds=new r(1),this.copyBufferToTextureCmds=new r(1)}return t.prototype.clearCmds=function(t){this.beginRenderPassCmds.length&&(t.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds),this.beginRenderPassCmds.clear()),this.bindStatesCmds.length&&(t.bindStatesCmdPool.freeCmds(this.bindStatesCmds),this.bindStatesCmds.clear()),this.drawCmds.length&&(t.drawCmdPool.freeCmds(this.drawCmds),this.drawCmds.clear()),this.updateBufferCmds.length&&(t.updateBufferCmdPool.freeCmds(this.updateBufferCmds),this.updateBufferCmds.clear()),this.copyBufferToTextureCmds.length&&(t.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds),this.copyBufferToTextureCmds.clear()),this.cmds.clear()},t}();function Ws(t,e,i,r,n){if(e.usage&d.UNIFORM)ArrayBuffer.isView(i)?e.vf32.set(i,r/Float32Array.BYTES_PER_ELEMENT):e.vf32.set(new Float32Array(i),r/Float32Array.BYTES_PER_ELEMENT);else if(e.usage&d.INDIRECT)e.indirects.length=r,Array.prototype.push.apply(e.indirects,i.drawInfos);else{var s=i,a=t.gl,o=t.stateCache;switch(e.glTarget){case a.ARRAY_BUFFER:t.useVAO&&o.glVAO&&(t.OES_vertex_array_object.bindVertexArrayOES(null),o.glVAO=Xs.gpuInputAssembler=null),t.stateCache.glArrayBuffer!==e.glBuffer&&(a.bindBuffer(a.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer);break;case a.ELEMENT_ARRAY_BUFFER:t.useVAO&&o.glVAO&&(t.OES_vertex_array_object.bindVertexArrayOES(null),o.glVAO=Xs.gpuInputAssembler=null),t.stateCache.glElementArrayBuffer!==e.glBuffer&&(a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer);break;default:return void console.error("Unsupported BufferType, update buffer failed.")}n===s.byteLength?a.bufferSubData(e.glTarget,r,s):a.bufferSubData(e.glTarget,r,s.slice(0,n))}}var Xs={gpuPipelineState:null,gpuInputAssembler:null,glPrimitive:0};function Ys(t,e,i,r,n,s,a){var o=t.gl,l=t.stateCache,h=0;if(i&&e){l.glFramebuffer!==i.glFramebuffer&&(o.bindFramebuffer(o.FRAMEBUFFER,i.glFramebuffer),l.glFramebuffer=i.glFramebuffer),l.viewport.left===r.x&&l.viewport.top===r.y&&l.viewport.width===r.width&&l.viewport.height===r.height||(o.viewport(r.x,r.y,r.width,r.height),l.viewport.left=r.x,l.viewport.top=r.y,l.viewport.width=r.width,l.viewport.height=r.height),l.scissorRect.x===r.x&&l.scissorRect.y===r.y&&l.scissorRect.width===r.width&&l.scissorRect.height===r.height||(o.scissor(r.x,r.y,r.width,r.height),l.scissorRect.x=r.x,l.scissorRect.y=r.y,l.scissorRect.width=r.width,l.scissorRect.height=r.height);var u=n.length;t.WEBGL_draw_buffers||(u=1);for(var c=0;c<u;++c){var f=e.colorAttachments[c];if(f.format!==_.UNKNOWN)switch(f.loadOp){case P.LOAD:break;case P.CLEAR:l.bs.targets[0].blendColorMask!==D.ALL&&o.colorMask(!0,!0,!0,!0);var p=n[0];o.clearColor(p.x,p.y,p.z,p.w),h|=o.COLOR_BUFFER_BIT;break;case P.DISCARD:}}if(e.depthStencilAttachment&&e.depthStencilAttachment.format!==_.UNKNOWN){switch(e.depthStencilAttachment.depthLoadOp){case P.LOAD:break;case P.CLEAR:l.dss.depthWrite||o.depthMask(!0),o.clearDepth(s),h|=o.DEPTH_BUFFER_BIT;break;case P.DISCARD:}if(Ht[e.depthStencilAttachment.format].hasStencil)switch(e.depthStencilAttachment.stencilLoadOp){case P.LOAD:break;case P.CLEAR:l.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,65535),l.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,65535),o.clearStencil(a),h|=o.STENCIL_BUFFER_BIT;break;case P.DISCARD:}}if(h&&o.clear(h),h&o.COLOR_BUFFER_BIT){var d=l.bs.targets[0].blendColorMask;if(d!==D.ALL){var m=(d&D.R)!==D.NONE,y=(d&D.G)!==D.NONE,g=(d&D.B)!==D.NONE,v=(d&D.A)!==D.NONE;o.colorMask(m,y,g,v)}}h&o.DEPTH_BUFFER_BIT&&!l.dss.depthWrite&&o.depthMask(!1),h&o.STENCIL_BUFFER_BIT&&(l.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,0),l.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,0))}}function qs(t,e,i,r,n,s,a,o,l,h,u,c,_){var f,p,d,m=t.gl,y=t.stateCache,g=e&&e.gpuShader,v=!1;if(e&&Xs.gpuPipelineState!==e){if(Xs.gpuPipelineState=e,Xs.glPrimitive=e.glPrimitive,e.gpuShader){var b=e.gpuShader.glProgram;y.glProgram!==b&&(m.useProgram(b),y.glProgram=b,v=!0)}var S=e.rs;if(S){if(y.rs.cullMode!==S.cullMode){switch(S.cullMode){case k.NONE:m.disable(m.CULL_FACE);break;case k.FRONT:m.enable(m.CULL_FACE),m.cullFace(m.FRONT);break;case k.BACK:m.enable(m.CULL_FACE),m.cullFace(m.BACK)}y.rs.cullMode=S.cullMode}var A=S.isFrontFaceCCW;y.rs.isFrontFaceCCW!==A&&(m.frontFace(A?m.CCW:m.CW),y.rs.isFrontFaceCCW=A),y.rs.depthBias===S.depthBias&&y.rs.depthBiasSlop===S.depthBiasSlop||(m.polygonOffset(S.depthBias,S.depthBiasSlop),y.rs.depthBias=S.depthBias,y.rs.depthBiasSlop=S.depthBiasSlop),y.rs.lineWidth!==S.lineWidth&&(m.lineWidth(S.lineWidth),y.rs.lineWidth=S.lineWidth)}var C=e.dss;C&&(y.dss.depthTest!==C.depthTest&&(C.depthTest?m.enable(m.DEPTH_TEST):m.disable(m.DEPTH_TEST),y.dss.depthTest=C.depthTest),y.dss.depthWrite!==C.depthWrite&&(m.depthMask(C.depthWrite),y.dss.depthWrite=C.depthWrite),y.dss.depthFunc!==C.depthFunc&&(m.depthFunc(Os[C.depthFunc]),y.dss.depthFunc=C.depthFunc),y.dss.stencilTestFront===C.stencilTestFront&&y.dss.stencilTestBack===C.stencilTestBack||(C.stencilTestFront||C.stencilTestBack?m.enable(m.STENCIL_TEST):m.disable(m.STENCIL_TEST),y.dss.stencilTestFront=C.stencilTestFront,y.dss.stencilTestBack=C.stencilTestBack),y.dss.stencilFuncFront===C.stencilFuncFront&&y.dss.stencilRefFront===C.stencilRefFront&&y.dss.stencilReadMaskFront===C.stencilReadMaskFront||(m.stencilFuncSeparate(m.FRONT,Os[C.stencilFuncFront],C.stencilRefFront,C.stencilReadMaskFront),y.dss.stencilFuncFront=C.stencilFuncFront,y.dss.stencilRefFront=C.stencilRefFront,y.dss.stencilReadMaskFront=C.stencilReadMaskFront),y.dss.stencilFailOpFront===C.stencilFailOpFront&&y.dss.stencilZFailOpFront===C.stencilZFailOpFront&&y.dss.stencilPassOpFront===C.stencilPassOpFront||(m.stencilOpSeparate(m.FRONT,Fs[C.stencilFailOpFront],Fs[C.stencilZFailOpFront],Fs[C.stencilPassOpFront]),y.dss.stencilFailOpFront=C.stencilFailOpFront,y.dss.stencilZFailOpFront=C.stencilZFailOpFront,y.dss.stencilPassOpFront=C.stencilPassOpFront),y.dss.stencilWriteMaskFront!==C.stencilWriteMaskFront&&(m.stencilMaskSeparate(m.FRONT,C.stencilWriteMaskFront),y.dss.stencilWriteMaskFront=C.stencilWriteMaskFront),y.dss.stencilFuncBack===C.stencilFuncBack&&y.dss.stencilRefBack===C.stencilRefBack&&y.dss.stencilReadMaskBack===C.stencilReadMaskBack||(m.stencilFuncSeparate(m.BACK,Os[C.stencilFuncBack],C.stencilRefBack,C.stencilReadMaskBack),y.dss.stencilFuncBack=C.stencilFuncBack,y.dss.stencilRefBack=C.stencilRefBack,y.dss.stencilReadMaskBack=C.stencilReadMaskBack),y.dss.stencilFailOpBack===C.stencilFailOpBack&&y.dss.stencilZFailOpBack===C.stencilZFailOpBack&&y.dss.stencilPassOpBack===C.stencilPassOpBack||(m.stencilOpSeparate(m.BACK,Fs[C.stencilFailOpBack],Fs[C.stencilZFailOpBack],Fs[C.stencilPassOpBack]),y.dss.stencilFailOpBack=C.stencilFailOpBack,y.dss.stencilZFailOpBack=C.stencilZFailOpBack,y.dss.stencilPassOpBack=C.stencilPassOpBack),y.dss.stencilWriteMaskBack!==C.stencilWriteMaskBack&&(m.stencilMaskSeparate(m.BACK,C.stencilWriteMaskBack),y.dss.stencilWriteMaskBack=C.stencilWriteMaskBack));var x=e.bs;if(x){y.bs.isA2C!==x.isA2C&&(x.isA2C?m.enable(m.SAMPLE_ALPHA_TO_COVERAGE):m.disable(m.SAMPLE_ALPHA_TO_COVERAGE),y.bs.isA2C=x.isA2C),y.bs.blendColor.x===x.blendColor.x&&y.bs.blendColor.y===x.blendColor.y&&y.bs.blendColor.z===x.blendColor.z&&y.bs.blendColor.w===x.blendColor.w||(m.blendColor(x.blendColor.x,x.blendColor.y,x.blendColor.z,x.blendColor.w),y.bs.blendColor.x=x.blendColor.x,y.bs.blendColor.y=x.blendColor.y,y.bs.blendColor.z=x.blendColor.z,y.bs.blendColor.w=x.blendColor.w);var T=x.targets[0],w=y.bs.targets[0];w.blend!==T.blend&&(T.blend?m.enable(m.BLEND):m.disable(m.BLEND),w.blend=T.blend),w.blendEq===T.blendEq&&w.blendAlphaEq===T.blendAlphaEq||(m.blendEquationSeparate(Ls[T.blendEq],Ls[T.blendAlphaEq]),w.blendEq=T.blendEq,w.blendAlphaEq=T.blendAlphaEq),w.blendSrc===T.blendSrc&&w.blendDst===T.blendDst&&w.blendSrcAlpha===T.blendSrcAlpha&&w.blendDstAlpha===T.blendDstAlpha||(m.blendFuncSeparate(Vs[T.blendSrc],Vs[T.blendDst],Vs[T.blendSrcAlpha],Vs[T.blendDstAlpha]),w.blendSrc=T.blendSrc,w.blendDst=T.blendDst,w.blendSrcAlpha=T.blendSrcAlpha,w.blendDstAlpha=T.blendDstAlpha),w.blendColorMask!==T.blendColorMask&&(m.colorMask((T.blendColorMask&D.R)!==D.NONE,(T.blendColorMask&D.G)!==D.NONE,(T.blendColorMask&D.B)!==D.NONE,(T.blendColorMask&D.A)!==D.NONE),w.blendColorMask=T.blendColorMask)}}if(e&&e.gpuPipelineLayout&&g){for(var E=g.glBlocks.length,B=e.gpuPipelineLayout.dynamicOffsetIndices,M=0;M<E;M++){var P=g.glBlocks[M],R=r[P.set],I=R&&R.descriptorIndices[P.binding],O=I>=0&&R.gpuDescriptors[I],F=null,L=0;if(O&&O.gpuBuffer){var V=O.gpuBuffer,z=B[P.set],U=z&&z[P.binding];U>=0&&(L=n[U]),"vf32"in V?F=V.vf32:(L+=V.offset,F=V.gpuBuffer.vf32),L>>=2}if(F)for(var H=P.glActiveUniforms.length,j=0;j<H;j++){var W=P.glActiveUniforms[j];switch(W.glType){case m.BOOL:case m.INT:for(var X=0;X<W.array.length;++X){var Y=W.begin+L+X;if(F[Y]!==W.array[X]){for(var q=X,J=Y;q<W.array.length;++q,++J)W.array[q]=F[J];m.uniform1iv(W.glLoc,W.array);break}}break;case m.BOOL_VEC2:case m.INT_VEC2:for(var K=0;K<W.array.length;++K){var Z=W.begin+L+K;if(F[Z]!==W.array[K]){for(var Q=K,$=Z;Q<W.array.length;++Q,++$)W.array[Q]=F[$];m.uniform2iv(W.glLoc,W.array);break}}break;case m.BOOL_VEC3:case m.INT_VEC3:for(var tt=0;tt<W.array.length;++tt){var et=W.begin+L+tt;if(F[et]!==W.array[tt]){for(var it=tt,rt=et;it<W.array.length;++it,++rt)W.array[it]=F[rt];m.uniform3iv(W.glLoc,W.array);break}}break;case m.BOOL_VEC4:case m.INT_VEC4:for(var nt=0;nt<W.array.length;++nt){var st=W.begin+L+nt;if(F[st]!==W.array[nt]){for(var at=nt,ot=st;at<W.array.length;++at,++ot)W.array[at]=F[ot];m.uniform4iv(W.glLoc,W.array);break}}break;case m.FLOAT:for(var lt=0;lt<W.array.length;++lt){var ht=W.begin+L+lt;if(F[ht]!==W.array[lt]){for(var ut=lt,ct=ht;ut<W.array.length;++ut,++ct)W.array[ut]=F[ct];m.uniform1fv(W.glLoc,W.array);break}}break;case m.FLOAT_VEC2:for(var _t=0;_t<W.array.length;++_t){var ft=W.begin+L+_t;if(F[ft]!==W.array[_t]){for(var pt=_t,dt=ft;pt<W.array.length;++pt,++dt)W.array[pt]=F[dt];m.uniform2fv(W.glLoc,W.array);break}}break;case m.FLOAT_VEC3:for(var mt=0;mt<W.array.length;++mt){var yt=W.begin+L+mt;if(F[yt]!==W.array[mt]){for(var gt=mt,vt=yt;gt<W.array.length;++gt,++vt)W.array[gt]=F[vt];m.uniform3fv(W.glLoc,W.array);break}}break;case m.FLOAT_VEC4:for(var bt=0;bt<W.array.length;++bt){var St=W.begin+L+bt;if(F[St]!==W.array[bt]){for(var At=bt,Ct=St;At<W.array.length;++At,++Ct)W.array[At]=F[Ct];m.uniform4fv(W.glLoc,W.array);break}}break;case m.FLOAT_MAT2:for(var xt=0;xt<W.array.length;++xt){var Tt=W.begin+L+xt;if(F[Tt]!==W.array[xt]){for(var wt=xt,Et=Tt;wt<W.array.length;++wt,++Et)W.array[wt]=F[Et];m.uniformMatrix2fv(W.glLoc,!1,W.array);break}}break;case m.FLOAT_MAT3:for(var Bt=0;Bt<W.array.length;++Bt){var Dt=W.begin+L+Bt;if(F[Dt]!==W.array[Bt]){for(var Mt=Bt,Pt=Dt;Mt<W.array.length;++Mt,++Pt)W.array[Mt]=F[Pt];m.uniformMatrix3fv(W.glLoc,!1,W.array);break}}break;case m.FLOAT_MAT4:for(var Rt=0;Rt<W.array.length;++Rt){var It=W.begin+L+Rt;if(F[It]!==W.array[Rt]){for(var Ot=Rt,Ft=It;Ot<W.array.length;++Ot,++Ft)W.array[Ot]=F[Ft];m.uniformMatrix4fv(W.glLoc,!1,W.array);break}}}}else Ie("Buffer binding '"+P.name+"' at set "+P.set+" binding "+P.binding+" is not bounded")}for(var Lt=g.glSamplerTextures.length,Vt=0;Vt<Lt;Vt++)for(var kt=g.glSamplerTextures[Vt],Nt=r[kt.set],Gt=Nt&&Nt.descriptorIndices[kt.binding],zt=Gt>=0&&Nt.gpuDescriptors[Gt],Ut=kt.units.length,Ht=0;Ht<Ut;Ht++){var jt=kt.units[Ht];if(zt&&zt.gpuSampler){if(zt.gpuTexture&&zt.gpuTexture.size>0){var Wt=zt.gpuTexture,Xt=y.glTexUnits[jt];Xt.glTexture!==Wt.glTexture&&(y.texUnit!==jt&&(m.activeTexture(m.TEXTURE0+jt),y.texUnit=jt),Wt.glTexture?m.bindTexture(Wt.glTarget,Wt.glTexture):m.bindTexture(Wt.glTarget,t.nullTex2D.gpuTexture.glTexture),Xt.glTexture=Wt.glTexture);var Yt=zt.gpuSampler;Wt.isPowerOf2?(f=Yt.glWrapS,p=Yt.glWrapT):(f=m.CLAMP_TO_EDGE,p=m.CLAMP_TO_EDGE),d=Wt.isPowerOf2?Wt.mipLevel<=1&&(Yt.glMinFilter===m.LINEAR_MIPMAP_NEAREST||Yt.glMinFilter===m.LINEAR_MIPMAP_LINEAR)?m.LINEAR:Yt.glMinFilter:Yt.glMinFilter===m.LINEAR||Yt.glMinFilter===m.LINEAR_MIPMAP_NEAREST||Yt.glMinFilter===m.LINEAR_MIPMAP_LINEAR?m.LINEAR:m.NEAREST,Wt.glWrapS!==f&&(y.texUnit!==jt&&(m.activeTexture(m.TEXTURE0+jt),y.texUnit=jt),m.texParameteri(Wt.glTarget,m.TEXTURE_WRAP_S,f),Wt.glWrapS=f),Wt.glWrapT!==p&&(y.texUnit!==jt&&(m.activeTexture(m.TEXTURE0+jt),y.texUnit=jt),m.texParameteri(Wt.glTarget,m.TEXTURE_WRAP_T,p),Wt.glWrapT=p),Wt.glMinFilter!==d&&(y.texUnit!==jt&&(m.activeTexture(m.TEXTURE0+jt),y.texUnit=jt),m.texParameteri(Wt.glTarget,m.TEXTURE_MIN_FILTER,d),Wt.glMinFilter=d),Wt.glMagFilter!==Yt.glMagFilter&&(y.texUnit!==jt&&(m.activeTexture(m.TEXTURE0+jt),y.texUnit=jt),m.texParameteri(Wt.glTarget,m.TEXTURE_MAG_FILTER,Yt.glMagFilter),Wt.glMagFilter=Yt.glMagFilter)}zt=Nt.gpuDescriptors[++Gt]}else Ie("Sampler binding '"+kt.name+"' at set "+kt.set+" binding "+kt.binding+" index "+Ht+" is not bounded")}}if(i&&g&&(v||Xs.gpuInputAssembler!==i)){Xs.gpuInputAssembler=i;var qt=t.ANGLE_instanced_arrays;if(t.useVAO){var Jt=t.OES_vertex_array_object,Kt=i.glVAOs.get(g.glProgram);if(!Kt){var Zt;Kt=Jt.createVertexArrayOES(),i.glVAOs.set(g.glProgram,Kt),Jt.bindVertexArrayOES(Kt),m.bindBuffer(m.ARRAY_BUFFER,null),m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,null),y.glArrayBuffer=null,y.glElementArrayBuffer=null;for(var Qt=g.glInputs.length,$t=0;$t<Qt;$t++){var te=g.glInputs[$t];Zt=null;for(var ee=i.glAttribs.length,ie=0;ie<ee;ie++){var re=i.glAttribs[ie];if(re.name===te.name){Zt=re;break}}if(Zt){y.glArrayBuffer!==Zt.glBuffer&&(m.bindBuffer(m.ARRAY_BUFFER,Zt.glBuffer),y.glArrayBuffer=Zt.glBuffer);for(var ne=0;ne<Zt.componentCount;++ne){var se=te.glLoc+ne,ae=Zt.offset+Zt.size*ne;m.enableVertexAttribArray(se),y.glCurrentAttribLocs[se]=!0,m.vertexAttribPointer(se,Zt.count,Zt.glType,Zt.isNormalized,Zt.stride,ae),qt&&qt.vertexAttribDivisorANGLE(se,Zt.isInstanced?1:0)}}}var oe=i.gpuIndexBuffer;oe&&m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,oe.glBuffer),Jt.bindVertexArrayOES(null),m.bindBuffer(m.ARRAY_BUFFER,null),m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,null),y.glArrayBuffer=null,y.glElementArrayBuffer=null}y.glVAO!==Kt&&(Jt.bindVertexArrayOES(Kt),y.glVAO=Kt)}else{for(var le=0;le<t.capabilities.maxVertexAttributes;++le)y.glCurrentAttribLocs[le]=!1;for(var he=g.glInputs.length,ue=0;ue<he;ue++){for(var ce=g.glInputs[ue],_e=null,fe=i.glAttribs.length,pe=0;pe<fe;pe++){var de=i.glAttribs[pe];if(de.name===ce.name){_e=de;break}}if(_e){y.glArrayBuffer!==_e.glBuffer&&(m.bindBuffer(m.ARRAY_BUFFER,_e.glBuffer),y.glArrayBuffer=_e.glBuffer);for(var me=0;me<_e.componentCount;++me){var ye=ce.glLoc+me,ge=_e.offset+_e.size*me;!y.glEnabledAttribLocs[ye]&&ye>=0&&(m.enableVertexAttribArray(ye),y.glEnabledAttribLocs[ye]=!0),y.glCurrentAttribLocs[ye]=!0,m.vertexAttribPointer(ye,_e.count,_e.glType,_e.isNormalized,_e.stride,ge),qt&&qt.vertexAttribDivisorANGLE(ye,_e.isInstanced?1:0)}}}var ve=i.gpuIndexBuffer;ve&&y.glElementArrayBuffer!==ve.glBuffer&&(m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,ve.glBuffer),y.glElementArrayBuffer=ve.glBuffer);for(var be=0;be<t.capabilities.maxVertexAttributes;++be)y.glEnabledAttribLocs[be]!==y.glCurrentAttribLocs[be]&&(m.disableVertexAttribArray(be),y.glEnabledAttribLocs[be]=!1)}}if(e&&e.dynamicStates.length)for(var Se=e.dynamicStates.length,Ae=0;Ae<Se;Ae++)switch(e.dynamicStates[Ae]){case N.VIEWPORT:s&&(y.viewport.left===s.left&&y.viewport.top===s.top&&y.viewport.width===s.width&&y.viewport.height===s.height||(m.viewport(s.left,s.top,s.width,s.height),y.viewport.left=s.left,y.viewport.top=s.top,y.viewport.width=s.width,y.viewport.height=s.height));break;case N.SCISSOR:a&&(y.scissorRect.x===a.x&&y.scissorRect.y===a.y&&y.scissorRect.width===a.width&&y.scissorRect.height===a.height||(m.scissor(a.x,a.y,a.width,a.height),y.scissorRect.x=a.x,y.scissorRect.y=a.y,y.scissorRect.width=a.width,y.scissorRect.height=a.height));break;case N.LINE_WIDTH:o&&y.rs.lineWidth!==o&&(m.lineWidth(o),y.rs.lineWidth=o);break;case N.DEPTH_BIAS:l&&(y.rs.depthBias===l.constantFactor&&y.rs.depthBiasSlop===l.slopeFactor||(m.polygonOffset(l.constantFactor,l.slopeFactor),y.rs.depthBias=l.constantFactor,y.rs.depthBiasSlop=l.slopeFactor));break;case N.BLEND_CONSTANTS:y.bs.blendColor.x===h[0]&&y.bs.blendColor.y===h[1]&&y.bs.blendColor.z===h[2]&&y.bs.blendColor.w===h[3]||(m.blendColor(h[0],h[1],h[2],h[3]),y.bs.blendColor.x=h[0],y.bs.blendColor.y=h[1],y.bs.blendColor.z=h[2],y.bs.blendColor.w=h[3]);break;case N.STENCIL_WRITE_MASK:if(c)switch(c.face){case G.FRONT:y.dss.stencilWriteMaskFront!==c.writeMask&&(m.stencilMaskSeparate(m.FRONT,c.writeMask),y.dss.stencilWriteMaskFront=c.writeMask);break;case G.BACK:y.dss.stencilWriteMaskBack!==c.writeMask&&(m.stencilMaskSeparate(m.BACK,c.writeMask),y.dss.stencilWriteMaskBack=c.writeMask);break;case G.ALL:y.dss.stencilWriteMaskFront===c.writeMask&&y.dss.stencilWriteMaskBack===c.writeMask||(m.stencilMask(c.writeMask),y.dss.stencilWriteMaskFront=c.writeMask,y.dss.stencilWriteMaskBack=c.writeMask)}break;case N.STENCIL_COMPARE_MASK:if(_)switch(_.face){case G.FRONT:y.dss.stencilRefFront===_.reference&&y.dss.stencilReadMaskFront===_.compareMask||(m.stencilFuncSeparate(m.FRONT,Os[y.dss.stencilFuncFront],_.reference,_.compareMask),y.dss.stencilRefFront=_.reference,y.dss.stencilReadMaskFront=_.compareMask);break;case G.BACK:y.dss.stencilRefBack===_.reference&&y.dss.stencilReadMaskBack===_.compareMask||(m.stencilFuncSeparate(m.BACK,Os[y.dss.stencilFuncBack],_.reference,_.compareMask),y.dss.stencilRefBack=_.reference,y.dss.stencilReadMaskBack=_.compareMask);break;case G.ALL:y.dss.stencilRefFront===_.reference&&y.dss.stencilReadMaskFront===_.compareMask&&y.dss.stencilRefBack===_.reference&&y.dss.stencilReadMaskBack===_.compareMask||(m.stencilFunc(Os[y.dss.stencilFuncBack],_.reference,_.compareMask),y.dss.stencilRefFront=_.reference,y.dss.stencilReadMaskFront=_.compareMask,y.dss.stencilRefBack=_.reference,y.dss.stencilReadMaskBack=_.compareMask)}}}function Js(t,e){var i=t.gl,r=t.ANGLE_instanced_arrays,n=Xs.gpuInputAssembler,s=Xs.glPrimitive;if(n)if(n.gpuIndirectBuffer)for(var a=n.gpuIndirectBuffer.indirects.length,o=0;o<a;o++){var l=n.gpuIndirectBuffer.indirects[o],h=n.gpuIndexBuffer;if(l.instanceCount&&r)if(h){if(l.indexCount>0){var u=l.firstIndex*h.stride;r.drawElementsInstancedANGLE(s,l.indexCount,n.glIndexType,u,l.instanceCount)}}else l.vertexCount>0&&r.drawArraysInstancedANGLE(s,l.firstVertex,l.vertexCount,l.instanceCount);else if(h){if(l.indexCount>0){var c=l.firstIndex*h.stride;i.drawElements(s,l.indexCount,n.glIndexType,c)}}else l.vertexCount>0&&i.drawArrays(s,l.firstVertex,l.vertexCount)}else{var _=n.gpuIndexBuffer;if(e.instanceCount&&r)if(_){if(e.indexCount>0){var f=e.firstIndex*_.stride;r.drawElementsInstancedANGLE(s,e.indexCount,n.glIndexType,f,e.instanceCount)}}else e.vertexCount>0&&r.drawArraysInstancedANGLE(s,e.firstVertex,e.vertexCount,e.instanceCount);else if(_){if(e.indexCount>0){var p=e.firstIndex*_.stride;i.drawElements(s,e.indexCount,n.glIndexType,p)}}else e.vertexCount>0&&i.drawArrays(s,e.firstVertex,e.vertexCount)}}var Ks=new Array(Is.COUNT);function Zs(t,e){Ks.fill(0);for(var i=0;i<e.cmds.length;++i){var r=e.cmds.array[i],n=Ks[r]++;switch(r){case Is.BEGIN_RENDER_PASS:var s=e.beginRenderPassCmds.array[n];Ys(t,s.gpuRenderPass,s.gpuFramebuffer,s.renderArea,s.clearColors,s.clearDepth,s.clearStencil);break;case Is.BIND_STATES:var a=e.bindStatesCmds.array[n];qs(t,a.gpuPipelineState,a.gpuInputAssembler,a.gpuDescriptorSets,a.dynamicOffsets,a.viewport,a.scissor,a.lineWidth,a.depthBias,a.blendConstants,a.depthBounds,a.stencilWriteMask,a.stencilCompareMask);break;case Is.DRAW:Js(t,e.drawCmds.array[n].drawInfo);break;case Is.UPDATE_BUFFER:var o=e.updateBufferCmds.array[n];Ws(t,o.gpuBuffer,o.buffer,o.offset,o.size);break;case Is.COPY_BUFFER_TO_TEXTURE:var l=e.copyBufferToTextureCmds.array[n];Qs(t,l.buffers,l.gpuTexture,l.regions)}}}function Qs(t,e,i,r){var n=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(n.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var a=0,o=1,l=1,h=0,u=Ht[i.format].isCompressed;switch(i.glTarget){case n.TEXTURE_2D:for(var c=0;c<r.length;c++){var _=r[c];o=_.texExtent.width,l=_.texExtent.height;var f=e[a++];u?i.glInternalFmt===Cs.COMPRESSED_RGB_ETC1_WEBGL||t.noCompressedTexSubImage2D?n.compressedTexImage2D(n.TEXTURE_2D,_.texSubres.mipLevel,i.glInternalFmt,o,l,0,f):n.compressedTexSubImage2D(n.TEXTURE_2D,_.texSubres.mipLevel,_.texOffset.x,_.texOffset.y,o,l,i.glFormat,f):n.texSubImage2D(n.TEXTURE_2D,_.texSubres.mipLevel,_.texOffset.x,_.texOffset.y,o,l,i.glFormat,i.glType,f)}break;case n.TEXTURE_CUBE_MAP:for(var p=0;p<r.length;p++){var d=r[p],m=d.texSubres.baseArrayLayer+d.texSubres.layerCount;for(h=d.texSubres.baseArrayLayer;h<m;++h){o=d.texExtent.width,l=d.texExtent.height;var y=e[a++];u?i.glInternalFmt===Cs.COMPRESSED_RGB_ETC1_WEBGL||t.noCompressedTexSubImage2D?n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+h,d.texSubres.mipLevel,i.glInternalFmt,o,l,0,y):n.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+h,d.texSubres.mipLevel,d.texOffset.x,d.texOffset.y,o,l,i.glFormat,y):n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+h,d.texSubres.mipLevel,d.texOffset.x,d.texOffset.y,o,l,i.glFormat,i.glType,y)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&S.GEN_MIPMAP&&n.generateMipmap(i.glTarget)}var $s,ta=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuBuffer=null,e._gpuBufferView=null,e._uniformBuffer=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){if("buffer"in t){this._isBufferView=!0;var e=t.buffer;this._usage=e.usage,this._memUsage=e.memUsage,this._size=this._stride=t.range,this._count=1,this._flags=e.flags,this._gpuBufferView={gpuBuffer:e.gpuBuffer,offset:t.offset,range:t.range}}else this._usage=t.usage,this._memUsage=t.memUsage,this._size=t.size,this._stride=Math.max(t.stride||this._size,1),this._count=this._size/this._stride,this._flags=t.flags,this._usage&d.INDIRECT&&(this._indirectBuffer=new lt),this._usage&d.UNIFORM&&this._size>0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,vf32:null,indirects:[],glTarget:0,glBuffer:null},t.usage&d.INDIRECT&&(this._gpuBuffer.indirects=this._indirectBuffer.drawInfos),this._usage&d.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),function(t,e){var i=t.gl,r=t.stateCache,n=e.memUsage&g.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;if(e.usage&d.VERTEX){e.glTarget=i.ARRAY_BUFFER;var s=i.createBuffer();s&&(e.glBuffer=s,e.size>0&&(t.useVAO&&r.glVAO&&(t.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=Xs.gpuInputAssembler=null),t.stateCache.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer),i.bufferData(i.ARRAY_BUFFER,e.size,n),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null))}else if(e.usage&d.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.useVAO&&r.glVAO&&(t.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=Xs.gpuInputAssembler=null),t.stateCache.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,n),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null))}else e.usage&d.UNIFORM?(e.glTarget=i.NONE,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(e.usage&d.INDIRECT||e.usage&d.TRANSFER_DST||e.usage&d.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize+=this._size;return!0},i.destroy=function(){var t,e;this._gpuBuffer&&(t=this._device,(e=this._gpuBuffer).glBuffer&&(t.gl.deleteBuffer(e.glBuffer),e.glBuffer=null),this._device.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},i.resize=function(t){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var e,i,r,n,s,a=this._size;a!==t&&(this._size=t,this._count=this._size/this._stride,this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(t)),this._gpuBuffer&&(this._uniformBuffer&&(this._gpuBuffer.buffer=this._uniformBuffer),this._gpuBuffer.size=t,t>0&&(e=this._device,i=this._gpuBuffer,r=e.gl,n=e.stateCache,s=i.memUsage&g.HOST?r.DYNAMIC_DRAW:r.STATIC_DRAW,i.usage&d.VERTEX?(e.useVAO&&n.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=Xs.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==i.glBuffer&&r.bindBuffer(r.ARRAY_BUFFER,i.glBuffer),i.buffer?r.bufferData(r.ARRAY_BUFFER,i.buffer,s):r.bufferData(r.ARRAY_BUFFER,i.size,s),r.bindBuffer(r.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null):i.usage&d.INDEX?(e.useVAO&&n.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=Xs.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==i.glBuffer&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,i.glBuffer),i.buffer?r.bufferData(r.ELEMENT_ARRAY_BUFFER,i.buffer,s):r.bufferData(r.ELEMENT_ARRAY_BUFFER,i.size,s),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):i.usage&d.UNIFORM?i.buffer&&(i.vf32=new Float32Array(i.buffer.buffer)):(i.usage&d.INDIRECT||i.usage&d.TRANSFER_DST||i.usage&d.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),i.glTarget=r.NONE),this._device.memoryStatus.bufferSize-=a,this._device.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?console.warn("cannot update through buffer views!"):(i=void 0!==e?e:this._usage&d.INDIRECT?0:t.byteLength,Ws(this._device,this._gpuBuffer,t,0,i))},Pe(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(s),ea=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new r(e);for(var i=0;i<e;++i)this._frees[i]=new t;this._freeIdx=e-1}var e=t.prototype;return e.alloc=function(t){if(this._freeIdx<0){var e=2*this._frees.length,i=this._frees;this._frees=new Array(e);for(var r=e-i.length,n=0;n<r;++n)this._frees[n]=new t;for(var s=r,a=0;s<e;++s,++a)this._frees[s]=i[a];this._freeIdx+=r}var o=this._frees[this._freeIdx];return this._frees[this._freeIdx--]=null,++o.refCount,o},e.free=function(t){0==--t.refCount&&this._freeCmds.push(t)},e.freeCmds=function(t){for(var e=0;e<t.length;++e)0==--t.array[e].refCount&&this._freeCmds.push(t.array[e])},e.release=function(){for(var t=0;t<this._freeCmds.length;++t){var e=this._freeCmds.array[t];e.clear(),this._frees[++this._freeIdx]=e}this._freeCmds.clear()},t}(),ia=function(){function t(){this.beginRenderPassCmdPool=void 0,this.bindStatesCmdPool=void 0,this.drawCmdPool=void 0,this.updateBufferCmdPool=void 0,this.copyBufferToTextureCmdPool=void 0,this.beginRenderPassCmdPool=new ea(Ns,1),this.bindStatesCmdPool=new ea(Gs,1),this.drawCmdPool=new ea(zs,1),this.updateBufferCmdPool=new ea(Us,1),this.copyBufferToTextureCmdPool=new ea(Hs,1)}var e=t.prototype;return e.clearCmds=function(t){t.beginRenderPassCmds.length&&(this.beginRenderPassCmdPool.freeCmds(t.beginRenderPassCmds),t.beginRenderPassCmds.clear()),t.bindStatesCmds.length&&(this.bindStatesCmdPool.freeCmds(t.bindStatesCmds),t.bindStatesCmds.clear()),t.drawCmds.length&&(this.drawCmdPool.freeCmds(t.drawCmds),t.drawCmds.clear()),t.updateBufferCmds.length&&(this.updateBufferCmdPool.freeCmds(t.updateBufferCmds),t.updateBufferCmds.clear()),t.copyBufferToTextureCmds.length&&(this.copyBufferToTextureCmdPool.freeCmds(t.copyBufferToTextureCmds),t.copyBufferToTextureCmds.clear()),t.cmds.clear()},e.releaseCmds=function(){this.beginRenderPassCmdPool.release(),this.bindStatesCmdPool.release(),this.drawCmdPool.release(),this.updateBufferCmdPool.release(),this.copyBufferToTextureCmdPool.release()},t}(),ra=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).cmdPackage=new js,e._webGLAllocator=null,e._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUInputAssembler=null,e._curGPUDescriptorSets=[],e._curDynamicOffsets=[],e._curViewport=null,e._curScissor=null,e._curLineWidth=null,e._curDepthBias=null,e._curBlendConstants=[],e._curDepthBounds=null,e._curStencilWriteMask=null,e._curStencilCompareMask=null,e._isStateInvalied=!1,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue,this._webGLAllocator=this._device.cmdAllocator;for(var e=this._device.bindingMappingInfo.bufferOffsets.length,i=0;i<e;i++)this._curGPUDescriptorSets.push(null),this._curDynamicOffsets.push([]);return!0},i.destroy=function(){this._webGLAllocator&&(this._webGLAllocator.clearCmds(this.cmdPackage),this._webGLAllocator=null)},i.begin=function(){this._webGLAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0;for(var t=0;t<this._curDynamicOffsets.length;t++)this._curDynamicOffsets[t].length=0;this._curViewport=null,this._curScissor=null,this._curLineWidth=null,this._curDepthBias=null,this._curBlendConstants.length=0,this._curDepthBounds=null,this._curStencilWriteMask=null,this._curStencilCompareMask=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0},i.end=function(){this._isStateInvalied&&this.bindStates(),this._isInRenderPass=!1},i.beginRenderPass=function(t,e,i,r,n,s){var a=this._webGLAllocator.beginRenderPassCmdPool.alloc(Ns);a.gpuRenderPass=t.gpuRenderPass,a.gpuFramebuffer=e.gpuFramebuffer,a.renderArea=i,a.clearColors.length=r.length;for(var o=0;o<r.length;++o)a.clearColors[o]=r[o];a.clearDepth=n,a.clearStencil=s,this.cmdPackage.beginRenderPassCmds.push(a),this.cmdPackage.cmds.push(Is.BEGIN_RENDER_PASS),this._isInRenderPass=!0},i.endRenderPass=function(){this._isInRenderPass=!1},i.bindPipelineState=function(t){var e=t.gpuPipelineState;e!==this._curGPUPipelineState&&(this._curGPUPipelineState=e,this._isStateInvalied=!0)},i.bindDescriptorSet=function(t,e,i){var r=e.gpuDescriptorSet;if(r!==this._curGPUDescriptorSets[t]&&(this._curGPUDescriptorSets[t]=r,this._isStateInvalied=!0),i){for(var n=this._curDynamicOffsets[t],s=0;s<i.length;s++)n[s]=i[s];n.length=i.length,this._isStateInvalied=!0}},i.bindInputAssembler=function(t){var e=t.gpuInputAssembler;this._curGPUInputAssembler=e,this._isStateInvalied=!0},i.setViewport=function(t){this._curViewport?this._curViewport.left===t.left&&this._curViewport.top===t.top&&this._curViewport.width===t.width&&this._curViewport.height===t.height&&this._curViewport.minDepth===t.minDepth&&this._curViewport.maxDepth===t.maxDepth||(this._curViewport.left=t.left,this._curViewport.top=t.top,this._curViewport.width=t.width,this._curViewport.height=t.height,this._curViewport.minDepth=t.minDepth,this._curViewport.maxDepth=t.maxDepth,this._isStateInvalied=!0):this._curViewport=new et(t.left,t.top,t.width,t.height,t.minDepth,t.maxDepth)},i.setScissor=function(t){this._curScissor?this._curScissor.x===t.x&&this._curScissor.y===t.y&&this._curScissor.width===t.width&&this._curScissor.height===t.height||(this._curScissor.x=t.x,this._curScissor.y=t.y,this._curScissor.width=t.width,this._curScissor.height=t.height,this._isStateInvalied=!0):this._curScissor=new q(t.x,t.y,t.width,t.height)},i.setLineWidth=function(t){this._curLineWidth!==t&&(this._curLineWidth=t,this._isStateInvalied=!0)},i.setDepthBias=function(t,e,i){this._curDepthBias?this._curDepthBias.constantFactor===t&&this._curDepthBias.clamp===e&&this._curDepthBias.slopeFactor===i||(this._curDepthBias.constantFactor=t,this._curDepthBias.clamp=e,this._curDepthBias.slopeFactor=i,this._isStateInvalied=!0):(this._curDepthBias={constantFactor:t,clamp:e,slopeFactor:i},this._isStateInvalied=!0)},i.setBlendConstants=function(t){4!==t.length||this._curBlendConstants[0]===t[0]&&this._curBlendConstants[1]===t[1]&&this._curBlendConstants[2]===t[2]&&this._curBlendConstants[3]===t[3]||(this._curBlendConstants.length=0,Array.prototype.push.apply(this._curBlendConstants,t),this._isStateInvalied=!0)},i.setDepthBound=function(t,e){this._curDepthBounds&&this._curDepthBounds.minBounds===t&&this._curDepthBounds.maxBounds===e||(this._curDepthBounds={minBounds:t,maxBounds:e},this._isStateInvalied=!0)},i.setStencilWriteMask=function(t,e){this._curStencilWriteMask?this._curStencilWriteMask.face===t&&this._curStencilWriteMask.writeMask===e||(this._curStencilWriteMask.face=t,this._curStencilWriteMask.writeMask=e,this._isStateInvalied=!0):(this._curStencilWriteMask={face:t,writeMask:e},this._isStateInvalied=!0)},i.setStencilCompareMask=function(t,e,i){this._curStencilCompareMask?this._curStencilCompareMask.face===t&&this._curStencilCompareMask.reference===e&&this._curStencilCompareMask.compareMask===i||(this._curStencilCompareMask.face=t,this._curStencilCompareMask.reference=e,this._curStencilCompareMask.compareMask=i,this._isStateInvalied=!0):(this._curStencilCompareMask={face:t,reference:e,compareMask:i},this._isStateInvalied=!0)},i.draw=function(t){if(this._type===H.PRIMARY&&this._isInRenderPass||this._type===H.SECONDARY){this._isStateInvalied&&this.bindStates();var e=this._webGLAllocator.drawCmdPool.alloc(zs);e.drawInfo.vertexCount=t.vertexCount,e.drawInfo.firstVertex=t.firstVertex,e.drawInfo.indexCount=t.indexCount,e.drawInfo.firstIndex=t.firstIndex,e.drawInfo.vertexOffset=t.vertexOffset,e.drawInfo.instanceCount=t.instanceCount,e.drawInfo.firstInstance=t.firstInstance,this.cmdPackage.drawCmds.push(e),this.cmdPackage.cmds.push(Is.DRAW),++this._numDrawCalls,this._numInstances+=t.instanceCount;var i=t.indexCount||t.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=i/3*Math.max(t.instanceCount,1);break;case 5:case 6:this._numTris+=(i-2)*Math.max(t.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._type===H.PRIMARY&&!this._isInRenderPass||this._type===H.SECONDARY){var r=t.gpuBuffer;if(r){var n,s=this._webGLAllocator.updateBufferCmdPool.alloc(Us),a=0;t.usage&d.INDIRECT||(a=void 0!==i?i:e.byteLength),n=e,s.gpuBuffer=r,s.buffer=n,s.offset=0,s.size=a,this.cmdPackage.updateBufferCmds.push(s),this.cmdPackage.cmds.push(Is.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},i.copyBuffersToTexture=function(t,e,i){if(this._type===H.PRIMARY&&!this._isInRenderPass||this._type===H.SECONDARY){var r=e.gpuTexture;if(r){var n=this._webGLAllocator.copyBufferToTextureCmdPool.alloc(Hs);n&&(n.gpuTexture=r,n.regions=i,n.buffers=t,this.cmdPackage.copyBufferToTextureCmds.push(n),this.cmdPackage.cmds.push(Is.COPY_BUFFER_TO_TEXTURE))}}else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.")},i.execute=function(t,e){for(var i=0;i<e;++i){for(var r=t[i],n=0;n<r.cmdPackage.beginRenderPassCmds.length;++n){var s=r.cmdPackage.beginRenderPassCmds.array[n];++s.refCount,this.cmdPackage.beginRenderPassCmds.push(s)}for(var a=0;a<r.cmdPackage.bindStatesCmds.length;++a){var o=r.cmdPackage.bindStatesCmds.array[a];++o.refCount,this.cmdPackage.bindStatesCmds.push(o)}for(var l=0;l<r.cmdPackage.drawCmds.length;++l){var h=r.cmdPackage.drawCmds.array[l];++h.refCount,this.cmdPackage.drawCmds.push(h)}for(var u=0;u<r.cmdPackage.updateBufferCmds.length;++u){var c=r.cmdPackage.updateBufferCmds.array[u];++c.refCount,this.cmdPackage.updateBufferCmds.push(c)}for(var _=0;_<r.cmdPackage.copyBufferToTextureCmds.length;++_){var f=r.cmdPackage.copyBufferToTextureCmds.array[_];++f.refCount,this.cmdPackage.copyBufferToTextureCmds.push(f)}this.cmdPackage.cmds.concat(r.cmdPackage.cmds.array),this._numDrawCalls+=r._numDrawCalls,this._numInstances+=r._numInstances,this._numTris+=r._numTris}},i.pipelineBarrier=function(){},i.bindStates=function(){var t=this._webGLAllocator.bindStatesCmdPool.alloc(Gs);if(t){t.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(t.gpuDescriptorSets,this._curGPUDescriptorSets);for(var e=0;e<this._curDynamicOffsets.length;e++)Array.prototype.push.apply(t.dynamicOffsets,this._curDynamicOffsets[e]);t.gpuInputAssembler=this._curGPUInputAssembler,t.viewport=this._curViewport,t.scissor=this._curScissor,t.lineWidth=this._curLineWidth,t.depthBias=this._curDepthBias,Array.prototype.push.apply(t.blendConstants,this._curBlendConstants),t.depthBounds=this._curDepthBounds,t.stencilWriteMask=this._curStencilWriteMask,t.stencilCompareMask=this._curStencilCompareMask,this.cmdPackage.bindStatesCmds.push(t),this.cmdPackage.cmds.push(Is.BIND_STATES),this._isStateInvalied=!1}},Pe(e,[{key:"webGLDevice",get:function(){return this._device}}]),e}(a),na=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuFramebuffer=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._renderPass=t.renderPass,this._colorTextures=t.colorTextures||[],this._depthStencilTexture=t.depthStencilTexture||null,0!==t.depthStencilMipmapLevel&&console.warn("The mipmap level of th texture image to be attached of depth stencil attachment should be 0. Convert to 0.");for(var e=0;e<t.colorMipmapLevels.length;++e)0!==t.colorMipmapLevels[e]&&console.warn("The mipmap level of th texture image to be attached of color attachment "+e+" should be 0. Convert to 0.");for(var i=[],r=0;r<t.colorTextures.length;++r){var n=t.colorTextures[r];n&&i.push(n.gpuTexture)}var s=null;return t.depthStencilTexture&&(s=t.depthStencilTexture.gpuTexture),this._gpuFramebuffer={gpuRenderPass:t.renderPass.gpuRenderPass,gpuColorTextures:i,gpuDepthStencilTexture:s,glFramebuffer:null},function(t,e){if(e.gpuColorTextures.length||e.gpuDepthStencilTexture){var i=t.gl,r=[],n=i.createFramebuffer();if(n){e.glFramebuffer=n,t.stateCache.glFramebuffer!==e.glFramebuffer&&i.bindFramebuffer(i.FRAMEBUFFER,e.glFramebuffer);for(var s=0;s<e.gpuColorTextures.length;++s){var a=e.gpuColorTextures[s];a&&(a.glTexture?i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+s,a.glTarget,a.glTexture,0):i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+s,i.RENDERBUFFER,a.glRenderbuffer),r.push(i.COLOR_ATTACHMENT0+s))}var o=e.gpuDepthStencilTexture;if(o){var l=Ht[o.format].hasStencil?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;o.glTexture?i.framebufferTexture2D(i.FRAMEBUFFER,l,o.glTarget,o.glTexture,0):i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,o.glRenderbuffer)}t.WEBGL_draw_buffers&&t.WEBGL_draw_buffers.drawBuffersWEBGL(r);var h=i.checkFramebufferStatus(i.FRAMEBUFFER);if(h!==i.FRAMEBUFFER_COMPLETE)switch(h){case i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case i.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}t.stateCache.glFramebuffer!==e.glFramebuffer&&i.bindFramebuffer(i.FRAMEBUFFER,t.stateCache.glFramebuffer)}}}(this._device,this._gpuFramebuffer),!0},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=this._device,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),e.glFramebuffer=null),this._gpuFramebuffer=null)},Pe(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),e}(te),sa=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuInputAssembler=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){if(0===t.vertexBuffers.length)return console.error("InputAssemblerInfo.vertexBuffers is null."),!1;if(this._attributes=t.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=t.vertexBuffers,t.indexBuffer)this._indexBuffer=t.indexBuffer,this._indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._firstIndex=0;else{var e=this._vertexBuffers[0];this._vertexCount=e.size/e.stride,this._firstVertex=0,this._vertexOffset=0}this._instanceCount=0,this._firstInstance=0,this._indirectBuffer=t.indirectBuffer||null;for(var i=new Array(t.vertexBuffers.length),r=0;r<t.vertexBuffers.length;++r){var n=t.vertexBuffers[r];n.gpuBuffer&&(i[r]=n.gpuBuffer)}var s=null,a=0;if(t.indexBuffer&&(s=t.indexBuffer.gpuBuffer))switch(s.stride){case 1:a=5121;break;case 2:a=5123;break;case 4:a=5125;break;default:console.error("Error index buffer stride.")}var o=null;return t.indirectBuffer&&(o=t.indirectBuffer.gpuBuffer),this._gpuInputAssembler={attributes:t.attributes,gpuVertexBuffers:i,gpuIndexBuffer:s,gpuIndirectBuffer:o,glAttribs:[],glIndexType:a,glVAOs:new Map},function(t,e){var i=t.gl;e.glAttribs=new Array(e.attributes.length);for(var r=[0,0,0,0,0,0,0,0],n=0;n<e.attributes.length;++n){var s=e.attributes[n],a=void 0!==s.stream?s.stream:0,o=e.gpuVertexBuffers[a],l=Ts(s.format,i),h=Ht[s.format].size;e.glAttribs[n]={name:s.name,glBuffer:o.glBuffer,glType:l,size:h,count:Ht[s.format].count,stride:o.stride,componentCount:Rs(l,i),isNormalized:void 0!==s.isNormalized&&s.isNormalized,isInstanced:void 0!==s.isInstanced&&s.isInstanced,offset:r[a]},r[a]+=h}}(this._device,this._gpuInputAssembler),!0},i.destroy=function(){var t=this._device;this._gpuInputAssembler&&t.useVAO&&function(t,e){for(var i=e.glVAOs.values(),r=i.next();!r.done;)t.OES_vertex_array_object.deleteVertexArrayOES(r.value),r=i.next();e.glVAOs.clear()}(t,this._gpuInputAssembler),this._gpuInputAssembler=null},Pe(e,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),e}(ee),aa=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuDescriptorSetLayout=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._bindings,t.bindings);for(var e=0,i=-1,r=[],n=0;n<this._bindings.length;n++){var s=this._bindings[n];r.push(e),e+=s.count,s.binding>i&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o<this._bindings.length;o++){var l=this._bindings[o];this._bindingIndices[l.binding]=o,a[l.binding]=r[o]}for(var h=[],u=0;u<this._bindings.length;u++){var c=this._bindings[u];if(c.descriptorType&Xt)for(var _=0;_<c.count;_++)h.push(c.binding)}return this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:h,descriptorIndices:a,descriptorCount:e},!0},i.destroy=function(){this._bindings.length=0},Pe(e,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),e}(ie),oa=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuPipelineLayout=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._setLayouts,t.setLayouts);for(var e=[],i=[],r=0,n=0;n<this._setLayouts.length;n++){for(var s=this._setLayouts[n],a=s.gpuDescriptorSetLayout.dynamicBindings,o=Array(s.bindingIndices.length).fill(-1),l=0;l<a.length;l++){var h=a[l];o[h]<0&&(o[h]=r+l)}i.push(s.gpuDescriptorSetLayout),e.push(o),r+=a.length}return this._gpuPipelineLayout={gpuSetLayouts:i,dynamicOffsetIndices:e,dynamicOffsetCount:r},!0},i.destroy=function(){this._setLayouts.length=0},Pe(e,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),e}(re),la=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],ha=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuPipelineState=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._primitive=t.primitive,this._shader=t.shader,this._pipelineLayout=t.pipelineLayout;var e=this._bs;if(t.blendState){var i=t.blendState,r=i.targets;r&&r.forEach((function(t,i){e.setTarget(i,t)})),void 0!==i.isA2C&&(e.isA2C=i.isA2C),void 0!==i.isIndepend&&(e.isIndepend=i.isIndepend),void 0!==i.blendColor&&(e.blendColor=i.blendColor)}Object.assign(this._rs,t.rasterizerState),Object.assign(this._dss,t.depthStencilState),this._is=t.inputState,this._renderPass=t.renderPass,this._dynamicStates=t.dynamicStates;for(var n=[],s=0;s<31;s++)this._dynamicStates&1<<s&&n.push(1<<s);return this._gpuPipelineState={glPrimitive:la[t.primitive],gpuShader:t.shader.gpuShader,gpuPipelineLayout:t.pipelineLayout.gpuPipelineLayout,rs:t.rasterizerState,dss:t.depthStencilState,bs:t.blendState,gpuRenderPass:t.renderPass.gpuRenderPass,dynamicStates:n},!0},i.destroy=function(){this._gpuPipelineState=null},Pe(e,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),e}(he),ua=[],ca=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.beginRenderPass=function(t,e,i,r,n,s){Ys(this._device,t.gpuRenderPass,e.gpuFramebuffer,i,r,n,s),this._isInRenderPass=!0},i.draw=function(t){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates(),Js(this._device,t),++this._numDrawCalls,this._numInstances+=t.instanceCount;var e=t.indexCount||t.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=e/3*Math.max(t.instanceCount,1);break;case 5:case 6:this._numTris+=(e-2)*Math.max(t.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._isInRenderPass)console.error("Command 'updateBuffer' must be recorded outside a render pass.");else{var r,n=t.gpuBuffer;n&&(r=void 0!==i?i:t.usage&d.INDIRECT?0:e.byteLength,Ws(this._device,n,e,0,r))}},i.copyBuffersToTexture=function(t,e,i){if(this._isInRenderPass)console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.");else{var r=e.gpuTexture;r&&Qs(this._device,t,r,i)}},i.execute=function(t,e){for(var i=0;i<e;++i){var r=t[i];Zs(this._device,r.cmdPackage),this._numDrawCalls+=r._numDrawCalls,this._numInstances+=r._numInstances,this._numTris+=r._numTris}},i.bindStates=function(){ua.length=0;for(var t=0;t<this._curDynamicOffsets.length;t++)Array.prototype.push.apply(ua,this._curDynamicOffsets[t]);qs(this._device,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,ua,this._curViewport,this._curScissor,this._curLineWidth,this._curDepthBias,this._curBlendConstants,this._curDepthBounds,this._curStencilWriteMask,this._curStencilCompareMask),this._isStateInvalied=!1},e}(ra),_a=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).numDrawCalls=0,e.numInstances=0,e.numTris=0,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){return this._type=t.type,!0},i.destroy=function(){},i.submit=function(t){if(!this._isAsync)for(var e=t.length,i=0;i<e;i++){var r=t[i];this.numDrawCalls+=r.numDrawCalls,this.numInstances+=r.numInstances,this.numTris+=r.numTris}},i.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},e}(ue),fa=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuRenderPass=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){return this._colorInfos=t.colorAttachments,this._depthStencilInfo=t.depthStencilAttachment,t.subpasses&&(this._subpasses=t.subpasses),this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash(),!0},i.destroy=function(){this._gpuRenderPass=null},Pe(e,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),e}(ce),pa=[10497,33648,33071,33071],da=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuSampler=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._minFilter=t.minFilter,this._magFilter=t.magFilter,this._mipFilter=t.mipFilter,this._addressU=t.addressU,this._addressV=t.addressV,this._addressW=t.addressW,this._maxAnisotropy=t.maxAnisotropy,this._cmpFunc=t.cmpFunc,this._borderColor=t.borderColor,this._mipLODBias=t.mipLODBias;var e,i,r=this._minFilter,n=this._magFilter,s=this._mipFilter;e=r===C.LINEAR||r===C.ANISOTROPIC?s===C.LINEAR||s===C.ANISOTROPIC?9987:s===C.POINT?9985:9729:s===C.LINEAR||s===C.ANISOTROPIC?9986:s===C.POINT?9984:9728,i=n===C.LINEAR||n===C.ANISOTROPIC?9729:9728;var a=pa[this._addressU],o=pa[this._addressV],l=pa[this._addressW];return this._gpuSampler={glMinFilter:e,glMagFilter:i,glWrapS:a,glWrapT:o,glWrapR:l},!0},i.destroy=function(){this._gpuSampler=null},Pe(e,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),e}(_e),ma=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuShader=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._name=t.name,this._stages=t.stages,this._attributes=t.attributes,this._blocks=t.blocks,this._samplers=t.samplers,this._gpuShader={name:t.name,blocks:t.blocks,samplerTextures:t.samplerTextures,gpuStages:new Array(t.stages.length),glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]};for(var e=0;e<t.stages.length;++e){var i=t.stages[e];this._gpuShader.gpuStages[e]={type:i.stage,source:i.source,glShader:null}}return function(t,e){for(var i=t.gl,r=function(t){var r=e.gpuStages[t],n=0,s="",a=1;switch(r.type){case M.VERTEX:s="VertexShader",n=i.VERTEX_SHADER;break;case M.FRAGMENT:s="FragmentShader",n=i.FRAGMENT_SHADER;break;default:return console.error("Unsupported ShaderType."),{v:void 0}}var o=i.createShader(n);if(o&&(r.glShader=o,i.shaderSource(r.glShader,r.source),i.compileShader(r.glShader),!i.getShaderParameter(r.glShader,i.COMPILE_STATUS))){console.error(s+" in '"+e.name+"' compilation failed."),console.error("Shader source dump:",r.source.replace(/^|\n/g,(function(){return"\n"+a+++" "}))),console.error(i.getShaderInfoLog(r.glShader));for(var l=0;l<e.gpuStages.length;l++){var h=e.gpuStages[t];h.glShader&&(i.deleteShader(h.glShader),h.glShader=null)}return{v:void 0}}},n=0;n<e.gpuStages.length;n++){var s=r(n);if("object"==typeof s)return s.v}var a=i.createProgram();if(a){e.glProgram=a;for(var o=0;o<e.gpuStages.length;o++){var l=e.gpuStages[o];i.attachShader(e.glProgram,l.glShader)}if(i.linkProgram(e.glProgram),t.destroyShadersImmediately)for(var h=0;h<e.gpuStages.length;h++){var u=e.gpuStages[h];u.glShader&&(i.detachShader(e.glProgram,u.glShader),i.deleteShader(u.glShader),u.glShader=null)}if(!i.getProgramParameter(e.glProgram,i.LINK_STATUS))return console.error("Failed to link shader '"+e.name+"'."),void console.error(i.getProgramInfoLog(e.glProgram));console.info("Shader '"+e.name+"' compilation succeeded.");var c=i.getProgramParameter(e.glProgram,i.ACTIVE_ATTRIBUTES);e.glInputs=new Array(c);for(var _=0;_<c;++_){var f=i.getActiveAttrib(e.glProgram,_);if(f){var p,d=f.name.indexOf("[");p=-1!==d?f.name.substr(0,d):f.name;var m=i.getAttribLocation(e.glProgram,p),y=Ms(f.type,i),g=Ps(f.type,i);e.glInputs[_]={binding:m,name:p,type:y,stride:g,count:f.size,size:g*f.size,glType:f.type,glLoc:m}}}if(e.blocks.length>0){e.glBlocks=new Array(e.blocks.length);for(var v=0;v<e.blocks.length;++v){var b=e.blocks[v],S={set:b.set,binding:b.binding,name:b.name,size:0,glUniforms:new Array(b.members.length),glActiveUniforms:[]};e.glBlocks[v]=S;for(var A=0;A<b.members.length;++A){var C=b.members[A],x=Bs(C.type,i),T=Ds(C.type),w=Ps(x,i),E=w*C.count,B=S.size/4,D=new T(E/4);S.glUniforms[A]={binding:-1,name:C.name,type:C.type,stride:w,count:C.count,size:E,offset:S.size,glType:x,glLoc:-1,array:D,begin:B},S.size+=E}}}if(e.samplerTextures.length>0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var P=0;P<e.samplerTextures.length;++P){var R=e.samplerTextures[P];e.glSamplerTextures[P]={set:R.set,binding:R.binding,name:R.name,type:R.type,count:R.count,units:[],glUnits:null,glType:Bs(R.type,i),glLoc:null}}}for(var I=i.getProgramParameter(e.glProgram,i.ACTIVE_UNIFORMS),O=0;O<I;++O){var F=i.getActiveUniform(e.glProgram,O);if(F&&F.type!==i.SAMPLER_2D&&F.type!==i.SAMPLER_CUBE){var L=i.getUniformLocation(e.glProgram,F.name);if(null!==L&&("number"==typeof L||-1!==L.id)){var V,k=F.name.indexOf("[");V=-1!==k?F.name.substr(0,k):F.name;for(var N=0;N<e.glBlocks.length;N++)for(var G=e.glBlocks[N],z=0;z<G.glUniforms.length;z++){var U=G.glUniforms[z];if(U.name===V){U.glLoc=L,G.glActiveUniforms.push(U);break}}}}}for(var H=[],j=[],W=t.bindingMappingInfo,X=t.stateCache.texUnitCacheMap,Y=0,q=0;q<e.blocks.length;++q)e.blocks[q].set===W.flexibleSet&&Y++;for(var J=0,K=0;K<e.samplerTextures.length;++K){var Z=e.samplerTextures[K],Q=i.getUniformLocation(e.glProgram,Z.name);if(null===Q||"number"!=typeof Q&&-1===Q.id||(H.push(e.glSamplerTextures[K]),j.push(Q)),void 0===X[Z.name]){var $=Z.binding+W.samplerOffsets[Z.set]+J;Z.set===W.flexibleSet&&($-=Y),X[Z.name]=$%t.capabilities.maxTextureUnits,J+=Z.count-1}}if(H.length){for(var tt=[],et=0;et<H.length;++et){var it=H[et],rt=X[it.name];if(void 0!==rt){it.glLoc=j[et];for(var nt=0;nt<it.count;++nt){for(;tt[rt];)rt=(rt+1)%t.capabilities.maxTextureUnits;it.units.push(rt),tt[rt]=!0}}}for(var st=0,at=0;at<H.length;++at){var ot=H[at];if(!ot.glLoc){ot.glLoc=j[at];for(var lt=0;lt<ot.count;++lt){for(;tt[st];)st=(st+1)%t.capabilities.maxTextureUnits;void 0===X[ot.name]&&(X[ot.name]=st),ot.units.push(st),tt[st]=!0}}}t.stateCache.glProgram!==e.glProgram&&i.useProgram(e.glProgram);for(var ht=0;ht<H.length;ht++){var ut=H[ht];ut.glUnits=new Int32Array(ut.units),i.uniform1iv(ut.glLoc,ut.glUnits)}t.stateCache.glProgram!==e.glProgram&&i.useProgram(t.stateCache.glProgram)}for(var ct=0;ct<e.glBlocks.length;)e.glBlocks[ct].glActiveUniforms.length?ct++:(e.glBlocks[ct]=e.glBlocks[e.glBlocks.length-1],e.glBlocks.length--);e.glSamplerTextures=H}}(this._device,this._gpuShader),!0},i.destroy=function(){this._gpuShader&&(function(t,e){if(e.glProgram){var i=t.gl;if(!t.destroyShadersImmediately)for(var r=0;r<e.gpuStages.length;r++){var n=e.gpuStages[r];n.glShader&&(i.detachShader(e.glProgram,n.glShader),i.deleteShader(n.glShader),n.glShader=null)}i.deleteProgram(e.glProgram),e.glProgram=null}}(this._device,this._gpuShader),this._gpuShader=null)},Pe(e,[{key:"gpuShader",get:function(){return this._gpuShader}}]),e}(fe),ya=function(){function t(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.viewport=new et,this.scissorRect=new q(0,0,0,0),this.rs=new ne,this.dss=new se,this.bs=new oe,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return t.prototype.initialize=function(t,e){for(var i=0;i<t;++i)this.glTexUnits.push({glTexture:null});this.glEnabledAttribLocs.length=e,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=e,this.glCurrentAttribLocs.fill(!1)},t}(),ga=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._gpuTexture=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){return"texture"in t?(console.log("WebGL does not support texture view."),!1):(this._type=t.type,this._usage=t.usage,this._format=t.format,this._width=t.width,this._height=t.height,this._depth=t.depth,this._layerCount=t.layerCount,this._levelCount=t.levelCount,this._samples=t.samples,this._flags=t.flags,this._isPowerOf2=qt(this._width)&&qt(this._height),this._size=Kt(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._gpuTexture={type:this._type,format:this._format,usage:this._usage,width:this._width,height:this._height,depth:this._depth,size:this._size,arrayLayer:this._layerCount,mipLevel:this._levelCount,samples:this._samples,flags:this._flags,isPowerOf2:this._isPowerOf2,glTarget:0,glInternalFmt:0,glFormat:0,glType:0,glUsage:0,glTexture:null,glRenderbuffer:null,glWrapS:0,glWrapT:0,glMinFilter:0,glMagFilter:0},function(t,e){var i=t.gl;e.glInternalFmt=ws(e.format,i),e.glFormat=Es(e.format,i),e.glType=Ts(e.format,i);var r=e.width,n=e.height;switch(e.type){case v.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(r,n);if(s>t.capabilities.maxTextureSize&&Re(9100,s,t.capabilities.maxTextureSize),!t.WEBGL_depth_texture&&Ht[e.format].hasDepth){var a=i.createRenderbuffer();a&&e.size>0&&(e.glRenderbuffer=a,t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),e.glInternalFmt===i.DEPTH_COMPONENT&&(e.glInternalFmt=i.DEPTH_COMPONENT16),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,r,n))}else if(e.samples===A.X1){var o=i.createTexture();if(o&&e.size>0){e.glTexture=o;var l=t.stateCache.glTexUnits[t.stateCache.texUnit];if(l.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),l.glTexture=e.glTexture),Ht[e.format].isCompressed)if(e.glInternalFmt!==Cs.COMPRESSED_RGB_ETC1_WEBGL)for(var h=0;h<e.mipLevel;++h){var u=Jt(e.format,r,n,1),c=new Uint8Array(u);i.compressedTexImage2D(i.TEXTURE_2D,h,e.glInternalFmt,r,n,0,c),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}else{var _=Jt(e.format,2,2,1),f=new Uint8Array(_);i.compressedTexImage2D(i.TEXTURE_2D,0,e.glInternalFmt,2,2,0,f)}else for(var p=0;p<e.mipLevel;++p)i.texImage2D(i.TEXTURE_2D,p,e.glInternalFmt,r,n,0,e.glFormat,e.glType,null),r=Math.max(1,r>>1),n=Math.max(1,n>>1);e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}else i.deleteTexture(o)}break;case v.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var d=Math.max(r,n);d>t.capabilities.maxCubeMapTextureSize&&Re(9100,d,t.capabilities.maxTextureSize);var m=i.createTexture();if(m&&e.size>0){e.glTexture=m;var y=t.stateCache.glTexUnits[t.stateCache.texUnit];if(y.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),y.glTexture=e.glTexture),Ht[e.format].isCompressed)if(e.glInternalFmt!==Cs.COMPRESSED_RGB_ETC1_WEBGL)for(var g=0;g<6;++g){r=e.width,n=e.height;for(var b=0;b<e.mipLevel;++b){var S=Jt(e.format,r,n,1),C=new Uint8Array(S);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+g,b,e.glInternalFmt,r,n,0,C),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}}else for(var x=0;x<6;++x){var T=Jt(e.format,2,2,1),w=new Uint8Array(T);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,e.glInternalFmt,2,2,0,w)}else for(var E=0;E<6;++E){r=e.width,n=e.height;for(var B=0;B<e.mipLevel;++B)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+E,B,e.glInternalFmt,r,n,0,e.glFormat,e.glType,null),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}break;default:console.error("Unsupported TextureType, create texture failed."),e.type=v.TEX2D,e.glTarget=i.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize+=this._size,!0)},i.destroy=function(){var t,e;this._gpuTexture&&(t=this._device,(e=this._gpuTexture).glTexture&&(t.gl.deleteTexture(e.glTexture),e.glTexture=null),e.glRenderbuffer&&(t.gl.deleteRenderbuffer(e.glRenderbuffer),e.glRenderbuffer=null),this._device.memoryStatus.textureSize-=this._size,this._gpuTexture=null)},i.resize=function(t,e){var i=this._size;this._width=t,this._height=e,this._size=Kt(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=e,this._gpuTexture.size=this._size,function(t,e){var i=t.gl;e.glInternalFmt=ws(e.format,i),e.glFormat=Es(e.format,i),e.glType=Ts(e.format,i);var r=e.width,n=e.height;switch(e.type){case v.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(r,n);if(s>t.capabilities.maxTextureSize&&Re(9100,s,t.capabilities.maxTextureSize),e.glRenderbuffer)t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,r,n);else if(e.glTexture){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),Ht[e.format].isCompressed){if(e.glInternalFmt!==Cs.COMPRESSED_RGB_ETC1_WEBGL)for(var o=0;o<e.mipLevel;++o){var l=Jt(e.format,r,n,1),h=new Uint8Array(l);i.compressedTexImage2D(i.TEXTURE_2D,o,e.glInternalFmt,r,n,0,h),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}}else for(var u=0;u<e.mipLevel;++u)i.texImage2D(i.TEXTURE_2D,u,e.glInternalFmt,r,n,0,e.glFormat,e.glType,null),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}break;case v.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(r,n);c>t.capabilities.maxCubeMapTextureSize&&Re(9100,c,t.capabilities.maxTextureSize);var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),_.glTexture=e.glTexture),Ht[e.format].isCompressed){if(e.glInternalFmt!==Cs.COMPRESSED_RGB_ETC1_WEBGL)for(var f=0;f<6;++f){r=e.width,n=e.height;for(var p=0;p<e.mipLevel;++p){var d=Jt(e.format,r,n,1),m=new Uint8Array(d);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+f,p,e.glInternalFmt,r,n,0,m),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}}}else for(var y=0;y<6;++y){r=e.width,n=e.height;for(var g=0;g<e.mipLevel;++g)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+y,g,e.glInternalFmt,r,n,0,e.glFormat,e.glType,null),r=Math.max(1,r>>1),n=Math.max(1,n>>1)}break;default:console.error("Unsupported TextureType, create texture failed."),e.type=v.TEX2D,e.glTarget=i.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize-=i,this._device.memoryStatus.textureSize+=this._size)},Pe(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),e}(pe),va="webglcontextlost",ba=t("WebGLDevice",function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).stateCache=new ya,e.cmdAllocator=new ia,e.nullTex2D=null,e.nullTexCube=null,e._webGLRC=null,e._isAntialias=!0,e._isPremultipliedAlpha=!0,e._useVAO=!1,e._destroyShadersImmediately=!0,e._noCompressedTexSubImage2D=!1,e._bindingMappingInfo=new rt,e._webGLContextLostHandler=null,e._extensions=null,e._EXT_texture_filter_anisotropic=null,e._EXT_blend_minmax=null,e._EXT_frag_depth=null,e._EXT_shader_texture_lod=null,e._EXT_sRGB=null,e._OES_vertex_array_object=null,e._EXT_color_buffer_half_float=null,e._WEBGL_color_buffer_float=null,e._WEBGL_compressed_texture_etc1=null,e._WEBGL_compressed_texture_etc=null,e._WEBGL_compressed_texture_pvrtc=null,e._WEBGL_compressed_texture_astc=null,e._WEBGL_compressed_texture_s3tc=null,e._WEBGL_compressed_texture_s3tc_srgb=null,e._WEBGL_debug_shaders=null,e._WEBGL_draw_buffers=null,e._WEBGL_lose_context=null,e._WEBGL_depth_texture=null,e._WEBGL_debug_renderer_info=null,e._OES_texture_half_float=null,e._OES_texture_half_float_linear=null,e._OES_texture_float=null,e._OES_texture_float_linear=null,e._OES_standard_derivatives=null,e._OES_element_index_uint=null,e._ANGLE_instanced_arrays=null,e}Me(e,t);var i=e.prototype;return i.initialize=function(t){this._canvas=t.canvasElm,this._isAntialias=t.isAntialias,this._isPremultipliedAlpha=t.isPremultipliedAlpha,this._bindingMappingInfo=t.bindingMappingInfo,this._bindingMappingInfo.bufferOffsets.length||this._bindingMappingInfo.bufferOffsets.push(0),this._bindingMappingInfo.samplerOffsets.length||this._bindingMappingInfo.samplerOffsets.push(0);try{var e={alpha:Oe.ENABLE_TRANSPARENT_CANVAS,antialias:this._isAntialias,depth:!0,stencil:!0,premultipliedAlpha:this._isPremultipliedAlpha,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};this._webGLRC=this._canvas.getContext("webgl",e)}catch(t){return console.error(t),!1}if(!this._webGLRC)return console.error("This device does not support WebGL."),!1;this._webGLContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener(va,this._onWebGLContextLost),this._canvas2D=document.createElement("canvas"),console.info("WebGL device initialized."),this._gfxAPI=h.WEBGL,this._deviceName="WebGL";var i=this._webGLRC;this._WEBGL_debug_renderer_info=this.getExtension("WEBGL_debug_renderer_info"),this._WEBGL_debug_renderer_info?(this._renderer=i.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=i.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=i.getParameter(i.RENDERER),this._vendor=i.getParameter(i.VENDOR)),this._version=i.getParameter(i.VERSION),this._caps.maxVertexAttributes=i.getParameter(i.MAX_VERTEX_ATTRIBS),this._caps.maxVertexUniformVectors=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),this._caps.maxFragmentUniformVectors=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxTextureUnits=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureUnits=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),this._caps.maxCubeMapTextureSize=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.depthBits=i.getParameter(i.DEPTH_BITS),this._caps.stencilBits=i.getParameter(i.STENCIL_BITS),this.stateCache.initialize(this._caps.maxTextureUnits,this._caps.maxVertexAttributes),this._devicePixelRatio=t.devicePixelRatio||1,this._width=this._canvas.width,this._height=this._canvas.height,this._nativeWidth=Math.max(t.nativeWidth||this._width,0),this._nativeHeight=Math.max(t.nativeHeight||this._height,0),this._colorFmt=_.RGBA8,24===this._caps.depthBits?8===this._caps.stencilBits?this._depthStencilFmt=_.D24S8:this._depthStencilFmt=_.D24:8===this._caps.stencilBits?this._depthStencilFmt=_.D16S8:this._depthStencilFmt=_.D16,this._extensions=i.getSupportedExtensions();var r="";if(this._extensions){for(var n,s=Fe(this._extensions);!(n=s()).done;)r+=n.value+" ";console.debug("EXTENSIONS: "+r)}this._EXT_texture_filter_anisotropic=this.getExtension("EXT_texture_filter_anisotropic"),this._EXT_blend_minmax=this.getExtension("EXT_blend_minmax"),this._EXT_frag_depth=this.getExtension("EXT_frag_depth"),this._EXT_shader_texture_lod=this.getExtension("EXT_shader_texture_lod"),this._EXT_sRGB=this.getExtension("EXT_sRGB"),this._OES_vertex_array_object=this.getExtension("OES_vertex_array_object"),this._EXT_color_buffer_half_float=this.getExtension("EXT_color_buffer_half_float"),this._WEBGL_color_buffer_float=this.getExtension("WEBGL_color_buffer_float"),this._WEBGL_compressed_texture_etc1=this.getExtension("WEBGL_compressed_texture_etc1"),this._WEBGL_compressed_texture_etc=this.getExtension("WEBGL_compressed_texture_etc"),this._WEBGL_compressed_texture_pvrtc=this.getExtension("WEBGL_compressed_texture_pvrtc"),this._WEBGL_compressed_texture_s3tc=this.getExtension("WEBGL_compressed_texture_s3tc"),this._WEBGL_compressed_texture_s3tc_srgb=this.getExtension("WEBGL_compressed_texture_s3tc_srgb"),this._WEBGL_debug_shaders=this.getExtension("WEBGL_debug_shaders"),this._WEBGL_draw_buffers=this.getExtension("WEBGL_draw_buffers"),this._WEBGL_lose_context=this.getExtension("WEBGL_lose_context"),this._WEBGL_depth_texture=this.getExtension("WEBGL_depth_texture"),this._OES_texture_half_float=this.getExtension("OES_texture_half_float"),this._OES_texture_half_float_linear=this.getExtension("OES_texture_half_float_linear"),this._OES_texture_float=this.getExtension("OES_texture_float"),this._OES_texture_float_linear=this.getExtension("OES_texture_float_linear"),this._OES_standard_derivatives=this.getExtension("OES_standard_derivatives"),this._OES_element_index_uint=this.getExtension("OES_element_index_uint"),this._ANGLE_instanced_arrays=this.getExtension("ANGLE_instanced_arrays"),Le.os===Ve.IOS&&14===ke.osMainVersion&&ke.isBrowser||(this._WEBGL_compressed_texture_astc=this.getExtension("WEBGL_compressed_texture_astc")),Le.browserType===Ne.UC&&(this._ANGLE_instanced_arrays=null),(Le.os===Ve.IOS&&ke.osMainVersion<=10||Ge)&&(this._destroyShadersImmediately=!1),this._features.fill(!1),this._EXT_blend_minmax&&(this._features[c.BLEND_MINMAX]=!0),this._WEBGL_color_buffer_float&&(this._features[c.COLOR_FLOAT]=!0),this._EXT_color_buffer_half_float&&(this._features[c.COLOR_HALF_FLOAT]=!0),this._OES_texture_float&&(this._features[c.TEXTURE_FLOAT]=!0),this._OES_texture_half_float&&(this._features[c.TEXTURE_HALF_FLOAT]=!0),this._OES_texture_float_linear&&(this._features[c.TEXTURE_FLOAT_LINEAR]=!0),this._OES_texture_half_float_linear&&(this._features[c.TEXTURE_HALF_FLOAT_LINEAR]=!0),this._features[c.FORMAT_RGB8]=!0,this._WEBGL_depth_texture&&(this._features[c.FORMAT_D16]=!0,this._features[c.FORMAT_D24]=!0,this._features[c.FORMAT_D24S8]=!0),this._OES_element_index_uint&&(this._features[c.ELEMENT_INDEX_UINT]=!0),this._ANGLE_instanced_arrays&&(this._features[c.INSTANCED_ARRAYS]=!0),this._WEBGL_draw_buffers&&(this._features[c.MULTIPLE_RENDER_TARGETS]=!0);var a="";this._WEBGL_compressed_texture_etc1&&(this._features[c.FORMAT_ETC1]=!0,a+="etc1 "),this._WEBGL_compressed_texture_etc&&(this._features[c.FORMAT_ETC2]=!0,a+="etc2 "),this._WEBGL_compressed_texture_s3tc&&(this._features[c.FORMAT_DXT]=!0,a+="dxt "),this._WEBGL_compressed_texture_pvrtc&&(this._features[c.FORMAT_PVRTC]=!0,a+="pvrtc "),this._WEBGL_compressed_texture_astc&&(this._features[c.FORMAT_ASTC]=!0,a+="astc "),this._OES_vertex_array_object&&(this._useVAO=!0),console.info("RENDERER: "+this._renderer),console.info("VENDOR: "+this._vendor),console.info("VERSION: "+this._version),console.info("DPR: "+this._devicePixelRatio),console.info("SCREEN_SIZE: "+this._width+" x "+this._height),console.info("NATIVE_SIZE: "+this._nativeWidth+" x "+this._nativeHeight),console.info("MAX_VERTEX_UNIFORM_VECTORS: "+this._caps.maxVertexUniformVectors),console.info("DEPTH_BITS: "+this._caps.depthBits),console.info("STENCIL_BITS: "+this._caps.stencilBits),this._EXT_texture_filter_anisotropic&&console.info("MAX_TEXTURE_MAX_ANISOTROPY_EXT: "+this._EXT_texture_filter_anisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT),console.info("USE_VAO: "+this._useVAO),console.info("COMPRESSED_FORMAT: "+a),this.initStates(i),this._queue=this.createQueue(new Vt(U.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Lt(this._queue)),this.nullTex2D=this.createTexture(new ht(v.TEX2D,b.SAMPLED,_.RGBA8,2,2,S.GEN_MIPMAP)),this.nullTexCube=this.createTexture(new ht(v.CUBE,b.SAMPLED,_.RGBA8,2,2,S.GEN_MIPMAP,6));var o=new tt;o.texExtent.width=2,o.texExtent.height=2;var l=new Uint8Array(this.nullTex2D.size);return l.fill(0),this.copyBuffersToTexture([l],this.nullTex2D,[o]),o.texSubres.layerCount=6,this.copyBuffersToTexture([l,l,l,l,l,l],this.nullTexCube,[o]),!0},i.destroy=function(){this._canvas&&this._webGLContextLostHandler&&(this._canvas.removeEventListener(va,this._webGLContextLostHandler),this._webGLContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null),this._extensions=null,this._webGLRC=null},i.resize=function(t,e){this._width===t&&this._height===e||(console.info("Resizing device: "+t+"x"+e),this._canvas.width=t,this._canvas.height=e,this._width=t,this._height=e)},i.flushCommands=function(){},i.acquire=function(){this.cmdAllocator.releaseCmds()},i.present=function(){var t=this._queue;this._numDrawCalls=t.numDrawCalls,this._numInstances=t.numInstances,this._numTris=t.numTris,t.clear()},i.createCommandBuffer=function(t){var e=new(t.type===H.PRIMARY?ca:ra)(this);return e.initialize(t),e},i.createBuffer=function(t){var e=new ta(this);return e.initialize(t)?e:null},i.createTexture=function(t){var e=new ga(this);return e.initialize(t)?e:null},i.createSampler=function(t){var e=new da(this);return e.initialize(t)?e:null},i.createDescriptorSet=function(t){var e=new xs(this);return e.initialize(t)?e:null},i.createShader=function(t){var e=new ma(this);return e.initialize(t)?e:null},i.createInputAssembler=function(t){var e=new sa(this);return e.initialize(t)?e:null},i.createRenderPass=function(t){var e=new fa(this);return e.initialize(t)?e:null},i.createFramebuffer=function(t){var e=new na(this);return e.initialize(t)?e:null},i.createDescriptorSetLayout=function(t){var e=new aa(this);return e.initialize(t)?e:null},i.createPipelineLayout=function(t){var e=new oa(this);return e.initialize(t)?e:null},i.createPipelineState=function(t){var e=new ha(this);return e.initialize(t)?e:null},i.createQueue=function(t){var e=new _a(this);return e.initialize(t)?e:null},i.createGlobalBarrier=function(t){var e=new de(this);return e.initialize(t)?e:null},i.createTextureBarrier=function(t){var e=new me(this);return e.initialize(t)?e:null},i.copyBuffersToTexture=function(t,e,i){Qs(this,t,e.gpuTexture,i)},i.copyTexImagesToTexture=function(t,e,i){!function(t,e,i,r){var n=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(n.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var a=0,o=0;switch(i.glTarget){case n.TEXTURE_2D:for(var l=0;l<r.length;l++){var h=r[l];n.texSubImage2D(n.TEXTURE_2D,h.texSubres.mipLevel,h.texOffset.x,h.texOffset.y,i.glFormat,i.glType,e[a++])}break;case n.TEXTURE_CUBE_MAP:for(var u=0;u<r.length;u++){var c=r[u],_=c.texSubres.baseArrayLayer+c.texSubres.layerCount;for(o=c.texSubres.baseArrayLayer;o<_;++o)n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,c.texSubres.mipLevel,c.texOffset.x,c.texOffset.y,i.glFormat,i.glType,e[a++])}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&S.GEN_MIPMAP&&i.isPowerOf2&&n.generateMipmap(i.glTarget)}(this,t,e.gpuTexture,i)},i.copyFramebufferToBuffer=function(t,e,i){var r=this._webGLRC,n=t.gpuFramebuffer,s=n.gpuColorTextures[0].format,a=Es(s,r),o=Ts(s,r),l=Qt(Ht[s]),h=this.stateCache.glFramebuffer;this.stateCache.glFramebuffer!==n.glFramebuffer&&(r.bindFramebuffer(r.FRAMEBUFFER,n.glFramebuffer),this.stateCache.glFramebuffer=n.glFramebuffer);for(var u,c=new l(e),_=Fe(i);!(u=_()).done;){var f=u.value,p=f.texExtent.width,d=f.texExtent.height;r.readPixels(f.texOffset.x,f.texOffset.y,p,d,a,o,c)}this.stateCache.glFramebuffer!==h&&(r.bindFramebuffer(r.FRAMEBUFFER,h),this.stateCache.glFramebuffer=h)},i.blitFramebuffer=function(){},i.getExtension=function(t){for(var e=["","WEBKIT_","MOZ_"],i=0;i<e.length;++i){var r=this.gl.getExtension(e[i]+t);if(r)return r}return null},i.initStates=function(t){t.activeTexture(t.TEXTURE0),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.bindFramebuffer(t.FRAMEBUFFER,null),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.frontFace(t.CCW),t.disable(t.POLYGON_OFFSET_FILL),t.polygonOffset(0,0),t.enable(t.DEPTH_TEST),t.depthMask(!0),t.depthFunc(t.LESS),t.depthRange(0,1),t.stencilFuncSeparate(t.FRONT,t.ALWAYS,1,65535),t.stencilOpSeparate(t.FRONT,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.FRONT,65535),t.stencilFuncSeparate(t.BACK,t.ALWAYS,1,65535),t.stencilOpSeparate(t.BACK,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.BACK,65535),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.disable(t.BLEND),t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.colorMask(!0,!0,!0,!0),t.blendColor(0,0,0,0)},i._onWebGLContextLost=function(t){ze(11e3),Ue(t)},Pe(e,[{key:"gl",get:function(){return this._webGLRC}},{key:"webGLQueue",get:function(){return this._queue}},{key:"isAntialias",get:function(){return this._isAntialias}},{key:"isPremultipliedAlpha",get:function(){return this._isPremultipliedAlpha}},{key:"useVAO",get:function(){return this._useVAO}},{key:"destroyShadersImmediately",get:function(){return this._destroyShadersImmediately}},{key:"noCompressedTexSubImage2D",get:function(){return this._noCompressedTexSubImage2D}},{key:"bindingMappingInfo",get:function(){return this._bindingMappingInfo}},{key:"EXT_texture_filter_anisotropic",get:function(){return this._EXT_texture_filter_anisotropic}},{key:"EXT_blend_minmax",get:function(){return this._EXT_blend_minmax}},{key:"EXT_frag_depth",get:function(){return this._EXT_frag_depth}},{key:"EXT_shader_texture_lod",get:function(){return this._EXT_shader_texture_lod}},{key:"EXT_sRGB",get:function(){return this._EXT_sRGB}},{key:"OES_vertex_array_object",get:function(){return this._OES_vertex_array_object}},{key:"WEBGL_color_buffer_float",get:function(){return this._WEBGL_color_buffer_float}},{key:"WEBGL_compressed_texture_etc1",get:function(){return this._WEBGL_compressed_texture_etc1}},{key:"WEBGL_compressed_texture_pvrtc",get:function(){return this._WEBGL_compressed_texture_pvrtc}},{key:"WEBGL_compressed_texture_astc",get:function(){return this._WEBGL_compressed_texture_astc}},{key:"WEBGL_compressed_texture_s3tc",get:function(){return this._WEBGL_compressed_texture_s3tc}},{key:"WEBGL_compressed_texture_s3tc_srgb",get:function(){return this._WEBGL_compressed_texture_s3tc_srgb}},{key:"WEBGL_debug_shaders",get:function(){return this._WEBGL_debug_shaders}},{key:"WEBGL_draw_buffers",get:function(){return this._WEBGL_draw_buffers}},{key:"WEBGL_lose_context",get:function(){return this._WEBGL_lose_context}},{key:"WEBGL_depth_texture",get:function(){return this._WEBGL_depth_texture}},{key:"WEBGL_debug_renderer_info",get:function(){return this._WEBGL_debug_renderer_info}},{key:"OES_texture_half_float",get:function(){return this._OES_texture_half_float}},{key:"OES_texture_half_float_linear",get:function(){return this._OES_texture_half_float_linear}},{key:"OES_texture_float",get:function(){return this._OES_texture_float}},{key:"OES_standard_derivatives",get:function(){return this._OES_standard_derivatives}},{key:"OES_element_index_uint",get:function(){return this._OES_element_index_uint}},{key:"ANGLE_instanced_arrays",get:function(){return this._ANGLE_instanced_arrays}}]),e}($t));He.WebGLDevice=ba,function(t){t[t.positions=Ut.ATTR_POSITION]="positions",t[t.normals=Ut.ATTR_NORMAL]="normals",t[t.uvs=Ut.ATTR_TEX_COORD]="uvs",t[t.colors=Ut.ATTR_COLOR]="colors"}($s||($s={}));var Sa,Aa,Ca,xa,Ta,wa,Ea=function(){function t(){this._arrayBufferOrPaddings=[],this._length=0}var e=t.prototype;return e.setNextAlignment=function(t){if(0!==t){var e=this._length%t;if(0!==e){var i=t-e;this._arrayBufferOrPaddings.push(i),this._length+=i}}},e.addBuffer=function(t){var e=this._length;return this._arrayBufferOrPaddings.push(t),this._length+=t.byteLength,e},e.getLength=function(){return this._length},e.getCombined=function(){var t=new Uint8Array(this._length),e=0;return this._arrayBufferOrPaddings.forEach((function(i){"number"==typeof i?e+=i:(t.set(new Uint8Array(i),e),e+=i.byteLength)})),t.buffer},t}(),Ba=function(){function t(t,e){if(this._mesh=void 0,this._subMeshRenderings=[],this._mesh=t,this._mesh.struct.morph){var i=this._mesh.struct.primitives.length;this._subMeshRenderings=new Array(i).fill(null);for(var r=0;r<i;++r){var n=this._mesh.struct.morph.subMeshMorphs[r];n&&(n.targets.length>Xe.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[r]=new Ma(this._mesh,r,this._mesh.struct.morph,e):this._subMeshRenderings[r]=new Da(this._mesh,r,this._mesh.struct.morph,e))}}}return t.prototype.createInstance=function(){for(var t=this,e=this._mesh.struct.primitives.length,i=new Array(e),r=0;r<e;++r){var n,s;i[r]=null!==(n=null===(s=this._subMeshRenderings[r])||void 0===s?void 0:s.createInstance())&&void 0!==n?n:null}return{setWeights:function(t,e){var r;null===(r=i[t])||void 0===r||r.setWeights(e)},requiredPatches:function(e){Qe(t._mesh.struct.morph);var r=t._mesh.struct.morph.subMeshMorphs[e],n=i[e];if(null===n)return null;var s=[{name:"CC_USE_MORPH",value:!0},{name:"CC_MORPH_TARGET_COUNT",value:r.targets.length}];return r.attributes.includes(Ut.ATTR_POSITION)&&s.push({name:"CC_MORPH_TARGET_HAS_POSITION",value:!0}),r.attributes.includes(Ut.ATTR_NORMAL)&&s.push({name:"CC_MORPH_TARGET_HAS_NORMAL",value:!0}),r.attributes.includes(Ut.ATTR_TANGENT)&&s.push({name:"CC_MORPH_TARGET_HAS_TANGENT",value:!0}),s.push.apply(s,n.requiredPatches()),s},adaptPipelineState:function(t,e){var r;null===(r=i[t])||void 0===r||r.adaptPipelineState(e)},destroy:function(){for(var t,e=Fe(i);!(t=e()).done;){var r=t.value;null==r||r.destroy()}}}},t}(),Da=function(){function t(t,e,i,r){this._gfxDevice=void 0,this._subMeshMorph=void 0,this._textureInfo=void 0,this._attributes=void 0,this._verticesCount=void 0,this._gfxDevice=r;var n=i.subMeshMorphs[e];this._subMeshMorph=n,Oa(t,e,r);var s=t.struct.vertexBundles[t.struct.primitives[e].vertexBundelIndices[0]].view.count;this._verticesCount=s;var a=n.targets.length,o=Ia(r,s*a);this._textureInfo={width:o.width,height:o.height},this._attributes=n.attributes.map((function(e,i){var r=o.create(),a=r.valueView;return n.targets.forEach((function(e,r){for(var n=e.displacements[i],o=new Float32Array(t.data.buffer,t.data.byteOffset+n.offset,n.count),l=s*r*4,h=0;h<s;++h)a[l+4*h+0]=o[3*h+0],a[l+4*h+1]=o[3*h+1],a[l+4*h+2]=o[3*h+2]})),r.updatePixels(),{name:e,morphTexture:r}}))}var e=t.prototype;return e.destroy=function(){for(var t,e=Fe(this._attributes);!(t=e()).done;)t.value.morphTexture.destroy()},e.createInstance=function(){var t=this,e=new Ra(this._gfxDevice,this._subMeshMorph.targets.length);return e.setMorphTextureInfo(this._textureInfo.width,this._textureInfo.height),e.setVerticesCount(this._verticesCount),e.commit(),{setWeights:function(t){e.setWeights(t),e.commit()},requiredPatches:function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0}]},adaptPipelineState:function(i){for(var r,n=Fe(t._attributes);!(r=n()).done;){var s=r.value,a=void 0;switch(s.name){case Ut.ATTR_POSITION:a=ei;break;case Ut.ATTR_NORMAL:a=ti;break;case Ut.ATTR_TANGENT:a=$e;break;default:Ue("Unexpected attribute!")}void 0!==a&&(i.bindSampler(a,s.morphTexture.sampler),i.bindTexture(a,s.morphTexture.texture))}i.bindBuffer(Xe.BINDING,e.buffer),i.update()},destroy:function(){}}},t}(),Ma=function(){function t(t,e,i,r){this._gfxDevice=void 0,this._attributes=[],this._gfxDevice=r;var n=i.subMeshMorphs[e];Oa(t,e,r),this._attributes=n.attributes.map((function(e,i){return{name:e,targets:n.targets.map((function(e){return{displacements:new Float32Array(t.data.buffer,t.data.byteOffset+e.displacements[i].offset,e.displacements[i].count)}}))}}))}return t.prototype.createInstance=function(){return new Pa(this,this._attributes[0].targets[0].displacements.length/3,this._gfxDevice)},Pe(t,[{key:"data",get:function(){return this._attributes}}]),t}(),Pa=function(){function t(t,e,i){this._attributes=void 0,this._owner=void 0,this._morphUniforms=void 0,this._owner=t,this._morphUniforms=new Ra(i,0);var r=Ia(i,e);this._morphUniforms.setMorphTextureInfo(r.width,r.height),this._morphUniforms.commit(),this._attributes=this._owner.data.map((function(t){var e=r.create();return{attributeName:t.name,morphTexture:e}}))}var e=t.prototype;return e.setWeights=function(t){for(var e=0;e<this._attributes.length;++e){var i=this._attributes[e],r=i.morphTexture.valueView,n=this._owner.data[e];We(t.length===n.targets.length);for(var s=0;s<n.targets.length;++s){var a=n.targets[s].displacements,o=t[s],l=a.length/3;if(0===s)for(var h=0;h<l;++h)r[4*h+0]=a[3*h+0]*o,r[4*h+1]=a[3*h+1]*o,r[4*h+2]=a[3*h+2]*o;else if(0!==o)for(var u=0;u<l;++u)r[4*u+0]+=a[3*u+0]*o,r[4*u+1]+=a[3*u+1]*o,r[4*u+2]+=a[3*u+2]*o}i.morphTexture.updatePixels()}},e.requiredPatches=function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0},{name:"CC_MORPH_PRECOMPUTED",value:!0}]},e.adaptPipelineState=function(t){for(var e,i=Fe(this._attributes);!(e=i()).done;){var r=e.value,n=void 0;switch(r.attributeName){case Ut.ATTR_POSITION:n=ei;break;case Ut.ATTR_NORMAL:n=ti;break;case Ut.ATTR_TANGENT:n=$e;break;default:Ue("Unexpected attribute!")}void 0!==n&&(t.bindSampler(n,r.morphTexture.sampler),t.bindTexture(n,r.morphTexture.texture))}t.bindBuffer(Xe.BINDING,this._morphUniforms.buffer),t.update()},e.destroy=function(){this._morphUniforms.destroy();for(var t=0;t<this._attributes.length;++t)this._attributes[t].morphTexture.destroy()},t}(),Ra=function(){function t(t,e){this._targetCount=void 0,this._localBuffer=void 0,this._remoteBuffer=void 0,this._targetCount=e,this._localBuffer=new DataView(new ArrayBuffer(Xe.SIZE)),this._remoteBuffer=t.createBuffer(new nt(d.UNIFORM|d.TRANSFER_DST,g.HOST|g.DEVICE,Xe.SIZE,Xe.SIZE))}var e=t.prototype;return e.destroy=function(){this._remoteBuffer.destroy()},e.setWeights=function(t){We(t.length===this._targetCount);for(var e=0;e<t.length;++e)this._localBuffer.setFloat32(Xe.OFFSET_OF_WEIGHTS+4*e,t[e],He.sys.isLittleEndian)},e.setMorphTextureInfo=function(t,e){this._localBuffer.setFloat32(Xe.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH,t,He.sys.isLittleEndian),this._localBuffer.setFloat32(Xe.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT,e,He.sys.isLittleEndian)},e.setVerticesCount=function(t){this._localBuffer.setFloat32(Xe.OFFSET_OF_VERTICES_COUNT,t,He.sys.isLittleEndian)},e.commit=function(){this._remoteBuffer.update(this._localBuffer.buffer)},Pe(t,[{key:"buffer",get:function(){return this._remoteBuffer}}]),t}();function Ia(t,e){var i,r,n,s;t.hasFeature(c.TEXTURE_FLOAT)?(i=e,n=16,r=qe.PixelFormat.RGBA32F,s=Float32Array):(i=4*e,n=4,r=qe.PixelFormat.RGBA8888,s=Uint8Array);var a=function(t){t<5&&(t=5);var e=Ke(t),i=Ze(e),r=i>>1;return{width:1<<(1&i?r+1:r),height:1<<r}}(i),o=a.width,l=a.height;return{width:o,height:l,create:function(){var e=new ArrayBuffer(o*l*n),i=new Float32Array(e),a=s===Float32Array?i:new s(e),h=new Ye({width:o,height:l,_data:a,_compressed:!1,format:r}),u=new qe;u.setFilters(qe.Filter.NEAREST,qe.Filter.NEAREST),u.setMipFilter(qe.Filter.NONE),u.setWrapMode(qe.WrapMode.CLAMP_TO_EDGE,qe.WrapMode.CLAMP_TO_EDGE,qe.WrapMode.CLAMP_TO_EDGE),u.image=h,u.getGFXTexture()||Ue("Unexpected: failed to create morph texture?");var c=Je.getSampler(t,u.getSamplerHash());return{get texture(){return u.getGFXTexture()},get sampler(){return c},get valueView(){return i},destroy:function(){u.destroy()},updatePixels:function(){u.uploadData(a)}}}}}function Oa(t,e,i){t.renderingSubMeshes[e].enableVertexIdChannel(i)}function Fa(t){switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}}var La=new ii,Va=new ii,ka=new Uint8Array,Na=t("Mesh",ri("cc.Mesh")((wa=function(t){function e(){var e;return(e=t.call(this)||this).morphRendering=null,li(e,"_struct",Ca,hi(e)),li(e,"_dataLength",xa,hi(e)),li(e,"_hash",Ta,hi(e)),e._data=ka,e._initialized=!1,e._renderingSubMeshes=null,e._boneSpaceBounds=new Map,e._jointBufferIndices=null,e.loaded=!1,e}Me(e,t);var i=e.prototype;return i.initialize=function(){var t=this;if(!this._initialized){this._initialized=!0,this._data.byteLength!==this._dataLength&&(this._data=new Uint8Array(this._dataLength),He.assetManager.postLoadNative(this));for(var e=this._data.buffer,i=He.director.root.device,r=this._createVertexBuffers(i,e),n=[],s=function(s){var a=t._struct.primitives[s];if(0===a.vertexBundelIndices.length)return"continue";var o=null,l=null;if(a.indexView){var h=a.indexView,u=h.stride,_=h.length;if(4===u&&!i.hasFeature(c.ELEMENT_INDEX_UINT)){var f=t._struct.vertexBundles[a.vertexBundelIndices[0]].view.count;if(f>=65536)return ze(10001,f,65536),"continue";u>>=1,_>>=1}o=i.createBuffer(new nt(d.INDEX,g.DEVICE,_,u)),l=new(Fa(h.stride))(e,h.offset,h.count),h.stride!==u&&(l=Fa(u).from(l)),t.loaded?o.update(l):t.once("load",(function(){o.update(l)}))}var p=a.vertexBundelIndices.map((function(t){return r[t]})),m=[];if(a.vertexBundelIndices.length>0)for(var y=a.vertexBundelIndices[0],v=t._struct.vertexBundles[y].attributes,b=0;b<v.length;++b){var S=v[b];m[b]=new St(S.name,S.format,S.isInstanced,S.stream,S.isInstanced,S.location)}var A=new ui(p,m,a.primitiveMode,o);A.mesh=t,A.subMeshIdx=s,n.push(A)},a=0;a<this._struct.primitives.length;a++)s(a);this._renderingSubMeshes=n,this._struct.morph&&(this.morphRendering=function(t,e){return new Ba(t,e)}(this,i))}},i.destroy=function(){return this.destroyRenderingMesh(),t.prototype.destroy.call(this)},i.destroyRenderingMesh=function(){if(this._renderingSubMeshes){for(var t=0;t<this._renderingSubMeshes.length;t++)this._renderingSubMeshes[t].destroy();this._renderingSubMeshes=null,this._initialized=!1}},i.assign=function(t,e){this.reset({struct:t,data:e})},i.reset=function(t){this.destroyRenderingMesh(),this._struct=t.struct,this._data=t.data,this._dataLength=this.data.byteLength,this._hash=0,this.loaded=!0,this.emit("load")},i.getBoneSpaceBounds=function(t){if(this._boneSpaceBounds.has(t.hash))return this._boneSpaceBounds.get(t.hash);var e=[];this._boneSpaceBounds.set(t.hash,e);for(var i=[],r=t.bindposes,n=0;n<r.length;n++)e.push(new ni(1/0,1/0,1/0,-1/0,-1/0,-1/0)),i.push(!1);for(var s=this._struct.primitives,a=0;a<s.length;a++){var o=this.readAttribute(a,Ut.ATTR_JOINTS),l=this.readAttribute(a,Ut.ATTR_WEIGHTS),h=this.readAttribute(a,Ut.ATTR_POSITION);if(o&&l&&h)for(var u=Math.min(o.length/4,l.length/4,h.length/3),c=0;c<u;c++){ii.set(La,h[3*c+0],h[3*c+1],h[3*c+2]);for(var _=0;_<4;++_){var f=4*c+_,p=o[f];if(!(0===l[f]||p>=r.length)){ii.transformMat4(Va,La,r[p]),i[p]=!0;var d=e[p];ii.min(d.center,d.center,Va),ii.max(d.halfExtents,d.halfExtents,Va)}}}}for(var m=0;m<r.length;m++){var y=e[m];i[m]?ni.fromPoints(y,y.center,y.halfExtents):e[m]=null}return e},i.merge=function(t,e,i){if(i&&(!this.loaded||!t.loaded||!this.validateMergingMesh(t)))return!1;var r=new ii,n=e&&new si,s=e&&new ni;if(n&&e.getRotation(n),!this._initialized){var a=JSON.parse(JSON.stringify(t._struct)),o=t._data.slice();if(e){a.maxPosition&&a.minPosition&&(ii.add(s.center,a.maxPosition,a.minPosition),ii.multiplyScalar(s.center,s.center,.5),ii.subtract(s.halfExtents,a.maxPosition,a.minPosition),ii.multiplyScalar(s.halfExtents,s.halfExtents,.5),ni.transform(s,s,e),ii.add(a.maxPosition,s.center,s.halfExtents),ii.subtract(a.minPosition,s.center,s.halfExtents));for(var l=0;l<a.vertexBundles.length;l++)for(var h=a.vertexBundles[l],u=0;u<h.attributes.length;u++)if(h.attributes[u].name===Ut.ATTR_POSITION||h.attributes[u].name===Ut.ATTR_NORMAL){var c=h.attributes[u].format,_=new DataView(o.buffer,h.view.offset+Ga(h.attributes,u)),f=Ha(_,c),p=ja(_,c);if(!f||!p)continue;for(var d=h.view.count,m=h.view.stride,y=Ua(c),g=0;g<d;g++){var v=g*m,b=v+y,S=b+y;switch(r.set(f(v),f(b),f(S)),h.attributes[u].name){case Ut.ATTR_POSITION:r.transformMat4(e);break;case Ut.ATTR_NORMAL:ii.transformQuat(r,r,n)}p(v,r.x),p(b,r.y),p(S,r.z)}}}return this.reset({struct:a,data:o}),this.initialize(),!0}for(var A,C,x,T,w,E=new Ea,B=0,D=0,M=0,P=0,R=0,I=0,O=0,F=0,L=!1,V=new Array(this._struct.vertexBundles.length),k=0;k<this._struct.vertexBundles.length;++k){var N=this._struct.vertexBundles[k],G=t._struct.vertexBundles[k];M=N.view.offset,P=G.view.offset,D=N.view.stride,B=N.view.count+G.view.count,A=new ArrayBuffer(B*D),C=new Uint8Array(A),M+=(x=this._data.subarray(M,M+N.view.length)).length,P+=(T=t._data.subarray(P,P+G.view.length)).length,C.set(x),R=0;for(var z,U=Fe(N.attributes);!(z=U()).done;){var H=z.value;O=0,L=!1;for(var j,W=Fe(G.attributes);!(j=W()).done;){var X=j.value;if(H.name===X.name&&H.format===X.format){L=!0;break}O+=Ht[X.format].size}if(L){F=Ht[H.format].size,I=N.view.length+R;for(var Y=0;Y<G.view.count;++Y){if(w=T.subarray(O,O+F),C.set(w,I),(H.name===Ut.ATTR_POSITION||H.name===Ut.ATTR_NORMAL)&&e){var q=new Float32Array(C.buffer,I,3);switch(r.set(q[0],q[1],q[2]),H.name){case Ut.ATTR_POSITION:r.transformMat4(e);break;case Ut.ATTR_NORMAL:ii.transformQuat(r,r,n)}q[0]=r.x,q[1]=r.y,q[2]=r.z}I+=N.view.stride,O+=G.view.stride}}R+=Ht[H.format].size}V[k]={attributes:N.attributes,view:{offset:E.getLength(),length:A.byteLength,count:B,stride:D}},E.addBuffer(A)}for(var J,K,Z,Q=0,$=2,tt=0,et=new Array(this._struct.primitives.length),it=0;it<this._struct.primitives.length;++it){var rt=this._struct.primitives[it],nt=t._struct.primitives[it];et[it]={primitiveMode:rt.primitiveMode,vertexBundelIndices:rt.vertexBundelIndices};for(var st,at=Fe(rt.vertexBundelIndices);!(st=at()).done;){var ot=st.value;tt=Math.max(tt,this._struct.vertexBundles[ot].view.count)}if(rt.indexView&&nt.indexView){Q=rt.indexView.count,Q+=nt.indexView.count,M=rt.indexView.offset,P=nt.indexView.offset,$=Q<256?1:Q<65536?2:4;var lt=new ArrayBuffer(Q*$);if(J=2===$?new Uint16Array(lt):1===$?new Uint8Array(lt):new Uint32Array(lt),K=2===rt.indexView.stride?new Uint16Array(this._data.buffer,M,rt.indexView.count):1===rt.indexView.stride?new Uint8Array(this._data.buffer,M,rt.indexView.count):new Uint32Array(this._data.buffer,M,rt.indexView.count),$===rt.indexView.stride)J.set(K);else for(var ht=0;ht<rt.indexView.count;++ht)J[ht]=K[ht];M+=rt.indexView.length,Z=2===nt.indexView.stride?new Uint16Array(t._data.buffer,P,nt.indexView.count):1===nt.indexView.stride?new Uint8Array(t._data.buffer,P,nt.indexView.count):new Uint32Array(t._data.buffer,P,nt.indexView.count);for(var ut=0;ut<nt.indexView.count;++ut)J[rt.indexView.count+ut]=tt+Z[ut];P+=nt.indexView.length,et[it].indexView={offset:E.getLength(),length:lt.byteLength,count:Q,stride:$},E.setNextAlignment($),E.addBuffer(lt)}}var ct={vertexBundles:V,primitives:et,minPosition:this._struct.minPosition,maxPosition:this._struct.maxPosition};return ct.minPosition&&t._struct.minPosition&&ct.maxPosition&&t._struct.maxPosition&&(e?(ii.add(s.center,t._struct.maxPosition,t._struct.minPosition),ii.multiplyScalar(s.center,s.center,.5),ii.subtract(s.halfExtents,t._struct.maxPosition,t._struct.minPosition),ii.multiplyScalar(s.halfExtents,s.halfExtents,.5),ni.transform(s,s,e),ii.add(r,s.center,s.halfExtents),ii.max(ct.maxPosition,ct.maxPosition,r),ii.subtract(r,s.center,s.halfExtents),ii.min(ct.minPosition,ct.minPosition,r)):(ii.min(ct.minPosition,ct.minPosition,t._struct.minPosition),ii.max(ct.maxPosition,ct.maxPosition,t._struct.maxPosition))),this.reset({struct:ct,data:new Uint8Array(E.getCombined())}),this.initialize(),!0},i.validateMergingMesh=function(t){if(this._struct.vertexBundles.length!==t._struct.vertexBundles.length)return!1;for(var e=0;e<this._struct.vertexBundles.length;++e){var i=this._struct.vertexBundles[e],r=t._struct.vertexBundles[e];if(i.attributes.length!==r.attributes.length)return!1;for(var n=0;n<i.attributes.length;++n)if(i.attributes[n].format!==r.attributes[n].format)return!1}if(this._struct.primitives.length!==t._struct.primitives.length)return!1;for(var s=0;s<this._struct.primitives.length;++s){var a=this._struct.primitives[s],o=t._struct.primitives[s];if(a.vertexBundelIndices.length!==o.vertexBundelIndices.length)return!1;for(var l=0;l<a.vertexBundelIndices.length;++l)if(a.vertexBundelIndices[l]!==o.vertexBundelIndices[l])return!1;if(a.primitiveMode!==o.primitiveMode)return!1;if(a.indexView){if(void 0===o.indexView)return!1}else if(o.indexView)return!1}return!0},i.readAttribute=function(t,e){var i=this,r=null;return this._accessAttribute(t,e,(function(t,e){var n=t.view.count,s=t.attributes[e].format,a=Qt(Ht[s]);if(0!==n){var o=new DataView(i._data.buffer,t.view.offset+Ga(t.attributes,e)),l=Ht[s],h=Ha(o,s);if(a&&h){for(var u=l.count,c=new a(n*u),_=t.view.stride,f=0;f<n;++f)for(var p=0;p<u;++p)c[u*f+p]=h(_*f+c.BYTES_PER_ELEMENT*p);r=c}}})),r},i.copyAttribute=function(t,e,i,r,n){var s=this,a=!1;return this._accessAttribute(t,e,(function(t,e){var o=t.view.count;if(0!==o){var l=t.attributes[e].format,h=new DataView(s._data.buffer,t.view.offset+Ga(t.attributes,e)),u=new DataView(i,n),c=Ht[l],_=Ha(h,l),f=ja(u,l);if(_&&f){for(var p=c.count,d=t.view.stride,m=Ua(l),y=r,g=m,v=0;v<o;++v)for(var b=0;b<p;++b)f(y*v+g*b,_(d*v+m*b));a=!0}}else a=!0})),a},i.readIndices=function(t){if(t>=this._struct.primitives.length)return null;var e=this._struct.primitives[t];if(!e.indexView)return null;var i=e.indexView.stride;return new(1===i?Uint8Array:2===i?Uint16Array:Uint32Array)(this._data.buffer,e.indexView.offset,e.indexView.count)},i.copyIndices=function(t,e){if(t>=this._struct.primitives.length)return!1;var i=this._struct.primitives[t];if(!i.indexView)return!1;for(var r=i.indexView.count,n=1===i.indexView.stride?_.R8UI:2===i.indexView.stride?_.R16UI:_.R32UI,s=Ha(new DataView(this._data.buffer),n),a=0;a<r;++a)e[a]=s(i.indexView.offset+Ht[n].size*a);return!0},i._accessAttribute=function(t,e,i){if(!(t>=this._struct.primitives.length))for(var r,n=this._struct.primitives[t],s=Fe(n.vertexBundelIndices);!(r=s()).done;){var a=r.value,o=this._struct.vertexBundles[a],l=o.attributes.findIndex((function(t){return t.name===e}));if(!(l<0)){i(o,l);break}}},i._createVertexBuffers=function(t,e){var i=this;return this._struct.vertexBundles.map((function(r){var n=t.createBuffer(new nt(d.VERTEX,g.DEVICE,r.view.length,r.view.stride)),s=new Uint8Array(e,r.view.offset,r.view.length);return i.loaded?n.update(s):i.once("load",(function(){n.update(s)})),n}))},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.reset({struct:{vertexBundles:[],primitives:[]},data:ka})},i.validate=function(){return this.renderingSubMeshes.length>0&&this.data.byteLength>0},Pe(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data.byteLength===t.byteLength?this._data.set(new Uint8Array(t)):this._data=new Uint8Array(t),this.loaded=!0,this.emit("load")}},{key:"subMeshCount",get:function(){var t=this.renderingSubMeshes;return t?t.length:0}},{key:"minPosition",get:function(){return this.struct.minPosition}},{key:"maxPosition",get:function(){return this.struct.maxPosition}},{key:"struct",get:function(){return this._struct}},{key:"data",get:function(){return this._data}},{key:"hash",get:function(){return this._hash||(this._hash=ci(this._data,666)),this._hash}},{key:"jointBufferIndices",get:function(){return this._jointBufferIndices?this._jointBufferIndices:this._jointBufferIndices=this._struct.primitives.map((function(t){return t.jointMapIndex||0}))}},{key:"renderingSubMeshes",get:function(){return this.initialize(),this._renderingSubMeshes}}]),e}(ai),Ca=oi((Aa=wa).prototype,"_struct",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{vertexBundles:[],primitives:[]}}}),xa=oi(Aa.prototype,"_dataLength",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Ta=oi(Aa.prototype,"_hash",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Sa=Aa))||Sa);function Ga(t,e){for(var i=0,r=0;r<e;++r){var n=t[r];i+=Ht[n.format].size}return i}He.Mesh=Na;var za=ke.isLittleEndian;function Ua(t){var e=Ht[t];return e.size/e.count}function Ha(t,e){var i=Ht[e],r=i.size/i.count;switch(i.type){case f.UNORM:switch(r){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,za)};case 4:return function(e){return t.getUint32(e,za)}}break;case f.SNORM:case f.INT:switch(r){case 1:return function(e){return t.getInt8(e)};case 2:return function(e){return t.getInt16(e,za)};case 4:return function(e){return t.getInt32(e,za)}}break;case f.UINT:switch(r){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,za)};case 4:return function(e){return t.getUint32(e,za)}}break;case f.FLOAT:return function(e){return t.getFloat32(e,za)}}return null}function ja(t,e){var i=Ht[e],r=i.size/i.count;switch(i.type){case f.UNORM:switch(r){case 1:return function(e,i){return t.setUint8(e,i)};case 2:return function(e,i){return t.setUint16(e,i,za)};case 4:return function(e,i){return t.setUint32(e,i,za)}}break;case f.SNORM:case f.INT:switch(r){case 1:return function(e,i){return t.setInt8(e,i)};case 2:return function(e,i){return t.setInt16(e,i,za)};case 4:return function(e,i){return t.setInt32(e,i,za)}}break;case f.UINT:switch(r){case 1:return function(e,i){return t.setUint8(e,i)};case 2:return function(e,i){return t.setUint16(e,i,za)};case 4:return function(e,i){return t.setUint32(e,i,za)}}break;case f.FLOAT:return function(e,i){return t.setFloat32(e,i,za)}}return null}var Wa=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_NORMAL,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RG32F),new St(Ut.ATTR_TANGENT,_.RGBA32F),new St(Ut.ATTR_COLOR,_.RGBA32F)],Xa=new ii;function Ya(t,e,i){i=i||{};var r,n=[],s=0,a=[],o=0,l=t.positions.slice();if(l.length>0){if(r=null,t.attributes)for(var h,u=Fe(t.attributes);!(h=u()).done;){var c=h.value;if(c.name===Ut.ATTR_POSITION){r=c;break}}r||(r=Wa[0]),n.push(r);var f=Ht[r.format];o=Math.max(o,Math.floor(l.length/f.count)),a.push({offset:s,data:l,attribute:r}),s+=f.size}if(t.normals&&t.normals.length>0){if(r=null,t.attributes)for(var p,d=Fe(t.attributes);!(p=d()).done;){var m=p.value;if(m.name===Ut.ATTR_NORMAL){r=m;break}}r||(r=Wa[1]);var y=Ht[r.format];n.push(r),o=Math.max(o,Math.floor(t.normals.length/y.count)),a.push({offset:s,data:t.normals,attribute:r}),s+=y.size}if(t.uvs&&t.uvs.length>0){if(r=null,t.attributes)for(var g,v=Fe(t.attributes);!(g=v()).done;){var b=g.value;if(b.name===Ut.ATTR_TEX_COORD){r=b;break}}r||(r=Wa[2]);var S=Ht[r.format];n.push(r),o=Math.max(o,Math.floor(t.uvs.length/S.count)),a.push({offset:s,data:t.uvs,attribute:r}),s+=S.size}if(t.tangents&&t.tangents.length>0){if(r=null,t.attributes)for(var A,C=Fe(t.attributes);!(A=C()).done;){var x=A.value;if(x.name===Ut.ATTR_TANGENT){r=x;break}}r||(r=Wa[3]);var T=Ht[r.format];n.push(r),o=Math.max(o,Math.floor(t.tangents.length/T.count)),a.push({offset:s,data:t.tangents,attribute:r}),s+=T.size}if(t.colors&&t.colors.length>0){if(r=null,t.attributes)for(var w,E=Fe(t.attributes);!(w=E()).done;){var B=w.value;if(B.name===Ut.ATTR_COLOR){r=B;break}}r||(r=Wa[4]);var D=Ht[r.format];n.push(r),o=Math.max(o,Math.floor(t.colors.length/D.count)),a.push({offset:s,data:t.colors,attribute:r}),s+=D.size}if(t.customAttributes)for(var M,P=Fe(t.customAttributes);!(M=P()).done;){var R=M.value,I=Ht[R.attr.format];n.push(R.attr),o=Math.max(o,Math.floor(R.values.length/I.count)),a.push({offset:s,data:R.values,attribute:R.attr}),s+=I.size}for(var O=new Ea,L=new ArrayBuffer(o*s),V=new DataView(L),k=0,N=a;k<N.length;k++){var G=N[k];fi(V,G.data,G.attribute.format,G.offset,s)}O.setNextAlignment(0);var z={attributes:n,view:{offset:O.getLength(),length:L.byteLength,count:o,stride:s}};O.addBuffer(L);var U=null,H=0;if(t.indices){var j=t.indices;H=j.length,U=new ArrayBuffer(2*H);var W=new DataView(U);fi(W,j,_.R16UI)}var X={primitiveMode:t.primitiveMode||F.TRIANGLE_LIST,vertexBundelIndices:[0]};U&&(O.setNextAlignment(2),X.indexView={offset:O.getLength(),length:U.byteLength,count:H,stride:2},O.addBuffer(U));var Y=t.minPos;if(!Y&&i.calculateBounds){Y=ii.set(new ii,1/0,1/0,1/0);for(var q=0;q<o;++q)ii.set(Xa,l[3*q+0],l[3*q+1],l[3*q+2]),ii.min(Y,Y,Xa)}var J=t.maxPos;if(!J&&i.calculateBounds){J=ii.set(new ii,-1/0,-1/0,-1/0);for(var K=0;K<o;++K)ii.set(Xa,l[3*K+0],l[3*K+1],l[3*K+2]),ii.max(J,J,Xa)}var Z={vertexBundles:[z],primitives:[X]};return Y&&(Z.minPosition=new ii(Y.x,Y.y,Y.z)),J&&(Z.maxPosition=new ii(J.x,J.y,J.z)),e||(e=new Na),e.reset({struct:Z,data:new Uint8Array(O.getCombined())}),e}var qa=Object.freeze({__proto__:null,find:pi,toPPM:function(t,e,i){return"P3 "+e+" "+i+" 255\n"+t.filter((function(t,e){return e%4<3})).toString()+"\n"},readMesh:function(t,e){void 0===e&&(e=0);for(var i,r={positions:[]},n=new DataView(t.data.buffer,t.data.byteOffset,t.data.byteLength),s=t.struct,a=s.primitives[e],o=Fe(a.vertexBundelIndices);!(i=o()).done;)for(var l,h=i.value,u=s.vertexBundles[h],c=u.view.offset,f=u.view,p=f.length,d=f.stride,m=Fe(u.attributes);!(l=m()).done;){var y=l.value,g=$s[y.name];g&&(r[g]=(r[g]||[]).concat(je(n,y.format,c,p,d))),c+=Ht[y.format].size}var v=a.indexView;return r.indices=je(n,_["R"+8*v.stride+"UI"],v.offset,v.length),r},createMesh:Ya,readBuffer:je,writeBuffer:fi,mapBuffer:di});t("utils",qa);var Ja,Ka,Za,Qa,$a,to,eo,io,ro,no,so,ao,oo,lo,ho,uo,co,_o,fo,po,mo,yo,go,vo,bo,So,Ao,Co,xo,To,wo,Eo,Bo,Do,Mo,Po,Ro,Io,Oo,Fo,Lo,Vo=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._morphRenderingInstance=null,e._usedMaterials=new Set,e}Me(e,t);var i=e.prototype;return i.getMacroPatches=function(t){return this._morphRenderingInstance?this._morphRenderingInstance.requiredPatches(t):null},i.initSubModel=function(e,i,r){return t.prototype.initSubModel.call(this,e,i,this._launderMaterial(r))},i.setSubModelMaterial=function(e,i){return t.prototype.setSubModelMaterial.call(this,e,this._launderMaterial(i))},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i),this._morphRenderingInstance&&this._morphRenderingInstance.adaptPipelineState(e,i)},i._launderMaterial=function(t){return t},i.setMorphRendering=function(t){this._morphRenderingInstance=t},e}(mi),ko=yi({OFF:0,ON:1}),No=yi({OFF:0,ON:1}),Go=(Ja=ri("cc.ModelLightmapSettings"),Ka=gi("_recieveShadow"),Ja((so=function(){function t(){li(this,"texture",$a,this),li(this,"uvParam",to,this),li(this,"_bakeable",eo,this),li(this,"_castShadow",io,this),li(this,"_receiveShadow",ro,this),li(this,"_lightmapSize",no,this)}return Pe(t,[{key:"bakeable",get:function(){return this._bakeable},set:function(t){this._bakeable=t}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(t){this._receiveShadow=t}},{key:"lightmapSize",get:function(){return this._lightmapSize},set:function(t){this._lightmapSize=t}}]),t}(),$a=oi((Qa=so).prototype,"texture",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),to=oi(Qa.prototype,"uvParam",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ti}}),eo=oi(Qa.prototype,"_bakeable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),io=oi(Qa.prototype,"_castShadow",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),ro=oi(Qa.prototype,"_receiveShadow",[Ka],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),no=oi(Qa.prototype,"_lightmapSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),oi(Qa.prototype,"bakeable",[vi],Object.getOwnPropertyDescriptor(Qa.prototype,"bakeable"),Qa.prototype),oi(Qa.prototype,"castShadow",[vi],Object.getOwnPropertyDescriptor(Qa.prototype,"castShadow"),Qa.prototype),oi(Qa.prototype,"receiveShadow",[vi],Object.getOwnPropertyDescriptor(Qa.prototype,"receiveShadow"),Qa.prototype),oi(Qa.prototype,"lightmapSize",[vi],Object.getOwnPropertyDescriptor(Qa.prototype,"lightmapSize"),Qa.prototype),Za=Qa))||Za),zo=(ao=ri("cc.MeshRenderer"),oo=wi(),lo=Ei(100),ho=Bi(),uo=bi(ko),co=Di(),_o=bi(No),fo=Di(),po=bi(Na),mo=Di(),yo=Mi(),Eo=ao(go=oo(go=lo(go=ho(go=Si((wo=To=function(t){function e(){var e;return e=t.call(this)||this,li(e,"lightmapSettings",bo,hi(e)),li(e,"_mesh",So,hi(e)),li(e,"_shadowCastingMode",Ao,hi(e)),li(e,"_shadowReceivingMode",Co,hi(e)),e._modelType=void 0,e._model=null,e._morphInstance=null,li(e,"_enableMorph",xo,hi(e)),e._modelType=mi,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._mesh&&this._mesh.initialize(),this._watchMorphInMesh(),this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow()},i.onRestore=function(){this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow()},i.onEnable=function(){this._model||this._updateModels(),this._attachToScene()},i.onDisable=function(){this._model&&this._detachFromScene()},i.onDestroy=function(){this._model&&(He.director.root.destroyModel(this._model),this._model=null,this._models.length=0),this._morphInstance&&this._morphInstance.destroy()},i.setWeights=function(t,e){this._morphInstance&&this._morphInstance.setWeights(e,t)},i.setInstancedAttribute=function(t,e){if(this.model)for(var i=this.model.instancedAttributes,r=i.attributes,n=i.views,s=0;s<r.length;s++)if(r[s].name===t){n[s].set(e);break}},i._updateLightmap=function(t,e,i,r,n){this.lightmapSettings.texture=t,this.lightmapSettings.uvParam.x=e,this.lightmapSettings.uvParam.y=i,this.lightmapSettings.uvParam.z=r,this.lightmapSettings.uvParam.w=n,this._onUpdateLightingmap()},i._updateModels=function(){if(this.enabledInHierarchy&&this._mesh){var t=this._model;t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model&&(this._model.createBoundingShape(this._mesh.struct.minPosition,this._mesh.struct.maxPosition),this._updateModelParams(),this._onUpdateLightingmap())}},i._createModel=function(){var t=this._morphInstance&&this._modelType===mi?Vo:this._modelType,e=this._model=He.director.root.createModel(t);e.visFlags=this.visibility,e.node=e.transform=this.node,this._models.length=0,this._models.push(this._model),this._morphInstance&&e instanceof Vo&&e.setMorphRendering(this._morphInstance)},i._attachToScene=function(){if(this.node.scene&&this._model){var t=this._getRenderScene();null!==this._model.scene&&this._detachFromScene(),t.addModel(this._model)}},i._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},i._updateModelParams=function(){if(this._mesh&&this._model){this.node.hasChangedFlags|=Ai.POSITION,this._model.transform.hasChangedFlags|=Ai.POSITION,this._model.isDynamicBatching=this._isBatchingEnabled();var t=this._mesh?this._mesh.renderingSubMeshes.length:0,e=this._mesh.renderingSubMeshes;if(e)for(var i=0;i<t;++i){var r=this.getRenderMaterial(i);r&&!r.isValid&&(r=null);var n=e[i];n&&this._model.initSubModel(i,n,r||this._getBuiltinMaterial())}this._model.enabled=!0}},i._onUpdateLightingmap=function(){null!==this.model&&this.model.updateLightingmap(this.lightmapSettings.texture,this.lightmapSettings.uvParam),this.setInstancedAttribute("a_lightingMapUVParam",[this.lightmapSettings.uvParam.x,this.lightmapSettings.uvParam.y,this.lightmapSettings.uvParam.z,this.lightmapSettings.uvParam.w])},i._onMaterialModified=function(t,e){this._model&&this._model.inited&&this._onRebuildPSO(t,e||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.inited&&(this._model.isDynamicBatching=this._isBatchingEnabled(),this._model.setSubModelMaterial(t,e),this._onUpdateLightingmap())},i._onMeshChanged=function(){},i._clearMaterials=function(){if(this._model)for(var t=this._model.subModels,e=0;e<t.length;++e)this._onMaterialModified(e,null)},i._getBuiltinMaterial=function(){return Ci.get("missing-material")},i._onVisibilityChange=function(t){this._model&&(this._model.visFlags=t)},i._updateCastShadow=function(){this._model&&(this._shadowCastingMode===ko.OFF?this._model.castShadow=!1:(We(this._shadowCastingMode===ko.ON,"ShadowCastingMode "+this._shadowCastingMode+" is not supported."),this._model.castShadow=!0))},i._updateReceiveShadow=function(){this._model&&(this._shadowReceivingMode===No.OFF?this._model.receiveShadow=!1:this._model.receiveShadow=!0)},i._isBatchingEnabled=function(){for(var t=0;t<this._materials.length;++t){var e=this._materials[t];if(e)for(var i=0;i<e.passes.length;++i)if(e.passes[i].batchingScheme)return!0}return!1},i._watchMorphInMesh=function(){if(this._morphInstance&&(this._morphInstance.destroy(),this._morphInstance=null),this._enableMorph&&this._mesh&&this._mesh.struct.morph&&this._mesh.morphRendering){var t=this._mesh.struct.morph;this._morphInstance=this._mesh.morphRendering.createInstance();for(var e=this._mesh.struct.primitives.length,i=0;i<e;++i){var r=t.subMeshMorphs[i];if(r){var n=r.weights||t.weights,s=n?n.slice():new Array(r.targets.length).fill(0);this._morphInstance.setWeights(i,s)}}this._model&&this._model instanceof Vo&&this._model.setMorphRendering(this._morphInstance)}},i._syncMorphWeights=function(t){if(this._morphInstance){var e=this._morphInstance[t];e&&e.renderResources&&e.renderResources.setWeights(e.weights)}},Pe(e,[{key:"shadowCastingMode",get:function(){return this._shadowCastingMode},set:function(t){this._shadowCastingMode=t,this._updateCastShadow()}},{key:"receiveShadow",get:function(){return this._shadowReceivingMode},set:function(t){this._shadowReceivingMode=t,this._updateReceiveShadow()}},{key:"mesh",get:function(){return this._mesh},set:function(t){var e=this._mesh;this._mesh=t,this._mesh&&this._mesh.initialize(),this._watchMorphInMesh(),this._onMeshChanged(e),this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow()}},{key:"model",get:function(){return this._model}},{key:"enableMorph",get:function(){return this._enableMorph},set:function(t){this._enableMorph=t}}]),e}(Pi),To.ShadowCastingMode=ko,To.ShadowReceivingMode=No,bo=oi((vo=wo).prototype,"lightmapSettings",[_i,vi,xi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Go}}),So=oi(vo.prototype,"_mesh",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ao=oi(vo.prototype,"_shadowCastingMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ko.OFF}}),Co=oi(vo.prototype,"_shadowReceivingMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return No.ON}}),oi(vo.prototype,"shadowCastingMode",[uo,co,xi],Object.getOwnPropertyDescriptor(vo.prototype,"shadowCastingMode"),vo.prototype),oi(vo.prototype,"receiveShadow",[_o,fo,xi],Object.getOwnPropertyDescriptor(vo.prototype,"receiveShadow"),vo.prototype),oi(vo.prototype,"mesh",[po,mo],Object.getOwnPropertyDescriptor(vo.prototype,"mesh"),vo.prototype),oi(vo.prototype,"enableMorph",[yo,xi],Object.getOwnPropertyDescriptor(vo.prototype,"enableMorph"),vo.prototype),xo=oi(vo.prototype,"_enableMorph",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),go=vo))||go)||go)||go)||go)||go,t({MeshRenderer:Eo,ModelComponent:Eo}),Eo);function Uo(t,e){var i=t.sharedMaterials.length;if(i!==e.sharedMaterials.length)return!1;for(var r=0;r<i;r++)if(t.getRenderMaterial(r)!==e.getRenderMaterial(r))return!1;return!0}t("BatchingUtility",function(){function t(){}return t.batchStaticModel=function(t,e){var i=t.getComponentsInChildren(zo);if(i.length<2)return console.error("the number of static models to batch is less than 2,it needn't batch."),!1;for(var r=1;r<i.length;r++){if(!i[0].mesh.validateMergingMesh(i[r].mesh))return console.error("the meshes of "+i[0].node.name+" and "+i[r].node.name+" can't be merged"),!1;if(!Uo(i[0],i[r]))return console.error("the materials of "+i[0].node.name+" and "+i[r].node.name+" can't be merged"),!1}var n=new Na,s=new Ri,a=new Ri;t.getWorldMatrix(a),Ri.invert(a,a);for(var o=0;o<i.length;o++){var l=i[o];l.node.getWorldMatrix(s),Ri.multiply(s,a,s),n.merge(i[o].mesh,s),l.enabled=!1}var h=e.addComponent(zo);return h.mesh=n,h.sharedMaterials=i[0].sharedMaterials,!0},t.unbatchStaticModel=function(t,e){for(var i=t.getComponentsInChildren(zo),r=0;r<i.length;r++)i[r].enabled=!0;var n=e.getComponent(zo);return n&&(n.mesh&&n.mesh.destroyRenderingMesh(),n.destroy()),!0},t}()),Ii(Na.prototype,"Mesh.prototype",[{name:"renderingMesh",newName:"renderingSubMeshes"}]),Oi(Na.prototype,"Mesh.prototype",[{name:"hasFlatBuffers"},{name:"destroyFlatBuffers"}]);var Ho,jo,Wo,Xo,Yo,qo,Jo,Ko,Zo,Qo,$o,tl,el,il,rl,nl,sl,al,ol,ll,hl,ul=t("Skeleton",(Bo=ri("cc.Skeleton"),Do=bi([Fi]),Mo=bi([Ri]),Bo((Lo=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_joints",Io,hi(e)),li(e,"_bindposes",Oo,hi(e)),li(e,"_hash",Fo,hi(e)),e._invBindposes=null,e}Me(e,t);var i=e.prototype;return i.destroy=function(){return He.director.root.dataPoolManager.releaseSkeleton(this),t.prototype.destroy.call(this)},i.validate=function(){return this.joints.length>0&&this.bindposes.length>0},Pe(e,[{key:"joints",get:function(){return this._joints},set:function(t){this._joints=t}},{key:"bindposes",get:function(){return this._bindposes},set:function(t){this._bindposes=t}},{key:"inverseBindposes",get:function(){if(!this._invBindposes){this._invBindposes=[];for(var t=0;t<this._bindposes.length;t++){var e=new Ri;Ri.invert(e,this._bindposes[t]),this._invBindposes.push(e)}}return this._invBindposes}},{key:"hash",get:function(){if(!this._hash){for(var t="",e=0;e<this._bindposes.length;e++){var i=this._bindposes[e];t+=i.m00.toPrecision(2)+" "+i.m01.toPrecision(2)+" "+i.m02.toPrecision(2)+" "+i.m03.toPrecision(2)+" "+i.m04.toPrecision(2)+" "+i.m05.toPrecision(2)+" "+i.m06.toPrecision(2)+" "+i.m07.toPrecision(2)+" "+i.m08.toPrecision(2)+" "+i.m09.toPrecision(2)+" "+i.m10.toPrecision(2)+" "+i.m11.toPrecision(2)+" "+i.m12.toPrecision(2)+" "+i.m13.toPrecision(2)+" "+i.m14.toPrecision(2)+" "+i.m15.toPrecision(2)+"\n"}this._hash=ci(t,666)}return this._hash}}]),e}(ai),Io=oi((Ro=Lo).prototype,"_joints",[Do],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Oo=oi(Ro.prototype,"_bindposes",[Mo],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Fo=oi(Ro.prototype,"_hash",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Po=Ro))||Po));He.Skeleton=ul,Oi(zo.prototype,"MeshRenderer.prototype",[{name:"enableDynamicBatching"},{name:"recieveShadows"}]),He.ModelComponent=zo,Li.setClassAlias(zo,"cc.ModelComponent");var cl,_l,fl,pl,dl,ml,yl,gl,vl,bl,Sl,Al,Cl,xl,Tl,wl,El,Bl,Dl,Ml,Pl,Rl,Il,Ol,Fl,Ll,Vl,kl,Nl,Gl,zl,Ul,Hl,jl,Wl,Xl,Yl,ql,Jl,Kl,Zl,Ql,$l,th,eh,ih,rh,nh,sh=yi({LUMINOUS_POWER:0,LUMINANCE:1}),ah=new ii,oh=ri("cc.StaticLightSettings")((Jo=function(){function t(){li(this,"_baked",Wo,this),li(this,"_editorOnly",Xo,this),li(this,"_bakeable",Yo,this),li(this,"_castShadow",qo,this)}return Pe(t,[{key:"editorOnly",get:function(){return this._editorOnly},set:function(t){this._editorOnly=t}},{key:"baked",get:function(){return this._baked},set:function(t){this._baked=t}},{key:"bakeable",get:function(){return this._bakeable},set:function(t){this._bakeable=t}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}}]),t}(),Wo=oi((jo=Jo).prototype,"_baked",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Xo=oi(jo.prototype,"_editorOnly",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Yo=oi(jo.prototype,"_bakeable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),qo=oi(jo.prototype,"_castShadow",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(jo.prototype,"editorOnly",[vi],Object.getOwnPropertyDescriptor(jo.prototype,"editorOnly"),jo.prototype),oi(jo.prototype,"bakeable",[vi],Object.getOwnPropertyDescriptor(jo.prototype,"bakeable"),jo.prototype),oi(jo.prototype,"castShadow",[vi],Object.getOwnPropertyDescriptor(jo.prototype,"castShadow"),jo.prototype),Ho=jo))||Ho,lh=function(e){return t({Light:e,LightComponent:e}),e}((Ko=ri("cc.Light"),Zo=Di(),Qo=Di(),$o=Ni(),tl=Di(),el=bi(oh),Ko((hl=ll=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_color",nl,hi(e)),li(e,"_useColorTemperature",sl,hi(e)),li(e,"_colorTemperature",al,hi(e)),li(e,"_staticSettings",ol,hi(e)),e._type=Vi.UNKNOWN,e._lightType=void 0,e._light=null,e._lightType=Gi,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._createLight()},i.onEnable=function(){this._attachToScene()},i.onDisable=function(){this._detachFromScene()},i.onDestroy=function(){this._destroyLight()},i._createLight=function(){this._light||(this._light=He.director.root.createLight(this._lightType)),this.color=this._color,this.useColorTemperature=this._useColorTemperature,this.colorTemperature=this._colorTemperature,this._light.node=this.node,this._light.baked=this.baked},i._destroyLight=function(){this._light&&(He.director.root.destroyLight(this),this._light=null)},i._attachToScene=function(){if(this._detachFromScene(),this._light&&!this._light.scene&&this.node.scene){var t=this._getRenderScene();switch(this._type){case Vi.DIRECTIONAL:t.addDirectionalLight(this._light),t.setMainLight(this._light);break;case Vi.SPHERE:t.addSphereLight(this._light);break;case Vi.SPOT:t.addSpotLight(this._light)}}},i._detachFromScene=function(){if(this._light&&this._light.scene){var t=this._light.scene;switch(this._type){case Vi.DIRECTIONAL:t.removeDirectionalLight(this._light),t.unsetMainLight(this._light);break;case Vi.SPHERE:t.removeSphereLight(this._light);break;case Vi.SPOT:t.removeSpotLight(this._light)}}},Pe(e,[{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._light&&(ah.x=t.r/255,ah.y=t.g/255,ah.z=t.b/255,this._light.color=ah)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,this._light&&(this._light.useColorTemperature=t)}},{key:"colorTemperature",get:function(){return this._colorTemperature},set:function(t){this._colorTemperature=t,this._light&&(this._light.colorTemperature=t)}},{key:"staticSettings",get:function(){return this._staticSettings},set:function(t){this._staticSettings=t}},{key:"type",get:function(){return this._type}},{key:"baked",get:function(){return this.staticSettings.baked},set:function(t){this.staticSettings.baked=t,null!==this._light&&(this._light.baked=t)}}]),e}(zi),ll.Type=Vi,ll.PhotometricTerm=sh,nl=oi((rl=hl).prototype,"_color",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),sl=oi(rl.prototype,"_useColorTemperature",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),al=oi(rl.prototype,"_colorTemperature",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 6550}}),ol=oi(rl.prototype,"_staticSettings",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new oh}}),oi(rl.prototype,"color",[Zo],Object.getOwnPropertyDescriptor(rl.prototype,"color"),rl.prototype),oi(rl.prototype,"useColorTemperature",[Qo],Object.getOwnPropertyDescriptor(rl.prototype,"useColorTemperature"),rl.prototype),oi(rl.prototype,"colorTemperature",[ki,$o,tl],Object.getOwnPropertyDescriptor(rl.prototype,"colorTemperature"),rl.prototype),oi(rl.prototype,"staticSettings",[el],Object.getOwnPropertyDescriptor(rl.prototype,"staticSettings"),rl.prototype),il=rl))||il)),hh=function(e){return t({DirectionalLight:e,DirectionalLightComponent:e}),e}((cl=ri("cc.DirectionalLight"),_l=wi(),fl=Bi(),pl=Hi(),dl=Di(),cl(ml=_l(ml=fl(ml=Si((vl=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_illuminance",gl,hi(e)),e._type=Vi.DIRECTIONAL,e._light=null,e._lightType=ji,e}return Me(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._light&&(this.illuminance=this._illuminance)},Pe(e,[{key:"illuminance",get:function(){return this._illuminance},set:function(t){this._illuminance=t,this._light&&(this._light.illuminance=this._illuminance)}}]),e}(lh),gl=oi((yl=vl).prototype,"_illuminance",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 65e3}}),oi(yl.prototype,"illuminance",[pl,dl],Object.getOwnPropertyDescriptor(yl.prototype,"illuminance"),yl.prototype),ml=yl))||ml)||ml)||ml)||ml)),uh=function(e){return t({SphereLight:e,SphereLightComponent:e}),e}((bl=ri("cc.SphereLight"),Sl=wi(),Al=Bi(),Cl=Hi(),xl=Di(),Tl=Hi(),wl=Di(),El=bi(sh),Bl=Di(),Dl=Di(),Ml=Di(),bl(Pl=Sl(Pl=Al(Pl=Si((Vl=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_size",Il,hi(e)),li(e,"_luminance",Ol,hi(e)),li(e,"_term",Fl,hi(e)),li(e,"_range",Ll,hi(e)),e._type=Vi.SPHERE,e._light=null,e._lightType=Wi,e}return Me(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._light&&(this.luminance=this._luminance,this.size=this._size,this.range=this._range)},Pe(e,[{key:"luminousPower",get:function(){return this._luminance*Xi(this._size)},set:function(t){this._luminance=t/Xi(this._size),this._light&&(this._light.luminance=this._luminance)}},{key:"luminance",get:function(){return this._luminance},set:function(t){this._luminance=t,this._light&&(this._light.luminance=t)}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}}]),e}(lh),Il=oi((Rl=Vl).prototype,"_size",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.15}}),Ol=oi(Rl.prototype,"_luminance",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/Xi(.15)}}),Fl=oi(Rl.prototype,"_term",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sh.LUMINOUS_POWER}}),Ll=oi(Rl.prototype,"_range",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),oi(Rl.prototype,"luminousPower",[Cl,xl],Object.getOwnPropertyDescriptor(Rl.prototype,"luminousPower"),Rl.prototype),oi(Rl.prototype,"luminance",[Tl,wl],Object.getOwnPropertyDescriptor(Rl.prototype,"luminance"),Rl.prototype),oi(Rl.prototype,"term",[El,Bl],Object.getOwnPropertyDescriptor(Rl.prototype,"term"),Rl.prototype),oi(Rl.prototype,"size",[Dl],Object.getOwnPropertyDescriptor(Rl.prototype,"size"),Rl.prototype),oi(Rl.prototype,"range",[Ml],Object.getOwnPropertyDescriptor(Rl.prototype,"range"),Rl.prototype),Pl=Rl))||Pl)||Pl)||Pl)||Pl)),ch=function(e){return t({SpotLight:e,SpotLightComponent:e}),e}((kl=ri("cc.SpotLight"),Nl=wi(),Gl=Bi(),zl=Hi(),Ul=Di(),Hl=Hi(),jl=Di(),Wl=bi(sh),Xl=Di(),Yl=Di(),ql=Di(),Jl=Ni(),Kl=Di(),kl(Zl=Nl(Zl=Gl(Zl=Si((nh=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_size",$l,hi(e)),li(e,"_luminance",th,hi(e)),li(e,"_term",eh,hi(e)),li(e,"_range",ih,hi(e)),li(e,"_spotAngle",rh,hi(e)),e._type=Vi.SPOT,e._light=null,e._lightType=Yi,e}return Me(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._light&&(this.luminance=this._luminance,this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle)},Pe(e,[{key:"luminousPower",get:function(){return this._luminance*Xi(this._size)},set:function(t){this._luminance=t/Xi(this._size),this._light&&(this._light.luminance=this._luminance)}},{key:"luminance",get:function(){return this._luminance},set:function(t){this._luminance=t,this._light&&(this._light.luminance=t)}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(t){this._spotAngle=t,this._light&&(this._light.spotAngle=qi(t))}}]),e}(lh),$l=oi((Ql=nh).prototype,"_size",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.15}}),th=oi(Ql.prototype,"_luminance",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/Xi(.15)}}),eh=oi(Ql.prototype,"_term",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sh.LUMINOUS_POWER}}),ih=oi(Ql.prototype,"_range",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),rh=oi(Ql.prototype,"_spotAngle",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),oi(Ql.prototype,"luminousPower",[zl,Ul],Object.getOwnPropertyDescriptor(Ql.prototype,"luminousPower"),Ql.prototype),oi(Ql.prototype,"luminance",[Hl,jl],Object.getOwnPropertyDescriptor(Ql.prototype,"luminance"),Ql.prototype),oi(Ql.prototype,"term",[Wl,Xl],Object.getOwnPropertyDescriptor(Ql.prototype,"term"),Ql.prototype),oi(Ql.prototype,"size",[Yl],Object.getOwnPropertyDescriptor(Ql.prototype,"size"),Ql.prototype),oi(Ql.prototype,"range",[ql],Object.getOwnPropertyDescriptor(Ql.prototype,"range"),Ql.prototype),oi(Ql.prototype,"spotAngle",[ki,Jl,Kl],Object.getOwnPropertyDescriptor(Ql.prototype,"spotAngle"),Ql.prototype),Zl=Ql))||Zl)||Zl)||Zl)||Zl));He.LightComponent=lh,Li.setClassAlias(lh,"cc.LightComponent"),He.DirectionalLightComponent=hh,Li.setClassAlias(hh,"cc.DirectionalLightComponent"),He.SphereLightComponent=uh,Li.setClassAlias(uh,"cc.SphereLightComponent"),He.SpotLightComponent=ch,Li.setClassAlias(ch,"cc.SpotLightComponent");var _h=function(t,e,i){t[e+0]=i.m00,t[e+1]=i.m01,t[e+2]=i.m02,t[e+3]=i.m12,t[e+4]=i.m04,t[e+5]=i.m05,t[e+6]=i.m06,t[e+7]=i.m13,t[e+8]=i.m08,t[e+9]=i.m09,t[e+10]=i.m10,t[e+11]=i.m14};function fh(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new si,new si,new ii,new si,new ii;var ph=Ji([C.POINT,C.POINT,C.NONE,x.CLAMP,x.CLAMP,x.CLAMP]),dh=new ii,mh=new ii,yh=new ii,gh=new ii,vh=new Ri,bh=new Ri,Sh=new ni,Ah=Number.MAX_SAFE_INTEGER,Ch=function(){function t(t){this._device=void 0,this._pool=void 0,this._textureBuffers=new Map,this._formatSize=void 0,this._pixelsPerJoint=void 0,this._customPool=void 0,this._chunkIdxMap=new Map,this._device=t;var e=function(t){return t.hasFeature(c.TEXTURE_FLOAT)?_.RGBA32F:_.RGBA8}(this._device);this._formatSize=Ht[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new Qi(t),this._pool.initialize({format:e,roundUpFn:fh}),this._customPool=new Qi(t),this._customPool.initialize({format:e,roundUpFn:fh})}var e=t.prototype;return e.clear=function(){this._pool.destroy(),this._textureBuffers.clear()},e.registerCustomTextureLayouts=function(t){for(var e=0;e<t.length;e++)for(var i=t[e],r=this._customPool.createChunk(i.textureLength),n=0;n<i.contents.length;n++){var s=i.contents[n],a=s.skeleton;this._chunkIdxMap.set(a,r);for(var o=0;o<s.clips.length;o++){var l=s.clips[o];this._chunkIdxMap.set(a^l,r)}}},e.getDefaultPoseTexture=function(t,e,i){var r=0^t.hash,n=this._textureBuffers.get(r)||null;if(n&&n.bounds.has(e.hash))return n.refCount++,n;var s=t.joints,a=t.bindposes,o=null,l=!1,h=s.length;if(n)n.refCount++;else{var u=12*h,c=this._chunkIdxMap.get(r),_=void 0!==c?this._customPool.alloc(u*Float32Array.BYTES_PER_ELEMENT,c):this._pool.alloc(u*Float32Array.BYTES_PER_ELEMENT);if(!_)return n;n={pixelOffset:_.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:0,readyToBeDeleted:!1,handle:_},o=new Float32Array(u),l=!0}ii.set(yh,Ah,Ah,Ah),ii.set(gh,-Ah,-Ah,-Ah);for(var f=e.getBoneSpaceBounds(t),p=0,d=0;p<h;p++,d+=12){var m=i.getChildByPath(s[p]),y=m?Ki(m,i,vh):t.inverseBindposes[p],g=f[p];g&&(ni.transform(Sh,g,y),Sh.getBoundary(dh,mh),ii.min(yh,yh,dh),ii.max(gh,gh,mh)),l&&(m&&Ri.multiply(y,y,a[p]),_h(o,d,m?y:Ri.IDENTITY))}var v=[new ni];return n.bounds.set(e.hash,v),ni.fromPoints(v[0],yh,gh),l&&(this._pool.update(n.handle,o.buffer),this._textureBuffers.set(r,n)),n},e.getSequencePoseTexture=function(t,e,i,r){var n=t.hash^e.hash,s=this._textureBuffers.get(n)||null;if(s&&s.bounds.has(i.hash))return s.refCount++,s;var a=t.joints,o=t.bindposes,l=Zi.getOrExtract(e).info.frames,h=null,u=!1,c=a.length;if(s)s.refCount++;else{var _=12*c*l,f=this._chunkIdxMap.get(n),p=void 0!==f?this._customPool.alloc(_*Float32Array.BYTES_PER_ELEMENT,f):this._pool.alloc(_*Float32Array.BYTES_PER_ELEMENT);if(!p)return null;var d=this._createAnimInfos(t,e,r);s={pixelOffset:p.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:e.hash,readyToBeDeleted:!1,handle:p,animInfos:d},h=new Float32Array(_),u=!0}var m=i.getBoneSpaceBounds(t),y=[];s.bounds.set(i.hash,y);for(var g=0;g<l;g++)y.push(new ni(Ah,Ah,Ah,-Ah,-Ah,-Ah));for(var v=0,b=0;v<l;v++){for(var S=y[v],A=0;A<c;A++,b+=12){var C=s.animInfos[A],x=C.curveData,T=C.downstream,w=C.bindposeIdx,E=C.bindposeCorrection,B=void 0,D=!0;x&&T?B=Ri.multiply(vh,x[v],T):x?B=x[v]:T?B=T:(B=t.inverseBindposes[w],D=!1);var M=m[A];if(M){var P=E?Ri.multiply(bh,B,E):B;ni.transform(Sh,M,P),Sh.getBoundary(dh,mh),ii.min(S.center,S.center,dh),ii.max(S.halfExtents,S.halfExtents,mh)}u&&(D&&Ri.multiply(vh,B,o[w]),_h(h,b,D?vh:Ri.IDENTITY))}ni.fromPoints(S,S.center,S.halfExtents)}return u&&(this._pool.update(s.handle,h.buffer),this._textureBuffers.set(n,s)),s},e.releaseHandle=function(t){if(t.refCount>0&&t.refCount--,!t.refCount&&t.readyToBeDeleted){var e=t.skeletonHash^t.clipHash;(void 0!==this._chunkIdxMap.get(e)?this._customPool:this._pool).free(t.handle),this._textureBuffers.get(e)===t&&this._textureBuffers.delete(e)}},e.releaseSkeleton=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var r=i.value;r.skeletonHash===t.hash&&(r.readyToBeDeleted=!0,r.refCount?this._textureBuffers.delete(r.skeletonHash^r.clipHash):this.releaseHandle(r)),i=e.next()}},e.releaseAnimationClip=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var r=i.value;r.clipHash===t.hash&&(r.readyToBeDeleted=!0,r.refCount?this._textureBuffers.delete(r.skeletonHash^r.clipHash):this.releaseHandle(r)),i=e.next()}},e._createAnimInfos=function(t,e,i){for(var r=[],n=t.joints,s=t.bindposes,a=n.length,o=Zi.getOrExtract(e),l=0;l<a;l++){for(var h=n[l],u=o.data[h],c=i.getChildByPath(h),_=void 0,f=void 0;!u;){var p=h.lastIndexOf("/");if(h=h.substring(0,p),u=o.data[h],c?(_||(_=new Ri),Ri.fromRTS(vh,c.rotation,c.position,c.scale),Ri.multiply(_,vh,_),c=c.parent):f=h,p<0)break}var d=l,m=void 0;if(void 0!==f&&u){d=l-1;for(var y=0;y<a;y++)if(n[y]===f){d=y,m=new Ri,Ri.multiply(m,s[y],t.inverseBindposes[l]);break}}r.push({curveData:u&&u.worldMatrix.values,downstream:_,bindposeIdx:d,bindposeCorrection:m})}return r},Pe(t,[{key:"pixelsPerJoint",get:function(){return this._pixelsPerJoint}}]),t}(),xh=function(){function t(t){this._pool=new Map,this._device=void 0,this._device=t}var e=t.prototype;return e.getData=function(t){void 0===t&&(t="-1");var e=this._pool.get(t);if(e)return e;var i=this._device.createBuffer(new nt(d.UNIFORM|d.TRANSFER_DST,g.HOST|g.DEVICE,$i.SIZE,$i.SIZE)),r=new Float32Array([0,0,0,0]);i.update(r);var n={buffer:i,data:r,dirty:!1};return this._pool.set(t,n),n},e.destroy=function(t){var e=this._pool.get(t);e&&(e.buffer.destroy(),this._pool.delete(t))},e.switchClip=function(t){return t.data[0]=0,t.buffer.update(t.data),t.dirty=!1,t},e.clear=function(){for(var t,e=Fe(this._pool.values());!(t=e()).done;)t.value.buffer.destroy();this._pool.clear()},t}(),Th=function(){function t(t){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new Ch(t),this.jointAnimationInfo=new xh(t)}var e=t.prototype;return e.releaseSkeleton=function(t){this.jointTexturePool.releaseSkeleton(t)},e.releaseAnimationClip=function(t){this.jointTexturePool.releaseAnimationClip(t)},e.clear=function(){this.jointTexturePool.clear(),this.jointAnimationInfo.clear()},t}();He.internal.DataPoolManager=Th;var wh=[{name:"CC_USE_SKINNING",value:!0}];function Eh(t,e,i,r){for(var n=0;n<i.length;n++){for(var s=i[n],a=-1,o=0;o<s.length;o++)if(s[o]===r){a=o;break}a>=0&&(e.push(n),t.push(a))}}var Bh,Dh,Mh,Ph,Rh,Ih,Oh,Fh,Lh,Vh,kh,Nh,Gh,zh,Uh,Hh,jh,Wh,Xh,Yh,qh,Jh,Kh,Zh,Qh,$h,tu,eu,iu,ru,nu,su,au,ou,lu,hu,uu,cu,_u,fu,pu,du,mu,yu,gu,vu=new ii,bu=new ii,Su=new ii,Au=new ii,Cu=new Ri,xu=new ni,Tu=function(t){function e(){var e;return(e=t.call(this)||this).uploadAnimation=null,e._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e.type=ar.SKINNING,e}Me(e,t);var i=e.prototype;return i.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers.length=0}t.prototype.destroy.call(this)},i.bindSkeleton=function(t,e,i){void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null);for(var r=0;r<this._joints.length;r++)tr(this._joints[r].target);if(this._bufferIndices=null,this._joints.length=0,t&&e&&i){this.transform=e;var n=i.getBoneSpaceBounds(t),s=i.struct.jointMaps;this._ensureEnoughBuffers(s&&s.length||1),this._bufferIndices=i.jointBufferIndices;for(var a=0;a<t.joints.length;a++){var o=n[a],l=e.getChildByPath(t.joints[a]);if(o&&l){var h=er(l,e),u=t.bindposes[a],c=[],_=[];s?Eh(c,_,s,a):(c.push(a),_.push(0)),this._joints.push({indices:c,buffers:_,bound:o,target:l,bindpose:u,transform:h})}}}},i.updateTransform=function(t){var e=this.transform;(e.hasChangedFlags||e._dirtyFlags)&&(e.updateWorldTransform(),this._transformUpdated=!0),ii.set(vu,1/0,1/0,1/0),ii.set(bu,-1/0,-1/0,-1/0);for(var i=0;i<this._joints.length;i++){var r=this._joints[i],n=r.bound,s=r.transform,a=ir(s,t);ni.transform(xu,n,a),xu.getBoundary(Su,Au),ii.min(vu,vu,Su),ii.max(bu,bu,Au)}var o=this._worldBounds;this._modelBounds&&o&&(ni.fromPoints(this._modelBounds,vu,bu),this._modelBounds.transform(e._mat,e._pos,e._rot,e._scale,this._worldBounds),rr.setVec3(this._hWorldBounds,nr.CENTER,o.center),rr.setVec3(this._hWorldBounds,nr.HALF_EXTENSION,o.halfExtents))},i.updateUBOs=function(e){t.prototype.updateUBOs.call(this,e);for(var i=0;i<this._joints.length;i++){var r=this._joints[i],n=r.indices,s=r.buffers,a=r.transform,o=r.bindpose;Ri.multiply(Cu,a.world,o);for(var l=0;l<s.length;l++)_h(this._dataArray[s[l]],12*n[l],Cu)}for(var h=0;h<this._buffers.length;h++)this._buffers[h].update(this._dataArray[h]);return!0},i.initSubModel=function(e,i,r){var n=i.vertexBuffers,s=i.iaInfo;s.vertexBuffers=i.jointMappedBuffers,t.prototype.initSubModel.call(this,e,i,r),s.vertexBuffers=n},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);return i?wh.concat(i):wh},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var r=this._buffers[this._bufferIndices[e]];r&&i.bindBuffer(sr.BINDING,r)},i._ensureEnoughBuffers=function(t){for(var e=0;e<t;e++)this._buffers[e]||(this._buffers[e]=this._device.createBuffer(new nt(d.UNIFORM|d.TRANSFER_DST,g.HOST|g.DEVICE,sr.SIZE,sr.SIZE))),this._dataArray[e]||(this._dataArray[e]=new Float32Array(sr.COUNT))},e}(Vo),wu=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_BAKED_ANIMATION",value:!0}],Eu=function(t){function e(){var e;(e=t.call(this)||this).uploadedAnim=void 0,e._jointsMedium=void 0,e._skeleton=null,e._mesh=null,e._dataPoolManager=void 0,e._instAnimInfoIdx=-1,e.type=ar.BAKED_SKINNING,e._dataPoolManager=He.director.root.dataPoolManager;var i=new Float32Array(4),r=e._dataPoolManager.jointAnimationInfo.getData();return e._jointsMedium={buffer:null,jointTextureInfo:i,animInfo:r,texture:null,boundsInfo:null},e}Me(e,t);var i=e.prototype;return i.destroy=function(){this.uploadedAnim=void 0,this._jointsMedium.boundsInfo=null,this._jointsMedium.buffer&&(this._jointsMedium.buffer.destroy(),this._jointsMedium.buffer=null),this._applyJointTexture(),t.prototype.destroy.call(this)},i.bindSkeleton=function(t,e,i){if(void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null),this._skeleton=t,this._mesh=i,t&&e&&i){this.transform=e;var r=this._dataPoolManager;this._jointsMedium.animInfo=r.jointAnimationInfo.getData(e.uuid),this._jointsMedium.buffer||(this._jointsMedium.buffer=this._device.createBuffer(new nt(d.UNIFORM|d.TRANSFER_DST,g.HOST|g.DEVICE,or.SIZE,or.SIZE)))}},i.updateTransform=function(e){if(t.prototype.updateTransform.call(this,e),this.uploadedAnim){var i=this._jointsMedium,r=i.animInfo,n=i.boundsInfo[r.data[0]],s=this._worldBounds;if(s&&n){var a=this.transform;n.transform(a._mat,a._pos,a._rot,a._scale,s),rr.setVec3(this._hWorldBounds,nr.CENTER,s.center),rr.setVec3(this._hWorldBounds,nr.HALF_EXTENSION,s.halfExtents)}}},i.updateUBOs=function(e){t.prototype.updateUBOs.call(this,e);var i=this._jointsMedium.animInfo,r=this._instAnimInfoIdx;return r>=0?this.instancedAttributes.views[r][0]=i.data[0]:i.dirty&&(i.buffer.update(i.data),i.dirty=!1),!0},i.uploadAnimation=function(t){if(this._skeleton&&this._mesh&&this.uploadedAnim!==t){this.uploadedAnim=t;var e=this._dataPoolManager,i=null;t?(i=e.jointTexturePool.getSequencePoseTexture(this._skeleton,t,this._mesh,this.transform),this._jointsMedium.boundsInfo=i&&i.bounds.get(this._mesh.hash),this._modelBounds=null):(i=e.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._modelBounds=i&&i.bounds.get(this._mesh.hash)[0]),this._applyJointTexture(i)}},i._applyJointTexture=function(t){void 0===t&&(t=null);var e=this._jointsMedium.texture;if(e&&e!==t&&this._dataPoolManager.jointTexturePool.releaseHandle(e),this._jointsMedium.texture=t,t){var i=this._jointsMedium,r=i.buffer,n=i.jointTextureInfo;n[0]=t.handle.texture.width,n[1]=this._skeleton.joints.length,n[2]=t.pixelOffset+.1,n[3]=1/n[0],this.updateInstancedJointTextureInfo(),r&&r.update(n);for(var s=t.handle.texture,a=0;a<this._subModels.length;++a)this._subModels[a].descriptorSet.bindTexture(lr,s)}},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);return i?i.concat(wu):wu},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var r=this._jointsMedium,n=r.buffer,s=r.texture,a=r.animInfo;if(i.bindBuffer(or.BINDING,n),i.bindBuffer($i.BINDING,a.buffer),s){var o=Je.getSampler(this._device,ph);i.bindTexture(lr,s.handle.texture),i.bindSampler(lr,o)}},i._updateInstancedAttributes=function(e,i){t.prototype._updateInstancedAttributes.call(this,e,i),this._instAnimInfoIdx=this._getInstancedAttributeIndex(hr),this.updateInstancedJointTextureInfo()},i.updateInstancedJointTextureInfo=function(){var t=this._jointsMedium,e=t.jointTextureInfo,i=t.animInfo,r=this._instAnimInfoIdx;if(r>=0){var n=this.instancedAttributes.views[r];n[0]=i.data[0],n[1]=e[1],n[2]=e[2]}},e}(Vo),Bu=function(e){return t({SkinnedMeshRenderer:e,SkinningModelComponent:e}),e}((Bh=ri("cc.SkinnedMeshRenderer"),Dh=wi(),Mh=Ei(100),Ph=Bi(),Rh=bi(ul),Ih=bi(ur),Oh=bi(ul),Fh=bi(ur),Lh=Di(),Bh(Vh=Dh(Vh=Mh(Vh=Si(Vh=Ph((zh=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_skeleton",Nh,hi(e)),li(e,"_skinningRoot",Gh,hi(e)),e._clip=null,e._modelType=Eu,e}Me(e,t);var i=e.prototype;return i.__preload=function(){this._updateModelType()},i.uploadAnimation=function(t){this._clip=t,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(t)},i.setUseBakedAnimation=function(t){void 0===t&&(t=!0);var e=t?Eu:Tu;this._modelType!==e&&(this._modelType=e,this._model&&(He.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this.enabledInHierarchy&&this._attachToScene()))},i.setMaterial=function(e,i){t.prototype.setMaterial.call(this,e,i),this._modelType===Tu&&this.getMaterialInstance(i)},i._updateModelParams=function(){this._update(),t.prototype._updateModelParams.call(this)},i._updateModelType=function(){if(this._skinningRoot){var t=this._skinningRoot.getComponent("cc.SkeletalAnimation");t?this.setUseBakedAnimation(t.useBakedAnimation):this.setUseBakedAnimation(!1)}},i._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},Pe(e,[{key:"skeleton",get:function(){return this._skeleton},set:function(t){t!==this._skeleton&&(this._skeleton=t,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(t){t!==this._skinningRoot&&(this._skinningRoot=t,this._updateModelType(),this._update())}},{key:"model",get:function(){return this._model}}]),e}(zo),Nh=oi((kh=zh).prototype,"_skeleton",[Rh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Gh=oi(kh.prototype,"_skinningRoot",[Ih],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(kh.prototype,"skeleton",[Oh],Object.getOwnPropertyDescriptor(kh.prototype,"skeleton"),kh.prototype),oi(kh.prototype,"skinningRoot",[Fh,Lh],Object.getOwnPropertyDescriptor(kh.prototype,"skinningRoot"),kh.prototype),Vh=kh))||Vh)||Vh)||Vh)||Vh)||Vh)),Du=new St(Ut.ATTR_BATCH_ID,_.R32F),Mu=new St(Ut.ATTR_BATCH_UV,_.RG32F),Pu=Ht[Du.format].size+Ht[Mu.format].size,Ru=function(e){return t({SkinnedMeshUnit:e,SkinningModelUnit:e}),e}((Uh=ri("cc.SkinnedMeshUnit"),Hh=bi(Na),jh=bi(ul),Wh=bi(cr),Xh=bi(Bu),Uh((eu=function(){function t(){li(this,"mesh",Jh,this),li(this,"skeleton",Kh,this),li(this,"material",Zh,this),li(this,"_localTransform",Qh,this),li(this,"_offset",$h,this),li(this,"_size",tu,this)}return Pe(t,[{key:"offset",get:function(){return this._offset},set:function(t){dr.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){dr.copy(this._size,t)}},{key:"copyFrom",get:function(){return null},set:function(t){t&&(this.mesh=t.mesh,this.skeleton=t.skeleton,this.material=t.getMaterial(0),t.skinningRoot&&Ki(t.node,t.skinningRoot,this._localTransform))}}]),t}(),Jh=oi((qh=eu).prototype,"mesh",[Hh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Kh=oi(qh.prototype,"skeleton",[jh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Zh=oi(qh.prototype,"material",[Wh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Qh=oi(qh.prototype,"_localTransform",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ri}}),$h=oi(qh.prototype,"_offset",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(0,0)}}),tu=oi(qh.prototype,"_size",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(1,1)}}),oi(qh.prototype,"offset",[vi],Object.getOwnPropertyDescriptor(qh.prototype,"offset"),qh.prototype),oi(qh.prototype,"size",[vi],Object.getOwnPropertyDescriptor(qh.prototype,"size"),qh.prototype),oi(qh.prototype,"copyFrom",[Xh],Object.getOwnPropertyDescriptor(qh.prototype,"copyFrom"),qh.prototype),Yh=qh))||Yh)),Iu=new Ri,Ou=(new Ri,new ii),Fu=function(e){return t({SkinnedMeshBatchRenderer:e,BatchedSkinningModelComponent:e}),e}((iu=ri("cc.SkinnedMeshBatchRenderer"),ru=wi(),nu=Ei(100),su=Bi(),au=Di(),ou=bi([Fi]),lu=Di(),hu=bi([Ru]),uu=Di(),cu=Mi(),_u=Mi(),iu(fu=ru(fu=nu(fu=Si(fu=su((gu=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"atlasSize",du,hi(e)),li(e,"batchableTextureNames",mu,hi(e)),li(e,"units",yu,hi(e)),e._textures={},e._batchMaterial=null,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this.cook()},i.onDestroy=function(){for(var e in this._textures)this._textures[e].destroy();this._textures={},this._mesh&&(this._mesh.destroy(),this._mesh=null),t.prototype.onDestroy.call(this)},i._onMaterialModified=function(e){this.cookMaterials(),t.prototype._onMaterialModified.call(this,e,this.getMaterialInstance(e))},i.cook=function(){this.cookMaterials(),this.cookSkeletons(),this.cookMeshes()},i.cookMaterials=function(){var t=this;this._batchMaterial||(this._batchMaterial=this.getMaterial(0));var e=this.getMaterialInstance(0);if(e&&this._batchMaterial&&this._batchMaterial.effectAsset){e.copy(this._batchMaterial),this.resizeAtlases();for(var i=e.effectAsset.techniques[e.technique],r=function(r){var n=i.passes[r];if(!n.properties)return"continue";var s=function(i){if(n.properties[i].type>=p.SAMPLER1D){var s=null;t.batchableTextureNames.find((function(t){return t===i}))?((s=t._textures[i])||(s=t.createTexture(i)),t.cookTextures(s,i,r)):t.units.some((function(t){return s=t.material&&t.material.getProperty(i,r)})),s&&e.setProperty(i,s,r)}else{for(var a=[],o=0;o<t.units.length;o++){var l=t.units[o];l.material&&a.push(l.material.getProperty(i.slice(0,-3),r))}e.setProperty(i,a,r)}};for(var a in n.properties)s(a)},n=0;n<i.passes.length;n++)r(n)}else console.warn("incomplete batch material!")},i.cookSkeletons=function(){if(this._skinningRoot){for(var t=[],e=[],i=0;i<this.units.length;i++){var r=this.units[i];if(r&&r.skeleton){var n=r.skeleton;Ri.invert(Iu,r._localTransform);for(var s=function(i){var r=n.joints[i];if(t.findIndex((function(t){return t===r}))>=0)return"continue";t.push(r),e.push(Ri.multiply(new Ri,n.bindposes[i]||Ri.IDENTITY,Iu))},a=0;a<n.joints.length;a++)s(a)}}var o=Array.from(Array(t.length).keys()).sort((function(e,i){return t[e]>t[i]?1:t[e]<t[i]?-1:0})),l=new ul;l.joints=t.map((function(t,e,i){return i[o[e]]})),l.bindposes=e.map((function(t,e,i){return i[o[e]]})),this._skeleton&&this._skeleton.destroy(),this.skeleton=l}else console.warn("no skinning root specified!")},i.cookMeshes=function(){for(var t=this,e=!1,i=0;i<this.units.length;i++)if(this.units[i].mesh){e=!0;break}if(e&&this._skinningRoot){this._mesh?this._mesh.destroyRenderingMesh():this._mesh=new Na;for(var r=0,n=_.UNKNOWN,s=0,a=_.UNKNOWN,o=0,l=_.UNKNOWN,h=0,u=_.UNKNOWN,c=0,f=_.UNKNOWN,p=new Array(this.units.length),d=this.units.length,m=0;m<d;m++){var y=this.units[m];y&&y.skeleton&&(p[m]=y.skeleton.joints.map((function(e){return t._skeleton.joints.findIndex((function(t){return e===t}))})))}for(var g=function(e){var i=t.units[e];if(!i||!i.mesh||!i.mesh.data)return"continue";var d=t._createUnitMesh(e,i.mesh),m=new DataView(d.data.buffer);Ri.inverseTranspose(Iu,i._localTransform);for(var y=i.offset,g=i.size,v=function(t){var v=d.struct.vertexBundles[t];r=v.view.offset,n=_.UNKNOWN;for(var b=0;b<v.attributes.length;b++){var S=v.attributes[b];if(S.name===Ut.ATTR_POSITION){n=S.format;break}r+=Ht[S.format].size}if(n){for(var A=je(m,n,r,v.view.length,v.view.stride),C=0;C<A.length;C+=3)ii.fromArray(Ou,A,C),ii.transformMat4(Ou,Ou,i._localTransform),ii.toArray(A,Ou,C);fi(m,A,n,r,v.view.stride)}s=v.view.offset,a=_.UNKNOWN;for(var x=0;x<v.attributes.length;x++){var T=v.attributes[x];if(T.name===Ut.ATTR_NORMAL){a=T.format;break}s+=Ht[T.format].size}if(a){for(var w=je(m,a,s,v.view.length,v.view.stride),E=0;E<w.length;E+=3)ii.fromArray(Ou,w,E),ii.transformMat4Normal(Ou,Ou,Iu),ii.toArray(w,Ou,E);fi(m,w,a,s,v.view.stride)}o=v.view.offset,l=_.UNKNOWN;for(var B=0;B<v.attributes.length;B++){var D=v.attributes[B];if(D.name===Ut.ATTR_TANGENT){l=D.format;break}o+=Ht[D.format].size}if(l){for(var M=je(m,l,o,v.view.length,v.view.stride),P=0;P<M.length;P+=3)ii.fromArray(Ou,M,P),ii.transformMat4Normal(Ou,Ou,Iu),ii.toArray(M,Ou,P);fi(m,M,l,o,v.view.stride)}h=v.view.offset,u=_.UNKNOWN;for(var R=0;R<v.attributes.length;R++){var I=v.attributes[R];if(I.name===Ut.ATTR_BATCH_UV){u=I.format;break}h+=Ht[I.format].size}u&&di(m,(function(t,e){var i,r=0===e?"x":"y";return(t=(i=t)-Math.floor(i))*g[r]+y[r]}),u,h,v.view.length,v.view.stride,m);var O=p[e];if(!O)return"continue";c=v.view.offset,f=_.UNKNOWN;for(var F=0;F<v.attributes.length;F++){var L=v.attributes[F];if(L.name===Ut.ATTR_JOINTS){f=L.format;break}c+=Ht[L.format].size}f&&di(m,(function(t){return O[t]}),f,c,v.view.length,v.view.stride,m)},b=0;b<d.struct.vertexBundles.length;b++)v(b);t._mesh.merge(d)},v=0;v<d;v++)g(v);this._onMeshChanged(this._mesh),this._updateModels()}},i.cookTextures=function(t,e,i){for(var r=[],n=[],s=[],a=[],o=0;o<this.units.length;o++){var l=this.units[o];if(l.material){var h=l.material.getProperty(e,i);if(h&&h.image&&h.image.data){var u=new tt;u.texOffset.x=l.offset.x*this.atlasSize,u.texOffset.y=l.offset.y*this.atlasSize,u.texExtent.width=l.size.x*this.atlasSize,u.texExtent.height=l.size.y*this.atlasSize;var c=h.image.data;ArrayBuffer.isView(c)?(s.push(c),a.push(u)):(r.push(c),n.push(u))}}}var _=t.getGFXTexture(),f=He.director.root.device;s.length>0&&f.copyBuffersToTexture(s,_,a),r.length>0&&f.copyTexImagesToTexture(r,_,n)},i.createTexture=function(t){var e=new qe;return e.setFilters(_r.LINEAR,_r.LINEAR),e.setMipFilter(_r.NEAREST),e.reset({width:this.atlasSize,height:this.atlasSize,format:fr.RGBA8888}),e.loaded=!0,this._textures[t]=e,e},i.resizeAtlases=function(){for(var t in this._textures)this._textures[t].reset({width:this.atlasSize,height:this.atlasSize,format:fr.RGBA8888})},i._createUnitMesh=function(t,e){for(var i=JSON.parse(JSON.stringify(e.struct)),r={},n=0;n<e.struct.primitives.length;n++){for(var s=e.struct.primitives[n],a=0,o=_.UNKNOWN,l=0;l<s.vertexBundelIndices.length;l++){var h=e.struct.vertexBundles[s.vertexBundelIndices[l]];a=h.view.offset,o=_.UNKNOWN;for(var u=0;u<h.attributes.length;u++){var c=h.attributes[u];if(c.name===Ut.ATTR_TEX_COORD){o=c.format;break}a+=Ht[c.format].size}if(o)break}if(void 0===r[l]){r[l]=[o,a];var f=i.vertexBundles[l];f.attributes.push(Du),f.attributes.push(Mu),f.view.offset=0,f.view.length+=f.view.count*Pu,f.view.stride+=Pu}}for(var p=0,d=0;d<i.vertexBundles.length;d++)p+=i.vertexBundles[d].view.length;for(var m=0;m<i.primitives.length;m++){var y=i.primitives[m];y.indexView&&(y.indexView.offset=p,p+=y.indexView.length)}var g=new Uint8Array(p),v=e.data,b=new DataView(g.buffer),S=new DataView(v.buffer),A=He.sys.isLittleEndian;for(var C in r)for(var x=i.vertexBundles[C],T=e.struct.vertexBundles[C],w=r[C],E=w[0],B=w[1],D=je(S,E,B,T.view.length,T.view.stride),M=T.view,P=x.view,R=M.stride,I=P.stride,O=M.offset,F=P.offset,L=0;L<P.count;L++){var V=v.subarray(O,O+R);g.set(V,F),b.setFloat32(F+R,t),b.setFloat32(F+R+4,D[2*L],A),b.setFloat32(F+R+8,D[2*L+1],A),F+=I,O+=R}for(var k=0;k<i.primitives.length;k++){var N=e.struct.primitives[k],G=i.primitives[k];if(N.indexView&&G.indexView)for(var z=N.indexView.stride,U=G.indexView.stride,H=N.indexView.offset,j=G.indexView.offset,W=0;W<G.indexView.count;W++){var X=v.subarray(H,H+z);g.set(X,j),j+=U,H+=z}}var Y=new Na;return Y.reset({struct:i,data:g}),Y},Pe(e,[{key:"mesh",get:function(){return t.prototype.mesh},set:function(t){this.mesh=t}},{key:"skeleton",get:function(){return t.prototype.skeleton},set:function(t){this.skeleton=t}}]),e}(Bu),du=oi((pu=gu).prototype,"atlasSize",[_i,au],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1024}}),mu=oi(pu.prototype,"batchableTextureNames",[ou,_i,lu],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),yu=oi(pu.prototype,"units",[hu,_i,uu],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),oi(pu.prototype,"mesh",[pr,cu],Object.getOwnPropertyDescriptor(pu.prototype,"mesh"),pu.prototype),oi(pu.prototype,"skeleton",[pr,_u],Object.getOwnPropertyDescriptor(pu.prototype,"skeleton"),pu.prototype),fu=pu))||fu)||fu)||fu)||fu)||fu));He.SkinningModelComponent=Bu,Li.setClassAlias(Bu,"cc.SkinningModelComponent"),He.SkinningModelUnit=Ru,Li.setClassAlias(Ru,"cc.SkinningModelUnit"),He.BatchedSkinningModelComponent=Fu,Li.setClassAlias(Fu,"cc.BatchedSkinningModelComponent");var Lu,Vu,ku,Nu,Gu,zu,Uu,Hu,ju,Wu,Xu,Yu,qu,Ju,Ku,Zu,Qu,$u,tc,ec,ic=new Ri,rc=new Ri,nc=[],sc=t("SkeletalAnimationState",function(t){function e(e,i){var r;return void 0===i&&(i=""),(r=t.call(this,e,i)||this)._frames=1,r._bakedDuration=0,r._animInfo=null,r._sockets=[],r._animInfoMgr=void 0,r._comps=[],r._parent=null,r._curvesInited=!1,r._animInfoMgr=He.director.root.dataPoolManager.jointAnimationInfo,r}Me(e,t);var i=e.prototype;return i.initialize=function(e){if(!this._curveLoaded){this._comps.length=0;for(var i=e.getComponentsInChildren(Bu),r=0;r<i.length;++r){var n=i[r];n.skinningRoot===e&&this._comps.push(n)}this._parent=e.getComponent("cc.SkeletalAnimation");var s=this._parent.useBakedAnimation;t.prototype.initialize.call(this,e,s?nc:void 0),this._curvesInited=!s;var a=Zi.getOrExtract(this.clip).info;this._frames=a.frames-1,this._animInfo=this._animInfoMgr.getData(e.uuid),this._bakedDuration=this._frames/a.sample}},i.onPlay=function(){if(t.prototype.onPlay.call(this),this._parent.useBakedAnimation){this._sampleCurves=this._sampleCurvesBaked,this.duration=this._bakedDuration,this._animInfoMgr.switchClip(this._animInfo,this.clip);for(var e=0;e<this._comps.length;++e)this._comps[e].uploadAnimation(this.clip)}else this._sampleCurves=t.prototype._sampleCurves,this.duration=this.clip.duration,this._curvesInited||(this._curveLoaded=!1,t.prototype.initialize.call(this,this._targetNode),this._curvesInited=!0)},i.rebuildSocketCurves=function(t){if(this._sockets.length=0,this._targetNode)for(var e=this._targetNode,i=0;i<t.length;++i){var r=t[i],n=e.getChildByPath(r.path);if(r.target){for(var s=Zi.getOrExtract(this.clip),a=r.path,o=s.data[a],l=n,h=void 0;!o;){var u=a.lastIndexOf("/");if(a=a.substring(0,u),o=s.data[a],l&&(h||(h=Ri.identity(rc)),Ri.fromRTS(ic,l.rotation,l.position,l.scale),Ri.multiply(h,ic,h),l=l.parent),u<0)break}for(var c=o&&o.worldMatrix.values,_=s.info.frames,f=[],p=0;p<_;p++){var d;d=c&&h?Ri.multiply(ic,c[p],h):c?c[p]:h||Ri.IDENTITY;var m={pos:new ii,rot:new si,scale:new ii};Ri.toRTS(d,m.rot,m.pos,m.scale),f.push(m)}this._sockets.push({target:r.target,frames:f})}}},i._sampleCurvesBaked=function(t){var e=this._animInfo,i=t*this._frames+.5|0;if(i!==e.data[0]){e.data[0]=i,e.dirty=!0;for(var r=0;r<this._sockets.length;++r){var n=this._sockets[r],s=n.target,a=n.frames[i],o=a.pos,l=a.rot,h=a.scale;s.setRTS(l,o,h)}}},e}(mr)),ac=t("Socket",(Lu=ri("cc.SkeletalAnimation.Socket"),Vu=bi(ur),Lu((Gu=oi((Nu=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),li(this,"path",Gu,this),li(this,"target",zu,this),this.path=t,this.target=e}).prototype,"path",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),zu=oi(Nu.prototype,"target",[Vu],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ku=Nu))||ku));Li.setClassAlias(ac,"cc.SkeletalAnimationComponent.Socket");var oc=new Ri,lc=new Ri;function hc(t,e,i){void 0===e&&(e=""),void 0===i&&(i=[]);for(var r=0;r<t.children.length;r++){var n=t.children[r];if(n){var s=e?e+"/"+n.name:n.name;i.push(s),hc(n,s,i)}}return i}var uc=function(e){return t({SkeletalAnimation:e,SkeletalAnimationComponent:e}),e}((Uu=ri("cc.SkeletalAnimation"),Hu=wi(),ju=Ei(99),Wu=Bi(),Xu=bi([ac]),Yu=Di(),qu=Di(),Ju=bi([ac]),Uu(Ku=Hu(Ku=ju(Ku=Si(Ku=Wu((ec=tc=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_useBakedAnimation",Qu,hi(e)),li(e,"_sockets",$u,hi(e)),e}Me(e,t);var i=e.prototype;return i.onDestroy=function(){t.prototype.onDestroy.call(this),He.director.root.dataPoolManager.jointAnimationInfo.destroy(this.node.uuid),He.director.getAnimationManager().removeSockets(this.node,this._sockets)},i.start=function(){this.sockets=this._sockets,this.useBakedAnimation=this._useBakedAnimation,t.prototype.start.call(this)},i.querySockets=function(){var t=this._defaultClip&&Object.keys(Zi.getOrExtract(this._defaultClip).data).sort().reduce((function(t,e){return e.startsWith(t[t.length-1])||t.push(e),t}),[])||[];if(!t.length)return["please specify a valid default animation clip first"];for(var e=[],i=0;i<t.length;i++){var r=t[i],n=this.node.getChildByPath(r);n&&(e.push(r),hc(n,r,e))}return e},i.rebuildSocketAnimations=function(){for(var t,e=Fe(this._sockets);!(t=e()).done;){var i=t.value,r=this.node.getChildByPath(i.path),n=i.target;r&&n&&(n.name=i.path.substring(i.path.lastIndexOf("/")+1)+" Socket",n.parent=this.node,Ki(r,this.node,oc),Ri.fromRTS(lc,n.rotation,n.position,n.scale),Ri.equals(lc,oc)||(n.matrix=oc))}for(var s=0,a=Object.keys(this._nameToState);s<a.length;s++){var o=a[s];this._nameToState[o].rebuildSocketCurves(this._sockets)}},i.createSocket=function(t){var e=this._sockets.find((function(e){return e.path===t}));if(e)return e.target;if(!this.node.getChildByPath(t))return console.warn("illegal socket path"),null;var i=new ur;return i.parent=this.node,this._sockets.push(new ac(t,i)),this.rebuildSocketAnimations(),i},i._createState=function(t,e){return new sc(t,e)},i._doCreateState=function(e,i){var r=t.prototype._doCreateState.call(this,e,i);return r.rebuildSocketCurves(this._sockets),r},Pe(e,[{key:"sockets",get:function(){return this._sockets},set:function(t){if(!this._useBakedAnimation){var e=He.director.getAnimationManager();e.removeSockets(this.node,this._sockets),e.addSockets(this.node,t)}this._sockets=t,this.rebuildSocketAnimations()}},{key:"useBakedAnimation",get:function(){return this._useBakedAnimation},set:function(t){this._useBakedAnimation=t;for(var e=this.node.getComponentsInChildren(Bu),i=0;i<e.length;++i){var r=e[i];r.skinningRoot===this.node&&r.setUseBakedAnimation(this._useBakedAnimation)}this._useBakedAnimation?He.director.getAnimationManager().removeSockets(this.node,this._sockets):He.director.getAnimationManager().addSockets(this.node,this._sockets)}}]),e}(yr),tc.Socket=ac,oi((Zu=ec).prototype,"sockets",[Xu,Yu],Object.getOwnPropertyDescriptor(Zu.prototype,"sockets"),Zu.prototype),oi(Zu.prototype,"useBakedAnimation",[qu],Object.getOwnPropertyDescriptor(Zu.prototype,"useBakedAnimation"),Zu.prototype),Qu=oi(Zu.prototype,"_useBakedAnimation",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),$u=oi(Zu.prototype,"_sockets",[Ju],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ku=Zu))||Ku)||Ku)||Ku)||Ku)||Ku));He.SkeletalAnimationComponent=uc,Li.setClassAlias(uc,"cc.SkeletalAnimationComponent"),He.utils=qa;var cc=new ii,_c=new Ri;function fc(t,e,i,r){var n=i.data,s=e.acquireBufferBatch(),a=s.byteOffset>>2,o=i.vertexCount,l=s.indicesOffset,h=s.vertexOffset;s.request(o,i.indicesCount)||(s=e.currBufferBatch,o=0,l=0,h=0);var u=s.vData,c=s.iData;t.getWorldMatrix(_c);for(var _=0;_<o;_++){var f=n[_];ii.set(cc,f.x,f.y,0),ii.transformMat4(cc,cc,_c),u[a++]=cc.x,u[a++]=cc.y,u[a++]=cc.z,u[a++]=f.u,u[a++]=f.v,Ui.toArray(u,r,a),a+=4}for(var p=0,d=o/4;p<d;p++){var m=h+4*p;c[l++]=m,c[l++]=m+1,c[l++]=m+2,c[l++]=m+1,c[l++]=m+3,c[l++]=m+2}}var pc=function(){function t(t,e){this._texture=void 0,this._width=void 0,this._height=void 0,this._x=void 0,this._y=void 0,this._nexty=void 0,this._innerTextureInfos={},this._innerSpriteFrames=void 0,this._count=void 0;var i=new dc;i.initWithSize(t,e),this._texture=i,this._width=t,this._height=e,this._x=2,this._y=2,this._nexty=2,this._innerTextureInfos={},this._innerSpriteFrames=[],this._count=0}var e=t.prototype;return e.insertSpriteFrame=function(t){var e=t.rect,i=t.texture,r=this._innerTextureInfos[i.getId()],n=e.x,s=e.y;if(r)n+=r.x,s+=r.y;else{var a=i.width,o=i.height;if(this._x+a+2>this._width&&(this._x=2,this._y=this._nexty),this._y+o+2>this._nexty&&(this._nexty=this._y+o+2),this._nexty>this._height)return null;He.internal.dynamicAtlasManager.textureBleeding&&((a<=8||o<=8)&&(this._texture.drawTextureAt(i.image,this._x-1,this._y-1),this._texture.drawTextureAt(i.image,this._x-1,this._y+1),this._texture.drawTextureAt(i.image,this._x+1,this._y-1),this._texture.drawTextureAt(i.image,this._x+1,this._y+1)),this._texture.drawTextureAt(i.image,this._x-1,this._y),this._texture.drawTextureAt(i.image,this._x+1,this._y),this._texture.drawTextureAt(i.image,this._x,this._y-1),this._texture.drawTextureAt(i.image,this._x,this._y+1)),this._texture.drawTextureAt(i.image,this._x,this._y),this._innerTextureInfos[i.getId()]={x:this._x,y:this._y,texture:i},this._count++,n+=this._x,s+=this._y,this._x+=a+2}var l={x:n,y:s,texture:this._texture};return this._innerSpriteFrames.push(t),l},e.deleteInnerTexture=function(t){t&&this._innerTextureInfos[t.getId()]&&(delete this._innerTextureInfos[t.getId()],this._count--)},e.isEmpty=function(){return this._count<=0},e.reset=function(){this._x=2,this._y=2,this._nexty=2;for(var t=this._innerSpriteFrames,e=0,i=t.length;e<i;e++){var r=t[e];r.isValid&&r._resetDynamicAtlasFrame()}this._innerSpriteFrames.length=0,this._innerTextureInfos={}},e.destroy=function(){this.reset(),this._texture.destroy()},t}(),dc=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=fr.RGBA8888),this.reset({width:t,height:e,format:i}),this.loaded=!0,this.emit("load")},i.drawTextureAt=function(t,e,i){var r=this.getGFXTexture();if(t&&r){var n=this._getGFXDevice();if(n){var s=new tt;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,n.copyTexImagesToTexture([t.data],r,[s])}else console.warn("Unable to get device")}},e}(qe),mc=function(){function t(){this._atlases=[],this._atlasIndex=-1,this._maxAtlasCount=5,this._textureSize=2048,this._maxFrameSize=512,this._textureBleeding=!0,this._enabled=!1}var e=t.prototype;return e.newAtlas=function(){var t=this._atlases[++this._atlasIndex];return t||(t=new pc(this._textureSize,this._textureSize),this._atlases.push(t)),t},e.beforeSceneLoad=function(){this.reset()},e.insertSpriteFrame=function(t){if(!this._enabled||this._atlasIndex===this._maxAtlasCount||!t||t._original)return null;if(!t.packable)return null;var e=this._atlases[this._atlasIndex];e||(e=this.newAtlas());var i=e.insertSpriteFrame(t);return i||this._atlasIndex===this._maxAtlasCount?i:(e=this.newAtlas()).insertSpriteFrame(t)},e.reset=function(){for(var t=0,e=this._atlases.length;t<e;t++)this._atlases[t].destroy();this._atlases.length=0,this._atlasIndex=-1},e.deleteAtlasSpriteFrame=function(t){if(t._original){var e=t._original._texture;this.deleteAtlasTexture(e)}},e.deleteAtlasTexture=function(t){if(t)for(var e=this._atlases.length-1;e>=0;e--)this._atlases[e].deleteInnerTexture(t),this._atlases[e].isEmpty()&&(this._atlases[e].destroy(),this._atlases.splice(e,1),this._atlasIndex--)},e.packToDynamicAtlas=function(t,e){if(!e._original&&e.packable){var i=this.insertSpriteFrame(e);i&&e._setDynamicAtlasFrame(i)}},Pe(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(t?(this.reset(),He.director.on(He.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),He.director.off(He.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)),this._enabled=t)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(t){this._maxAtlasCount=t}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(t){this._textureBleeding=t}},{key:"textureSize",get:function(){return this._textureSize},set:function(t){this._textureSize=t}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(t){this._maxFrameSize=t}}]),t}();mc.instance=void 0;var yc,gc=t("dynamicAtlasManager",mc.instance=new mc);He.internal.dynamicAtlasManager=gc;var vc,bc,Sc,Ac,Cc=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],xc=t("SpriteFrame",ri("cc.SpriteFrame")(yc=function(t){function e(){var e;return(e=t.call(this)||this).vertices=null,e.uv=[],e.uvHash=0,e.unbiasUV=[],e.uvSliced=[],e._rect=new gr,e._offset=new dr,e._originalSize=new vr,e._rotated=!1,e._capInsets=[0,0,0,0],e._atlasUuid="",e._texture=void 0,e._isFlipUVY=!1,e._isFlipUVX=!1,e._original=null,e._packable=!0,e}Me(e,t),e.createWithImage=function(t){var i=t instanceof Ye?t:new Ye(t),r=new qe;r.image=i;var n=new e;return n.texture=r,n};var i=e.prototype;return i.textureLoaded=function(){return this.texture&&this.texture.loaded},i.isRotated=function(){return this._rotated},i.setRotated=function(t){this.rotated=t},i.getRect=function(t){return t?(t.set(this._rect),t):this._rect.clone()},i.setRect=function(t){this.rect=t},i.getOriginalSize=function(t){return t?(t.set(this._originalSize),t):this._originalSize.clone()},i.setOriginalSize=function(t){this.originalSize=t},i.getOffset=function(t){return t?(t.set(this._offset),t):this._offset.clone()},i.setOffset=function(t){this.offset=t},i.getGFXTexture=function(){return this._texture.getGFXTexture()},i.getGFXSampler=function(){return this._texture.getGFXSampler()},i.getHash=function(){return this._texture.getHash()},i.getSamplerHash=function(){return this._texture.getSamplerHash()},i.reset=function(t,e){void 0===e&&(e=!1);var i=!1;e&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,i=!0),t&&(t.texture&&(this.loaded=!1,this._rect.x=this._rect.y=0,this._rect.width=t.texture.width,this._rect.height=t.texture.height,this._refreshTexture(t.texture),this.checkRect(this._texture)),t.originalSize&&this._originalSize.set(t.originalSize),t.rect&&this._rect.set(t.rect),t.offset&&this._offset.set(t.offset),void 0!==t.borderTop&&(this._capInsets[1]=t.borderTop),void 0!==t.borderBottom&&(this._capInsets[3]=t.borderBottom),void 0!==t.borderLeft&&(this._capInsets[0]=t.borderLeft),void 0!==t.borderRight&&(this._capInsets[2]=t.borderRight),void 0!==t.isRotate&&(this._rotated=!!t.isRotate),void 0!==t.isFlipUv&&(this._isFlipUVY=!!t.isFlipUv),i=!0),i&&this.texture&&this._calculateUV()},i.checkRect=function(t){var e=this._rect,i=e.x,r=e.y;return this._rotated?(i+=e.height,r+=e.width):(i+=e.width,r+=e.height),i>t.width?(Re(3300,this.name+"/"+t.name,i,t.width),!1):!(r>t.height&&(Re(3301,this.name+"/"+t.name,r,t.height),1))},i.onLoaded=function(){this.loaded=!0,this.emit("load")},i.destroy=function(){return this._packable&&gc&&gc.deleteAtlasSpriteFrame(this),t.prototype.destroy.call(this)},i._calculateSlicedUV=function(){var t=this._rect,e=this.texture,i=e.width,r=e.height,n=this._capInsets[0],s=this._capInsets[2],a=t.width-n-s,o=this._capInsets[1],l=this._capInsets[3],h=t.height-o-l,u=this.uvSliced;if(u.length=0,this._rotated){Cc[0].u=t.x/i,Cc[1].u=(t.x+l)/i,Cc[2].u=(t.x+l+h)/i,Cc[3].u=(t.x+t.height)/i,Cc[3].v=t.y/r,Cc[2].v=(t.y+n)/r,Cc[1].v=(t.y+n+a)/r,Cc[0].v=(t.y+t.width)/r;for(var c=0;c<4;++c)for(var _=Cc[c],f=0;f<4;++f){var p=Cc[3-f];u.push({u:_.u,v:p.v})}}else{Cc[0].u=t.x/i,Cc[1].u=(t.x+n)/i,Cc[2].u=(t.x+n+a)/i,Cc[3].u=(t.x+t.width)/i,Cc[3].v=t.y/r,Cc[2].v=(t.y+o)/r,Cc[1].v=(t.y+o+h)/r,Cc[0].v=(t.y+t.height)/r;for(var d=0;d<4;++d)for(var m=Cc[d],y=0;y<4;++y){var g=Cc[y];u.push({u:g.u,v:m.v})}}},i._calculateUV=function(){var t=this._rect,e=this.uv,i=this.unbiasUV,r=this.texture,n=r.width,s=r.height;if(this._rotated){var a=0===n?0:t.x/n,o=0===n?1:(t.x+t.height)/n,l=0===s?0:t.y/s,h=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=o,e[1]=h,e[2]=o,e[3]=l,e[4]=a,e[5]=h,e[6]=a,e[7]=l):this._isFlipUVX?(e[0]=o,e[1]=l,e[2]=o,e[3]=h,e[4]=a,e[5]=l,e[6]=a,e[7]=h):this._isFlipUVY?(e[0]=a,e[1]=h,e[2]=a,e[3]=l,e[4]=o,e[5]=h,e[6]=o,e[7]=l):(e[0]=a,e[1]=l,e[2]=a,e[3]=h,e[4]=o,e[5]=l,e[6]=o,e[7]=h);var u=0===n?0:t.x/n,c=0===n?1:(t.x+t.height)/n,_=0===s?0:t.y/s,f=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=c,i[1]=f,i[2]=c,i[3]=_,i[4]=u,i[5]=f,i[6]=u,i[7]=_):this._isFlipUVX?(i[0]=c,i[1]=_,i[2]=c,i[3]=f,i[4]=u,i[5]=_,i[6]=u,i[7]=f):this._isFlipUVY?(i[0]=u,i[1]=f,i[2]=u,i[3]=_,i[4]=c,i[5]=f,i[6]=c,i[7]=_):(i[0]=u,i[1]=_,i[2]=u,i[3]=f,i[4]=c,i[5]=_,i[6]=c,i[7]=f)}else{var p=0===n?0:t.x/n,d=0===n?1:(t.x+t.width)/n,m=0===s?1:(t.y+t.height)/s,y=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=d,e[1]=y,e[2]=p,e[3]=y,e[4]=d,e[5]=m,e[6]=p,e[7]=m):this._isFlipUVX?(e[0]=d,e[1]=m,e[2]=p,e[3]=m,e[4]=d,e[5]=y,e[6]=p,e[7]=y):this._isFlipUVY?(e[0]=p,e[1]=y,e[2]=d,e[3]=y,e[4]=p,e[5]=m,e[6]=d,e[7]=m):(e[0]=p,e[1]=m,e[2]=d,e[3]=m,e[4]=p,e[5]=y,e[6]=d,e[7]=y);var g=0===n?0:t.x/n,v=0===n?1:(t.x+t.width)/n,b=0===s?1:(t.y+t.height)/s,S=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=v,i[1]=S,i[2]=g,i[3]=S,i[4]=v,i[5]=b,i[6]=g,i[7]=b):this._isFlipUVX?(i[0]=v,i[1]=b,i[2]=g,i[3]=b,i[4]=v,i[5]=S,i[6]=g,i[7]=S):this._isFlipUVY?(i[0]=g,i[1]=S,i[2]=v,i[3]=S,i[4]=g,i[5]=b,i[6]=v,i[7]=b):(i[0]=g,i[1]=b,i[2]=v,i[3]=b,i[4]=g,i[5]=S,i[6]=v,i[7]=S)}for(var A="",C=0;C<e.length;C++)A+=e[C];this.uvHash=ci(A,666);var x=this.vertices;if(x){x.nu.length=0,x.nv.length=0;for(var T=0;T<x.u.length;T++)x.nu[T]=x.u[T]/n,x.nv[T]=x.v[T]/s}this._calculateSlicedUV()},i._setDynamicAtlasFrame=function(t){t&&(this._original={_texture:this._texture,_x:this._rect.x,_y:this._rect.y},this._texture=t.texture,this._rect.x=t.x,this._rect.y=t.y,this._calculateUV())},i._resetDynamicAtlasFrame=function(){this._original&&(this._rect.x=this._original._x,this._rect.y=this._original._y,this._texture=this._original._texture,this._original=null,this._calculateUV())},i._checkPackable=function(){var t=gc;if(t){var e=this._texture;if(e instanceof qe&&!e.isCompressed){var i=this.width,r=this.height;!e.image||i>t.maxFrameSize||r>t.maxFrameSize?this._packable=!1:e.image&&e.image instanceof HTMLCanvasElement&&(this._packable=!0)}else this._packable=!1}},i._serialize=function(){return null},i._deserialize=function(t){var e=t,i=e.rect;i&&(this._rect=new gr(i.x,i.y,i.width,i.height));var r=e.offset;e.offset&&(this._offset=new dr(r.x,r.y));var n=e.originalSize;e.originalSize&&(this._originalSize=new vr(n.width,n.height)),this._rotated=!!e.rotated,this._name=e.name,this._packable=!!e.packable;var s=e.capInsets;s&&(this._capInsets[0]=s[0],this._capInsets[1]=s[1],this._capInsets[2]=s[2],this._capInsets[3]=s[3]),this.vertices=e.vertices,this.vertices&&(this.vertices.nu=[],this.vertices.nv=[])},i.clone=function(){var t,i,r,n,s,a,o,l,h=new e,u=this.vertices;return h.vertices=u?{x:u.x,y:u.y,triangles:u.triangles,nu:null===(t=u.nu)||void 0===t?void 0:t.slice(0),u:null===(i=u.u)||void 0===i?void 0:i.slice(0),nv:null===(r=u.nv)||void 0===r?void 0:r.slice(0),v:null===(n=u.v)||void 0===n?void 0:n.slice(0)}:null,(s=h.uv).splice.apply(s,[0,h.uv.length].concat(this.uv)),h.uvHash=this.uvHash,(a=h.unbiasUV).splice.apply(a,[0,h.unbiasUV.length].concat(this.unbiasUV)),(o=h.uvSliced).splice.apply(o,[0,h.uvSliced.length].concat(this.uvSliced)),h._rect.set(this._rect),h._offset.set(this._offset),h._originalSize.set(this._originalSize),h._rotated=this._rotated,(l=h._capInsets).splice.apply(l,[0,h._capInsets.length].concat(this._capInsets)),h._atlasUuid=this._atlasUuid,h._texture=this._texture,h._isFlipUVX=this._isFlipUVX,h._isFlipUVY=this._isFlipUVY,h},i._textureLoaded=function(){var t=this._texture,e={},i=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(t)||(e.rect=new gr(0,0,t.width,t.height),i=!0),(0===this._originalSize.width||0===this._originalSize.height||i)&&(e.originalSize=new vr(t.width,t.height),i=!0),i&&(this.reset(e),this.onLoaded()),this._checkPackable()},i._refreshTexture=function(t){this._texture=t,t.loaded?this._textureLoaded():t.once("load",this._textureLoaded,this)},i.initDefault=function(e){t.prototype.initDefault.call(this,e);var i=new qe;i.initDefault(),this._refreshTexture(i),this._calculateUV()},i.validate=function(){return this._texture&&this._rect&&0!==this._rect.width&&0!==this._rect.height},Pe(e,[{key:"insetTop",get:function(){return this._capInsets[1]},set:function(t){this._capInsets[1]!==t&&(this._capInsets[1]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetBottom",get:function(){return this._capInsets[3]},set:function(t){this._capInsets[3]!==t&&(this._capInsets[3]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetLeft",get:function(){return this._capInsets[0]},set:function(t){this._capInsets[0]!==t&&(this._capInsets[0]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetRight",get:function(){return this._capInsets[2]},set:function(t){this._capInsets[2]!==t&&(this._capInsets[2]=t,this._texture&&this._calculateSlicedUV())}},{key:"rect",get:function(){return this._rect},set:function(t){this._rect.equals(t)||(this._rect.set(t),this._texture&&this._calculateUV())}},{key:"originalSize",get:function(){return this._originalSize},set:function(t){this._originalSize.equals(t)||(this._originalSize.set(t),this._texture&&this._calculateUV())}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t)}},{key:"rotated",get:function(){return this._rotated},set:function(t){this._rotated!==t&&(this._rotated=t,this._texture&&this._calculateUV())}},{key:"texture",get:function(){return this._texture},set:function(t){t?this.reset({texture:t},!0):console.warn("Error Texture in "+this.name)}},{key:"atlasUuid",get:function(){return this._atlasUuid},set:function(t){this._atlasUuid=t}},{key:"width",get:function(){return this._texture.width}},{key:"height",get:function(){return this._texture.height}},{key:"_textureSource",set:function(t){window.Build?this._texture=t:t&&(this._refreshTexture(t),this._calculateUV())}},{key:"flipUVX",get:function(){return this._isFlipUVX},set:function(t){this._isFlipUVX=t,this._calculateUV()}},{key:"flipUVY",get:function(){return this._isFlipUVY},set:function(t){this._isFlipUVY=t,this._calculateUV()}},{key:"packable",get:function(){return this._packable},set:function(t){this._packable=t}},{key:"original",get:function(){return this._original}}]),e}(ai))||yc);He.SpriteFrame=xc;var Tc,wc=t("SpriteAtlas",ri("cc.SpriteAtlas")((Ac=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"spriteFrames",Sc,hi(e)),e}Me(e,t);var i=e.prototype;return i.getTexture=function(){var t=Object.keys(this.spriteFrames);if(t.length>0){var e=this.spriteFrames[t[0]];return e&&e.texture}return null},i.getSpriteFrame=function(t){var e=this.spriteFrames[t];return e?(e.name||(e.name=t),e):null},i.getSpriteFrames=function(){for(var t=[],e=this.spriteFrames,i=0,r=Object.keys(e);i<r.length;i++){var n=r[i];t.push(e[n])}return t},i._serialize=function(){},i._deserialize=function(t,e){var i=t;this._name=i.name;var r=i.spriteFrames;this.spriteFrames=br();for(var n=0;n<r.length;n+=2)e.result.push(this.spriteFrames,r[n],r[n+1],Sr(xc))},e}(ai),Sc=oi((bc=Ac).prototype,"spriteFrames",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return br()}}),vc=bc))||vc);He.SpriteAtlas=wc;var Ec,Bc,Dc,Mc,Pc=t("Font",ri("cc.Font")(Tc=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e}(ai))||Tc);He.Font=Pc;var Rc,Ic,Oc,Fc,Lc,Vc,kc,Nc,Gc,zc=t("TTFFont",ri("cc.TTFFont")((Mc=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_fontFamily",Dc,hi(e)),e}return Me(e,t),Pe(e,[{key:"_nativeAsset",get:function(){return this._fontFamily},set:function(t){this._fontFamily=t||"Arial"}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,__nativeName__:this._native,ext:Cr(this._native),__isNative__:!0}}}]),e}(Pc),Dc=oi((Bc=Mc).prototype,"_fontFamily",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(Bc.prototype,"_nativeAsset",[pr,Ar],Object.getOwnPropertyDescriptor(Bc.prototype,"_nativeAsset"),Bc.prototype),oi(Bc.prototype,"_nativeDep",[pr],Object.getOwnPropertyDescriptor(Bc.prototype,"_nativeDep"),Bc.prototype),Ec=Bc))||Ec);He.TTFFont=zc;var Uc,Hc=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.offsetX=0,this.offsetY=0,this.textureID=0,this.valid=!1,this.xAdvance=0},jc=function(){function t(t){this.letterDefinitions={},this.texture=t}var e=t.prototype;return e.addLetterDefinitions=function(t,e){this.letterDefinitions[t]=e},e.cloneLetterDefinition=function(){for(var t={},e=0,i=Object.keys(this.letterDefinitions);e<i.length;e++){var r=i[e],n=new Hc;xr(n,this.letterDefinitions[r]),t[r]=n}return t},e.getTexture=function(){return this.texture},e.getLetter=function(t){return this.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t){var e=t.charCodeAt(0);return this.letterDefinitions.hasOwnProperty(e)?this.letterDefinitions[e]:null},e.clear=function(){this.letterDefinitions={}},t}(),Wc=t("BitmapFont",(Rc=ri("cc.BitmapFont"),Ic=bi(xc),Rc((Gc=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"fntDataStr",Lc,hi(e)),li(e,"spriteFrame",Vc,hi(e)),li(e,"fontSize",kc,hi(e)),li(e,"fntConfig",Nc,hi(e)),e}return Me(e,t),e.prototype.onLoaded=function(){var t=this.spriteFrame;!this.fontDefDictionary&&t&&(this.fontDefDictionary=new jc(t.texture));var e=this.fntConfig;if(e){var i=e.fontDefDictionary;for(var r in i){var n=new Hc,s=i[r].rect;n.offsetX=i[r].xOffset,n.offsetY=i[r].yOffset,n.w=s.width,n.h=s.height,n.u=s.x,n.v=s.y,n.textureID=0,n.valid=!0,n.xAdvance=i[r].xAdvance,this.fontDefDictionary.addLetterDefinitions(r,n)}}else Ue("The fnt config is not exists!")},e}(Pc),Lc=oi((Fc=Gc).prototype,"fntDataStr",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Vc=oi(Fc.prototype,"spriteFrame",[Ic],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),kc=oi(Fc.prototype,"fontSize",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Nc=oi(Fc.prototype,"fntConfig",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Oc=Fc))||Oc));He.BitmapFont=Wc;var Xc=t("LabelAtlas",ri("cc.LabelAtlas")(Uc=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e}(Wc))||Uc);He.LabelAtlas=Xc;var Yc=t("BASELINE_RATIO",.26),qc=t("MIDDLE_RATIO",(Yc+1)/2-Yc);var Jc=new Tr(2);Jc.get=function(){return this._get()||{key:"",value:0,prev:null,next:null}};var Kc,Zc=new(function(){function t(t){this.count=0,this.limit=0,this.datas={},this.limit=t}var e=t.prototype;return e.moveToHead=function(t){t.next=this.head,t.prev=null,this.head&&(this.head.prev=t),this.head=t,this.tail||(this.tail=t),this.count++,this.datas[t.key]=t},e.put=function(t,e){var i=Jc.get();if(i.key=t,i.value=e,this.count>=this.limit){var r=this.tail;delete this.datas[r.key],this.count--,this.tail=r.prev,this.tail.next=null,r.prev=null,r.next=null,Jc.put(r)}this.moveToHead(i)},e.remove=function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.datas[t.key],this.count--},e.get=function(t){var e=this.datas[t];return e?(this.remove(e),this.moveToHead(e),e.value):null},e.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},e.has=function(t){return!!this.datas[t]},e.delete=function(t){var e=this.datas[t];this.remove(e)},t}())(100),Qc=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,$c=/^[!,.:;'}\]%\?>、‘“》?。,!]/,t_=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,e_=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,i_=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/;function r_(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)}function n_(t){var e=t.charCodeAt(0);return e>=9&&e<=13||32===e||133===e||160===e||5760===e||e>=8192&&e<=8202||8232===e||8233===e||8239===e||8287===e||12288===e}function s_(t,e,i){var r=(i||t.font)+"🎮"+e,n=Zc.get(r);if(null!==n)return n;var s=t.measureText(e),a=s&&s.width||0;return Zc.put(r,a),a}function a_(t,e,i){var r=e,n=i,s=t[e];if(s>="\udc00"&&s<="\udfff"&&r--,void 0!==i)if(i-1!==e){var a=t[i-1];a>="\ud800"&&a<="\udbff"&&n--}else s>="\ud800"&&s<="\udbff"&&n++;return t.substring(r,n)}function o_(t,e,i,r){var n=[];if(0===t.length||i<0)return n.push(""),n;for(var s=t;e>i&&s.length>1;){for(var a=s.length*(i/e)|0,o=a_(s,a),l=e-r(o),h=o,u=0,c=0;l>i&&c++<10;)a*=i/l,l=e-r(o=a_(s,a|=0));for(c=0;l<=i&&c++<10;){if(o){var _=Qc.exec(o);u=_?_[0].length:1,h=o}l=e-r(o=a_(s,a+=u))}0==(a-=u)?(a=1,h=a_(s,1)):1===a&&s[0]>="\ud800"&&s[0]<="\udbff"&&(a=2,h=a_(s,2));var f=a_(s,0,a),p=void 0;$c.test(h||o)&&(0==(a-=(p=t_.exec(f))?p[0].length:0)&&(a=1),h=a_(s,a),f=a_(s,0,a)),i_.test(h)&&(p=e_.exec(f))&&f!==p[0]&&(h=a_(s,a-=p[0].length),f=a_(s,0,a)),(0===n.length||(f=f.trim()).length>0)&&n.push(f),e=r(s=h||o)}return(0===n.length||(s=s.trim()).length>0)&&n.push(s),n}var l_,h_,u_,c_,__,f_,p_,d_,m_,y_,g_,v_,b_,S_,A_,C_=t("CanvasPool",function(){function t(){this.pool=[]}t.getInstance=function(){return Kc||(Kc=new t),Kc};var e=t.prototype;return e.get=function(){var t=this.pool.pop();if(!t){var e=document.createElement("canvas"),i=e.getContext("2d");t={canvas:e,context:i}}return t},e.put=function(t){this.pool.length>=Oe.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}()),x_=Ui.WHITE.clone(),T_=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},w_="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",E_=function(){function t(t,e){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=t,this.labelInfo=e,this.hash=t.charCodeAt(0)+e.hash}var e=t.prototype;return e.updateRenderData=function(){this._updateProperties(),this._updateTexture()},e.destroy=function(){this.image=null},e._updateProperties=function(){if(this.data=C_.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){this.context.font=this.labelInfo.fontDesc;var t=s_(this.context,this.char,this.labelInfo.fontDesc),e=2*this.labelInfo.margin+2;this.width=parseFloat(t.toFixed(2))+e,this.height=(1+Yc)*this.labelInfo.fontSize+e,this.offsetY=-this.labelInfo.fontSize*Yc/2}this.canvas.width!==this.width&&(this.canvas.width=this.width),this.canvas.height!==this.height&&(this.canvas.height=this.height),this.image||(this.image=new Ye),this.image.reset(this.canvas)},e._updateTexture=function(){if(this.context&&this.canvas){var t=this.context,e=this.labelInfo,i=this.canvas.width,r=this.canvas.height;t.textAlign="center",t.textBaseline="alphabetic",t.clearRect(0,0,i,r),t.fillStyle=w_,t.fillRect(0,0,i,r),t.font=e.fontDesc;var n=e.fontSize,s=i/2,a=r/2+n*qc+0*n,o=e.color;if(t.lineJoin="round",t.fillStyle="rgba("+o.r+", "+o.g+", "+o.b+", 1)",e.isOutlined){var l=e.out||x_;t.strokeStyle="rgba("+l.r+", "+l.g+", "+l.b+", "+l.a/255+")",t.lineWidth=2*e.margin,t.strokeText(this.char,s,a)}t.fillText(this.char,s,a)}},t}(),B_=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=fr.RGBA8888),this.reset({width:t,height:e,format:i}),this.loaded=!0,this.emit("load")},i.drawTextureAt=function(t,e,i){var r=this.getGFXTexture();if(t&&r){var n=this._getGFXDevice();if(n){var s=new tt;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,n.copyTexImagesToTexture([t.data],r,[s])}else console.warn("Unable to get device")}},e}(qe),D_=function(){function t(t,e){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var i=new B_;i.initWithSize(t,e),this.fontDefDictionary=new jc(i),this._halfBleed=1,this._width=t,this._height=e,wr.on(Er.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=wr.root.device;if(!e||!this.fontDefDictionary||!i)return null;var r=e.width,n=e.height;if(this._x+r+0>this._width&&(this._x=0,this._y=this._nextY),this._y+n>this._nextY&&(this._nextY=this._y+n+0),this._nextY>this._height)return ze(12100),null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new T_;return s.u=this._x+this._halfBleed,s.v=this._y+this._halfBleed,s.texture=this.fontDefDictionary.texture,s.valid=!0,s.w=t.width-2,s.h=t.height-2,s.xAdvance=s.w,s.offsetY=t.offsetY,this._x+=r+0,this.fontDefDictionary.addLetterDefinitions(t.hash,s),s},e.update=function(){this._dirty&&(this._dirty=!1)},e.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},e.destroy=function(){this.reset(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},e.getTexture=function(){return this.fontDefDictionary.getTexture()},e.beforeSceneLoad=function(){this.clearAllCache()},e.clearAllCache=function(){this.destroy();var t=new B_;t.initWithSize(this._width,this._height),this.fontDefDictionary.texture=t},e.getLetter=function(t){return this.fontDefDictionary.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t,e){var i=t.charCodeAt(0)+e.hash,r=this.fontDefDictionary.letterDefinitions[i];if(!r){var n=new E_(t,e);n.updateRenderData(),r=this.insertLetterTexture(n),n.destroy()}return r},Pe(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(),M_={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:Ui.WHITE.clone(),isOutlined:!1,out:Ui.WHITE.clone(),margin:0},P_=function(){this.material=null,this.vertexCount=0,this.indicesCount=0},R_=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).vData=null,e.uvDirty=!0,e.vertDirty=!0,e._data=[],e._indices=[],e._pivotX=0,e._pivotY=0,e._width=0,e._height=0,e}Me(e,t),e.add=function(){return F_.add()},e.remove=function(t){var e=F_.data.indexOf(t);-1!==e&&(F_.data[e].clear(),F_.removeAt(e))};var i=e.prototype;return i.updateSizeNPivot=function(t,e,i,r){t===this._width&&e===this._height&&i===this._pivotX&&r===this._pivotY||(this._width=t,this._height=e,this._pivotX=i,this._pivotY=r,this.vertDirty=!0)},i.clear=function(){this._data.length=0,this._indices.length=0,this._pivotX=0,this._pivotY=0,this._width=0,this._height=0,this.uvDirty=!0,this.vertDirty=!0,this.material=null,this.vertexCount=0,this.indicesCount=0},Pe(e,[{key:"dataLength",get:function(){return this._data.length},set:function(t){var e=this._data;if(e.length!==t){var i=e.length,r=0;for(r=t;r<i;r++)O_.free(e[r]);for(r=i;r<t;r++)e[r]=O_.alloc();e.length=t}}},{key:"data",get:function(){return this._data}}]),e}(P_),I_=function(t){function e(e){var i;return void 0===e&&(e=9),(i=t.call(this)||this).vData=void 0,i.iData=void 0,i.vertexStart=0,i.indicesStart=0,i.byteStart=0,i.byteCount=0,i.lastFilledIndices=0,i.lastFilledVertex=0,i._formatByte=void 0,i._formatByte=e*Float32Array.BYTES_PER_ELEMENT,i.vData=new Float32Array(256*e*Float32Array.BYTES_PER_ELEMENT),i.iData=new Uint16Array(1536),i}Me(e,t),e.add=function(){return L_.add()},e.remove=function(t){var e=L_.data.indexOf(t);-1!==e&&(L_.data[e].reset(),L_.removeAt(e))};var i=e.prototype;return i.request=function(t,e){var i=this.byteCount+t*this._formatByte;return this.reserve(t,e),this.vertexCount+=t,this.indicesCount+=e,this.byteCount=i,!0},i.reserve=function(t,e){var i=this.byteCount+t*this._formatByte,r=this.indicesCount+e;if(t+this.vertexCount>65535)return!1;var n=this.vData.byteLength,s=this.iData.length,a=this.vData.length,o=this.iData.length;if(i>n||r>s){for(;n<i||s<r;)n=4*(a*=2),s=o*=2;this._reallocBuffer(a,o)}return!0},i.advance=function(t,e){this.vertexCount+=t,this.indicesCount+=e,this.byteCount+=t*this._formatByte},i.reset=function(){this.vertexCount=0,this.indicesCount=0,this.byteCount=0,this.vertexStart=0,this.indicesStart=0,this.byteStart=0,this.lastFilledIndices=0,this.lastFilledVertex=0},i._reallocBuffer=function(t,e){var i=this.vData;this.vData=new Float32Array(t),this.vData.set(i,0);var r=this.iData;this.iData=new Uint16Array(e),this.iData.set(r,0)},Pe(e,[{key:"formatByte",get:function(){return this._formatByte},set:function(t){this._formatByte=t}},{key:"floatStride",get:function(){return this._formatByte>>2}},{key:"vDataOffset",get:function(){return this.byteCount>>>2}}]),e}(P_),O_=(function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;i._fillQuadBuffer=function(){for(var t=this.iData.length/6,e=this.iData,i=0,r=0;i<t;i++){var n=4*i;e[r++]=n,e[r++]=n+1,e[r++]=n+2,e[r++]=n+1,e[r++]=n+3,e[r++]=n+2}},i._reallocBuffer=function(e,i){t.prototype._reallocBuffer.call(this,e,i),this._fillQuadBuffer()}}(I_),new e((function(){return{x:0,y:0,z:0,u:0,v:0,color:Ui.WHITE.clone()}}),128)),F_=new i((function(){return new R_}),32),L_=new i((function(){return new I_}),32),V_=new dr,k_=new dr,N_=new Ri,G_=new Ri,z_=new Ri,U_=new Ri(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),H_=new gr,j_=function(e){return t({UITransform:e,UITransformComponent:e}),e}((l_=ri("cc.UITransform"),h_=wi(),u_=Ei(110),c_=Bi(),__=Mr(),f_=Di(),p_=Mr(),d_=Di(),l_(m_=h_(m_=u_(m_=c_(m_=Br(m_=Si((S_=b_=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._priority=0,li(e,"_contentSize",g_,hi(e)),li(e,"_anchorPoint",v_,hi(e)),e}Me(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiTransformComp=this},i.onLoad=function(){this.node.parent&&e.insertChangeMap(this.node.parent)},i.onEnable=function(){this.node.on(Dr.PARENT_CHANGED,this._parentChanged,this)},i.onDisable=function(){this.node.off(Dr.PARENT_CHANGED,this._parentChanged,this)},i.onDestroy=function(){this.node._uiProps.uiTransformComp=null},i.setContentSize=function(t,e){var i=this._contentSize;if(void 0===e){if((t=t).width===i.width&&t.height===i.height)return;i.width=t.width,i.height=t.height}else{if(t===i.width&&e===i.height)return;i.width=t,i.height=e}this.node.emit(Dr.SIZE_CHANGED)},i.setAnchorPoint=function(t,e){var i=this._anchorPoint;if(void 0===e){if((t=t).x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this.node.emit(Dr.ANCHOR_CHANGED,this._anchorPoint)},i.isHit=function(t,e){for(var i=this._contentSize.width,r=this._contentSize.height,n=V_,s=k_,a=this._getRenderScene().cameras,o=0;o<a.length;o++){var l=a[o];if(l.visibility&this.node.layer){l.node.getWorldRT(N_);var h=N_.m12,u=N_.m13,c=He.visibleRect.center;if(N_.m12=c.x-(N_.m00*h+N_.m04*u),N_.m13=c.y-(N_.m01*h+N_.m05*u),Ri.invert(N_,N_),dr.transformMat4(n,t,N_),this.node.getWorldMatrix(z_),Ri.invert(N_,z_),!Ri.strictEquals(N_,U_)){dr.transformMat4(s,n,N_),s.x+=this._anchorPoint.x*i,s.y+=this._anchorPoint.y*r;var _=!1;if(s.x>=0&&s.y>=0&&s.x<=i&&s.y<=r&&(_=!0,e&&e.mask))for(var f=e.mask,p=this.node,d=f?f.length:0,m=0,y=0;p&&y<d;++m,p=p.parent){var g=f[y];if(m===g.index){if(p!==g.comp.node){f.length=y;break}var v=g.comp;if(v&&v._enabled&&!v.isHit(n)){_=!1;break}y++}else if(m>g.index){f.length=y;break}}if(_)return!0}}}return!1},i.convertToNodeSpaceAR=function(t,e){return this.node.getWorldMatrix(z_),Ri.invert(N_,z_),e||(e=new ii),ii.transformMat4(e,t,N_)},i.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(z_),e||(e=new ii),ii.transformMat4(e,t,z_)},i.getBoundingBox=function(){Ri.fromRTS(G_,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var t=this._contentSize.width,e=this._contentSize.height,i=new gr(-this._anchorPoint.x*t,-this._anchorPoint.y*e,t,e);return i.transformMat4(G_),i},i.getBoundingBoxToWorld=function(){return this.node.parent?(this.node.parent.getWorldMatrix(z_),this.getBoundingBoxTo(z_)):this.getBoundingBox()},i.getBoundingBoxTo=function(t){Ri.fromRTS(G_,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var i=this._contentSize.width,r=this._contentSize.height,n=new gr(-this._anchorPoint.x*i,-this._anchorPoint.y*r,i,r);if(Ri.multiply(z_,t,G_),n.transformMat4(z_),!this.node.children)return n;for(var s,a=this.node.children,o=Fe(a);!(s=o()).done;){var l=s.value;if(l&&l.active){var h=l.getComponent(e);if(h){var u=h.getBoundingBoxTo(t);u&&gr.union(n,n,u)}}}return n},i.getComputeAABB=function(t){var e=this._contentSize.width,i=this._contentSize.height;H_.set(-this._anchorPoint.x*e,-this._anchorPoint.y*i,e,i),H_.transformMat4(this.node.worldMatrix);var r=H_.x+.5*H_.width,n=H_.y+.5*H_.height,s=this.node.worldPosition.z,a=H_.width/2,o=H_.height/2;return null!=t?(ni.set(t,r,n,s,a,o,.001),t):new ni(r,n,s,a,o,.001)},i._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this.node.parent&&e.insertChangeMap(this.node.parent)},e.insertChangeMap=function(t){var i=t.uuid;e.priorityChangeNodeMap.has(i)||e.priorityChangeNodeMap.set(i,t)},e._sortChildrenSibling=function(t){var e=t.children;e&&e.sort((function(t,e){var i=t._uiProps.uiTransformComp,r=e._uiProps.uiTransformComp,n=(i?i._priority:0)-(r?r._priority:0);return 0===n?t.getSiblingIndex()-e.getSiblingIndex():n}))},e._sortSiblings=function(){e.priorityChangeNodeMap.forEach((function(t){e._sortChildrenSibling(t),t._updateSiblingIndex(),t.emit("childrenSiblingOrderChanged")})),e.priorityChangeNodeMap.clear()},e._cleanChangeMap=function(){e.priorityChangeNodeMap.clear()},Pe(e,[{key:"contentSize",get:function(){return this._contentSize},set:function(t){this._contentSize.equals(t)||(this._contentSize.set(t),this.node.emit(Dr.SIZE_CHANGED))}},{key:"width",get:function(){return this._contentSize.width},set:function(t){this._contentSize.width!==t&&(this._contentSize.width=t,this.node.emit(Dr.SIZE_CHANGED))}},{key:"height",get:function(){return this._contentSize.height},set:function(t){this.contentSize.height!==t&&(this._contentSize.height=t,this.node.emit(Dr.SIZE_CHANGED))}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(t){this._anchorPoint.equals(t)||(this._anchorPoint.set(t),this.node.emit(Dr.ANCHOR_CHANGED,this._anchorPoint))}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(t){this._anchorPoint.x!==t&&(this._anchorPoint.x=t,this.node.emit(Dr.ANCHOR_CHANGED,this._anchorPoint))}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(t){this._anchorPoint.y!==t&&(this._anchorPoint.y=t,this.node.emit(Dr.ANCHOR_CHANGED,this._anchorPoint))}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority!==t&&(this.node.getComponent("cc.RenderRoot2D")?ze(6706):(this._priority=t,this.node.parent&&e.insertChangeMap(this.node.parent)))}},{key:"visibility",get:function(){var t=wr.root.batcher2D.getFirstRenderCamera(this.node);return t?t.visibility:0}},{key:"cameraPriority",get:function(){var t=wr.root.batcher2D.getFirstRenderCamera(this.node);return t?t.priority:0}}]),e}(zi),b_.EventType=Dr,b_.priorityChangeNodeMap=new Map,oi((y_=S_).prototype,"contentSize",[__,f_],Object.getOwnPropertyDescriptor(y_.prototype,"contentSize"),y_.prototype),oi(y_.prototype,"anchorPoint",[p_,d_],Object.getOwnPropertyDescriptor(y_.prototype,"anchorPoint"),y_.prototype),g_=oi(y_.prototype,"_contentSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new vr(100,100)}}),v_=oi(y_.prototype,"_anchorPoint",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(.5,.5)}}),m_=y_))||m_)||m_)||m_)||m_)||m_)||m_));wr.on(Er.EVENT_AFTER_UPDATE,j_._sortSiblings),wr.on(Er.EVENT_BEFORE_SCENE_LAUNCH,j_._cleanChangeMap),function(t){t[t.DISABLED=0]="DISABLED",t[t.CLEAR=1]="CLEAR",t[t.ENTER_LEVEL=2]="ENTER_LEVEL",t[t.ENABLED=3]="ENABLED",t[t.EXIT_LEVEL=4]="EXIT_LEVEL",t[t.CLEAR_INVERTED=5]="CLEAR_INVERTED",t[t.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(A_||(A_={}));var W_,X_,Y_,q_,J_,K_,Z_,Q_,$_,tf,ef,rf,nf,sf,af,of,lf,hf,uf,cf=t("StencilManager",function(){function t(){this.stage=A_.DISABLED,this._maskStack=[],this._stencilPattern={stencilTest:!0,func:T.ALWAYS,stencilMask:65535,writeMask:65535,failOp:w.KEEP,zFailOp:w.KEEP,passOp:w.KEEP,ref:1},this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var e=t.prototype;return e.pushMask=function(t){this._maskStack.push(t)},e.clear=function(t){t.stencilStage=t.inverted?A_.CLEAR_INVERTED:A_.CLEAR},e.enterLevel=function(t){t.graphics.stencilStage=t.inverted?A_.ENTER_LEVEL_INVERTED:A_.ENTER_LEVEL},e.enableMask=function(){this.stage=A_.ENABLED},e.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=A_.DISABLED:this.stage=A_.ENABLED)},e.getWriteMask=function(){return 1<<this._maskStack.length-1},e.getExitWriteMask=function(){return 1<<this._maskStack.length},e.getStencilRef=function(){for(var t=0,e=0;e<this._maskStack.length;++e)t+=1<<e;return t},e.reset=function(){this._maskStack.length=0,this.stage=A_.DISABLED},e.destroy=function(){this.stencilStateMap.forEach((function(t){t.destroy()})),this.stencilStateMap.clear()},e.getStencilStage=function(t,e){var i=0,r=!1,n=!1,s=T.LESS,a=this.stencilStateMap;if(e&&e.passes[0]){var o=e.passes[0].depthStencilState,l=0,h=0;o.depthTest&&(l=1),o.depthWrite&&(h=1),i=l|h<<1|o.depthFunc<<2|t<<6|this._maskStack.length<<9,r=o.depthTest,n=o.depthWrite,s=o.depthFunc,a=this.stencilStateMapWithDepth}else i=t<<16|this._maskStack.length;if(a&&a.has(i))return a.get(i);this.setStateFromStage(t);var u=new se(r,n,s,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref);return a.set(i,u),u},e.getStencilHash=function(t){return t<<8|this._maskStack.length},e.setStateFromStage=function(t){var e=this._stencilPattern;t===A_.DISABLED?(e.stencilTest=!1,e.func=T.ALWAYS,e.failOp=w.KEEP,e.stencilMask=e.writeMask=65535,e.ref=1):(e.stencilTest=!0,t===A_.ENABLED?(e.func=T.EQUAL,e.failOp=w.KEEP,e.stencilMask=e.ref=this.getStencilRef(),e.writeMask=this.getWriteMask()):t===A_.CLEAR?(e.func=T.NEVER,e.failOp=w.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===A_.CLEAR_INVERTED||t===A_.ENTER_LEVEL?(e.func=T.NEVER,e.failOp=w.REPLACE,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===A_.ENTER_LEVEL_INVERTED&&(e.func=T.NEVER,e.failOp=w.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()))},Pe(t,[{key:"pattern",get:function(){return this._stencilPattern}}]),t}());cf.sharedManager=null,cf.sharedManager=new cf,Pr(E),function(t){t[t.ADD_COLOR=0]="ADD_COLOR",t[t.ADD_COLOR_AND_TEXTURE=1]="ADD_COLOR_AND_TEXTURE",t[t.GRAYSCALE=2]="GRAYSCALE",t[t.USE_ALPHA_SEPARATED=3]="USE_ALPHA_SEPARATED",t[t.USE_ALPHA_SEPARATED_AND_GRAY=4]="USE_ALPHA_SEPARATED_AND_GRAY"}(uf||(uf=t("InstanceMaterialType",{})));var _f,ff,pf,df,mf,yf,gf,vf,bf,Sf,Af,Cf,xf,Tf,wf,Ef,Bf,Df,Mf,Pf,Rf,If,Of,Ff,Lf,Vf,kf,Nf,Gf,zf,Uf,Hf,jf,Wf,Xf,Yf,qf,Jf,Kf,Zf,Qf,$f,tp,ep,ip,rp,np,sp,ap,op,lp,hp,up,cp,_p,fp,pp,dp,mp,yp,gp,vp,bp,Sp,Ap=function(e){return t({Renderable2D:e,RenderComponent:e,UIRenderable:e}),e}((W_=ri("cc.Renderable2D"),X_=Rr(j_),Y_=Mi(),q_=bi(cr),J_=bi(cr),K_=Mr(),Z_=Ir(),Q_=Mr(),$_=Di(),W_(tf=X_(tf=Br(tf=Si((hf=lf=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_materials",rf,hi(e)),li(e,"_customMaterial",nf,hi(e)),e.stencilStage=A_.DISABLED,li(e,"_srcBlendFactor",sf,hi(e)),li(e,"_dstBlendFactor",af,hi(e)),li(e,"_color",of,hi(e)),e._assembler=null,e._postAssembler=null,e._renderData=null,e._renderDataFlag=!0,e._renderFlag=!0,e._delegateSrc=null,e._instanceMaterialType=uf.ADD_COLOR_AND_TEXTURE,e._blendState=new oe,e._blendHash=0,e._colorDirty=!0,e._cacheAlpha=1,e._lastParent=null,e}Me(e,t);var i=e.prototype;return i.updateMaterial=function(){if(this._customMaterial)return this.setMaterial(this._customMaterial,0),void(this._blendHash=-1);var t=this._updateBuiltinMaterial();this.setMaterial(t,0),this._updateBlendFunc()},i.updateBlendHash=function(){var t=this._blendState.targets[0].blendDst<<4;this._blendHash=t|this._blendState.targets[0].blendSrc},i.__preload=function(){this.node._uiProps.uiComp=this,this._flushAssembler&&this._flushAssembler()},i.onEnable=function(){this.node.on(Dr.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(Dr.SIZE_CHANGED,this._nodeStateChange,this),this.updateMaterial(),this._renderFlag=this._canRender()},i.onRestore=function(){this.updateMaterial(),this._renderFlag=this._canRender()},i.onDisable=function(){this.node.off(Dr.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(Dr.SIZE_CHANGED,this._nodeStateChange,this),this._renderFlag=!1},i.onDestroy=function(){if(this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this.destroyRenderData(),this._materialInstances)for(var t=0;t<this._materialInstances.length;t++)this._materialInstances[t]&&this._materialInstances[t].destroy();this._renderData=null,this._blendState&&this._blendState.destroy()},i.markForUpdateRenderData=function(t){if(void 0===t&&(t=!0),this._renderFlag=this._canRender(),t&&this._renderFlag){var e=this._renderData;e&&(e.vertDirty=!0),this._renderDataFlag=t}else t||(this._renderDataFlag=t)},i.requestRenderData=function(){var t=R_.add();return this._renderData=t,t},i.destroyRenderData=function(){this._renderData&&(R_.remove(this._renderData),this._renderData=null)},i.updateAssembler=function(t){this._updateColor(),this._renderFlag&&(this._checkAndUpdateRenderData(),this._render(t))},i.postUpdateAssembler=function(t){this._renderFlag&&this._postRender(t)},i._render=function(){},i._postRender=function(){},i._checkAndUpdateRenderData=function(){this._renderDataFlag&&(this._assembler.updateRenderData(this),this._renderDataFlag=!1)},i._canRender=function(){return this.isValid&&null!==this.getMaterial(0)&&this.enabled&&(this._delegateSrc?this._delegateSrc.activeInHierarchy:this.enabledInHierarchy)&&this.node._uiProps.opacity>0},i._postCanRender=function(){},i._updateColor=function(){this._updateWorldAlpha(),(this._colorDirty||this._cacheAlpha!==this.node._uiProps.opacity)&&this._renderFlag&&this._assembler&&this._assembler.updateColor&&(this._assembler.updateColor(this),this._cacheAlpha=this.node._uiProps.opacity,this._colorDirty=!1)},i._updateWorldAlpha=function(){var t=this.color.a/255;1===t&&(t=this.node._uiProps.localOpacity),this.node._uiProps.opacity=this.node.parent&&this.node.parent._uiProps?this.node.parent._uiProps.opacity*t:t,this._renderFlag=this._canRender()},i._updateBlendFunc=function(){var t=this._blendState.targets[0];t||(t=new ae,this._blendState.setTarget(0,t)),t.blendDst===this._dstBlendFactor&&t.blendSrc===this._srcBlendFactor||(t.blend=!0,t.blendDstAlpha=E.ONE_MINUS_SRC_ALPHA,t.blendDst=this._dstBlendFactor,t.blendSrc=this._srcBlendFactor),this.updateBlendHash()},i.getBlendState=function(){return this._blendState},i._nodeStateChange=function(){this._renderData&&this.markForUpdateRenderData();for(var t=0;t<this.node.children.length;++t){var i=this.node.children[t].getComponent(e);i&&i.markForUpdateRenderData()}},i._updateBuiltinMaterial=function(){var t;switch(this._instanceMaterialType){case uf.ADD_COLOR:t=Ci.get("ui-base-material");break;case uf.GRAYSCALE:t=Ci.get("ui-sprite-gray-material");break;case uf.USE_ALPHA_SEPARATED:t=Ci.get("ui-sprite-alpha-sep-material");break;case uf.USE_ALPHA_SEPARATED_AND_GRAY:t=Ci.get("ui-sprite-gray-alpha-sep-material");break;default:t=Ci.get("ui-sprite-material")}return t},i._setCacheAlpha=function(t){this._cacheAlpha=t},Pe(e,[{key:"sharedMaterials",get:function(){return this._materials},set:function(t){for(var e=0;e<t.length;e++)t[e]!==this._materials[e]&&this.setMaterial(t[e],e);if(t.length<this._materials.length){for(var i=t.length;i<this._materials.length;i++)this.setMaterial(null,i);this._materials.splice(t.length)}}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this.updateMaterial()}},{key:"srcBlendFactor",get:function(){return this._customMaterial&&ze(12001),this._srcBlendFactor},set:function(t){this._customMaterial?ze(12001):this._srcBlendFactor!==t&&(this._srcBlendFactor=t,this._updateBlendFunc())}},{key:"dstBlendFactor",get:function(){return this._customMaterial&&ze(12001),this._dstBlendFactor},set:function(t){this._customMaterial?ze(12001):this._dstBlendFactor!==t&&(this._dstBlendFactor=t,this._updateBlendFunc())}},{key:"color",get:function(){return this._color},set:function(t){this._color.equals(t)||(this._color.set(t),this._colorDirty=!0)}},{key:"renderData",get:function(){return this._renderData}},{key:"delegateSrc",set:function(t){this._delegateSrc=t}},{key:"blendHash",get:function(){return this._blendHash}}]),e}(Pi),lf.BlendState=E,lf.Assembler=null,lf.PostAssembler=null,rf=oi((ef=hf).prototype,"_materials",[pr],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),oi(ef.prototype,"sharedMaterials",[pr,Y_],Object.getOwnPropertyDescriptor(ef.prototype,"sharedMaterials"),ef.prototype),nf=oi(ef.prototype,"_customMaterial",[q_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(ef.prototype,"customMaterial",[J_,K_,Z_],Object.getOwnPropertyDescriptor(ef.prototype,"customMaterial"),ef.prototype),oi(ef.prototype,"color",[Q_,$_],Object.getOwnPropertyDescriptor(ef.prototype,"color"),ef.prototype),sf=oi(ef.prototype,"_srcBlendFactor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return E.SRC_ALPHA}}),af=oi(ef.prototype,"_dstBlendFactor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return E.ONE_MINUS_SRC_ALPHA}}),of=oi(ef.prototype,"_color",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),tf=ef))||tf)||tf)||tf)||tf));He.internal.Renderable2D=Ap,function(t){t[t.LEFT=0]="LEFT",t[t.CENTER=1]="CENTER",t[t.RIGHT=2]="RIGHT"}(gp||(gp=t("HorizontalTextAlignment",{}))),Pr(gp),function(t){t[t.TOP=0]="TOP",t[t.CENTER=1]="CENTER",t[t.BOTTOM=2]="BOTTOM"}(vp||(vp=t("VerticalTextAlignment",{}))),Pr(vp),function(t){t[t.NONE=0]="NONE",t[t.CLAMP=1]="CLAMP",t[t.SHRINK=2]="SHRINK",t[t.RESIZE_HEIGHT=3]="RESIZE_HEIGHT"}(bp||(bp=t("Overflow",{}))),Pr(bp),function(t){t[t.NONE=0]="NONE",t[t.BITMAP=1]="BITMAP",t[t.CHAR=2]="CHAR"}(Sp||(Sp=t("CacheMode",{}))),Pr(Sp);var Cp,xp,Tp,wp=function(e){return t({Label:e,LabelComponent:e}),e}((_f=ri("cc.Label"),ff=wi(),pf=Ei(110),df=Bi(),mf=Mr(),yf=Di(),gf=bi(gp),vf=Mr(),bf=Di(),Sf=bi(vp),Af=Mr(),Cf=Di(),xf=Mr(),Tf=Di(),wf=Mr(),Ef=Mi(),Bf=Di(),Df=Mr(),Mf=Di(),Pf=bi(bp),Rf=Mr(),If=Di(),Of=Mr(),Ff=Di(),Lf=bi(Pc),Vf=Mr(),kf=Mi(),Nf=Di(),Gf=Mr(),zf=Di(),Uf=bi(Sp),Hf=Mr(),jf=Di(),Wf=Mr(),Xf=Di(),Yf=Mr(),qf=Di(),Jf=Mr(),Kf=Di(),Zf=Mi(),_f(Qf=ff(Qf=pf(Qf=df((yp=mp=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_string",tp,hi(e)),li(e,"_horizontalAlign",ep,hi(e)),li(e,"_verticalAlign",ip,hi(e)),li(e,"_actualFontSize",rp,hi(e)),li(e,"_fontSize",np,hi(e)),li(e,"_fontFamily",sp,hi(e)),li(e,"_lineHeight",ap,hi(e)),li(e,"_overflow",op,hi(e)),li(e,"_enableWrapText",lp,hi(e)),li(e,"_font",hp,hi(e)),li(e,"_isSystemFontUsed",up,hi(e)),e._spacingX=0,li(e,"_isItalic",cp,hi(e)),li(e,"_isBold",_p,hi(e)),li(e,"_isUnderline",fp,hi(e)),li(e,"_underlineHeight",pp,hi(e)),li(e,"_cacheMode",dp,hi(e)),e._N$file=null,e._texture=null,e._ttfSpriteFrame=null,e._userDefinedFont=null,e._assemblerData=null,e._fontAtlas=null,e._letterTexture=null,e._ttfSpriteFrame=null,e}Me(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this._font||this._isSystemFontUsed||(this.useSystemFont=!0),this._isSystemFontUsed&&!this._fontFamily&&(this.fontFamily="Arial"),this.updateRenderData(!0)},i.onDisable=function(){t.prototype.onDisable.call(this)},i.onDestroy=function(){if(this._assembler&&this._assembler.resetAssemblerData&&this._assembler.resetAssemblerData(this._assemblerData),this._assemblerData=null,this._ttfSpriteFrame){var e=this._ttfSpriteFrame.texture;if(e&&null===this._ttfSpriteFrame.original){var i=e;i.image&&i.image.destroy(),e.destroy()}this._ttfSpriteFrame=null}this._letterTexture=null,t.prototype.onDestroy.call(this)},i.updateRenderData=function(t){void 0===t&&(t=!1),this.markForUpdateRenderData(),t&&(this._flushAssembler(),this.renderData&&(this.renderData.vertDirty=!0),this._applyFontTexture())},i._render=function(t){t.commitComp(this,this._texture,this._assembler,null)},i._updateColor=function(){this._font instanceof Wc?(this._updateWorldAlpha(),this._colorDirty=!1):(this._updateWorldAlpha(),this._colorDirty?(this.updateRenderData(!1),this._colorDirty=!1):this._cacheAlpha!==this.node._uiProps.opacity&&this._renderFlag&&this._assembler&&this._assembler.updateOpacity&&(this._assembler.updateOpacity(this),this._cacheAlpha=this.node._uiProps.opacity))},i._canRender=function(){if(!t.prototype._canRender.call(this)||!this._string)return!1;var e=this._font;if(e&&e instanceof Wc){var i=e.spriteFrame;if(!i||!i.textureLoaded())return!1}return!0},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.material)},i._applyFontTexture=function(){var t=this,e=this._font;if(e instanceof Wc){var i=e.spriteFrame,r=function(){t._texture=i,t.changeMaterialForDefine(),t._assembler&&t._assembler.updateRenderData(t)};i&&(i.loaded||i.textureLoaded?r():i.once("load",r,this))}else{if(this.cacheMode===Sp.CHAR)this._letterTexture=this._assembler.getAssemblerData(),this._texture=this._letterTexture;else if(!this._ttfSpriteFrame){this._ttfSpriteFrame=new xc,this._assemblerData=this._assembler.getAssemblerData();var n=new Ye(this._assemblerData.canvas)._texture;this._ttfSpriteFrame.texture=n}this.cacheMode!==Sp.CHAR&&(this._texture=this._ttfSpriteFrame),this.changeMaterialForDefine(),this._assembler&&this._assembler.updateRenderData(this)}},i.changeMaterialForDefine=function(){if(this._texture){var t=!1;if(this.cacheMode!==Sp.CHAR){var e=this._texture.texture;if(e instanceof Or){var i=e.getPixelFormat();t=i===fr.RGBA_ETC1||i===fr.RGB_A_PVRTC_4BPPV1||i===fr.RGB_A_PVRTC_2BPPV1}}this._instanceMaterialType=t?uf.USE_ALPHA_SEPARATED:uf.ADD_COLOR_AND_TEXTURE,this.updateMaterial()}},Pe(e,[{key:"string",get:function(){return this._string},set:function(t){t+="",this._string!==t&&(this._string=t,this.updateRenderData())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this._horizontalAlign!==t&&(this._horizontalAlign=t,this.updateRenderData())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this.updateRenderData())}},{key:"actualFontSize",get:function(){return this._actualFontSize},set:function(t){this._actualFontSize=t}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this.updateRenderData())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.updateRenderData())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this.updateRenderData())}},{key:"overflow",get:function(){return this._overflow},set:function(t){this._overflow!==t&&(this._overflow=t,this.updateRenderData())}},{key:"enableWrapText",get:function(){return this._enableWrapText},set:function(t){this._enableWrapText!==t&&(this._enableWrapText=t,this.updateRenderData())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._isSystemFontUsed=!t,this._font=t,this._renderData&&(this.destroyRenderData(),this._renderData=null),this._fontAtlas=null,this.updateRenderData(!0))}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this.destroyRenderData(),this._renderData=null,this._isSystemFontUsed=!!t,t&&(this.font=null),this._flushAssembler(),this.updateRenderData())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode!==Sp.BITMAP||this._font instanceof Wc||!this._ttfSpriteFrame||this._ttfSpriteFrame._resetDynamicAtlasFrame(),this._cacheMode===Sp.CHAR&&(this._ttfSpriteFrame=null),this._cacheMode=t,this.updateRenderData(!0))}},{key:"spriteFrame",get:function(){return this._texture}},{key:"ttfSpriteFrame",get:function(){return this._ttfSpriteFrame}},{key:"isBold",get:function(){return this._isBold},set:function(t){this._isBold!==t&&(this._isBold=t,this.updateRenderData())}},{key:"isItalic",get:function(){return this._isItalic},set:function(t){this._isItalic!==t&&(this._isItalic=t,this.updateRenderData())}},{key:"isUnderline",get:function(){return this._isUnderline},set:function(t){this._isUnderline!==t&&(this._isUnderline=t,this.updateRenderData())}},{key:"underlineHeight",get:function(){return this._underlineHeight},set:function(t){this._underlineHeight!==t&&(this._underlineHeight=t,this.updateRenderData())}},{key:"assemblerData",get:function(){return this._assemblerData}},{key:"fontAtlas",get:function(){return this._fontAtlas},set:function(t){this._fontAtlas=t}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this.updateRenderData())}},{key:"_bmFontOriginalSize",get:function(){return this._font instanceof Wc?this._font.fontSize:-1}}]),e}(Ap),mp.HorizontalAlign=gp,mp.VerticalAlign=vp,mp.Overflow=bp,mp.CacheMode=Sp,mp._canvasPool=C_.getInstance(),oi(($f=yp).prototype,"string",[mf,yf,Fr],Object.getOwnPropertyDescriptor($f.prototype,"string"),$f.prototype),oi($f.prototype,"horizontalAlign",[gf,vf,bf],Object.getOwnPropertyDescriptor($f.prototype,"horizontalAlign"),$f.prototype),oi($f.prototype,"verticalAlign",[Sf,Af,Cf],Object.getOwnPropertyDescriptor($f.prototype,"verticalAlign"),$f.prototype),oi($f.prototype,"fontSize",[xf,Tf],Object.getOwnPropertyDescriptor($f.prototype,"fontSize"),$f.prototype),oi($f.prototype,"fontFamily",[wf,Ef,Bf],Object.getOwnPropertyDescriptor($f.prototype,"fontFamily"),$f.prototype),oi($f.prototype,"lineHeight",[Df,Mf],Object.getOwnPropertyDescriptor($f.prototype,"lineHeight"),$f.prototype),oi($f.prototype,"overflow",[Pf,Rf,If],Object.getOwnPropertyDescriptor($f.prototype,"overflow"),$f.prototype),oi($f.prototype,"enableWrapText",[Of,Ff],Object.getOwnPropertyDescriptor($f.prototype,"enableWrapText"),$f.prototype),oi($f.prototype,"font",[Lf,Vf,kf,Nf],Object.getOwnPropertyDescriptor($f.prototype,"font"),$f.prototype),oi($f.prototype,"useSystemFont",[Gf,zf],Object.getOwnPropertyDescriptor($f.prototype,"useSystemFont"),$f.prototype),oi($f.prototype,"cacheMode",[Uf,Hf,jf],Object.getOwnPropertyDescriptor($f.prototype,"cacheMode"),$f.prototype),oi($f.prototype,"isBold",[Wf,Xf],Object.getOwnPropertyDescriptor($f.prototype,"isBold"),$f.prototype),oi($f.prototype,"isItalic",[Yf,qf],Object.getOwnPropertyDescriptor($f.prototype,"isItalic"),$f.prototype),oi($f.prototype,"isUnderline",[Jf,Kf],Object.getOwnPropertyDescriptor($f.prototype,"isUnderline"),$f.prototype),oi($f.prototype,"underlineHeight",[Zf,vi],Object.getOwnPropertyDescriptor($f.prototype,"underlineHeight"),$f.prototype),tp=oi($f.prototype,"_string",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"label"}}),ep=oi($f.prototype,"_horizontalAlign",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return gp.CENTER}}),ip=oi($f.prototype,"_verticalAlign",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return vp.CENTER}}),rp=oi($f.prototype,"_actualFontSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),np=oi($f.prototype,"_fontSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),sp=oi($f.prototype,"_fontFamily",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),ap=oi($f.prototype,"_lineHeight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),op=oi($f.prototype,"_overflow",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return bp.NONE}}),lp=oi($f.prototype,"_enableWrapText",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),hp=oi($f.prototype,"_font",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),up=oi($f.prototype,"_isSystemFontUsed",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),cp=oi($f.prototype,"_isItalic",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),_p=oi($f.prototype,"_isBold",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),fp=oi($f.prototype,"_isUnderline",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),pp=oi($f.prototype,"_underlineHeight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),dp=oi($f.prototype,"_cacheMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Sp.NONE}}),Qf=$f))||Qf)||Qf)||Qf)||Qf));!function(t){t[t.BUTT=0]="BUTT",t[t.ROUND=1]="ROUND",t[t.SQUARE=2]="SQUARE"}(Cp||(Cp={})),Pr(Cp),function(t){t[t.BEVEL=0]="BEVEL",t[t.ROUND=1]="ROUND",t[t.MITER=2]="MITER"}(xp||(xp={})),Pr(xp),function(t){t[t.PT_CORNER=1]="PT_CORNER",t[t.PT_LEFT=2]="PT_LEFT",t[t.PT_BEVEL=4]="PT_BEVEL",t[t.PT_INNERBEVEL=8]="PT_INNERBEVEL"}(Tp||(Tp={})),Pr(Tp);var Ep=Math.PI,Bp=Math.min,Dp=Math.max,Mp=Math.cos,Pp=Math.sin,Rp=Math.abs,Ip=Math.sign,Op=.5522847493;function Fp(t,e,i,r,n){t.moveTo(e-r,i),t.bezierCurveTo(e-r,i+n*Op,e-r*Op,i+n,e,i+n),t.bezierCurveTo(e+r*Op,i+n,e+r,i+n*Op,e+r,i),t.bezierCurveTo(e+r,i-n*Op,e+r*Op,i-n,e,i-n),t.bezierCurveTo(e-r*Op,i-n,e-r,i-n*Op,e-r,i),t.close()}function Lp(t,e,i,r,n,s,a,o,l,h,u){var c,_,f,p,d,m,y,g,v,b,S,A,C,x,T,w;h>10||(d=.5*(s+o),m=.5*(a+l),y=.5*((c=.5*(e+r))+(f=.5*(r+s))),g=.5*((_=.5*(i+n))+(p=.5*(n+a))),((T=Rp((r-o)*(x=l-i)-(n-l)*(C=o-e)))+(w=Rp((s-o)*x-(a-l)*C)))*(T+w)<t.tessTol*(C*C+x*x)?t.addPoint(o,l,0===u?u|Tp.PT_BEVEL:u):(Lp(t,e,i,c,_,y,g,S=.5*(y+(v=.5*(f+d))),A=.5*(g+(b=.5*(p+m))),h+1,0),Lp(t,S,A,v,b,d,m,o,l,h+1,u)))}var Vp,kp,Np,Gp,zp,Up,Hp,jp,Wp,Xp,Yp,qp,Jp,Kp,Zp,Qp,$p,td,ed,id,rd,nd,sd=function(t){function e(e,i){var r;return(r=t.call(this,e,i)||this).dx=0,r.dy=0,r.dmx=0,r.dmy=0,r.flags=0,r.len=0,r.reset(),r}return Me(e,t),e.prototype.reset=function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0},e}(dr),ad=function(){function t(){this.closed=!1,this.bevel=0,this.complex=!0,this.points=[],this.reset()}return t.prototype.reset=function(){this.closed=!1,this.bevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]},t}(),od=function(){function t(){this.dataOffset=0,this.updatePathOffset=!1,this.pathLength=0,this.pathOffset=0,this.paths=[],this.tessTol=.25,this.distTol=.01,this.fillColor=Ui.WHITE.clone(),this.lineCap=Cp.BUTT,this.strokeColor=Ui.BLACK.clone(),this.lineJoin=xp.MITER,this.lineWidth=0,this.pointsOffset=0,this._commandX=0,this._commandY=0,this._points=[],this._renderDataList=[],this._curPath=null}var e=t.prototype;return e.moveTo=function(t,e){this.updatePathOffset&&(this.pathOffset=this.pathLength,this.updatePathOffset=!1),this._addPath(),this.addPoint(t,e,Tp.PT_CORNER),this._commandX=t,this._commandY=e},e.lineTo=function(t,e){this.addPoint(t,e,Tp.PT_CORNER),this._commandX=t,this._commandY=e},e.bezierCurveTo=function(t,e,i,r,n,s){var a=this._curPath,o=a.points[a.points.length-1];o&&(o.x!==t||o.y!==e||i!==n||r!==s?(Lp(this,o.x,o.y,t,e,i,r,n,s,0,Tp.PT_CORNER),this._commandX=n,this._commandY=s):this.lineTo(n,s))},e.quadraticCurveTo=function(t,e,i,r){var n=this._commandX,s=this._commandY;this.bezierCurveTo(n+2/3*(t-n),s+2/3*(e-s),i+2/3*(t-i),r+2/3*(e-r),i,r)},e.arc=function(t,e,i,r,n,s){!function(t,e,i,r,n,s,a){var o,l,h=0,u=0,c=0,_=0,f=0,p=0,d=0,m=0,y=0,g=0,v=0,b=0,S=0,A=0;if(u=s-n,a=a||!1)if(Rp(u)>=2*Ep)u=2*Ep;else for(;u<0;)u+=2*Ep;else if(Rp(u)>=2*Ep)u=2*-Ep;else for(;u>0;)u-=2*Ep;for(l=0|Dp(1,Bp(Rp(u)/(.5*Ep)+.5,5)),c=Rp(4/3*(1-Mp(o=u/l/2))/Pp(o)),a||(c=-c),A=0;A<=l;A++)p=e+(_=Mp(h=n+u*(A/l)))*r,d=i+(f=Pp(h))*r,m=-f*r*c,y=_*r*c,0===A?t.moveTo(p,d):t.bezierCurveTo(g+b,v+S,p-m,d-y,p,d),g=p,v=d,b=m,S=y}(this,t,e,i,r,n,s)},e.ellipse=function(t,e,i,r){Fp(this,t,e,i,r),this._curPath.complex=!1},e.circle=function(t,e,i){Fp(this,t,e,i,i),this._curPath.complex=!1},e.rect=function(t,e,i,r){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+r),this.lineTo(t,e+r),this.close(),this._curPath.complex=!1},e.roundRect=function(t,e,i,r,n){!function(t,e,i,r,n,s){if(s<.1)t.rect(e,i,r,n);else{var a=Bp(s,.5*Rp(r))*Ip(r),o=Bp(s,.5*Rp(n))*Ip(n);t.moveTo(e,i+o),t.lineTo(e,i+n-o),t.bezierCurveTo(e,i+n-o*(1-Op),e+a*(1-Op),i+n,e+a,i+n),t.lineTo(e+r-a,i+n),t.bezierCurveTo(e+r-a*(1-Op),i+n,e+r,i+n-o*(1-Op),e+r,i+n-o),t.lineTo(e+r,i+o),t.bezierCurveTo(e+r,i+o*(1-Op),e+r-a*(1-Op),i,e+r-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-Op),i,e,i+o*(1-Op),e,i+o),t.close()}}(this,t,e,i,r,n),this._curPath.complex=!1},e.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var t=this._renderDataList,e=0,i=t.length;e<i;e++){var r=t[e];r&&I_.remove(r)}this._renderDataList.length=0},e.close=function(){this._curPath.closed=!0},e.requestRenderData=function(){var t=I_.add();return this._renderDataList.push(t),t},e.getRenderDataList=function(){return 0===this._renderDataList.length&&this.requestRenderData(),this._renderDataList},e.addPoint=function(t,e,i){var r=this._curPath;if(r){var n=this._points,s=r.points,a=n[this.pointsOffset++];a?(a.x=t,a.y=e):(a=new sd(t,e),n.push(a)),a.flags=i,s.push(a)}},e._addPath=function(){var t=this.pathLength,e=this.paths[t];return e?e.reset():(e=new ad,this.paths.push(e)),this.pathLength++,this._curPath=e,e},t}(),ld=[new St(Ut.ATTR_POSITION,_.RGB32F)],hd=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_COLOR,_.RGBA32F)],ud=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RG32F),new St(Ut.ATTR_COLOR,_.RGBA32F)],cd=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RG32F),new St(Ut.ATTR_COLOR,_.RGBA32F),new St(Ut.ATTR_COLOR2,_.RGBA32F)];function _d(t){for(var e=0,i=0;i<t.length;i++){var r=t[i];e+=Ht[r.format].count}return e}function fd(t){for(var e=0,i=0;i<t.length;i++){var r=t[i];e+=Ht[r.format].size}return e}He.internal.vfmtPosUvColor=ud,He.internal.vfmtPosUvTwoColor=cd,t("UIVertexFormat",Object.freeze({__proto__:null,vfmt:ld,vfmtPosColor:hd,vfmtPosUvColor:ud,vfmtPosUvTwoColor:cd,getComponentPerVertex:_d,getAttributeStride:fd}));var pd,dd,md,yd,gd,vd,bd,Sd,Ad,Cd,xd,Td,wd,Ed,Bd,Dd,Md,Pd,Rd,Id,Od,Fd,Ld,Vd,kd,Nd,Gd=hd.concat([new St("a_dist",_.R32F)]),zd=_d(Gd),Ud=fd(Gd),Hd=function(e){return t({Graphics:e,GraphicsComponent:e}),e}((Vp=ri("cc.Graphics"),kp=wi(),Np=Ei(110),Gp=Bi(),zp=bi(xp),Up=Di(),Hp=bi(Cp),jp=Di(),Wp=Di(),Xp=Di(),Yp=Di(),qp=Mi(),Vp(Jp=kp(Jp=Np(Jp=Gp((nd=rd=function(t){function e(){var e;return(e=t.call(this)||this).impl=null,e.model=null,li(e,"_lineWidth",Zp,hi(e)),li(e,"_strokeColor",Qp,hi(e)),li(e,"_lineJoin",$p,hi(e)),li(e,"_lineCap",td,hi(e)),li(e,"_fillColor",ed,hi(e)),li(e,"_miterLimit",id,hi(e)),e._isDrawing=!1,e._isNeedUploadData=!0,e._instanceMaterialType=uf.ADD_COLOR,e.impl=new od,e}Me(e,t);var i=e.prototype;return i.onRestore=function(){this.impl||this._flushAssembler()},i.onLoad=function(){this.model=wr.root.createModel(mi),this.model.node=this.model.transform=this.node,this._flushAssembler()},i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMtlForGraphics()},i.onDisable=function(){t.prototype.onDisable.call(this)},i.onDestroy=function(){t.prototype.onDestroy.call(this),this._sceneGetter=null,this.model&&(wr.root.destroyModel(this.model),this.model=null),this.impl&&(this._isDrawing=!1,this.impl.clear(),this.impl=null)},i.moveTo=function(t,e){this.impl&&this.impl.moveTo(t,e)},i.lineTo=function(t,e){this.impl&&this.impl.lineTo(t,e)},i.bezierCurveTo=function(t,e,i,r,n,s){this.impl&&this.impl.bezierCurveTo(t,e,i,r,n,s)},i.quadraticCurveTo=function(t,e,i,r){this.impl&&this.impl.quadraticCurveTo(t,e,i,r)},i.arc=function(t,e,i,r,n,s){this.impl&&this.impl.arc(t,e,i,r,n,s)},i.ellipse=function(t,e,i,r){this.impl&&this.impl.ellipse(t,e,i,r)},i.circle=function(t,e,i){this.impl&&this.impl.circle(t,e,i)},i.rect=function(t,e,i,r){this.impl&&this.impl.rect(t,e,i,r)},i.roundRect=function(t,e,i,r,n){this.impl&&this.impl.roundRect(t,e,i,r,n)},i.fillRect=function(t,e,i,r){this.rect(t,e,i,r),this.fill()},i.clear=function(){if(this.impl){if(this.impl.clear(),this._isDrawing=!1,this.model)for(var t=0;t<this.model.subModels.length;t++)this.model.subModels[t].inputAssembler.indexCount=0;this.markForUpdateRenderData()}},i.close=function(){this.impl&&this.impl.close()},i.stroke=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.stroke(this)},i.fill=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.fill(this)},i._updateMtlForGraphics=function(){var t;this._customMaterial?t=this.getMaterialInstance(0):(t=Ci.get("ui-graphics-material"),this.setMaterial(t,0),(t=this.getMaterialInstance(0)).recompileShaders({USE_LOCAL:!0}))},i.activeSubModel=function(t){if(this.model){if(this.model.subModels.length<=t){var e=He.director.root.device,i=e.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.DEVICE,65535*Ud,Ud)),r=e.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.DEVICE,131070*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),n=new ui([i],Gd,F.TRIANGLE_LIST,r);n.subMeshIdx=0,this.model.initSubModel(t,n,this.getMaterialInstance(0))}}else ze(4500,this.node.name)},i._uploadData=function(t){var e=this.impl;if(e){var i=e&&e.getRenderDataList();if(!(i.length<=0)&&this.model){for(var r=this.model.subModels,n=0;n<i.length;n++){var s=i[n],a=r[n].inputAssembler;if(s.lastFilledVertex!==s.vertexStart){var o=new Float32Array(s.vData.buffer,0,s.vertexStart*zd);a.vertexBuffers[0].update(o),a.vertexCount=s.vertexStart;var l=new Uint16Array(s.iData.buffer,0,s.indicesStart);a.indexBuffer.update(l),a.indexCount=s.indicesStart,s.lastFilledVertex=s.vertexStart,s.lastFilledIndices=s.indicesStart}}t.removeUploadBuffersFunc(this),this._isNeedUploadData=!1}}},i._render=function(t){if(this._isNeedUploadData){if(this.impl){var e=this.impl.getRenderDataList(),i=this.model.subModels.length;if(e.length>i)for(var r=i;r<e.length;r++)this.activeSubModel(r)}t.addUploadBuffersFunc(this,this._uploadData)}t.commitModel(this,this.model,this.getMaterialInstance(0))},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t)},i._canRender=function(){return!!t.prototype._canRender.call(this)&&!!this.model&&this._isDrawing},Pe(e,[{key:"lineWidth",get:function(){return this._lineWidth},set:function(t){this._lineWidth=t,this.impl&&(this.impl.lineWidth=t)}},{key:"lineJoin",get:function(){return this._lineJoin},set:function(t){this._lineJoin=t,this.impl&&(this.impl.lineJoin=t)}},{key:"lineCap",get:function(){return this._lineCap},set:function(t){this._lineCap=t,this.impl&&(this.impl.lineCap=t)}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this.impl&&(this._strokeColor.set(t),this.impl.strokeColor=this._strokeColor)}},{key:"fillColor",get:function(){return this._fillColor},set:function(t){this.impl&&(this._fillColor.set(t),this.impl.fillColor=this._fillColor)}},{key:"miterLimit",get:function(){return this._miterLimit},set:function(t){this._miterLimit=t}},{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&this._color.set(t)}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(){}},{key:"dstBlendFactor",get:function(){return this._dstBlendFactor},set:function(){}}]),e}(Ap),rd.LineJoin=xp,rd.LineCap=Cp,oi((Kp=nd).prototype,"lineWidth",[vi],Object.getOwnPropertyDescriptor(Kp.prototype,"lineWidth"),Kp.prototype),oi(Kp.prototype,"lineJoin",[zp,Up],Object.getOwnPropertyDescriptor(Kp.prototype,"lineJoin"),Kp.prototype),oi(Kp.prototype,"lineCap",[Hp,jp],Object.getOwnPropertyDescriptor(Kp.prototype,"lineCap"),Kp.prototype),oi(Kp.prototype,"strokeColor",[Wp],Object.getOwnPropertyDescriptor(Kp.prototype,"strokeColor"),Kp.prototype),oi(Kp.prototype,"fillColor",[Xp],Object.getOwnPropertyDescriptor(Kp.prototype,"fillColor"),Kp.prototype),oi(Kp.prototype,"miterLimit",[Yp],Object.getOwnPropertyDescriptor(Kp.prototype,"miterLimit"),Kp.prototype),oi(Kp.prototype,"color",[pr,qp],Object.getOwnPropertyDescriptor(Kp.prototype,"color"),Kp.prototype),Zp=oi(Kp.prototype,"_lineWidth",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Qp=oi(Kp.prototype,"_strokeColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.BLACK.clone()}}),$p=oi(Kp.prototype,"_lineJoin",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return xp.MITER}}),td=oi(Kp.prototype,"_lineCap",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Cp.BUTT}}),ed=oi(Kp.prototype,"_fillColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),id=oi(Kp.prototype,"_miterLimit",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),Jp=Kp))||Jp)||Jp)||Jp)||Jp)),jd=new Ri,Wd=new dr,Xd=new Ri,Yd=[];!function(t){t[t.RECT=0]="RECT",t[t.ELLIPSE=1]="ELLIPSE",t[t.GRAPHICS_STENCIL=2]="GRAPHICS_STENCIL",t[t.IMAGE_STENCIL=3]="IMAGE_STENCIL"}(Nd||(Nd={})),Pr(Nd);var qd=function(e){return t({Mask:e,MaskComponent:e}),e}((pd=ri("cc.Mask"),dd=wi(),md=Ei(110),yd=Bi(),gd=bi(Nd),vd=Mr(),bd=Di(),Sd=Mr(),Ad=Di(),Cd=Mi(),xd=bi(xc),Td=Mi(),wd=Mi(),Ed=Ni(),Bd=Mi(),Dd=Mi(),pd(Md=dd(Md=md(Md=yd((kd=Vd=function(t){function e(){var e;return(e=t.call(this)||this)._clearStencilMtl=null,e._clearModel=null,li(e,"_type",Rd,hi(e)),li(e,"_inverted",Id,hi(e)),li(e,"_segments",Od,hi(e)),li(e,"_spriteFrame",Fd,hi(e)),li(e,"_alphaThreshold",Ld,hi(e)),e._graphics=null,e._instanceMaterialType=uf.ADD_COLOR,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._createClearModel(),this._createGraphics(),this._graphics&&this._graphics.onLoad()},i.onEnable=function(){t.prototype.onEnable.call(this),this._updateGraphics()},i.onRestore=function(){this._createGraphics(),t.prototype.updateMaterial.call(this),this._updateGraphics(),this._renderFlag=this._canRender()},i.onDisable=function(){t.prototype.onDisable.call(this),this._disableGraphics()},i.onDestroy=function(){t.prototype.onDestroy.call(this),this._clearModel&&wr.root.destroyModel(this._clearModel),this._clearStencilMtl&&this._clearStencilMtl.destroy(),this._removeGraphics()},i.isHit=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,r=i.width,n=i.height,s=Wd;this.node.getWorldMatrix(jd),Ri.invert(Xd,jd),dr.transformMat4(s,t,Xd);var a=e.anchorPoint;s.x+=a.x*r,s.y+=a.y*n;var o=!1;if(this.type===Nd.RECT||this.type===Nd.GRAPHICS_STENCIL)o=s.x>=0&&s.y>=0&&s.x<=r&&s.y<=n;else if(this.type===Nd.ELLIPSE){var l=r/2,h=n/2,u=s.x-.5*r,c=s.y-.5*n;o=u*u/(l*l)+c*c/(h*h)<1}return this._inverted&&(o=!o),o},i._render=function(t){t.commitComp(this,null,this._assembler,null)},i._postRender=function(t){this._postAssembler&&t.commitComp(this,null,this._postAssembler,null)},i._nodeStateChange=function(e){t.prototype._nodeStateChange.call(this,e),this._updateGraphics()},i._canRender=function(){return!!t.prototype._canRender.call(this)&&null!==this._graphics&&(this._type!==Nd.IMAGE_STENCIL||null!==this._spriteFrame)},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this),i=e.PostAssembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t),this._postAssembler!==i&&(this._postAssembler=i),this._useRenderData()},i._createGraphics=function(){if(!this._graphics){var t=this._graphics=new Hd;t._objFlags|=Lr.Flags.IsOnLoadCalled,t.node=this.node,t.node.getWorldMatrix(),t.lineWidth=0;var e=Ui.WHITE.clone();e.a=0,t.fillColor=e}this._updateMaterial()},i._updateGraphics=function(){if(this._graphics&&(this._type===Nd.RECT||this._type===Nd.ELLIPSE)){var t=this.node._uiProps.uiTransformComp,e=this._graphics;e.clear();var i=t.contentSize,r=i.width,n=i.height,s=t.anchorPoint,a=-r*s.x,o=-n*s.y;if(this._type===Nd.RECT)e.rect(a,o,r,n);else if(this._type===Nd.ELLIPSE){for(var l=function(t,e,i){Yd.length=0;for(var r=2*Math.PI/i,n=0;n<i;++n)Yd.push(new ii(e.x*Math.cos(r*n)+t.x,e.y*Math.sin(r*n)+t.y,0));return Yd}(new ii(a+r/2,o+n/2,0),new ii(r/2,n/2,0),this._segments),h=0;h<l.length;++h){var u=l[h];0===h?e.moveTo(u.x,u.y):e.lineTo(u.x,u.y)}e.close()}e.fill()}},i._createClearModel=function(){if(!this._clearModel){var t=Ci.get("default-clear-stencil");this._clearStencilMtl=new Vr({parent:t,owner:this,subModelIdx:0}),this._clearModel=wr.root.createModel(mi),this._clearModel.node=this._clearModel.transform=this.node;var e=fd(ld),i=He.director.root.device,r=i.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.DEVICE,4*e,e)),n=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);r.update(n);var s=i.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.DEVICE,6*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),a=new Uint16Array([0,1,2,2,1,3]);s.update(a);var o=new ui([r],ld,F.TRIANGLE_LIST,s);o.subMeshIdx=0,this._clearModel.initSubModel(0,o,this._clearStencilMtl)}},i._updateMaterial=function(){if(this._graphics){var t,e=this._graphics;e.stencilStage=A_.DISABLED,this._type===Nd.IMAGE_STENCIL?(t=Ci.get("ui-alpha-test-material"),e.setMaterial(t,0),(t=e.getMaterialInstance(0)).setProperty("alphaThreshold",this._alphaThreshold)):(t=Ci.get("ui-graphics-material"),e.setMaterial(t,0),e.getMaterialInstance(0))}},i._disableGraphics=function(){this._graphics&&this._graphics.onDisable()},i._removeGraphics=function(){this._graphics&&(this._graphics.destroy(),this._graphics._destroyImmediate(),this._graphics=null)},i._useRenderData=function(){this._type!==Nd.IMAGE_STENCIL||this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData())},Pe(e,[{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this.markForUpdateRenderData(!1),this._updateMaterial(),this._type!==Nd.IMAGE_STENCIL?(this._spriteFrame=null,this._updateGraphics(),this._renderData&&(this.destroyRenderData(),this._renderData=null)):(this._useRenderData(),this._graphics&&this._graphics.clear()))}},{key:"inverted",get:function(){return this._inverted},set:function(t){He.game.renderType!==Nr.RENDER_TYPE_CANVAS?(this._inverted=t,this.stencilStage=A_.DISABLED,this._graphics&&(this._graphics.stencilStage=A_.DISABLED)):ze(4202)}},{key:"segments",get:function(){return this._segments},set:function(t){this._segments!==t&&(this._segments=Gr(t,3,1e4),this._updateGraphics())}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){if(this._spriteFrame!==t){var e=this._spriteFrame;this._spriteFrame=t,this._type===Nd.IMAGE_STENCIL&&!e&&t&&this.markForUpdateRenderData()}}},{key:"alphaThreshold",get:function(){return this._alphaThreshold},set:function(t){this._alphaThreshold!==t&&(this._alphaThreshold=t,this.type===Nd.IMAGE_STENCIL&&this._graphics&&this._graphics.getMaterialInstance(0).setProperty("alphaThreshold",this._alphaThreshold))}},{key:"graphics",get:function(){return this._graphics}},{key:"dstBlendFactor",get:function(){return this._dstBlendFactor},set:function(t){this._dstBlendFactor!==t&&(this._dstBlendFactor=t,this._updateBlendFunc())}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(t){this._srcBlendFactor!==t&&(this._srcBlendFactor=t,this._updateBlendFunc())}},{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&(this._color.set(t),this.markForUpdateRenderData())}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(){}}]),e}(Ap),Vd.Type=Nd,oi((Pd=kd).prototype,"type",[gd,vd,bd],Object.getOwnPropertyDescriptor(Pd.prototype,"type"),Pd.prototype),oi(Pd.prototype,"inverted",[Sd,Ad],Object.getOwnPropertyDescriptor(Pd.prototype,"inverted"),Pd.prototype),oi(Pd.prototype,"segments",[Cd],Object.getOwnPropertyDescriptor(Pd.prototype,"segments"),Pd.prototype),oi(Pd.prototype,"spriteFrame",[xd,Td],Object.getOwnPropertyDescriptor(Pd.prototype,"spriteFrame"),Pd.prototype),oi(Pd.prototype,"alphaThreshold",[wd,Ed,ki],Object.getOwnPropertyDescriptor(Pd.prototype,"alphaThreshold"),Pd.prototype),oi(Pd.prototype,"color",[pr,Bd],Object.getOwnPropertyDescriptor(Pd.prototype,"color"),Pd.prototype),oi(Pd.prototype,"customMaterial",[pr,Dd],Object.getOwnPropertyDescriptor(Pd.prototype,"customMaterial"),Pd.prototype),Rd=oi(Pd.prototype,"_type",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Nd.RECT}}),Id=oi(Pd.prototype,"_inverted",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Od=oi(Pd.prototype,"_segments",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),Fd=oi(Pd.prototype,"_spriteFrame",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ld=oi(Pd.prototype,"_alphaThreshold",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),Md=Pd))||Md)||Md)||Md)||Md));kr._comp=qd,He.Mask=qd;var Jd,Kd,Zd,Qd,$d,tm,em,im,rm,nm,sm,am,om,lm,hm,um,cm,_m,fm,pm,dm,mm,ym,gm,vm,bm,Sm,Am,Cm,xm,Tm,wm,Em,Bm,Dm,Mm,Pm,Rm,Im,Om,Fm,Lm,Vm,km,Nm,Gm,zm,Um,Hm,jm,Wm,Xm,Ym,qm,Jm,Km=/^(click)(\s)*=|(param)(\s)*=/,Zm=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,Qm=t("HtmlTextParser",function(){function t(){this._specialSymbolArray=[],this._stack=[],this._resultObjectArray=[],this._specialSymbolArray.push([/</g,"<"]),this._specialSymbolArray.push([/>/g,">"]),this._specialSymbolArray.push([/&/g,"&"]),this._specialSymbolArray.push([/"/g,'"']),this._specialSymbolArray.push([/'/g,"'"])}var e=t.prototype;return e.parse=function(t){this._resultObjectArray.length=0,this._stack.length=0;for(var e=0,i=t.length;e<i;){var r=t.indexOf(">",e),n=-1;if(r>=0&&(n=t.lastIndexOf("<",r))<e-1&&(n=t.indexOf("<",r+1),r=t.indexOf(">",n+1)),n<0)this._stack.pop(),this._processResult(t.substring(e)),e=i;else{var s=t.substring(e,n),a=t.substring(n+1,r);""===a&&(s=t.substring(e,r+1)),this._processResult(s),-1===r?r=n:"/"===t.charAt(n+1)?this._stack.pop():this._addToStack(a),e=r+1}}return this._resultObjectArray},e._attributeToObject=function(t){t=t.trim();var e={},i=/^(color|size)(\s)*=/.exec(t),r="",n=0,s="";if(i){if(r=i[0],""===(t=t.substring(r.length).trim()))return e;switch(n=t.indexOf(" "),r[0]){case"c":e.color=n>-1?t.substring(0,n).trim():t;break;case"s":e.size=parseInt(t)}return n>-1&&(s=t.substring(n+1).trim(),e.event=this._processEventHandler(s)),e}if((i=/^(br(\s)*\/)/.exec(t))&&i[0].length>0&&(r=i[0].trim()).startsWith("br")&&"/"===r[r.length-1])return e.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),e;var a="";if((i=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(t))&&i[0].length>0&&(r=i[0].trim()).startsWith("img")&&"/"===r[r.length-1]){var o;i=Zm.exec(t);for(var l=!1;i;){if(r=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),o=(n=(a=t.substring(r.length).trim()).indexOf(" "))>-1?a.substr(0,n):a,r=(r=r.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),t=a.substring(n).trim(),o.endsWith("/")&&(o=o.slice(0,-1)),"src"===r){switch(o.charCodeAt(0)){case 34:case 39:l=!0,o=o.slice(1,-1)}e.isImage=!0,e.src=o}else if("height"===r)e.imageHeight=parseInt(o);else if("width"===r)e.imageWidth=parseInt(o);else if("align"===r){switch(o.charCodeAt(0)){case 34:case 39:o=o.slice(1,-1)}e.imageAlign=o.toLowerCase()}else"offset"===r?e.imageOffset=o:"click"===r&&(e.event=this._processEventHandler(r+"="+o));e.event&&"param"===r&&(e.event[r]=o.replace(/^"|"$/g,"")),i=Zm.exec(t)}return l&&e.isImage&&this._resultObjectArray.push({text:"",style:e}),{}}if(i=/^(outline(\s)*[^>]*)/.exec(t)){var h={color:"#ffffff",width:1};if(t=i[0].substring("outline".length).trim()){var u,c=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=c.exec(t);i;)r=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),u=(n=(a=t.substring(r.length).trim()).indexOf(" "))>-1?a.substr(0,n):a,r=(r=r.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),t=a.substring(n).trim(),"click"===r?e.event=this._processEventHandler(r+"="+u):"color"===r?h.color=u:"width"===r&&(h.width=parseInt(u)),e.event&&"param"===r&&(e.event[r]=u.replace(/^"|"$/g,"")),i=c.exec(t)}e.outline=h}if((i=/^(on|u|b|i)(\s)*/.exec(t))&&i[0].length>0){switch(r=i[0],t=t.substring(r.length).trim(),r[0]){case"u":e.underline=!0;break;case"i":e.italic=!0;break;case"b":e.bold=!0}if(""===t)return e;e.event=this._processEventHandler(t)}return e},e._processEventHandler=function(t){for(var e={},i=0,r=!1,n=Km.exec(t);n;){var s=n[0],a="";if(r=!1,'"'===(t=t.substring(s.length).trim()).charAt(0))(i=t.indexOf('"',1))>-1&&(a=t.substring(1,i).trim(),r=!0),i++;else if("'"===t.charAt(0))(i=t.indexOf("'",1))>-1&&(a=t.substring(1,i).trim(),r=!0),i++;else{var o=/(\S)+/.exec(t);i=(a=o?o[0]:"").length}r&&(e[s=s.substring(0,s.length-1).trim()]=a),t=t.substring(i).trim(),n=Km.exec(t)}return e},e._addToStack=function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var r in i)e[r]||(e[r]=i[r]);this._stack.push(e)}},e._processResult=function(t){0!==t.length&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},e._escapeSpecialSymbol=function(t){for(var e,i=Fe(this._specialSymbolArray);!(e=i()).done;){var r=e.value,n=r[0],s=r[1];t=t.replace(n,s)}return t},t}()),$m=function(e){return t({LabelOutline:e,LabelOutlineComponent:e}),e}((Jd=ri("cc.LabelOutline"),Kd=wi(),Zd=Ei(110),Qd=Bi(),$d=Rr(wp),tm=Di(),em=Di(),Jd(im=Kd(im=Zd(im=Qd(im=$d(im=Si((am=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_color",nm,hi(e)),li(e,"_width",sm,hi(e)),e}Me(e,t);var i=e.prototype;return i.onEnable=function(){this._updateRenderData()},i.onDisable=function(){this._updateRenderData()},i._updateRenderData=function(){var t=this.node.getComponent(wp);t&&t.updateRenderData(!0)},Pe(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&(this._color.set(t),this._updateRenderData())}},{key:"width",get:function(){return this._width},set:function(t){this._width!==t&&(this._width=t,this._updateRenderData())}}]),e}(zi),nm=oi((rm=am).prototype,"_color",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(0,0,0,255)}}),sm=oi(rm.prototype,"_width",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),oi(rm.prototype,"color",[tm],Object.getOwnPropertyDescriptor(rm.prototype,"color"),rm.prototype),oi(rm.prototype,"width",[em],Object.getOwnPropertyDescriptor(rm.prototype,"width"),rm.prototype),im=rm))||im)||im)||im)||im)||im)||im));!function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED",t[t.FILLED=3]="FILLED"}(Xm||(Xm={})),Pr(Xm),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.RADIAL=2]="RADIAL"}(Ym||(Ym={})),Pr(Ym),function(t){t[t.CUSTOM=0]="CUSTOM",t[t.TRIMMED=1]="TRIMMED",t[t.RAW=2]="RAW"}(qm||(qm={})),Pr(qm),function(t){t.SPRITE_FRAME_CHANGED="spriteframe-changed"}(Jm||(Jm={}));var ty,ey,iy,ry,ny,sy,ay,oy,ly,hy,uy,cy,_y,fy,py,dy=function(e){return t({Sprite:e,SpriteComponent:e}),e}((om=ri("cc.Sprite"),lm=wi(),hm=Ei(110),um=Bi(),cm=bi(wc),_m=Mr(),fm=Di(),pm=bi(xc),dm=Mr(),mm=Di(),ym=bi(Xm),gm=Mr(),vm=Di(),bm=bi(Ym),Sm=Di(),Am=Di(),Cm=Ni(),xm=Di(),Tm=Ni(),wm=Di(),Em=Mr(),Bm=Di(),Dm=bi(qm),Mm=Mr(),Pm=Di(),om(Rm=lm(Rm=hm(Rm=um((Wm=jm=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_spriteFrame",Om,hi(e)),li(e,"_type",Fm,hi(e)),li(e,"_fillType",Lm,hi(e)),li(e,"_sizeMode",Vm,hi(e)),li(e,"_fillCenter",km,hi(e)),li(e,"_fillStart",Nm,hi(e)),li(e,"_fillRange",Gm,hi(e)),li(e,"_isTrimmedMode",zm,hi(e)),li(e,"_useGrayscale",Um,hi(e)),li(e,"_atlas",Hm,hi(e)),e}Me(e,t);var i=e.prototype;return i.__preload=function(){this.changeMaterialForDefine(),t.prototype.__preload.call(this),this._spriteFrame&&this._spriteFrame.once("load",this._onTextureLoaded,this)},i.onEnable=function(){t.prototype.onEnable.call(this),this._activateMaterial(),this._markForUpdateUvDirty()},i.onDestroy=function(){this.destroyRenderData(),this._spriteFrame&&!this._spriteFrame.loaded&&this._spriteFrame.off("load",this._onTextureLoaded,this),t.prototype.onDestroy.call(this)},i.changeSpriteFrameFromAtlas=function(t){if(this._atlas){var e=this._atlas.getSpriteFrame(t);this.spriteFrame=e}else console.warn("SpriteAtlas is null.")},i.changeMaterialForDefine=function(){var t,e=this._instanceMaterialType;this._spriteFrame&&(t=this._spriteFrame.texture);var i=!1;if(t instanceof Or){var r=t.getPixelFormat();i=r===fr.RGBA_ETC1||r===fr.RGB_A_PVRTC_4BPPV1||r===fr.RGB_A_PVRTC_2BPPV1}i&&this.grayscale?this._instanceMaterialType=uf.USE_ALPHA_SEPARATED_AND_GRAY:i?this._instanceMaterialType=uf.USE_ALPHA_SEPARATED:this.grayscale?this._instanceMaterialType=uf.GRAYSCALE:this._instanceMaterialType=uf.ADD_COLOR_AND_TEXTURE,e!==this._instanceMaterialType&&this.updateMaterial()},i._updateBuiltinMaterial=function(){var e=t.prototype._updateBuiltinMaterial.call(this);if(this.spriteFrame&&this.spriteFrame.texture instanceof zr){var i=Ur({SAMPLE_FROM_RT:!0},e.passes[0].defines),r=new cr;r.initialize({effectAsset:e.effectAsset,defines:i}),e=r}return e},i._render=function(t){t.commitComp(this,this._spriteFrame,this._assembler,null)},i._canRender=function(){if(!t.prototype._canRender.call(this))return!1;var e=this._spriteFrame;return!(!e||!e.textureLoaded())},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.getRenderMaterial(0),this.markForUpdateRenderData(),this._colorDirty=!0,this._updateColor())},i._applySpriteSize=function(){if(this._spriteFrame){if(!this._spriteFrame.isDefault)if(qm.RAW===this._sizeMode){var t=this._spriteFrame.originalSize;this.node._uiProps.uiTransformComp.setContentSize(t)}else if(qm.TRIMMED===this._sizeMode){var e=this._spriteFrame.getRect();this.node._uiProps.uiTransformComp.setContentSize(e.width,e.height)}this._activateMaterial()}},i._resized=function(){},i._activateMaterial=function(){var t=this._spriteFrame,e=this.getRenderMaterial(0);He.game.renderType!==He.game.RENDER_TYPE_CANVAS?(t&&e&&this.markForUpdateRenderData(),this._renderData&&(this._renderData.material=e)):this.markForUpdateRenderData()},i._onTextureLoaded=function(){this.isValid&&(this.changeMaterialForDefine(),this._applySpriteSize())},i._applySpriteFrame=function(t){var e=this._spriteFrame;this._renderData&&(t&&!t.loaded&&t.off("load",this._onTextureLoaded,this),this._renderData.uvDirty||(this._renderData.uvDirty=!t||!e||t.uvHash!==e.uvHash),this._renderDataFlag=this._renderData.uvDirty),e&&(t&&e===t||(e.loaded?this._onTextureLoaded():e.once("load",this._onTextureLoaded,this)))},i._markForUpdateUvDirty=function(){this._renderData&&(this._renderData.uvDirty=!0,this._renderDataFlag=!0)},Pe(e,[{key:"spriteAtlas",get:function(){return this._atlas},set:function(t){this._atlas!==t&&(this._atlas=t)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){if(this._spriteFrame!==t){var e=this._spriteFrame;this._spriteFrame=t,this.markForUpdateRenderData(!1),this._applySpriteFrame(e)}}},{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._flushAssembler())}},{key:"fillType",get:function(){return this._fillType},set:function(t){this._fillType!==t&&(t===Ym.RADIAL||this._fillType===Ym.RADIAL?(this.destroyRenderData(),this._renderData=null):this._renderData&&this.markForUpdateRenderData(!0)),this._fillType=t,this._flushAssembler()}},{key:"fillCenter",get:function(){return this._fillCenter},set:function(t){this._fillCenter.x=t.x,this._fillCenter.y=t.y,this._type===Xm.FILLED&&this._renderData&&this.markForUpdateRenderData()}},{key:"fillStart",get:function(){return this._fillStart},set:function(t){this._fillStart=Gr(t,-1,1),this._type===Xm.FILLED&&this._renderData&&(this.markForUpdateRenderData(),this._renderData.uvDirty=!0)}},{key:"fillRange",get:function(){return this._fillRange},set:function(t){this._fillRange=Gr(t,-1,1),this._type===Xm.FILLED&&this._renderData&&(this.markForUpdateRenderData(),this._renderData.uvDirty=!0)}},{key:"trim",get:function(){return this._isTrimmedMode},set:function(t){this._isTrimmedMode!==t&&(this._isTrimmedMode=t,this._type===Xm.SIMPLE&&this._renderData&&this.markForUpdateRenderData(!0))}},{key:"grayscale",get:function(){return this._useGrayscale},set:function(t){this._useGrayscale!==t&&(this._useGrayscale=t,this._instanceMaterialType=!0===t?uf.GRAYSCALE:uf.ADD_COLOR_AND_TEXTURE,this.updateMaterial())}},{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,t!==qm.CUSTOM&&this._applySpriteSize())}}]),e}(Ap),jm.FillType=Ym,jm.Type=Xm,jm.SizeMode=qm,jm.EventType=Jm,oi((Im=Wm).prototype,"spriteAtlas",[cm,_m,fm],Object.getOwnPropertyDescriptor(Im.prototype,"spriteAtlas"),Im.prototype),oi(Im.prototype,"spriteFrame",[pm,dm,mm],Object.getOwnPropertyDescriptor(Im.prototype,"spriteFrame"),Im.prototype),oi(Im.prototype,"type",[ym,gm,vm],Object.getOwnPropertyDescriptor(Im.prototype,"type"),Im.prototype),oi(Im.prototype,"fillType",[bm,Sm],Object.getOwnPropertyDescriptor(Im.prototype,"fillType"),Im.prototype),oi(Im.prototype,"fillCenter",[Am],Object.getOwnPropertyDescriptor(Im.prototype,"fillCenter"),Im.prototype),oi(Im.prototype,"fillStart",[Cm,xm],Object.getOwnPropertyDescriptor(Im.prototype,"fillStart"),Im.prototype),oi(Im.prototype,"fillRange",[Tm,wm],Object.getOwnPropertyDescriptor(Im.prototype,"fillRange"),Im.prototype),oi(Im.prototype,"trim",[Em,Bm],Object.getOwnPropertyDescriptor(Im.prototype,"trim"),Im.prototype),oi(Im.prototype,"grayscale",[vi],Object.getOwnPropertyDescriptor(Im.prototype,"grayscale"),Im.prototype),oi(Im.prototype,"sizeMode",[Dm,Mm,Pm],Object.getOwnPropertyDescriptor(Im.prototype,"sizeMode"),Im.prototype),Om=oi(Im.prototype,"_spriteFrame",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Fm=oi(Im.prototype,"_type",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Xm.SIMPLE}}),Lm=oi(Im.prototype,"_fillType",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ym.HORIZONTAL}}),Vm=oi(Im.prototype,"_sizeMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qm.TRIMMED}}),km=oi(Im.prototype,"_fillCenter",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(0,0)}}),Nm=oi(Im.prototype,"_fillStart",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Gm=oi(Im.prototype,"_fillRange",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),zm=oi(Im.prototype,"_isTrimmedMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Um=oi(Im.prototype,"_useGrayscale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Hm=oi(Im.prototype,"_atlas",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Rm=Im))||Rm)||Rm)||Rm)||Rm)),my=t("RenderRoot2D",ri("cc.RenderRoot2D")(ty=Ei(100)(ty=Bi()(ty=Rr(j_)(ty=Br(ty=Si(ty=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.onEnable=function(){He.director.root.batcher2D.addScreen(this)},i.onDisable=function(){He.director.root.batcher2D.removeScreen(this)},i.onDestroy=function(){He.director.root.batcher2D.removeScreen(this)},e}(zi))||ty)||ty)||ty)||ty)||ty)||ty),yy=new ii,gy=yi({OVERLAY:0,INTERSPERSE:1}),vy=function(e){return t({Canvas:e,CanvasComponent:e}),e}((ey=ri("cc.Canvas"),iy=wi(),ry=Ei(100),ny=Bi(),sy=bi(Hr),ay=Di(),oy=Di(),ly=bi(Hr),ey(hy=iy(hy=ry(hy=ny(hy=Si(hy=Br((fy=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_cameraComponent",cy,hi(e)),li(e,"_alignCanvasWithScreen",_y,hi(e)),e._thisOnCameraResized=void 0,e._fitDesignResolution=void 0,e._pos=new ii,e._renderMode=gy.OVERLAY,e._thisOnCameraResized=e._onResizeCamera.bind(hi(e)),e}Me(e,t);var i=e.prototype;return i.__preload=function(){var t=this.getComponent("cc.Widget");t&&t.updateAlignment(),this._cameraComponent&&this._cameraComponent._createCamera(),this._onResizeCamera(),this.node.on(Dr.TRANSFORM_CHANGED,this._thisOnCameraResized)},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.node.off(Dr.TRANSFORM_CHANGED,this._thisOnCameraResized)},i._onResizeCamera=function(){if(this._cameraComponent&&this._alignCanvasWithScreen){if(this._cameraComponent.targetTexture){var t=this._cameraComponent.targetTexture.window;this._cameraComponent.camera&&this._cameraComponent.camera.setFixedSize(t.width,t.height),this._cameraComponent.orthoHeight=jr.height/2}else if(Wr.canvas){var e=Wr.canvas;this._cameraComponent.camera&&this._cameraComponent.camera.resize(e.width,e.height),this._cameraComponent.orthoHeight=Wr.canvas.height/Xr.getScaleY()/2}this.node.getWorldPosition(yy),this._cameraComponent.node.setWorldPosition(yy.x,yy.y,1e3)}},i._getViewPriority=function(){if(this._cameraComponent){var t,e=null===(t=this.cameraComponent)||void 0===t?void 0:t.priority;return this._renderMode===gy.OVERLAY?e|1<<30:e&~(1<<30)}return 0},Pe(e,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){this._renderMode=t,this._cameraComponent&&(this._cameraComponent.priority=this._getViewPriority())}},{key:"cameraComponent",get:function(){return this._cameraComponent},set:function(t){this._cameraComponent!==t&&(this._cameraComponent=t,this._onResizeCamera())}},{key:"alignCanvasWithScreen",get:function(){return this._alignCanvasWithScreen},set:function(t){this._alignCanvasWithScreen=t,this._onResizeCamera()}}]),e}(my),oi((uy=fy).prototype,"cameraComponent",[sy,ay],Object.getOwnPropertyDescriptor(uy.prototype,"cameraComponent"),uy.prototype),oi(uy.prototype,"alignCanvasWithScreen",[oy],Object.getOwnPropertyDescriptor(uy.prototype,"alignCanvasWithScreen"),uy.prototype),cy=oi(uy.prototype,"_cameraComponent",[ly],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),_y=oi(uy.prototype,"_alignCanvasWithScreen",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),hy=uy))||hy)||hy)||hy)||hy)||hy)||hy));He.Canvas=vy;var by,Sy,Ay,Cy,xy,Ty,wy,Ey,By,Dy,My,Py,Ry,Iy,Oy,Fy,Ly,Vy,ky,Ny,Gy,zy,Uy,Hy,jy,Wy,Xy,Yy,qy,Jy,Ky,Zy,Qy,$y,tg,eg=t("UIComponent",ri("cc.UIComponent")(py=Rr(j_)(py=Ei(110)(py=Br(py=Si(py=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._lastParent=null,e.stencilStage=A_.DISABLED,e}Me(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){},i.onDisable=function(){},i.onDestroy=function(){this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null)},i.updateAssembler=function(){},i.postUpdateAssembler=function(){},e}(zi))||py)||py)||py)||py)||py);Oi(eg.prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),Ii(vy.prototype,"Canvas.prototype",[{name:"camera",newName:"cameraComponent.camera",customGetter:function(){return this._cameraComponent.camera}},{name:"clearFlag",newName:"cameraComponent.clearFlags",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearFlags:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearFlags=t)}},{name:"color",newName:"cameraComponent.clearColor",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearColor:Ui.BLACK},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearColor=t)}},{name:"priority",newName:"cameraComponent.priority",customGetter:function(){return this._cameraComponent?this._cameraComponent.priority:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.priority=t)}},{name:"targetTexture",newName:"cameraComponent.targetTexture",customGetter:function(){return this._cameraComponent?this._cameraComponent.targetTexture:null},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.targetTexture=t)}},{name:"visibility",newName:"cameraComponent.visibility",customGetter:function(){return this._cameraComponent?this._cameraComponent.visibility:0}}]),Yr(Ap.prototype,"Renderable2D.prototype",[{name:"srcBlendFactor",suggest:"Please use a custom material to specify blending options instead."},{name:"dstBlendFactor",suggest:"Please use a custom material to specify blending options instead."}]),Yr(j_.prototype,"UITransform.prototype",[{name:"priority",suggest:"Please use setSiblingIndex to change index of the current node in its parent's children array."}]),He.UITransformComponent=j_,Li.setClassAlias(j_,"cc.UITransformComponent"),Li.setClassAlias(Ap,"cc.RenderComponent"),He.CanvasComponent=vy,Li.setClassAlias(vy,"cc.CanvasComponent");var ig=new Qm,rg="RICHTEXT_CHILD",ng="RICHTEXT_Image_CHILD",sg=new Tr((function(t){if(!He.isValid(t.node))return!1;var e=t.node.getComponent($m);return e&&(e.width=0),!0}),20),ag=new Tr((function(t){return He.isValid(t.node)}),10);function og(t){return{node:new ur(t),comp:null,lineCount:0,styleIndex:0,imageOffset:"",clickParam:"",clickHandler:"",type:t}}function lg(t,e){var i;t===rg?i=sg._get():t===ng&&(i=ag._get());var r=(i=i||og(t)).node;return r||(r=new ur(t)),r.hideFlags|=Lr.Flags.DontSave|Lr.Flags.HideInHierarchy,t===ng?(i.comp=r.getComponent(dy)||r.addComponent(dy),i.comp.spriteFrame=e,i.comp.type=dy.Type.SLICED,i.comp.sizeMode=dy.SizeMode.CUSTOM):(i.comp=r.getComponent(wp)||r.addComponent(wp),i.comp.string=e,i.comp.horizontalAlign=gp.LEFT,i.comp.verticalAlign=vp.TOP),r.setPosition(0,0,0),r._uiProps.uiTransformComp.setAnchorPoint(.5,.5),i.node=r,i.lineCount=0,i.styleIndex=0,i.imageOffset="",i.clickParam="",i.clickHandler="",i}var hg,ug=function(e){return t({RichText:e,RichTextComponent:e}),e}((by=ri("cc.RichText"),Sy=wi(),Ay=Ei(110),Cy=Bi(),xy=Di(),Ty=bi(gp),wy=Di(),Ey=Di(),By=Di(),Dy=bi(Pc),My=Di(),Py=Di(),Ry=bi(Sp),Iy=Di(),Oy=Di(),Fy=Di(),Ly=bi(wc),Vy=Di(),ky=Di(),by(Ny=Sy(Ny=Ay(Ny=Cy(Ny=Si((tg=$y=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_lineHeight",zy,hi(e)),li(e,"_string",Uy,hi(e)),li(e,"_horizontalAlign",Hy,hi(e)),li(e,"_fontSize",jy,hi(e)),li(e,"_maxWidth",Wy,hi(e)),li(e,"_fontFamily",Xy,hi(e)),li(e,"_font",Yy,hi(e)),li(e,"_isSystemFontUsed",qy,hi(e)),li(e,"_userDefinedFont",Jy,hi(e)),li(e,"_cacheMode",Ky,hi(e)),li(e,"_imageAtlas",Zy,hi(e)),li(e,"_handleTouchEvent",Qy,hi(e)),e._textArray=[],e._segments=[],e._labelSegmentsCache=[],e._linesWidth=[],e._lineCount=1,e._labelWidth=0,e._labelHeight=0,e._layoutDirty=!0,e._lineOffsetX=0,e._updateRichTextStatus=void 0,e._updateRichTextStatus=e._updateRichText,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this.node.on(Dr.LAYER_CHANGED,this._applyLayer,this)},i.onEnable=function(){this.handleTouchEvent&&this._addEventListeners(),this._updateRichText(),this._activateChildren(!0)},i.onDisable=function(){this.handleTouchEvent&&this._removeEventListeners(),this._activateChildren(!1)},i.start=function(){this._onTTFLoaded(),this.node.on(ur.EventType.ANCHOR_CHANGED,this._updateRichTextPosition,this)},i.onRestore=function(){},i.onDestroy=function(){for(var t,e=Fe(this._segments);!(t=e()).done;){var i=t.value;i.node.removeFromParent(),i.type===rg?sg.put(i):i.type===ng&&ag.put(i)}this.node.off(ur.EventType.ANCHOR_CHANGED,this._updateRichTextPosition,this),this.node.off(Dr.LAYER_CHANGED,this._applyLayer,this)},i._addEventListeners=function(){this.node.on(ur.EventType.TOUCH_END,this._onTouchEnded,this)},i._removeEventListeners=function(){this.node.off(ur.EventType.TOUCH_END,this._onTouchEnded,this)},i._updateLabelSegmentTextAttributes=function(){var t=this;this._segments.forEach((function(e){t._applyTextAttribute(e)}))},i._createFontLabel=function(t){return lg(rg,t)},i._createImage=function(t){return lg(ng,t)},i._onTTFLoaded=function(){var t=this;this._font instanceof zc?this._font._nativeAsset?(this._layoutDirty=!0,this._updateRichText()):qr.postLoadNative(this._font,(function(){t.isValid&&(t._layoutDirty=!0,t._updateRichText())})):(this._layoutDirty=!0,this._updateRichText())},i._measureText=function(t,e){var i=this,r=function(e){var r;return 0===i._labelSegmentsCache.length?(r=i._createFontLabel(e),i._labelSegmentsCache.push(r)):(r=i._labelSegmentsCache[0]).node.getComponent(wp).string=e,r.styleIndex=t,i._applyTextAttribute(r),r.node._uiProps.uiTransformComp.contentSize.width};return e?r(e):r},i._onTouchEnded=function(t){for(var e,i=this,r=this.node.getComponents(zi),n=function(){var n=e.value,s=n.clickHandler,a=n.clickParam;s&&i._containsTouchLocation(n,t.touch.getUILocation())&&(r.forEach((function(e){var i=e[s];e.enabledInHierarchy&&i&&i.call(e,t,a)})),t.propagationStopped=!0)},s=Fe(this._segments);!(e=s()).done;)n()},i._containsTouchLocation=function(t,e){var i=t.node.getComponent(j_);return!!i&&i.getBoundingBoxToWorld().contains(e)},i._resetState=function(){for(var t=this.node.children,e=t.length-1;e>=0;e--){var i=t[e];if(i.name===rg||i.name===ng){i.parent===this.node?i.parent=null:t.splice(e,1);var r=og(i.name);r.node=i,i.name===rg?(r.comp=i.getComponent(wp),sg.put(r)):(r.comp=i.getComponent(dy),ag.put(r))}}t.length=0,this._segments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},i._activateChildren=function(t){for(var e=this.node.children.length-1;e>=0;e--){var i=this.node.children[e];i.name!==rg&&i.name!==ng||(i.active=t)}},i._addLabelSegment=function(t,e){var i;if(0===this._labelSegmentsCache.length)i=this._createFontLabel(t);else{var r=(i=this._labelSegmentsCache.pop()).node.getComponent(wp);r&&(r.string=t)}return i.styleIndex=e,i.lineCount=this._lineCount,i.node._uiProps.uiTransformComp.setAnchorPoint(0,0),i.node.layer=this.node.layer,this._applyTextAttribute(i),this.node.addChild(i.node),this._segments.push(i),i},i._updateRichTextWithMaxWidth=function(t,e,i){var r=e;if(this._lineOffsetX>0&&r+this._lineOffsetX>this._maxWidth)for(var n=0;this._lineOffsetX<=this._maxWidth;){var s=this._getFirstWordLen(t,n,t.length),a=t.substr(n,s),o=this._measureText(i,a);if(!(this._lineOffsetX+o<=this._maxWidth)){if(n>0){var l=t.substr(0,n);this._addLabelSegment(l,i),t=t.substr(n,t.length),r=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=o,n+=s}if(r>this._maxWidth)for(var h=o_(t,r,this._maxWidth,this._measureText(i)),u=0;u<h.length;++u){var c=h[u],_=this._addLabelSegment(c,i).node._uiProps.uiTransformComp.contentSize;this._lineOffsetX+=_.width,h.length>1&&u<h.length-1&&this._updateLineInfo()}else this._lineOffsetX+=r,this._addLabelSegment(t,i)},i._isLastComponentCR=function(t){return t.length-1===t.lastIndexOf("\n")},i._updateLineInfo=function(){this._linesWidth.push(this._lineOffsetX),this._lineOffsetX=0,this._lineCount++},i._needsUpdateTextLayout=function(t){if(this._layoutDirty||!this._textArray||!t)return!0;if(this._textArray.length!==t.length)return!0;for(var e=0;e<this._textArray.length;e++){var i=this._textArray[e],r=t[e];if(i.text!==r.text)return!0;var n=i.style,s=r.style;if(n){if(s){if(!!s.outline!=!!n.outline)return!0;if(n.size!==s.size||n.italic!==s.italic||n.isImage!==s.isImage)return!0;if(n.src!==s.src||n.imageAlign!==s.imageAlign||n.imageHeight!==s.imageHeight||n.imageWidth!==s.imageWidth||n.imageOffset!==s.imageOffset)return!0}else if(n.size||n.italic||n.isImage||n.outline)return!0}else if(s&&(s.size||s.italic||s.isImage||s.outline))return!0}return!1},i._addRichTextImageElement=function(t){if(t.style){var e=t.style,i=e.src,r=this._imageAtlas&&i&&this._imageAtlas.getSpriteFrame(i);if(r){var n=this._createImage(r);switch(n.comp,e.imageAlign){case"top":n.node._uiProps.uiTransformComp.setAnchorPoint(0,1);break;case"center":n.node._uiProps.uiTransformComp.setAnchorPoint(0,.5);break;default:n.node._uiProps.uiTransformComp.setAnchorPoint(0,0)}n.node.layer=this.node.layer,this.node.addChild(n.node),this._segments.push(n);var s=r.rect.clone(),a=1,o=s.width,l=s.height,h=e.imageWidth||0,u=e.imageHeight||0;u>0?(o*=a=u/l,l*=a):(o*=a=this._lineHeight/l,l*=a),h>0&&(o=h),this._maxWidth>0?(this._lineOffsetX+o>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=o):(this._lineOffsetX+=o,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),n.node._uiProps.uiTransformComp.setContentSize(o,l),n.lineCount=this._lineCount,n.clickHandler="",n.clickParam="";var c=e.event;c&&(n.clickHandler=c.click,n.clickParam=c.param)}else ze(4400)}},i._updateRichText=function(){if(this.enabledInHierarchy){var t=ig.parse(this._string);if(!this._needsUpdateTextLayout(t))return this._textArray=t.slice(),void this._updateLabelSegmentTextAttributes();this._textArray=t.slice(),this._resetState();for(var e,i=!1,r=0;r<this._textArray.length;++r){var n=this._textArray[r],s=n.text;if(void 0!==s){if(""===s){if(n.style&&n.style.isNewLine){this._updateLineInfo();continue}if(n.style&&n.style.isImage&&this._imageAtlas){this._addRichTextImageElement(n);continue}}for(var a=s.split("\n"),o=0;o<a.length;++o){var l=a[o];if(""!==l)if(i=!1,this._maxWidth>0){var h=this._measureText(r,l);this._updateRichTextWithMaxWidth(l,h,r),a.length>1&&o<a.length-1&&this._updateLineInfo()}else e=this._addLabelSegment(l,r),this._lineOffsetX+=e.node._uiProps.uiTransformComp.width,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX),a.length>1&&o<a.length-1&&this._updateLineInfo();else{if(this._isLastComponentCR(s)&&o===a.length-1)continue;this._updateLineInfo(),i=!0}}}}i||this._linesWidth.push(this._lineOffsetX),this._maxWidth>0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+Yc)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},i._getFirstWordLen=function(t,e,i){var r=t.charAt(e);if(r_(r)||n_(r))return 1;for(var n=1,s=e+1;s<i&&!n_(r=t.charAt(s))&&!r_(r);++s)n++;return n},i._updateRichTextPosition=function(){for(var t=0,e=1,i=this._lineCount,r=this.node._uiProps.uiTransformComp,n=r.anchorX,s=r.anchorY,a=0;a<this._segments.length;++a){var o=this._segments[a],l=o.lineCount;l>e&&(t=0,e=l);var h=this._labelWidth*(.5*this._horizontalAlign-n);switch(this._horizontalAlign){case gp.LEFT:break;case gp.CENTER:h-=this._linesWidth[l-1]/2;break;case gp.RIGHT:h-=this._linesWidth[l-1]}var u=o.node.position;if(o.node.setPosition(t+h,this._lineHeight*(i-l)-this._labelHeight*s,u.z),l===e&&(t+=o.node._uiProps.uiTransformComp.width),o.node.getComponent(dy)){var c=o.node.position.clone(),_=this._lineHeight,f=this._lineHeight*(1+Yc);switch(o.node._uiProps.uiTransformComp.anchorY){case 1:c.y+=_+(f-_)/2;break;case.5:c.y+=f/2;break;default:c.y+=(f-_)/2}if(o.imageOffset){var p=o.imageOffset.split(",");if(1===p.length&&p[0]){var d=parseFloat(p[0]);Number.isInteger(d)&&(c.y+=d)}else if(2===p.length){var m=parseFloat(p[0]),y=parseFloat(p[1]);Number.isInteger(m)&&(c.x+=m),Number.isInteger(y)&&(c.y+=y)}}o.node.position=c}var g=o.node.getComponent($m);if(g){var v=o.node.position.clone();v.y-=g.width,o.node.position=v}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return Ui[e]?Ui[e]:(new Ui).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(wp);if(e){var i,r=t.styleIndex;if(this._textArray[r]&&(i=this._textArray[r].style),i){if(e.color=this._convertLiteralColorValue(i.color||"white"),e.isBold=!!i.bold,e.isItalic=!!i.italic,e.isUnderline=!!i.underline,i.outline){var n=t.node.getComponent($m);n||(n=t.node.addComponent($m)),n.color=this._convertLiteralColorValue(i.outline.color),n.width=i.outline.width}e.fontSize=i.size||this._fontSize,t.clickHandler="",t.clickParam="";var s=i.event;s&&(t.clickHandler=s.click||"",t.clickParam=s.param||"")}else e.fontSize=this._fontSize;e.cacheMode=this._cacheMode,this._font instanceof Pc&&!this._isSystemFontUsed?e.font=this._font:e.fontFamily=this._fontFamily,e.useSystemFont=this._isSystemFontUsed,e.lineHeight=this._lineHeight,e.updateRenderData(!0);var a=e._assembler;a&&a.updateRenderData(e)}},i._applyLayer=function(){for(var t,e=Fe(this._segments);!(t=e()).done;)t.value.node.layer=this.node.layer},Pe(e,[{key:"string",get:function(){return this._string},set:function(t){this._string!==t&&(this._string=t,this._updateRichTextStatus())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this.horizontalAlign!==t&&(this._horizontalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._font=t,this._layoutDirty=!0,this._font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this._isSystemFontUsed=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode=t,this._updateRichTextStatus())}},{key:"maxWidth",get:function(){return this._maxWidth},set:function(t){this._maxWidth!==t&&(this._maxWidth=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"imageAtlas",get:function(){return this._imageAtlas},set:function(t){this._imageAtlas!==t&&(this._imageAtlas=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"handleTouchEvent",get:function(){return this._handleTouchEvent},set:function(t){this._handleTouchEvent!==t&&(this._handleTouchEvent=t,this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners()))}}]),e}(eg),$y.HorizontalAlign=gp,$y.VerticalAlign=vp,oi((Gy=tg).prototype,"string",[Fr,xy],Object.getOwnPropertyDescriptor(Gy.prototype,"string"),Gy.prototype),oi(Gy.prototype,"horizontalAlign",[Ty,wy],Object.getOwnPropertyDescriptor(Gy.prototype,"horizontalAlign"),Gy.prototype),oi(Gy.prototype,"fontSize",[Ey],Object.getOwnPropertyDescriptor(Gy.prototype,"fontSize"),Gy.prototype),oi(Gy.prototype,"fontFamily",[By],Object.getOwnPropertyDescriptor(Gy.prototype,"fontFamily"),Gy.prototype),oi(Gy.prototype,"font",[Dy,My],Object.getOwnPropertyDescriptor(Gy.prototype,"font"),Gy.prototype),oi(Gy.prototype,"useSystemFont",[Py],Object.getOwnPropertyDescriptor(Gy.prototype,"useSystemFont"),Gy.prototype),oi(Gy.prototype,"cacheMode",[Ry,Iy],Object.getOwnPropertyDescriptor(Gy.prototype,"cacheMode"),Gy.prototype),oi(Gy.prototype,"maxWidth",[Oy],Object.getOwnPropertyDescriptor(Gy.prototype,"maxWidth"),Gy.prototype),oi(Gy.prototype,"lineHeight",[Fy],Object.getOwnPropertyDescriptor(Gy.prototype,"lineHeight"),Gy.prototype),oi(Gy.prototype,"imageAtlas",[Ly,Vy],Object.getOwnPropertyDescriptor(Gy.prototype,"imageAtlas"),Gy.prototype),oi(Gy.prototype,"handleTouchEvent",[ky],Object.getOwnPropertyDescriptor(Gy.prototype,"handleTouchEvent"),Gy.prototype),zy=oi(Gy.prototype,"_lineHeight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),Uy=oi(Gy.prototype,"_string",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"<color=#00ff00>Rich</color><color=#0fffff>Text</color>"}}),Hy=oi(Gy.prototype,"_horizontalAlign",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return gp.LEFT}}),jy=oi(Gy.prototype,"_fontSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),Wy=oi(Gy.prototype,"_maxWidth",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Xy=oi(Gy.prototype,"_fontFamily",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),Yy=oi(Gy.prototype,"_font",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qy=oi(Gy.prototype,"_isSystemFontUsed",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Jy=oi(Gy.prototype,"_userDefinedFont",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ky=oi(Gy.prototype,"_cacheMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Sp.NONE}}),Zy=oi(Gy.prototype,"_imageAtlas",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Qy=oi(Gy.prototype,"_handleTouchEvent",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Ny=Gy))||Ny)||Ny)||Ny)||Ny)||Ny)),cg=function(e){return t({UIMeshRenderer:e,UIModelComponent:e}),e}(ri("cc.UIMeshRenderer")(hg=wi()(hg=Ei(110)(hg=Bi()(hg=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._models=null,e._modelComponent=null,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this.node._uiProps.uiTransformComp||this.node.addComponent("cc.UITransform"),this._modelComponent=this.getComponent("cc.RenderableComponent"),this._modelComponent?this._models=this._modelComponent._collectModels():console.warn("node '"+(this.node&&this.node.name)+"' doesn't have any renderable component")},i.onEnable=function(){t.prototype.onEnable.call(this)},i.onDisable=function(){t.prototype.onDisable.call(this)},i.onDestroy=function(){t.prototype.onDestroy.call(this),this._modelComponent=this.getComponent("cc.RenderableComponent"),this._modelComponent&&(this._modelComponent._sceneGetter=null,this._models=null)},i.updateAssembler=function(t){if(this._models){this._modelComponent._detachFromScene();for(var e,i=Fe(this._models);!(e=i()).done;){var r=e.value;t.commitModel.call(t,this,r,this._modelComponent.material)}return!0}return!1},i.update=function(){this._fitUIRenderQueue()},i._fitUIRenderQueue=function(){if(this._modelComponent)for(var t=this._modelComponent.sharedMaterials.length,e=0;e<t;e++){var i=this._modelComponent.getMaterialInstance(e);if(null!=i)for(var r=i.passes,n=r.length,s=0;s<n;s++){var a=r[s];a._priority=Jr.MAX-11,a.blendState.targets[0].blend||i.overridePipelineStates({blendState:{targets:[{blend:!0}]}},s)}}},Pe(e,[{key:"modelComponent",get:function(){return this._modelComponent}}]),e}(eg))||hg)||hg)||hg)||hg),_g=t("MeshBuffer",function(){function t(t){this.vData=null,this.iData=null,this.byteStart=0,this.byteOffset=0,this.indicesStart=0,this.indicesOffset=0,this.vertexStart=0,this.vertexOffset=0,this.lastByteOffset=1,this._attributes=null,this._vertexBuffers=[],this._indexBuffer=null,this._iaInfo=null,this._batcher=void 0,this._dirty=!1,this._vertexFormatBytes=0,this._initVDataCount=0,this._initIDataCount=1536,this._outOfCallback=null,this._hInputAssemblers=[],this._nextFreeIAHandle=0,this._batcher=t}var e=t.prototype;return e.initialize=function(t,e){this._outOfCallback=e;var i=_d(t);this._vertexFormatBytes=i*Float32Array.BYTES_PER_ELEMENT,this._initVDataCount=256*this._vertexFormatBytes;var r=Float32Array.BYTES_PER_ELEMENT*i;this.vertexBuffers.length||this.vertexBuffers.push(this._batcher.device.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.HOST|g.DEVICE,r,r)));var n=Uint16Array.BYTES_PER_ELEMENT;this.indexBuffer||(this._indexBuffer=this._batcher.device.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.HOST|g.DEVICE,n,n))),this._attributes=t,this._iaInfo=new Ct(this.attributes,this.vertexBuffers,this.indexBuffer),this._reallocBuffer()},e.request=function(t,e){void 0===t&&(t=4),void 0===e&&(e=6),this.lastByteOffset=this.byteOffset;var i=this.byteOffset+t*this._vertexFormatBytes,r=this.indicesOffset+e;if(t+this.vertexOffset>65535)return this._outOfCallback&&this._outOfCallback.call(this._batcher,t,e),!1;var n=this.vData.byteLength,s=this.iData.length;if(i>n||r>s){for(;n<i||s<r;)this._initVDataCount*=2,this._initIDataCount*=2,n=4*this._initVDataCount,s=this._initIDataCount;this._reallocBuffer()}return this.vertexOffset+=t,this.indicesOffset+=e,this.byteOffset=i,this._dirty=!0,!0},e.reset=function(){this.byteStart=0,this.byteOffset=0,this.indicesStart=0,this.indicesOffset=0,this.vertexStart=0,this.vertexOffset=0,this.lastByteOffset=0,this._nextFreeIAHandle=0,this._dirty=!1},e.destroy=function(){this._attributes=null,this.vertexBuffers[0].destroy(),this.vertexBuffers.length=0,this.indexBuffer.destroy(),this._indexBuffer=null;for(var t=0;t<this._hInputAssemblers.length;t++)Kr.free(this._hInputAssemblers[t]);this._hInputAssemblers.length=0},e.recordBatch=function(){var t=this.indicesOffset-this.indicesStart;if(!t)return Zr;this._hInputAssemblers.length<=this._nextFreeIAHandle&&this._hInputAssemblers.push(Kr.alloc(this._batcher.device,this._iaInfo));var e=this._hInputAssemblers[this._nextFreeIAHandle++],i=Kr.get(e);return i.firstIndex=this.indicesStart,i.indexCount=t,e},e.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){var t=new Float32Array(this.vData.buffer,0,this.byteOffset>>2),e=new Uint16Array(this.iData.buffer,0,this.indicesOffset);this.byteOffset>this.vertexBuffers[0].size&&this.vertexBuffers[0].resize(this.byteOffset),this.vertexBuffers[0].update(t),2*this.indicesOffset>this.indexBuffer.size&&this.indexBuffer.resize(2*this.indicesOffset),this.indexBuffer.update(e),this._dirty=!1}},e._reallocBuffer=function(){this._reallocVData(!0),this._reallocIData(!0)},e._reallocVData=function(t){var e;if(this.vData&&(e=new Uint8Array(this.vData.buffer)),this.vData=new Float32Array(this._initVDataCount),e&&t)for(var i=new Uint8Array(this.vData.buffer),r=0,n=e.length;r<n;r++)i[r]=e[r]},e._reallocIData=function(t){var e=this.iData;if(this.iData=new Uint16Array(this._initIDataCount),e&&t)for(var i=this.iData,r=0,n=e.length;r<n;r++)i[r]=e[r]},Pe(t,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}}]),t}());_g.OPACITY_OFFSET=8;var fg,pg,dg,mg,yg,gg,vg,bg,Sg,Ag,Cg,xg,Tg,wg,Eg,Bg,Dg,Mg,Pg,Rg,Ig,Og,Fg,Lg,Vg,kg,Ng=Qr.Enum.NONE|Qr.Enum.UI_3D,Gg=t("UIDrawBatch",function(){function t(){this.bufferBatch=null,this.camera=null,this.renderScene=null,this.model=null,this.texture=null,this.sampler=null,this.useLocalData=null,this.isStatic=!1,this.textureHash=0,this.samplerHash=0,this._handle=Zr,this._passes=[],this._handle=$r.alloc(),$r.set(this._handle,tn.VIS_FLAGS,Ng),$r.set(this._handle,tn.INPUT_ASSEMBLER,Zr),$r.set(this._handle,tn.DESCRIPTOR_SET,Zr)}var e=t.prototype;return e.destroy=function(){if(this._handle){for(var t=this.passes.length,e=0;e<t;e++)this.passes[e]._destroyHandle();this._passes=[],$r.free(this._handle),this._handle=Zr}},e.clear=function(){this.bufferBatch=null,this.hInputAssembler=Zr,this.hDescriptorSet=Zr,this.camera=null,this.texture=null,this.sampler=null,this.model=null,this.isStatic=!1,this.useLocalData=null,this.visFlags=Ng},e.fillPasses=function(t,e,i,r,n,s){if(t){var a=t.passes;if(!a)return;$r.set(this._handle,tn.PASS_COUNT,a.length);for(var o=tn.PASS_0,l=tn.SHADER_0,h=0,u=0;u<a.length;u++,o++,l++){this._passes[u]||(this._passes[u]=new en(He.director.root),this._passes[u]._handle=rn.alloc());var c=a[u],_=this._passes[u];e||(e=c.depthStencilState,i=0),r||(r=c.blendState,n=0),-1===n&&(n=0),h=i<<16|n,c.update(),_._initPassFromTarget(c,e,r,h),$r.set(this._handle,o,_.handle),$r.set(this._handle,l,_.getShaderVariant(s))}}},Pe(t,[{key:"handle",get:function(){return this._handle}},{key:"hInputAssembler",get:function(){return $r.get(this._handle,tn.INPUT_ASSEMBLER)},set:function(t){$r.set(this._handle,tn.INPUT_ASSEMBLER,t)}},{key:"hDescriptorSet",get:function(){return $r.get(this._handle,tn.DESCRIPTOR_SET)},set:function(t){$r.set(this._handle,tn.DESCRIPTOR_SET,t)}},{key:"visFlags",get:function(){return $r.get(this._handle,tn.VIS_FLAGS)},set:function(t){$r.set(this._handle,tn.VIS_FLAGS,t)}},{key:"passes",get:function(){return this._passes}}]),t}()),zg=function(e){return t({UIStaticBatch:e,UIStaticBatchComponent:e}),e}((fg=ri("cc.UIStaticBatch"),pg=wi(),dg=Bi(),mg=Ei(110),yg=Mi(),fg(gg=pg(gg=dg(gg=mg((bg=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._init=!1,e._meshBuffer=null,e._dirty=!0,e._lastMeshBuffer=null,e._uiDrawBatchList=[],e}Me(e,t);var i=e.prototype;return i.onLoad=function(){var t=this._getBatcher();if(t){var e=ud,i=new _g(t);i.initialize(e,this._arrivalMaxBuffer.bind(this)),this._meshBuffer=i}},i.onDestroy=function(){t.prototype.onDestroy.call(this),this._clearData(),this._meshBuffer&&(this._meshBuffer.destroy(),this._meshBuffer=null)},i.updateAssembler=function(t){t.currIsStatic=!0,this._dirty&&(t.finishMergeBatches(),this._lastMeshBuffer=t.currBufferBatch,t.currBufferBatch=this._meshBuffer,t.currStaticRoot=this),this._init&&(t.finishMergeBatches(),t.commitStaticBatch(this))},i.postUpdateAssembler=function(t){this._dirty&&(t.finishMergeBatches(),t.currBufferBatch=this._lastMeshBuffer,t.currStaticRoot=null,this._dirty=!1,this._init=!0,this.node._static=!0,this._meshBuffer.uploadBuffers()),t.currIsStatic=!1},i.markAsDirty=function(){this._getBatcher()&&(this.node._static=!1,this._dirty=!0,this._init=!1,this._clearData())},i._requireDrawBatch=function(){var t=new Gg;return t.isStatic=!0,this._uiDrawBatchList.push(t),t},i._clearData=function(){if(this._meshBuffer){this._meshBuffer.reset();for(var t=this._getBatcher(),e=0;e<this._uiDrawBatchList.length;e++)this._uiDrawBatchList[e].destroy(t)}this._uiDrawBatchList.length=0,this._init=!1},i._getBatcher=function(){return wr.root&&wr.root.batcher2D?wr.root.batcher2D:(ze(9301),null)},i._arrivalMaxBuffer=function(){var t=this._getBatcher();t&&t.autoMergeBatches(),ze(9300)},Pe(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&this._color.set(t)}},{key:"drawBatchList",get:function(){return this._uiDrawBatchList}}]),e}(Ap),oi((vg=bg).prototype,"color",[pr,yg],Object.getOwnPropertyDescriptor(vg.prototype,"color"),vg.prototype),gg=vg))||gg)||gg)||gg)||gg)),Ug=t("LabelShadow",(Sg=ri("cc.LabelShadow"),Ag=wi(),Cg=Ei(110),xg=Bi(),Tg=Rr(wp),wg=Di(),Eg=Di(),Bg=Di(),Sg(Dg=Ag(Dg=Cg(Dg=xg(Dg=Tg(Dg=Si((Og=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_color",Pg,hi(e)),li(e,"_offset",Rg,hi(e)),li(e,"_blur",Ig,hi(e)),e}Me(e,t);var i=e.prototype;return i.onEnable=function(){this._updateRenderData()},i.onDisable=function(){this._updateRenderData()},i._updateRenderData=function(){var t=this.node.getComponent(wp);t&&t.updateRenderData(!0)},Pe(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&(this._color.set(t),this._updateRenderData())}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset=t,this._updateRenderData()}},{key:"blur",get:function(){return this._blur},set:function(t){this._blur=t,this._updateRenderData()}}]),e}(zi),Pg=oi((Mg=Og).prototype,"_color",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(0,0,0,255)}}),Rg=oi(Mg.prototype,"_offset",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(2,2)}}),Ig=oi(Mg.prototype,"_blur",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),oi(Mg.prototype,"color",[wg],Object.getOwnPropertyDescriptor(Mg.prototype,"color"),Mg.prototype),oi(Mg.prototype,"offset",[Eg],Object.getOwnPropertyDescriptor(Mg.prototype,"offset"),Mg.prototype),oi(Mg.prototype,"blur",[Bg],Object.getOwnPropertyDescriptor(Mg.prototype,"blur"),Mg.prototype),Dg=Mg))||Dg)||Dg)||Dg)||Dg)||Dg)||Dg)),Hg=function(e){return t({UIOpacity:e,UIOpacityComponent:e}),e}(ri("cc.UIOpacity")(Fg=wi()(Fg=Ei(110)(Fg=Bi()(Fg=Si((kg=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_opacity",Vg,hi(e)),e}Me(e,t);var i=e.prototype;return i.onEnable=function(){this.node._uiProps.localOpacity=this._opacity/255},i.onDisable=function(){this.node._uiProps.localOpacity=1},Pe(e,[{key:"opacity",get:function(){return this._opacity},set:function(t){this._opacity!==t&&(t=nn(t,0,255),this._opacity=t,this.node._uiProps.localOpacity=t/255)}}]),e}(zi),oi((Lg=kg).prototype,"opacity",[vi],Object.getOwnPropertyDescriptor(Lg.prototype,"opacity"),Lg.prototype),Vg=oi(Lg.prototype,"_opacity",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 255}}),Fg=Lg))||Fg)||Fg)||Fg)||Fg)||Fg);He.MaskComponent=qd,Li.setClassAlias(qd,"cc.MaskComponent"),He.LabelComponent=wp,Li.setClassAlias(wp,"cc.LabelComponent"),He.LabelOutlineComponent=$m,Li.setClassAlias($m,"cc.LabelOutlineComponent"),He.RichTextComponent=ug,Li.setClassAlias(ug,"cc.RichTextComponent"),He.SpriteComponent=dy,Li.setClassAlias(dy,"cc.SpriteComponent"),He.UIModelComponent=cg,Li.setClassAlias(cg,"cc.UIModelComponent"),He.GraphicsComponent=Hd,Li.setClassAlias(Hd,"cc.GraphicsComponent"),Li.setClassAlias(zg,"cc.UIStaticBatchComponent"),Li.setClassAlias(Hg,"cc.UIOpacityComponent");var jg=function(t,e,i){this.i=void 0,this.x=void 0,this.y=void 0,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=i};function Wg(t,e,i,r,n){var s=0,a=null;if(n===function(t,e,i,r){for(var n=0,s=e,a=i-r;s<i;s+=r)n+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return n}(t,e,i,r)>0)for(s=e;s<i;s+=r)a=hv(s,t[s],t[s+1],a);else for(s=i-r;s>=e;s-=r)a=hv(s,t[s],t[s+1],a);return a&&sv(a,a.next)&&(uv(a),a=a.next),a}function Xg(t,e){if(void 0===e&&(e=null),!t)return t;e||(e=t);var i=t,r=!1;do{if(r=!1,i.steiner||!sv(i,i.next)&&0!==nv(i.prev,i,i.next))i=i.next;else{if(uv(i),(i=e=i.prev)===i.next)return null;r=!0}}while(r||i!==e);return e}function Yg(t,e,i,r,n,s,a){if(void 0===a&&(a=0),t){!a&&s&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=tv(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e=0,i=null,r=null,n=null,s=null,a=0,o=0,l=0,h=1;do{for(i=t,t=null,s=null,a=0;i;){for(a++,r=i,o=0,e=0;e<h&&(o++,r=r.nextZ);e++);for(l=h;o>0||l>0&&r;)0===o?(n=r,r=r.nextZ,l--):0!==l&&r?i.z<=r.z?(n=i,i=i.nextZ,o--):(n=r,r=r.nextZ,l--):(n=i,i=i.nextZ,o--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=r}s.nextZ=null,h*=2}while(a>1)}(n)}(t,r,n,s);for(var o=t,l=null,h=null;t.prev!==t.next;)if(l=t.prev,h=t.next,s?Jg(t,r,n,s):qg(t))e.push(l.i/i),e.push(t.i/i),e.push(h.i/i),uv(t),t=h.next,o=h.next;else if((t=h)===o){a?1===a?Yg(t=Kg(t,e,i),e,i,r,n,s,2):2===a&&Zg(t,e,i,r,n,s):Yg(Xg(t),e,i,r,n,s,1);break}}}function qg(t){var e=t.prev,i=t,r=t.next;if(nv(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(iv(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&nv(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Jg(t,e,i,r){var n=t.prev,s=t,a=t.next;if(nv(n,s,a)>=0)return!1;for(var o=n.x<s.x?n.x<a.x?n.x:a.x:s.x<a.x?s.x:a.x,l=n.y<s.y?n.y<a.y?n.y:a.y:s.y<a.y?s.y:a.y,h=n.x>s.x?n.x>a.x?n.x:a.x:s.x>a.x?s.x:a.x,u=n.y>s.y?n.y>a.y?n.y:a.y:s.y>a.y?s.y:a.y,c=tv(o,l,e,i,r),_=tv(h,u,e,i,r),f=t.nextZ;f&&f.z<=_;){if(f!==t.prev&&f!==t.next&&iv(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&nv(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=c;){if(f!==t.prev&&f!==t.next&&iv(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&nv(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function Kg(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!sv(n,s)&&av(n,r,r.next,s)&&ov(n,s)&&ov(s,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(s.i/i),uv(r),uv(r.next),r=t=s),r=r.next}while(r!==t);return r}function Zg(t,e,i,r,n,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&rv(a,o)){var l=lv(a,o);return a=Xg(a,a.next),l=Xg(l,l.next),Yg(a,e,i,r,n,s),void Yg(l,e,i,r,n,s)}o=o.next}a=a.next}while(a!==t)}function Qg(t,e){return t.x-e.x}function $g(t,e){if(e=function(t,e){var i=e,r=t.x,n=t.y,s=-1/0,a=null;do{if(n<=i.y&&n>=i.next.y){var o=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=r&&o>s){if(s=o,o===r){if(n===i.y)return i;if(n===i.next.y)return i.next}a=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!a)return null;if(r===s)return a.prev;var l,h=a,u=a.x,c=a.y,_=1/0;for(i=a.next;i!==h;)r>=i.x&&i.x>=u&&iv(n<c?r:s,n,u,c,n<c?s:r,n,i.x,i.y)&&((l=Math.abs(n-i.y)/(r-i.x))<_||l===_&&i.x>a.x)&&ov(i,t)&&(a=i,_=l),i=i.next;return a}(t,e)){var i=lv(e,t);Xg(i,i.next)}}function tv(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)/n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ev(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}function iv(t,e,i,r,n,s,a,o){return(n-a)*(e-o)-(t-a)*(s-o)>=0&&(t-a)*(r-o)-(i-a)*(e-o)>=0&&(i-a)*(s-o)-(n-a)*(r-o)>=0}function rv(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&av(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&ov(t,e)&&ov(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)}function nv(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function sv(t,e){return t.x===e.x&&t.y===e.y}function av(t,e,i,r){return!!(sv(t,e)&&sv(i,r)||sv(t,r)&&sv(i,e))||nv(t,e,i)>0!=nv(t,e,r)>0&&nv(i,r,t)>0!=nv(i,r,e)>0}function ov(t,e){return nv(t.prev,t,t.next)<0?nv(t,e,t.next)>=0&&nv(t,t.prev,e)>=0:nv(t,e,t.prev)<0||nv(t,t.next,e)<0}function lv(t,e){var i=new jg(t.i,t.x,t.y),r=new jg(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function hv(t,e,i,r){var n=new jg(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function uv(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function cv(t,e,i){i=i||3;var r=e?e.length:0,n=r?e[0]*i:t.length,s=Wg(t,0,n,i,!0),a=[];if(!s)return a;var o=0,l=0,h=0,u=0,c=0,_=0,f=0;if(r&&(s=function(t,e,i,r){var n,s=[],a=0,o=null;for(a=0,n=e.length;a<n;a++)(o=Wg(t,e[a]*r,a<n-1?e[a+1]*r:t.length,r,!1))&&(o===o.next&&(o.steiner=!0),s.push(ev(o)));if(s.sort(Qg),!i)return i;for(a=0;a<s.length;a++)$g(s[a],i),i=Xg(i,i.next);return i}(t,e,s,i)),t.length>80*i){o=h=t[0],l=u=t[1];for(var p=i;p<n;p+=i)(c=t[p])<o&&(o=c),(_=t[p+1])<l&&(l=_),c>h&&(h=c),_>u&&(u=_);f=Math.max(h-o,u-l)}return Yg(s,a,i,o,l,f),a}for(var _v=Math.PI,fv=Math.min,pv=Math.max,dv=Math.ceil,mv=Math.acos,yv=Math.cos,gv=Math.sin,vv=Math.atan2,bv=null,Sv=null,Av=new Ui,Cv=[],xv=0;xv<4;xv++)Cv.push(new ii);function Tv(t,e,i){return t<e?e:t>i?i:t}var wv={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(t,e){if(!Sv)return null;var i=Sv.getRenderDataList(),r=i[Sv.dataOffset];if(!r)return null;var n=r,s=n?n.vertexStart+e:0;return(s>65535||3*s>131070)&&(++Sv.dataOffset,Sv.dataOffset<i.length?r=i[Sv.dataOffset]:(r=Sv.requestRenderData(),i[Sv.dataOffset]=r),n=r),n&&n.vertexCount<s&&n.request(e,3*e),r},stroke:function(t){Ui.copy(Av,t.strokeColor),t.impl&&(this._flattenPaths(t.impl),this._expandStroke(t),t.impl.updatePathOffset=!0,this.end(t))},fill:function(t){Ui.copy(Av,t.fillColor),this._expandFill(t),t.impl&&(t.impl.updatePathOffset=!0),this.end(t)},end:function(t){t.markForUpdateRenderData()},_expandStroke:function(t){var e=.5*t.lineWidth,i=t.lineCap,r=t.lineJoin,n=t.miterLimit;if(Sv=t.impl){var s=function(t,e,i){var r=2*mv(t/(t+i));return pv(2,dv(e/r))}(e,_v,Sv.tessTol);this._calculateJoins(Sv,e,r,n);for(var a=Sv.paths,o=0,l=Sv.pathOffset,h=Sv.pathLength;l<h;l++){var u=a[l],c=u.points.length;r===xp.ROUND?o+=2*(c+u.bevel*(s+2)+1):o+=2*(c+5*u.bevel+1),u.closed||(i===Cp.ROUND?o+=2*(2*s+2):o+=12)}var _=bv=this.getRenderData(t,o);if(_){for(var f=_.vData,p=_.iData,d=Sv.pathOffset,m=Sv.pathLength;d<m;d++){var y=a[d],g=y.points,v=g.length,b=_.vertexStart,S=void 0,A=void 0,C=0,x=0,T=y.closed;if(T?(S=g[v-1],A=g[0],C=0,x=v):(S=g[0],A=g[1],C=1,x=v-1),A=A||S,!T){var w=new sd(A.x,A.y);w.subtract(S),w.normalize();var E=w.x,B=w.y;i===Cp.BUTT?this._buttCapStart(S,E,B,e,0):i===Cp.SQUARE?this._buttCapStart(S,E,B,e,e):i===Cp.ROUND&&this._roundCapStart(S,E,B,e,s)}for(var D=C;D<x;++D)r===xp.ROUND?this._roundJoin(S,A,e,e,s):0!=(A.flags&(Tp.PT_BEVEL|Tp.PT_INNERBEVEL))?this._bevelJoin(S,A,e,e):(this._vSet(A.x+A.dmx*e,A.y+A.dmy*e,1),this._vSet(A.x-A.dmx*e,A.y-A.dmy*e,-1)),S=A,A=g[D+1];if(T){var M=8*b;this._vSet(f[M],f[M+1],1),this._vSet(f[M+8],f[M+8+1],-1)}else{var P=new sd(A.x,A.y);P.subtract(S),P.normalize();var R=P.x,I=P.y;i===Cp.BUTT?this._buttCapEnd(A,R,I,e,0):i===Cp.SQUARE?this._buttCapEnd(A,R,I,e,e):i===Cp.ROUND&&this._roundCapEnd(A,R,I,e,s)}for(var O=_.indicesStart,F=b+2,L=_.vertexStart;F<L;F++)p[O++]=F-2,p[O++]=F-1,p[O++]=F;_.indicesStart=O}bv=null,Sv=null}}},_expandFill:function(t){if(Sv=t.impl){for(var e=Sv.paths,i=0,r=Sv.pathOffset,n=Sv.pathLength;r<n;r++)i+=e[r].points.length;var s=bv=this.getRenderData(t,i);if(s){for(var a=s,o=a.vData,l=a.iData,h=Sv.pathOffset,u=Sv.pathLength;h<u;h++){var c=e[h],_=c.points,f=_.length;if(0!==f){for(var p=s.vertexStart,d=0;d<f;++d)this._vSet(_[d].x,_[d].y);var m=s.indicesStart;if(c.complex){for(var y=[],g=p,v=s.vertexStart;g<v;g++){var b=8*g;y.push(o[b++]),y.push(o[b++]),y.push(o[b++])}var S=cv(y,null,3);if(!S||0===S.length)continue;for(var A=0,C=S.length;A<C;A++)l[m++]=S[A]+p}else for(var x=p,T=p+2,w=a.vertexStart;T<w;T++)l[m++]=x,l[m++]=T-1,l[m++]=T;a.indicesStart=m}}bv=null,Sv=null}}},_calculateJoins:function(t,e,i,r){var n=0;e>0&&(n=1/e);for(var s=t.paths,a=t.pathOffset,o=t.pathLength;a<o;a++){var l=s[a],h=l.points,u=h.length,c=h[u-1],_=h[0];l.bevel=0;for(var f=0;f<u;f++){var p,d,m=c.dy,y=-c.dx,g=_.dy,v=-_.dx;if(_.dmx=.5*(m+g),_.dmy=.5*(y+v),(p=_.dmx*_.dmx+_.dmy*_.dmy)>1e-6){var b=1/p;b>600&&(b=600),_.dmx*=b,_.dmy*=b}_.dx*c.dy-c.dx*_.dy>0&&(_.flags|=Tp.PT_LEFT),p*(d=pv(11,fv(c.len,_.len)*n))*d<1&&(_.flags|=Tp.PT_INNERBEVEL),_.flags&Tp.PT_CORNER&&(p*r*r<1||i===xp.BEVEL||i===xp.ROUND)&&(_.flags|=Tp.PT_BEVEL),0!=(_.flags&(Tp.PT_BEVEL|Tp.PT_INNERBEVEL))&&l.bevel++,c=_,_=h[f+1]}}},_flattenPaths:function(t){for(var e=t.paths,i=t.pathOffset,r=t.pathLength;i<r;i++){var n=e[i],s=n.points,a=s[s.length-1],o=s[0];s.length>2&&a.equals(o)&&(n.closed=!0,s.pop(),a=s[s.length-1]);for(var l=0,h=s.length;l<h;l++){var u=new sd(o.x,o.y);u.subtract(a),a.len=u.length(),(u.x||u.y)&&u.normalize(),a.dx=u.x,a.dy=u.y,a=o,o=s[l+1]}}},_chooseBevel:function(t,e,i,r){var n=i.x,s=i.y,a=0,o=0,l=0,h=0;return 0!==t?(a=n+e.dy*r,o=s-e.dx*r,l=n+i.dy*r,h=s-i.dx*r):(a=l=n+i.dmx*r,o=h=s+i.dmy*r),[a,o,l,h]},_buttCapStart:function(t,e,i,r,n){var s=t.x-e*n,a=t.y-i*n,o=i,l=-e;this._vSet(s+o*r,a+l*r,1),this._vSet(s-o*r,a-l*r,-1)},_buttCapEnd:function(t,e,i,r,n){var s=t.x+e*n,a=t.y+i*n,o=i,l=-e;this._vSet(s+o*r,a+l*r,1),this._vSet(s-o*r,a-l*r,-1)},_roundCapStart:function(t,e,i,r,n){for(var s=t.x,a=t.y,o=i,l=-e,h=0;h<n;h++){var u=h/(n-1)*_v,c=yv(u)*r,_=gv(u)*r;this._vSet(s-o*c-e*_,a-l*c-i*_,1),this._vSet(s,a,0)}this._vSet(s+o*r,a+l*r,1),this._vSet(s-o*r,a-l*r,-1)},_roundCapEnd:function(t,e,i,r,n){var s=t.x,a=t.y,o=i,l=-e;this._vSet(s+o*r,a+l*r,1),this._vSet(s-o*r,a-l*r,-1);for(var h=0;h<n;h++){var u=h/(n-1)*_v,c=yv(u)*r,_=gv(u)*r;this._vSet(s,a,0),this._vSet(s-o*c+e*_,a-l*c+i*_,1)}},_roundJoin:function(t,e,i,r,n){var s=t.dy,a=-t.dx,o=e.dy,l=-e.dx,h=e.x,u=e.y;if(0!=(e.flags&Tp.PT_LEFT)){var c=this._chooseBevel(e.flags&Tp.PT_INNERBEVEL,t,e,i),_=c[0],f=c[1],p=c[2],d=c[3],m=vv(-a,-s),y=vv(-l,-o);y>m&&(y-=2*_v),this._vSet(_,f,1),this._vSet(h-s*r,e.y-a*r,-1);for(var g=Tv(dv((m-y)/_v)*n,2,n),v=0;v<g;v++){var b=m+v/(g-1)*(y-m),S=h+yv(b)*r,A=u+gv(b)*r;this._vSet(h,u,0),this._vSet(S,A,-1)}this._vSet(p,d,1),this._vSet(h-o*r,u-l*r,-1)}else{var C=this._chooseBevel(e.flags&Tp.PT_INNERBEVEL,t,e,-r),x=C[0],T=C[1],w=C[2],E=C[3],B=vv(a,s),D=vv(l,o);D<B&&(D+=2*_v),this._vSet(h+s*r,u+a*r,1),this._vSet(x,T,-1);for(var M=Tv(dv((D-B)/_v)*n,2,n),P=0;P<M;P++){var R=B+P/(M-1)*(D-B),I=h+yv(R)*i,O=u+gv(R)*i;this._vSet(I,O,1),this._vSet(h,u,0)}this._vSet(h+o*r,u+l*r,1),this._vSet(w,E,-1)}},_bevelJoin:function(t,e,i,r){var n=0,s=0,a=0,o=0,l=0,h=0,u=0,c=0,_=t.dy,f=-t.dx,p=e.dy,d=-e.dx;if(e.flags&Tp.PT_LEFT){var m=this._chooseBevel(e.flags&Tp.PT_INNERBEVEL,t,e,i);l=m[0],h=m[1],u=m[2],c=m[3],this._vSet(l,h,1),this._vSet(e.x-_*r,e.y-f*r,-1),this._vSet(u,c,1),this._vSet(e.x-p*r,e.y-d*r,-1)}else{var y=this._chooseBevel(e.flags&Tp.PT_INNERBEVEL,t,e,-r);n=y[0],s=y[1],a=y[2],o=y[3],this._vSet(e.x+_*i,e.y+f*i,1),this._vSet(n,s,-1),this._vSet(e.x+p*i,e.y+d*i,1),this._vSet(a,o,-1)}},_vSet:function(t,e,i){if(void 0===i&&(i=0),bv){var r=bv,n=8*r.vertexStart,s=r.vData;s[n++]=t,s[n++]=e,s[n++]=0,Ui.toArray(s,Av,n),n+=4,s[n++]=i,r.vertexStart++}}},Ev=t("graphicsAssembler",{getAssembler:function(){return wv}});Hd.Assembler=Ev;var Bv=function(){this.char="",this.valid=!0,this.x=0,this.y=0,this.line=0,this.hash=""},Dv=new gr,Mv=null,Pv=null,Rv=[],Iv=[],Ov=[],Fv=[],Lv=new vr,Vv=new vr,kv=new dr,Nv=null,Gv=0,zv=0,Uv=0,Hv=0,jv=0,Wv=1,Xv=null,Yv="",qv=0,Jv=0,Kv=0,Zv=0,Qv=0,$v=0,tb=0,eb=!1,ib=0,rb=0,nb=0,sb={updateRenderData:function(t){t.renderData&&t.renderData.vertDirty&&Mv!==t&&(Pv=(Mv=t).node._uiProps.uiTransformComp,this._updateFontFamily(t),this._updateProperties(t),this._updateLabelInfo(t),this._updateContent(),Mv.actualFontSize=qv,Pv.setContentSize(Vv),Mv.renderData.vertDirty=Mv.renderData.uvDirty=!1,Mv.markForUpdateRenderData(!1),Mv=null,this._resetProperties())},_updateFontScale:function(){Wv=qv/Jv},_updateFontFamily:function(t){var e=t.font;Xv=e.spriteFrame,Nv=e.fntConfig,M_.fontAtlas=e.fontDefDictionary,gc.packToDynamicAtlas(t,Xv)},_updateLabelInfo:function(){M_.hash="",M_.margin=0},_updateProperties:function(t){Yv=t.string.toString(),qv=t.fontSize,Jv=Nv?Nv.fontSize:t.fontSize,Kv=t.horizontalAlign,Zv=t.verticalAlign,Qv=t.spacingX,tb=t.overflow,$v=t._lineHeight;var e=Pv.contentSize;Vv.width=e.width,Vv.height=e.height,tb===bp.NONE?(eb=!1,Vv.width+=2*M_.margin,Vv.height+=2*M_.margin):tb===bp.RESIZE_HEIGHT?(eb=!0,Vv.height+=2*M_.margin):eb=t.enableWrapText,M_.lineHeight=$v,M_.fontSize=qv,this._setupBMFontOverflowMetrics()},_resetProperties:function(){Nv=null,Xv=null,M_.hash="",M_.margin=0},_updateContent:function(){this._updateFontScale(),this._computeHorizontalKerningForText(),this._alignText()},_computeHorizontalKerningForText:function(){for(var t=Yv,e=t.length,i=Nv.kerningDict,r=Rv,n=-1,s=0;s<e;++s){var a=t.charCodeAt(s),o=i[n<<16|65535&a]||0;r[s]=s<e-1?o:0,n=a}},_multilineTextWrap:function(t){for(var e=Yv.length,i=0,r=0,n=0,s=0,a=0,o=0,l=0,h=null,u=0;u<e;){var c=Yv.charAt(u);if("\n"!==c){for(var _=t(Yv,u,e),f=o,p=l,d=a,m=r,y=!1,g=0;g<_;++g){var v=u+g;if("\r"!==(c=Yv.charAt(v)))if(h=M_.fontAtlas.getLetterDefinitionForChar(c,M_)){var b=m+h.offsetX*Wv-M_.margin;if(eb&&nb>0&&r>0&&b+h.w*Wv>nb&&!n_(c)){Ov.push(a),a=0,i++,r=0,n-=$v*this._getFontScale()+0,y=!0;break}kv.x=b,kv.y=n-h.offsetY*Wv,this._recordLetterInfo(kv,c,v,i),v+1<Rv.length&&v<e-1&&(m+=Rv[v+1]),m+=h.xAdvance*Wv+Qv,d=kv.x+h.w*Wv,f<kv.y&&(f=kv.y),p>kv.y-h.h*Wv&&(p=kv.y-h.h*Wv)}else this._recordPlaceholderInfo(v,c),console.log("Can't find letter definition in texture atlas "+Nv.atlasName+" for letter:"+c);else this._recordPlaceholderInfo(v,c)}y||(r=m,o<f&&(o=f),l>p&&(l=p),s<(a=d)&&(s=a),u+=_)}else Ov.push(a),a=0,i++,r=0,n-=$v*this._getFontScale()+0,this._recordPlaceholderInfo(u,c),u++}return Ov.push(a),zv=(Gv=i+1)*$v*this._getFontScale(),Gv>1&&(zv+=0*(Gv-1)),Vv.width=ib,Vv.height=rb,ib<=0&&(Vv.width=parseFloat(s.toFixed(2))+2*M_.margin),rb<=0&&(Vv.height=parseFloat(zv.toFixed(2))+2*M_.margin),Hv=Vv.height,jv=0,o>0&&(Hv=Vv.height+o),l<-zv&&(jv=zv+l),!0},_getFirstCharLen:function(){return 1},_getFontScale:function(){return tb===bp.SHRINK?Wv:1},_getFirstWordLen:function(t,e,i){var r=t.charAt(e);if(r_(r)||"\n"===r||n_(r))return 1;var n=1,s=M_.fontAtlas.getLetterDefinitionForChar(r,M_);if(!s)return n;for(var a=s.xAdvance*Wv+Qv,o=e+1;o<i&&(r=t.charAt(o),s=M_.fontAtlas.getLetterDefinitionForChar(r,M_));++o){if(a+s.offsetX*Wv+s.w*Wv>nb&&!n_(r)&&nb>0)return n;if(a+=s.xAdvance*Wv+Qv,"\n"===r||n_(r)||r_(r))break;n++}return n},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen)},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen)},_recordPlaceholderInfo:function(t,e){if(t>=Iv.length){var i=new Bv;Iv.push(i)}Iv[t].char=e,Iv[t].hash=e.charCodeAt(0)+M_.hash,Iv[t].valid=!1},_recordLetterInfo:function(t,e,i,r){if(i>=Iv.length){var n=new Bv;Iv.push(n)}var s=e.charCodeAt(0)+M_.hash;Iv[i].line=r,Iv[i].char=e,Iv[i].hash=s,Iv[i].valid=M_.fontAtlas.getLetter(s).valid,Iv[i].x=t.x,Iv[i].y=t.y},_alignText:function(){zv=0,Ov.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),tb===bp.SHRINK&&qv>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||tb===bp.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(t){var e=!0;t||(t=.1,e=!1),qv=t,e&&this._updateContent()},_shrinkLabelToContentSize:function(t){for(var e=0,i=0|qv,r=0;e<i;){var n=r=e+i+1>>1;if(n<=0)break;Wv=n/Jv,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),t()?i=r-1:e=r}e>=0&&this._scaleFontSizeDown(e)},_isVerticalClamp:function(){return zv>Vv.height},_isHorizontalClamp:function(){for(var t=!1,e=0,i=Yv.length;e<i;++e){var r=Iv[e];if(r.valid){var n=M_.fontAtlas.getLetterDefinitionForChar(r.char,M_);if(!n)continue;var s=r.x+n.w/2*Wv,a=r.line;if(ib>0)if(eb){if(Ov[a]>Vv.width&&(s>Vv.width||s<0)){t=!0;break}}else if(s>Vv.width){t=!0;break}}}return t},_isHorizontalClamped:function(t,e){var i=Ov[e],r=t>Vv.width||t<0;return eb?i>Vv.width&&r:r},_updateQuads:function(){if(!Mv)return!1;var t=Xv?Xv.texture:M_.fontAtlas.getTexture(),e=Mv.renderData;e.dataLength=e.vertexCount=e.indicesCount=0;for(var i=Pv.anchorPoint,r=Vv,n=i.x*r.width,s=i.y*r.height,a=!0,o=0,l=Yv.length;o<l;++o){var h=Iv[o];if(h.valid){var u=M_.fontAtlas.getLetter(h.hash);if(u){Dv.height=u.h,Dv.width=u.w,Dv.x=u.u,Dv.y=u.v;var c=h.y+Uv;if(rb>0){if(c>Hv){var _=c-Hv;Dv.y+=_,Dv.height-=_,c-=_}c-u.h*Wv<jv&&tb===bp.CLAMP&&(Dv.height=c<jv?0:(c-jv)/Wv)}var f=h.line,p=h.x+u.w/2*Wv+Fv[f];if(ib>0&&this._isHorizontalClamped(p,f))if(tb===bp.CLAMP)Dv.width=0;else if(tb===bp.SHRINK){if(Vv.width>u.w){a=!1;break}Dv.width=0}if(Dv.height>0&&Dv.width>0){var d=this._determineRect(),m=h.x+Fv[h.line];this.appendQuad(Mv,t,Dv,d,m-n,c-s,Wv)}}else console.warn("Can't find letter in this bitmap-font")}}return a},appendQuad:function(){},_determineRect:function(){var t=Xv.isRotated(),e=Xv.getOriginalSize(),i=Xv.getRect(),r=Xv.getOffset(),n=r.x+(e.width-i.width)/2,s=r.y-(e.height-i.height)/2;if(t){var a=Dv.x;Dv.x=i.x+i.height-Dv.y-Dv.height-s,Dv.y=a+i.y-n,Dv.y<0&&(Dv.height+=s)}else Dv.x+=i.x-n,Dv.y+=i.y+s;return t},_computeAlignmentOffset:function(){switch(Fv.length=0,Kv){case gp.LEFT:for(var t=0;t<Gv;++t)Fv.push(0);break;case gp.CENTER:for(var e=0,i=Ov.length;e<i;e++)Fv.push((Vv.width-Ov[e])/2);break;case gp.RIGHT:for(var r=0,n=Ov.length;r<n;r++)Fv.push(Vv.width-Ov[r])}if(Uv=Vv.height,Zv!==vp.TOP){var s=Vv.height-zv+$v*this._getFontScale()-Jv*Wv;Zv===vp.BOTTOM?Uv-=s:Uv-=s/2}},_setupBMFontOverflowMetrics:function(){var t=Vv.width,e=Vv.height;tb===bp.RESIZE_HEIGHT&&(e=0),tb===bp.NONE&&(t=0,e=0),ib=t,rb=e,Lv.width=t,Lv.height=e,nb=t}},ab=new Ui(255,255,255,255),ob={createData:function(t){return t.requestRenderData()},fillBuffers:function(t,e){var i=t.node;t._setCacheAlpha(i._uiProps.opacity),ab.set(t.color),ab.a=255*i._uiProps.opacity,fc(i,e,t.renderData,ab)},appendQuad:function(t,e,i,r,n,s,a){var o=t.renderData;if(o){var l=o.dataLength;o.dataLength+=4,o.vertexCount=o.dataLength,o.indicesCount=o.dataLength/2*3;var h=o.data,u=e.width,c=e.height,_=i.width,f=i.height,p=0,d=0,m=0,y=0;r?(p=i.x/u,y=(i.x+f)/u,d=(i.y+_)/c,m=i.y/c,h[l].u=p,h[l].v=m,h[l+1].u=p,h[l+1].v=d,h[l+2].u=y,h[l+2].v=m,h[l+3].u=y,h[l+3].v=d):(p=i.x/u,y=(i.x+_)/u,d=(i.y+f)/c,m=i.y/c,h[l].u=p,h[l].v=d,h[l+1].u=y,h[l+1].v=d,h[l+2].u=p,h[l+2].v=m,h[l+3].u=y,h[l+3].v=m),h[l].x=n,h[l].y=s-f*a,h[l+1].x=n+_*a,h[l+1].y=s-f*a,h[l+2].x=n,h[l+2].y=s,h[l+3].x=n+_*a,h[l+3].y=s}}};sn(ob,sb);var lb=null,hb=xr(sb,{getAssemblerData:function(){return lb||(lb=new D_(1024,1024)),lb.getTexture()},_updateFontFamily:function(t){M_.fontAtlas=lb,M_.fontFamily=this._getFontFamily(t);var e=t.getComponent($m);e&&e.enabled?(M_.isOutlined=!0,M_.margin=e.width,M_.out=e.color.clone(),M_.out.a=e.color.a*t.color.a/255):(M_.isOutlined=!1,M_.margin=0)},_getFontFamily:function(t){var e="Arial";return t.useSystemFont?e=t.fontFamily||"Arial":t.font&&(t.font._nativeAsset?e=t.font._nativeAsset:qr.postLoadNative(t.font,(function(){t.isValid&&(e=t.font._nativeAsset||"Arial",t.updateRenderData(!0))}))),e},_updateLabelInfo:function(t){var e,i,r;M_.fontDesc=this._getFontDesc(),M_.color=t.color,M_.hash=(i=(e=M_).color.toHEX(),r="",e.isOutlined&&e.margin>0&&(r=r+e.margin+e.out.toHEX()),""+e.fontSize+e.fontFamily+i+r)},_getFontDesc:function(){return M_.fontSize.toString()+"px "+M_.fontFamily},_computeHorizontalKerningForText:function(){},_determineRect:function(){return!1}}),ub=new Ui(255,255,255,255),cb={createData:function(t){return t.requestRenderData()},fillBuffers:function(t,e){if(t.renderData){var i=t.node;t._setCacheAlpha(i._uiProps.opacity),ub.a=255*i._uiProps.opacity,fc(i,e,t.renderData,ub)}},appendQuad:ob.appendQuad};sn(cb,hb);var _b=wp.Overflow,fb=(1/255).toFixed(3),pb=null,db=null,mb=null,yb="",gb="",vb=0,bb=0,Sb=[],Ab=new vr,Cb=0,xb=0,Tb=0,wb=new Ui,Eb=1,Bb="",Db=_b.NONE,Mb=!1,Pb=null,Rb=Ui.BLACK.clone(),Ib=null,Ob=Ui.BLACK.clone(),Fb=new gr,Lb=vr.ZERO.clone(),Vb=vr.ZERO.clone(),kb=dr.ZERO.clone(),Nb=dr.ZERO.clone(),Gb=0,zb=0,Ub=!1,Hb=!1,jb=!1,Wb=["left","center","right"],Xb={getAssemblerData:function(){return wp._canvasPool.get()},resetAssemblerData:function(t){t&&wp._canvasPool.put(t)},updateRenderData:function(t){if(t.renderData&&t.renderData.vertDirty){var e=t.node._uiProps.uiTransformComp;this._updateFontFamily(t),this._updateProperties(t,e),this._calculateLabelFont(),this._updateLabelDimensions(),this._resetDynamicAtlas(t),this._updateTexture(t),this.updateOpacity(t),t._setCacheAlpha(Eb),this._calDynamicAtlas(t),t.actualFontSize=vb,e.setContentSize(Ab),this.updateVertexData(t),this.updateUvs(t),t.markForUpdateRenderData(!1),pb=null,db=null,mb=null}},updateVertexData:function(){},updateUvs:function(){},updateOpacity:function(t){for(var e=t.renderData.vData,i=5,r=t.node._uiProps.opacity,n=0;n<4;n++)e[i+3]=r,i+=9},_updateFontFamily:function(t){t.useSystemFont?Bb=t.fontFamily||"Arial":t.font?t.font._nativeAsset?Bb=t.font._nativeAsset:(qr.postLoadNative(t.font,(function(){t.isValid&&(Bb=t.font._nativeAsset||"Arial",t.updateRenderData(!0))})),Bb="Arial"):Bb="Arial"},_updateProperties:function(t,e){var i=t.assemblerData;i&&(pb=i.context,db=i.canvas,mb=t.spriteFrame,gb=t.string.toString(),vb=t.fontSize,bb=vb,Db=t.overflow,Vb.width=Ab.width=e.width,Vb.height=Ab.height=e.height,zb=t.underlineHeight,Cb=t.lineHeight,xb=t.horizontalAlign,Tb=t.verticalAlign,wb=t.color,Eb=t.node._uiProps.opacity,Ub=t.isBold,Hb=t.isItalic,jb=t.isUnderline,Mb=Db!==_b.NONE&&(Db===_b.RESIZE_HEIGHT||t.enableWrapText),(Pb=(Pb=$m&&t.getComponent($m))&&Pb.enabled&&Pb.width>0?Pb:null)&&Rb.set(Pb.color),(Ib=(Ib=Ug&&t.getComponent(Ug))&&Ib.enabled?Ib:null)&&Ob.set(Ib.color),this._updatePaddingRect())},_updatePaddingRect:function(){var t=0,e=0,i=0,r=0,n=0;if(Lb.width=Lb.height=0,Pb&&(t=e=i=r=n=Pb.width,Lb.width=Lb.height=2*n),Ib){var s=Ib.blur+n,a=Ib.offset.x,o=Ib.offset.y;i=Math.max(i,-a+s),r=Math.max(r,a+s),t=Math.max(t,o+s),e=Math.max(e,-o+s)}if(Hb){var l=bb*Math.tan(.20943951);r+=l,Lb.width+=l}Fb.x=i,Fb.y=t,Fb.width=i+r,Fb.height=t+e},_calculateFillTextStartPosition:function(){var t=0;xb===gp.RIGHT?t=Ab.width-Fb.width:xb===gp.CENTER&&(t=(Ab.width-Fb.width)/2);var e=this._getLineHeight()*(Sb.length-1),i=vb*(1-Yc/2);if(Tb!==vp.TOP){var r=e+Fb.height+vb-Ab.height;Tb===vp.BOTTOM?i-=r+=Yc/2*vb:i-=r/2}i+=0*vb,kb.set(t+Fb.x,i+Fb.y)},_updateTexture:function(t){if(pb&&db){pb.clearRect(0,0,db.width,db.height),pb.font=yb,this._calculateFillTextStartPosition();var e=this._getLineHeight();pb.lineJoin="round",t._srcBlendFactor===E.SRC_ALPHA&&(pb.fillStyle="rgba("+wb.r+", "+wb.g+", "+wb.b+", "+fb+")",pb.fillRect(0,0,db.width,db.height)),pb.fillStyle="rgb("+wb.r+", "+wb.g+", "+wb.b+")";var i,r=kb.x,n=0;this._drawTextEffect(kb,e);for(var s=0;s<Sb.length;++s)n=kb.y+s*e,Pb&&pb.strokeText(Sb[s],r,n),pb.fillText(Sb[s],r,n);Ib&&(pb.shadowColor="transparent"),mb&&(i=mb instanceof xc?mb.texture:mb,0!==db.width&&0!==db.height&&(i.reset({width:db.width,height:db.height,mipmapLevel:1}),i.uploadData(db),mb instanceof xc&&(mb.rect=new gr(0,0,db.width,db.height),mb._calculateUV()),He.director.root&&He.director.root.batcher2D&&He.director.root.batcher2D._releaseDescriptorSetCache(i.getHash())))}},_resetDynamicAtlas:function(t){if(t.cacheMode===wp.CacheMode.BITMAP){var e=t.ttfSpriteFrame;gc.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}},_calDynamicAtlas:function(t){if(t.cacheMode===wp.CacheMode.BITMAP){var e=t.ttfSpriteFrame;gc.packToDynamicAtlas(t,e),t.renderData.uvDirty=!0}},_setupOutline:function(){pb.strokeStyle="rgba("+Rb.r+", "+Rb.g+", "+Rb.b+", "+Rb.a/255+")",pb.lineWidth=2*Pb.width},_setupShadow:function(){pb.shadowColor="rgba("+Ob.r+", "+Ob.g+", "+Ob.b+", "+Ob.a/255+")",pb.shadowBlur=Ib.blur,pb.shadowOffsetX=Ib.offset.x,pb.shadowOffsetY=-Ib.offset.y},_drawTextEffect:function(t,e){if(Ib||Pb||jb){var i=Sb.length>1&&Ib,r=this._measureText(pb,yb),n=0,s=0;Ib&&this._setupShadow(),Pb&&this._setupOutline();for(var a=0;a<Sb.length;++a)n=t.x,s=t.y+a*e,i&&(Pb&&pb.strokeText(Sb[a],n,s),pb.fillText(Sb[a],n,s)),jb&&(Gb=r(Sb[a]),xb===gp.RIGHT?Nb.x=t.x-Gb:xb===gp.CENTER?Nb.x=t.x-Gb/2:Nb.x=t.x,Nb.y=s+bb/8,pb.fillRect(Nb.x,Nb.y,Gb,zb));i&&(pb.shadowColor="transparent")}},_updateLabelDimensions:function(){Ab.width=Math.min(Ab.width,2048),Ab.height=Math.min(Ab.height,2048);var t=!1;db.width!==Ab.width&&(db.width=Ab.width,t=!0),db.height!==Ab.height&&(db.height=Ab.height,t=!0),t&&(pb.font=yb),pb.textAlign=Wb[xb],pb.textBaseline="alphabetic"},_getFontDesc:function(){var t=vb.toString()+"px ";return t+=Bb,Ub&&(t="bold "+t),Hb&&(t="italic "+t),t},_getLineHeight:function(){return 0|(0===Cb?vb:Cb*vb/bb)},_calculateParagraphLength:function(t,e){for(var i,r=[],n=Fe(t);!(i=n()).done;){var s=s_(e,i.value,yb);r.push(s)}return r},_measureText:function(t,e){return function(i){return s_(t,i,e)}},_calculateShrinkFont:function(t){if(pb){var e=this._calculateParagraphLength(t,pb),i=0,r=0,n=0;if(Mb){var s=Vb.width,a=Vb.height;if(s<0||a<0)return;r=a+1;for(var o=0,l=0|vb+1,h=0;o<l;){if((h=o+l+1>>1)<=0){an(4003);break}vb=h,yb=this._getFontDesc(),pb.font=yb;var u=this._getLineHeight();for(r=0,i=0;i<t.length;++i){var c=s_(pb,t[i],yb);r+=o_(t[i],c,s,this._measureText(pb,yb)).length*u}r>a?l=h-1:o=h}0===o?an(4003):(vb=o,yb=this._getFontDesc(),pb.font=yb)}else{for(r=t.length*this._getLineHeight(),i=0;i<t.length;++i)n<e[i]&&(n=e[i]);var _=(Ab.width-Fb.width)/n,f=Ab.height/r;vb=bb*Math.min(1,_,f)|0,yb=this._getFontDesc(),pb.font=yb}}},_calculateWrapText:function(t){if(Mb&&pb){Sb=[];for(var e=Vb.width,i=0;i<t.length;++i){var r=s_(pb,t[i],yb),n=o_(t[i],r,e,this._measureText(pb,yb));Sb=Sb.concat(n)}}},_calculateLabelFont:function(){if(pb){var t=gb.split("\n");switch(Sb=t,yb=this._getFontDesc(),pb.font=yb,Db){case _b.NONE:for(var e=0,i=0,r=0;r<t.length;++r){var n=s_(pb,t[r],yb);e=e>n?e:n}i=(Sb.length+Yc)*this._getLineHeight();var s=parseFloat(e.toFixed(2)),a=parseFloat(i.toFixed(2));Ab.width=s+Fb.width,Ab.height=a+Fb.height,Vb.width=s+Lb.width,Vb.height=a+Lb.height;break;case _b.SHRINK:this._calculateShrinkFont(t),this._calculateWrapText(t);break;case _b.CLAMP:this._calculateWrapText(t);break;case _b.RESIZE_HEIGHT:this._calculateWrapText(t);var o=(Sb.length+Yc)*this._getLineHeight();Ab.height=o+Fb.height,Vb.height=o+Lb.height}}}},Yb=Ui.WHITE.clone(),qb={createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.vertexCount=4,e.indicesCount=6;var i=e.vData=new Float32Array(36);i[3]=i[21]=i[22]=i[31]=0,i[4]=i[12]=i[13]=i[30]=1;for(var r=5,n=0;n<4;n++)Ui.toArray(i,Yb,r),r+=9;return e},fillBuffers:function(t,e){var i=t.renderData,r=i.data,n=t.node,s=e.acquireBufferBatch(),a=s.byteOffset>>2,o=s.indicesOffset,l=s.vertexOffset;s.request()||(s=e.currBufferBatch,o=0,l=0,a=0);var h=s.vData,u=s.iData,c=i.vData,_=r[0],f=r[3];n.updateWorldTransform();var p=n._pos,d=n._rot,m=n._scale,y=_.x*m.x,g=f.x*m.x,v=_.y*m.y,b=f.y*m.y,S=d.x,A=d.y,C=d.z,x=d.w,T=S*A,w=C*x,E=S*S-A*A,B=x*x-C*C,D=B+E,M=2*(T-w),P=B-E,R=2*(T+w),I=p.x,O=p.y;c[0]=D*y+M*v+I,c[1]=P*v+R*y+O,c[9]=D*g+M*v+I,c[10]=P*v+R*g+O,c[18]=D*y+M*b+I,c[19]=P*b+R*y+O,c[27]=D*g+M*b+I,c[28]=P*b+R*g+O,h.set(c,a),u[o++]=l,u[o++]=l+1,u[o++]=l+2,u[o++]=l+2,u[o++]=l+1,u[o++]=l+3},updateVertexData:function(t){var e=t.renderData;if(e){var i=t.node._uiProps.uiTransformComp,r=i.width,n=i.height,s=i.anchorX*r,a=i.anchorY*n,o=e.data;o[0].x=-s,o[0].y=-a,o[3].x=r-s,o[3].y=n-a}},updateUvs:function(t){var e=t.renderData;if(e){var i=e.vData;if(i&&e.uvDirty){var r=t.ttfSpriteFrame.uv;i[3]=r[0],i[4]=r[1],i[12]=r[2],i[13]=r[3],i[21]=r[4],i[22]=r[5],i[30]=r[6],i[31]=r[7],e.uvDirty=!1}}}};sn(qb,Xb);var Jb=t("labelAssembler",{getAssembler:function(t){var e=qb;return t.font instanceof Wc?e=ob:t.cacheMode===wp.CacheMode.CHAR&&(e=cb),e}});wp.Assembler=Jb;var Kb=dy.FillType,Zb=new Ri,Qb=new Ui(255,255,255,255),$b={useModel:!1,updateRenderData:function(t){var e=t.spriteFrame;gc.packToDynamicAtlas(t,e);var i=t.renderData;if(i&&e){var r=i.uvDirty,n=i.vertDirty;if(!r&&!n)return;var s=t.fillStart,a=t.fillRange;a<0&&(s+=a,a=-a),a=(a=(a=s+a)>1?1:a)<0?0:a;var o=(s=(s=s>1?1:s)<0?0:s)+(a=(a-=s)<0?0:a);o=o>1?1:o,r&&this.updateUVs(t,s,o),n&&(this.updateVertexData&&this.updateVertexData(t,s,o),this.updateWorldVertexData(t))}},updateUVs:function(t,e,i){var r=t.spriteFrame,n=t.renderData,s=n.data,a=r.width,o=r.height,l=r.getRect(),h=0,u=0,c=0,_=0,f=0,p=0,d=0,m=0,y=0,g=0;switch(r.isRotated()?(h=l.x/a,u=(l.y+l.width)/o,c=f=h,d=y=(l.x+l.height)/a,p=g=u,_=m=l.y/o):(h=l.x/a,u=(l.y+l.height)/o,c=d=h,f=y=(l.x+l.width)/a,_=p=u,m=g=l.y/o),t.fillType){case Kb.HORIZONTAL:s[0].u=c+(f-c)*e,s[0].v=_+(p-_)*e,s[1].u=c+(f-c)*i,s[1].v=_+(p-_)*i,s[2].u=d+(y-d)*e,s[2].v=m+(g-m)*e,s[3].u=d+(y-d)*i,s[3].v=m+(g-m)*i;break;case Kb.VERTICAL:s[0].u=c+(d-c)*e,s[0].v=_+(m-_)*e,s[1].u=f+(y-f)*e,s[1].v=p+(g-p)*e,s[2].u=c+(d-c)*i,s[2].v=_+(m-_)*i,s[3].u=f+(y-f)*i,s[3].v=p+(g-p)*i;break;default:Re(2626)}n.uvDirty=!1},updateVertexData:function(t,e,i){var r=t.renderData,n=r.data,s=t.node._uiProps.uiTransformComp,a=s.width,o=s.height,l=s.anchorX*a,h=s.anchorY*o,u=-l,c=-h,_=a-l,f=o-h,p=0;switch(t.fillType){case Kb.HORIZONTAL:p=u+(_-u)*i,u+=(_-u)*e,_=p;break;case Kb.VERTICAL:p=c+(f-c)*i,c+=(f-c)*e,f=p;break;default:Re(2626)}n[4].x=u,n[4].y=c,n[5].x=_,n[5].y=c,n[6].x=u,n[6].y=f,n[7].x=_,n[7].y=f,r.vertDirty=!1},createData:function(t){var e=t.requestRenderData();e.dataLength=8,e.vertexCount=4,e.indicesCount=6;for(var i,r=e.data,n=Fe(r);!(i=n()).done;)i.value.z=0;return e},updateWorldVertexData:function(t){var e=t.node,i=t.renderData.data;e.getWorldMatrix(Zb);for(var r=0;r<4;r++){var n=i[r+4],s=i[r];ii.transformMat4(s,n,Zb)}},fillBuffers:function(t,e){t.node.hasChangedFlags&&this.updateWorldVertexData(t);var i=t.node;Qb.set(t.color),Qb.a=255*i._uiProps.opacity,function(t,e,i,r){var n=i.data,s=e.acquireBufferBatch(),a=s.byteOffset>>2,o=i.vertexCount,l=s.indicesOffset,h=s.vertexOffset;s.request(o,i.indicesCount)||(s=e.currBufferBatch,o=0,l=0,h=0);for(var u=s.vData,c=0;c<o;c++){var _=n[c];u[a++]=_.x,u[a++]=_.y,u[a++]=_.z,u[a++]=_.u,u[a++]=_.v,Ui.toArray(u,r,a),a+=4}var f=s.iData;f[l++]=h,f[l++]=h+1,f[l++]=h+2,f[l++]=h+1,f[l++]=h+3,f[l++]=h+2}(0,e,t.renderData,Qb)},updateColor:function(){}},tS=2*Math.PI,eS=1e-6,iS=new Ui(255,255,255,255),rS=[new dr,new dr,new dr,new dr],nS=new Array(4),sS=new Array(8),aS=[new dr,new dr,new dr,new dr],oS=[new dr,new dr,new dr,new dr],lS=new dr,hS=[new dr,new dr,new dr,new dr];function uS(t,e,i,r,n,s,a){var o=Math.sin(s);o=Math.abs(o)>eS?o:0;var l=Math.cos(s),h=0,u=0;if(0!==(l=Math.abs(l)>eS?l:0)){if(h=o/l,(t-n.x)*l>0){var c=n.y+h*(t-n.x);a[0].x=t,a[0].y=c}if((e-n.x)*l>0){var _=n.y+h*(e-n.x);a[2].x=e,a[2].y=_}}if(0!==o){if(u=l/o,(r-n.y)*o>0){var f=n.x+u*(r-n.y);a[3].x=f,a[3].y=r}if((i-n.y)*o>0){var p=n.x+u*(i-n.y);a[1].x=p,a[1].y=i}}}function cS(t,e){var i=e.x-t.x,r=e.y-t.y;if(0===i&&0===r)return 0;if(0===i)return r>0?.5*Math.PI:1.5*Math.PI;var n=Math.atan(r/i);return i<0&&(n+=Math.PI),n}function _S(t,e,i,r,n){var s=nS,a=s[0],o=s[1],l=s[2],h=s[3];t[e].x=i.x,t[e].y=i.y,t[e+1].x=r.x,t[e+1].y=r.y,t[e+2].x=n.x,t[e+2].y=n.y,fS((i.x-a)/(l-a),(i.y-o)/(h-o),t,e),fS((r.x-a)/(l-a),(r.y-o)/(h-o),t,e+1),fS((n.x-a)/(l-a),(n.y-o)/(h-o),t,e+2)}function fS(t,e,i,r){var n=sS,s=n[0]+(n[2]-n[0])*t,a=n[4]+(n[6]-n[4])*t,o=n[1]+(n[3]-n[1])*t,l=n[5]+(n[7]-n[5])*t,h=i[r];h.u=s+(a-s)*e,h.v=o+(l-o)*e}for(var pS={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;gc.packToDynamicAtlas(t,e);var i,r,n,s,a,o,l,h,u,c=t.renderData;if(c&&e&&(c.vertDirty||c.uvDirty)){var _=c.data,f=t.fillStart,p=t.fillRange;for(p<0&&(f+=p,p=-p);f>=1;)f-=1;for(;f<0;)f+=1;var d=(f*=tS)+(p*=tS);!function(t){var e=t.node._uiProps.uiTransformComp,i=e.width,r=e.height,n=e.anchorX*i,s=e.anchorY*r,a=-n,o=-s,l=i-n,h=r-s,u=nS;u[0]=a,u[1]=o,u[2]=l,u[3]=h;var c=t.fillCenter,_=lS.x=Math.min(Math.max(0,c.x),1)*(l-a)+a,f=lS.y=Math.min(Math.max(0,c.y),1)*(h-o)+o;rS[0].x=rS[3].x=a,rS[1].x=rS[2].x=l,rS[0].y=rS[1].y=o,rS[2].y=rS[3].y=h;for(var p,d=Fe(hS);!(p=d()).done;){var m=p.value;dr.set(m,0,0)}_!==u[0]&&dr.set(hS[0],3,0),_!==u[2]&&dr.set(hS[2],1,2),f!==u[1]&&dr.set(hS[1],0,1),f!==u[3]&&dr.set(hS[3],2,3)}(t),r=(i=e).width,n=i.height,s=i.getRect(),a=0,o=0,l=0,h=0,u=sS,i.isRotated()?(a=s.x/r,o=(s.x+s.height)/r,l=s.y/n,h=(s.y+s.width)/n,u[0]=u[2]=a,u[4]=u[6]=o,u[3]=u[7]=h,u[1]=u[5]=l):(a=s.x/r,o=(s.x+s.width)/r,l=s.y/n,h=(s.y+s.height)/n,u[0]=u[4]=a,u[2]=u[6]=o,u[1]=u[3]=h,u[5]=u[7]=l),uS(nS[0],nS[2],nS[1],nS[3],lS,f,aS),uS(nS[0],nS[2],nS[1],nS[3],lS,f+p,oS);for(var m=0,y=0;y<4;++y){var g=hS[y];if(g)if(p>=tS)c.dataLength=m+3,_S(_,m,lS,rS[g.x],rS[g.y]),m+=3;else{var v=cS(lS,rS[g.x]),b=cS(lS,rS[g.y]);b<v&&(b+=tS),v-=tS,b-=tS;for(var S=0;S<3;++S)v>=d||(v>=f?(c.dataLength=m+3,_S(_,m,lS,rS[g.x],b>=d?oS[y]:rS[g.y]),m+=3):b>f&&(b<=d?(c.dataLength=m+3,_S(_,m,lS,aS[y],rS[g.y]),m+=3):(c.dataLength=m+3,_S(_,m,lS,aS[y],oS[y]),m+=3))),v+=tS,b+=tS}}c.indicesCount=c.vertexCount=m,c.vertDirty=c.uvDirty=!1}},fillBuffers:function(t,e){var i=t.node,r=t.renderData;iS.set(t.color),iS.a=255*i._uiProps.opacity,function(t,e,i,r){var n=i.data,s=e.acquireBufferBatch(),a=s.byteOffset>>2,o=i.vertexCount,l=s.indicesOffset,h=s.vertexOffset;s.request(o,i.indicesCount)||(s=e.currBufferBatch,o=0,l=0,h=0);var u=s.vData;t.getWorldMatrix(_c);for(var c=0;c<o;c++){var _=n[c];ii.set(cc,_.x,_.y,0),ii.transformMat4(cc,cc,_c),u[a++]=cc.x,u[a++]=cc.y,u[a++]=cc.z,u[a++]=_.u,u[a++]=_.v,Ui.toArray(u,r,a),a+=4}for(var f=s.iData,p=0;p<i.dataLength;p++)f[l+p]=h+p}(i,e,r,iS)},updateColor:function(){}},dS=[],mS=0;mS<4;mS++)dS.push(new ii);for(var yS={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.vertexCount=4,e.indicesCount=6,e.vData=new Float32Array(36),e},updateRenderData:function(t){var e=t.spriteFrame;gc.packToDynamicAtlas(t,e);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.uvDirty&&this.updateUvs(t))},fillBuffers:function(t,e){if(null!==t){var i=t.renderData.data,r=t.node,n=e.acquireBufferBatch(),s=n.byteOffset>>2,a=n.indicesOffset,o=n.vertexOffset;n.request()||(n=e.currBufferBatch,s=0,a=0,o=0);var l=n.vData,h=n.iData,u=t.renderData.vData,c=i[0],_=i[3],f=r.worldMatrix,p=f.m00,d=f.m01,m=f.m04,y=f.m05,g=f.m12,v=f.m13,b=c.x,S=_.x,A=c.y,C=_.y,x=p*b,T=p*S,w=d*b,E=d*S,B=m*A,D=m*C,M=y*A,P=y*C;u[0]=x+B+g,u[1]=w+M+v,u[9]=T+B+g,u[10]=E+M+v,u[18]=x+D+g,u[19]=w+P+v,u[27]=T+D+g,u[28]=E+P+v,l.set(u,s),h[a++]=o,h[a++]=o+1,h[a++]=o+2,h[a++]=o+2,h[a++]=o+1,h[a++]=o+3}},updateVertexData:function(t){var e=t.renderData;if(e){var i=t.node._uiProps.uiTransformComp,r=e.data,n=i.width,s=i.height,a=i.anchorX*n,o=i.anchorY*s,l=0,h=0,u=0,c=0;if(t.trim)l=-a,h=-o,u=n-a,c=s-o;else{var _=t.spriteFrame,f=_.getOriginalSize(),p=_.getRect(),d=f.width,m=f.height,y=p.width,g=p.height,v=_.getOffset(),b=n/d,S=s/m,A=v.x+(d-y)/2,C=v.x-(d-y)/2;l=A*b-a,h=(v.y+(m-g)/2)*S-o,u=n+C*b-a,c=s+(v.y-(m-g)/2)*S-o}r[0].x=l,r[0].y=h,r[0].z=0,r[3].x=u,r[3].y=c,r[3].z=0,e.vertDirty=!1}},updateUvs:function(t){var e=t.renderData,i=e.vData,r=t.spriteFrame.uv;i[3]=r[0],i[4]=r[1],i[12]=r[2],i[13]=r[3],i[21]=r[4],i[22]=r[5],i[30]=r[6],i[31]=r[7],e.uvDirty=!1},updateColor:function(t){for(var e=t.renderData.vData,i=5,r=t.color,n=r.r/255,s=r.g/255,a=r.b/255,o=t.node._uiProps.opacity,l=0;l<4;l++)e[i]=n,e[i+1]=s,e[i+2]=a,e[i+3]=o,i+=9}},gS=new ii,vS=new Ri,bS={useModel:!1,createData:function(t){var e=t.requestRenderData();return e.dataLength=20,e.vertexCount=16,e.indicesCount=54,e},updateRenderData:function(t){var e=t.spriteFrame;gc.packToDynamicAtlas(t,e);var i=t.renderData;i&&e&&i.vertDirty&&(this.updateVertexData(t),this.updateWorldVertexData(t))},updateVertexData:function(t){var e=t.renderData,i=e.data,r=t.node._uiProps.uiTransformComp,n=r.width,s=r.height,a=r.anchorX*n,o=r.anchorY*s,l=t.spriteFrame,h=l.insetLeft,u=l.insetRight,c=l.insetTop,_=l.insetBottom,f=n-h-u,p=s-c-_,d=n/(h+u),m=s/(c+_);d=Number.isNaN(d)||d>1?1:d,m=Number.isNaN(m)||m>1?1:m,f=f<0?0:f,p=p<0?0:p,i[0].x=-a,i[0].y=-o,i[1].x=h*d-a,i[1].y=_*m-o,i[2].x=i[1].x+f,i[2].y=i[1].y+p,i[3].x=n-a,i[3].y=s-o,e.vertDirty=!1},fillBuffers:function(t,e){t.node.hasChangedFlags&&this.updateWorldVertexData(t);var i=e.acquireBufferBatch(),r=t.renderData,n=r.data,s=i.byteOffset>>2,a=r.vertexCount,o=i.indicesOffset,l=i.vertexOffset,h=t.spriteFrame.uvSliced;i.request(a,r.indicesCount)||(i=e.currBufferBatch,s=0,o=0,l=0);for(var u=i.vData,c=i.iData,_=4;_<20;++_){var f=n[_],p=h[_-4];u[s++]=f.x,u[s++]=f.y,u[s++]=f.z,u[s++]=p.u,u[s++]=p.v,Ui.toArray(u,n[_].color,s),s+=4}for(var d=0;d<3;++d)for(var m=0;m<3;++m){var y=l+4*d+m;c[o++]=y,c[o++]=y+1,c[o++]=y+4,c[o++]=y+1,c[o++]=y+5,c[o++]=y+4}},updateWorldVertexData:function(t){var e=t.node,i=t.renderData.data;e.getWorldMatrix(vS);for(var r=0;r<4;++r)for(var n=i[r],s=0;s<4;++s){var a=i[s],o=i[4+4*r+s];ii.set(gS,a.x,n.y,0),ii.transformMat4(o,gS,vS)}},updateColor:function(t){for(var e=t.renderData.data,i=t.color,r=i.r,n=i.g,s=i.b,a=255*t.node._uiProps.opacity,o=4;o<20;o++)e[o].color.r=r,e[o].color.g=n,e[o].color.b=s,e[o].color.a=a}},SS=[],AS=0;AS<4;AS++)SS.push(new ii);var CS={createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.renderData,i=t.spriteFrame;if(i&&e&&(e.uvDirty||e.vertDirty)){var r=t.node._uiProps.uiTransformComp,n=Math.abs(r.width),s=Math.abs(r.height),a=i.getRect(),o=i.insetLeft,l=i.insetRight,h=a.width-o-l,u=i.insetTop,c=i.insetBottom,_=a.height-u-c,f=n-o-l,p=s-u-c;f=f>0?f:0,p=p>0?p:0;var d=0===h?f:f/h,m=0===_?p:p/_,y=Math.ceil(m+2),g=Math.ceil(d+2);e.dataLength=Math.max(8,y+1,g+1),this.updateVerts(t,f,p,y,g),e.vertexCount=y*g*4,e.indicesCount=y*g*6,e.uvDirty=!1,e.vertDirty=!1,this.updateColor(t)}},fillBuffers:function(t,e){var i=t.node,r=t.node._uiProps.uiTransformComp,n=Math.abs(r.width),s=Math.abs(r.height),a=t.renderData,o=e.acquireBufferBatch(),l=o.indicesOffset,h=o.byteOffset>>2,u=o.vertexOffset,c=a.vertexCount,_=a.indicesCount,f=o.vData,p=o.iData;o.request(c,_)||(o=e.currBufferBatch,h=0,l=0,u=0);var d=t.spriteFrame,m=d.isRotated(),y=d.uv,g=t.spriteFrame.uvSliced,v=d.getRect(),b=d.insetLeft,S=d.insetRight,A=v.width-b-S,C=d.insetTop,x=d.insetBottom,T=v.height-C-x,w=n-b-S,E=s-C-x;w=w>0?w:0,E=E>0?E:0;var B=0===A?w:w/A,D=0===T?E:E/T,M=Math.ceil(D+2),P=Math.ceil(B+2),R=i.worldMatrix,I=a.data;this.fillVertices(f,h,R,M,P,I);for(var O=0,F=0,L=[],V=[],k=0,N=M;k<N;++k){F=E>T?E>=k*T?1:D%1:D;for(var G=0,z=P;G<z;++G){O=w>A?w>=G*A?1:B%1:B;var U=h+3,H=U+1;m?(0===k?(L[0]=g[0].u,L[1]=g[0].u,L[2]=g[4].u+(g[8].u-g[4].u)*F):k<M-1?(L[0]=g[4].u,L[1]=g[4].u,L[2]=g[4].u+(g[8].u-g[4].u)*F):k===M-1&&(L[0]=g[8].u,L[1]=g[8].u,L[2]=g[12].u),0===G?(V[0]=g[0].v,V[1]=g[1].v+(g[2].v-g[1].v)*O,V[2]=g[0].v):G<P-1?(V[0]=g[1].v,V[1]=g[1].v+(g[2].v-g[1].v)*O,V[2]=g[1].v):G===P-1&&(V[0]=g[2].v,V[1]=g[3].v,V[2]=g[2].v),L[3]=L[2],V[3]=V[1]):(0===G?(L[0]=g[0].u,L[1]=g[1].u+(g[2].u-g[1].u)*O,L[2]=y[0]):G<P-1?(L[0]=g[1].u,L[1]=g[1].u+(g[2].u-g[1].u)*O,L[2]=g[1].u):G===P-1&&(L[0]=g[2].u,L[1]=g[3].u,L[2]=g[2].u),0===k?(V[0]=g[0].v,V[1]=g[0].v,V[2]=g[4].v+(g[8].v-g[4].v)*F):k<M-1?(V[0]=g[4].v,V[1]=g[4].v,V[2]=g[4].v+(g[8].v-g[4].v)*F):k===M-1&&(V[0]=g[8].v,V[1]=g[8].v,V[2]=g[12].v),L[3]=L[1],V[3]=V[2]),f[U]=L[0],f[H]=V[0],f[U+9]=L[1],f[H+9]=V[1],f[U+18]=L[2],f[H+18]=V[2],f[U+27]=L[3],f[H+27]=V[3],Ui.toArray(f,I[0].color,H+1),Ui.toArray(f,I[0].color,H+9+1),Ui.toArray(f,I[0].color,H+18+1),Ui.toArray(f,I[0].color,H+27+1),h+=36}}for(var j=0;j<_;j+=6)p[l++]=u,p[l++]=u+1,p[l++]=u+2,p[l++]=u+1,p[l++]=u+3,p[l++]=u+2,u+=4},fillVertices:function(t,e,i,r,n,s){for(var a=0,o=0,l=0,h=0,u=0,c=r;u<c;++u){l=s[u].y,h=s[u+1].y;for(var _=0,f=n;_<f;++_){a=s[_].x,o=s[_+1].x,ii.set(SS[0],a,l,0),ii.set(SS[1],o,l,0),ii.set(SS[2],a,h,0),ii.set(SS[3],o,h,0);for(var p=0;p<4;p++){var d=SS[p];ii.transformMat4(d,d,i);var m=9*p;t[e+m]=d.x,t[e+m+1]=d.y,t[e+m+2]=d.z}e+=36}}},updateVerts:function(t,e,i,r,n){var s,a,o=t.node._uiProps.uiTransformComp,l=t.renderData.data,h=t.spriteFrame,u=h.getRect(),c=Math.abs(o.width),_=Math.abs(o.height),f=o.anchorX*c,p=o.anchorY*_,d=h.insetLeft,m=h.insetRight,y=u.width-d-m,g=h.insetTop,v=h.insetBottom,b=u.height-g-v,S=o.width/(d+m)>1?1:o.width/(d+m),A=o.height/(g+v)>1?1:o.height/(g+v);s=y>0?Math.floor(1e3*e)/1e3%y==0?y:e%y:e,a=b>0?Math.floor(1e3*i)/1e3%b==0?b:i%b:i;for(var C=0;C<=n;C++)0===C?l[C].x=-f:C>0&&C<n?l[C].x=1===C?d*S+Math.min(y,e)-f:y>0?C===n-1?d+s+y*(C-2)-f:d+Math.min(y,e)+y*(C-2)-f:d+e-f:C===n&&(l[C].x=Math.min(d+e+m,c)-f);for(var x=0;x<=r;x++)0===x?l[x].y=-p:x>0&&x<r?l[x].y=1===x?v*A+Math.min(b,i)-p:b>0?x===r-1?v+a+(x-2)*b-p:v+Math.min(b,i)+(x-2)*b-p:v+i-p:x===r&&(l[x].y=Math.min(v+i+g,_)-p)},updateColor:function(t){var e=t.renderData.data,i=e.length;if(0!==i)for(var r=t.color,n=r.r,s=r.g,a=r.b,o=255*t.node._uiProps.opacity,l=0;l<i;l++)e[l].color.r=n,e[l].color.g=s,e[l].color.b=a,e[l].color.a=o}},xS=dy.Type,TS=dy.FillType,wS=t("spriteAssembler",{getAssembler:function(t){var e=yS,i=t;switch(i.type){case xS.SLICED:e=bS;break;case xS.TILED:e=CS;break;case xS.FILLED:e=i.fillType===TS.RADIAL?pS:$b}return e}});dy.Assembler=wS;var ES=cf.sharedManager,BS={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.vertexCount=4,e.indicesCount=6,e.vData=new Float32Array(36),e},updateRenderData:function(t){t.type===Nd.IMAGE_STENCIL&&(yS.updateRenderData(t),yS.updateColor(t))},fillBuffers:function(t,e){(t.type!==Nd.IMAGE_STENCIL||t.spriteFrame)&&(ES.pushMask(t),e.finishMergeBatches(),function(t,e){ES.clear(t),e.commitModel(t,t._clearModel,t._clearStencilMtl)}(t,e),function(t,e){if(ES.enterLevel(t),t.type===Nd.IMAGE_STENCIL){yS.fillBuffers(t,e);var i=t.graphics.getMaterialInstance(0);e.forceMergeBatches(i,t.spriteFrame,t.graphics)}else t.graphics.updateAssembler(e)}(t,e),ES.enableMask())}},DS={fillBuffers:function(){ES.exitMask()}},MS={getAssembler:function(){return BS}},PS={getAssembler:function(){return DS}};qd.Assembler=MS,qd.PostAssembler=PS;var RS=new It(null),IS=new Ri,OS=t("UI",function(){var t=n.prototype;function n(t){var n=this;this.device=void 0,this._screens=[],this._bufferBatchPool=new i((function(){return new _g(n)}),128),this._drawBatchPool=void 0,this._meshBuffers=new Map,this._customMeshBuffers=new Map,this._meshBufferUseCount=new Map,this._batches=void 0,this._doUploadBuffersCall=new Map,this._emptyMaterial=new cr,this._currScene=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currMeshBuffer=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currBlendTargetHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._currIsStatic=!1,this._descriptorSetCache=new LS,this._root=t,this.device=t.device,this._batches=new r(64),this._drawBatchPool=new e((function(){return new Gg}),128)}return t.acquireBufferBatch=function(t){void 0===t&&(t=ud);var e=t===ud?36:fd(t);return this._currMeshBuffer&&this._currMeshBuffer.vertexFormatBytes===e||this._requireBufferBatch(t),this._currMeshBuffer},t.registerCustomBuffer=function(t,e){var i;t instanceof _g?i=t:(i=this._bufferBatchPool.add()).initialize(t,e||this._recreateMeshBuffer.bind(this,t));var r=i.vertexFormatBytes,n=this._customMeshBuffers.get(r);return n||(n=[],this._customMeshBuffers.set(r,n)),n.push(i),i},t.unRegisterCustomBuffer=function(t){var e=this._customMeshBuffers.get(t.vertexFormatBytes);if(e)for(var i=0;i<e.length;i++)if(e[i]===t){e.splice(i,1);break}},t.initialize=function(){return!0},t.destroy=function(){for(var t=this,e=0;e<this._batches.length;e++)this._batches.array[e]&&this._batches.array[e].destroy(this);this._batches.destroy();for(var i,r=Fe(this._meshBuffers.keys());!(i=r()).done;){var n=i.value,s=this._meshBuffers.get(n);s&&s.forEach((function(t){return t.destroy()}))}this._drawBatchPool&&this._drawBatchPool.destroy((function(e){e.destroy(t)})),this._descriptorSetCache.destroy(),this._meshBuffers.clear(),cf.sharedManager.destroy()},t.addScreen=function(t){this._screens.push(t),this._screens.sort(this._screenSort)},t.getFirstRenderCamera=function(t){if(t.scene&&t.scene.renderScene)for(var e=t.scene.renderScene.cameras,i=0;i<e.length;i++){var r=e[i];if(r.visibility&t.layer)return r}return null},t.removeScreen=function(t){var e=this._screens.indexOf(t);-1!==e&&this._screens.splice(e,1)},t.sortScreens=function(){this._screens.sort(this._screenSort)},t.addUploadBuffersFunc=function(t,e){this._doUploadBuffersCall.set(t,e)},t.removeUploadBuffersFunc=function(t){this._doUploadBuffersCall.delete(t)},t.update=function(){for(var t=this._screens,e=0;e<t.length;++e){var i=t[e];i.enabledInHierarchy&&this._recursiveScreenNode(i.node)}var r=0;if(this._batches.length)for(var n=0;n<this._batches.length;++n){var s=this._batches.array[n];if(s.renderScene){if(s.model)for(var a=s.model.subModels,o=0;o<a.length;o++)a[o].priority=r++;else s.hDescriptorSet=this._descriptorSetCache.getDescriptorSet(s);s.renderScene.addBatch(s)}}},t.uploadBuffers=function(){var t=this;this._batches.length>0&&(this._doUploadBuffersCall.forEach((function(e,i){e.call(i,t)})),this._meshBuffers.forEach((function(t){t.forEach((function(t){t.uploadBuffers(),t.reset()}))})),this._customMeshBuffers.forEach((function(t){t.forEach((function(t){t.uploadBuffers(),t.reset()}))})),this._descriptorSetCache.update())},t.reset=function(){for(var t=0;t<this._batches.length;++t){var e=this._batches.array[t];e.isStatic||(e.clear(),this._drawBatchPool.free(e))}this._currLayer=0,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currComponent=null,this._currTransform=null,this._currScene=null,this._currMeshBuffer=null,this._meshBufferUseCount.clear(),this._batches.clear(),cf.sharedManager.reset(),this._descriptorSetCache.reset()},t.commitComp=function(t,e,i,r){var n,s,a=t,o=0,l=0;e?(n=e.getGFXTexture(),s=e.getGFXSampler(),o=e.getHash(),l=e.getSamplerHash()):(n=null,s=null);var h=a._getRenderScene(),u=a.getRenderMaterial(0);a.stencilStage=cf.sharedManager.stage;var c=a.blendHash,_=a.stencilStage;this._currScene===h&&this._currLayer===t.node.layer&&this._currMaterial===u&&this._currBlendTargetHash===c&&this._currDepthStencilStateStage===_&&this._currTextureHash===o&&this._currSamplerHash===l&&this._currTransform===r||(this.autoMergeBatches(this._currComponent),this._currScene=h,this._currComponent=a,this._currTransform=r,this._currMaterial=u,this._currTexture=n,this._currSampler=s,this._currTextureHash=o,this._currSamplerHash=l,this._currBlendTargetHash=c,this._currDepthStencilStateStage=_,this._currLayer=t.node.layer),i&&i.fillBuffers(a,this)},t.commitModel=function(t,e,i){var r;this._currMaterial!==this._emptyMaterial&&this.autoMergeBatches(this._currComponent);var n=0;i&&(t.stencilStage!==A_.ENABLED&&t.stencilStage!==A_.DISABLED||(t.stencilStage=cf.sharedManager.stage),r=cf.sharedManager.getStencilStage(t.stencilStage,i),n=cf.sharedManager.getStencilHash(t.stencilStage));var s=He.director.getTotalFrames();e&&(e.updateTransform(s),e.updateUBOs(s));for(var a=0;a<e.subModels.length;a++){var o=this._drawBatchPool.alloc(),l=e.subModels[a];o.renderScene=t._getRenderScene(),o.visFlags=t.node.layer,o.model=e,o.bufferBatch=null,o.texture=null,o.sampler=null,o.useLocalData=null,r||(r=null),o.fillPasses(i,r,n,null,0,l.patches),o.hDescriptorSet=on.get(l.handle,ln.DESCRIPTOR_SET),o.hInputAssembler=on.get(l.handle,ln.INPUT_ASSEMBLER),o.model.visFlags=o.visFlags,this._batches.push(o)}this._currMaterial=this._emptyMaterial,this._currScene=null,this._currComponent=null,this._currTransform=null,this._currTexture=null,this._currSampler=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},t.commitStaticBatch=function(t){this._batches.concat(t.drawBatchList),this.finishMergeBatches()},t.autoMergeBatches=function(t){var e=this.currBufferBatch,i=null==e?void 0:e.recordBatch(),r=this._currMaterial;if(i&&r&&e){var n,s,a=0,o=0;t&&(n=-1===t.blendHash?null:t.getBlendState(),o=t.blendHash,s=null!==t.customMaterial?cf.sharedManager.getStencilStage(t.stencilStage,r):cf.sharedManager.getStencilStage(t.stencilStage),a=cf.sharedManager.getStencilHash(t.stencilStage));var l=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();l.renderScene=this._currScene,l.visFlags=this._currLayer,l.bufferBatch=e,l.texture=this._currTexture,l.sampler=this._currSampler,l.hInputAssembler=i,l.useLocalData=this._currTransform,l.textureHash=this._currTextureHash,l.samplerHash=this._currSamplerHash,l.fillPasses(r,s,a,n,o,null),this._batches.push(l),e.vertexStart=e.vertexOffset,e.indicesStart=e.indicesOffset,e.byteStart=e.byteOffset,ke.__isWebIOS14OrIPadOS14Env&&!this._currIsStatic&&(this._currMeshBuffer=null)}},t.forceMergeBatches=function(t,e,i){this._currMaterial=t,e?(this._currTexture=e.getGFXTexture(),this._currSampler=e.getGFXSampler(),this._currTextureHash=e.getHash(),this._currSamplerHash=e.getSamplerHash()):(this._currTexture=this._currSampler=null,this._currTextureHash=this._currSamplerHash=0),this._currLayer=i.node.layer,this._currScene=i._getRenderScene(),this.autoMergeBatches(i)},t.finishMergeBatches=function(){this.autoMergeBatches(),this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},t.flushMaterial=function(t){this._currMaterial=t},t.walk=function(t,e){void 0===e&&(e=0);var i=t.children.length;if(this._preProcess(t),i>0&&!t._static)for(var r=t.children,n=0;n<r.length;++n){var s=r[n];this.walk(s,e)}this._postProcess(t),e+=1},t._preProcess=function(t){var e=t._uiProps.uiComp;if(!e){var i=t._uiProps.localOpacity;t._uiProps.opacity=t.parent&&t.parent._uiProps?t.parent._uiProps.opacity*i:i}t._uiProps.uiTransformComp&&e&&e.enabledInHierarchy&&e.updateAssembler(this)},t._postProcess=function(t){var e=t._uiProps.uiComp;e&&e.enabledInHierarchy&&e.postUpdateAssembler(this)},t._recursiveScreenNode=function(t){this.walk(t),this.autoMergeBatches(this._currComponent)},t._createMeshBuffer=function(t){var e=this._bufferBatchPool.add();e.initialize(t,this._recreateMeshBuffer.bind(this,t));var i=fd(t),r=this._meshBuffers.get(i);return r||(r=[],this._meshBuffers.set(i,r)),r.push(e),e},t._recreateMeshBuffer=function(t,e,i){this.autoMergeBatches(),this._requireBufferBatch(t,e,i)},t._requireBufferBatch=function(t,e,i){var r=fd(t),n=this._meshBuffers.get(r);n||(n=[],this._meshBuffers.set(r,n));var s=this._meshBufferUseCount.get(r)||0;s>=n.length?this._currMeshBuffer=this._createMeshBuffer(t):this._currMeshBuffer=n[s],this._meshBufferUseCount.set(r,s+1),e&&i&&this._currMeshBuffer.request(e,i)},t._screenSort=function(t,e){return t.node.getSiblingIndex()-e.node.getSiblingIndex()},t._releaseDescriptorSetCache=function(t){this._descriptorSetCache.releaseDescriptorSetCache(t)},Pe(n,[{key:"currBufferBatch",get:function(){return this._currMeshBuffer||(this._currMeshBuffer=this.acquireBufferBatch()),this._currMeshBuffer},set:function(t){t&&(this._currMeshBuffer=t)}},{key:"batches",get:function(){return this._batches}},{key:"currStaticRoot",set:function(t){this._currStaticRoot=t}},{key:"currIsStatic",set:function(t){this._currIsStatic=t}}]),n}()),FS=function(){function t(){this._handle=null,this._transform=null,this._textureHash=0,this._samplerHash=0,this._localBuffer=null,this._transformUpdate=!0;var t=He.director.root.device;this._localData=new Float32Array(un.COUNT),this._localBuffer=t.createBuffer(new nt(d.UNIFORM|d.TRANSFER_DST,g.HOST|g.DEVICE,un.SIZE,un.SIZE))}var e=t.prototype;return e.initialize=function(t){var e=He.director.root.device;this._transform=t.useLocalData,this._textureHash=t.textureHash,this._samplerHash=t.samplerHash,RS.layout=t.passes[0].localSetLayout,this._handle&&(hn.free(this._handle),this._handle=null),this._handle=hn.alloc(e,RS),this._descriptorSet=hn.get(this._handle),this._descriptorSet.bindBuffer(un.BINDING,this._localBuffer);var i=cn.SAMPLER_SPRITE;this._descriptorSet.bindTexture(i,t.texture),this._descriptorSet.bindSampler(i,t.sampler),this._descriptorSet.update(),this._transformUpdate=!0},e.updateTransform=function(t){t!==this._transform&&(this._transform=t,this._transformUpdate=!0,this.uploadLocalData())},e.updateLocal=function(){this._transform&&this.uploadLocalData()},e.equals=function(t,e,i){return this._transform===t&&this._textureHash===e&&this._samplerHash===i},e.reset=function(){this._transform=null,this._textureHash=0,this._samplerHash=0},e.destroy=function(){this._localBuffer&&(this._localBuffer.destroy(),this._localBuffer=null),this._handle&&(hn.free(this._handle),this._handle=null),this._localData=null},e.uploadLocalData=function(){var t=this._transform;if((t.hasChangedFlags||t._dirtyFlags)&&t.updateWorldTransform(),this._transformUpdate){var e=t._mat;Ri.toArray(this._localData,e,un.MAT_WORLD_OFFSET),Ri.inverseTranspose(IS,e),Ri.toArray(this._localData,IS,un.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData),this._transformUpdate=!1}},Pe(t,[{key:"handle",get:function(){return this._handle}}]),t}(),LS=function(){function t(){this._descriptorSetCache=new Map,this._localDescriptorSetCache=[],this._localCachePool=void 0,this._localCachePool=new e((function(){return new FS}),16)}var i=t.prototype;return i.getDescriptorSet=function(t){var e=He.director.root;if(t.useLocalData){for(var i=this._localDescriptorSetCache,r=0,n=i.length;r<n;r++){var s=i[r];if(s.equals(t.useLocalData,t.textureHash,t.samplerHash))return s.handle}var a=this._localCachePool.alloc();return a.initialize(t),this._localDescriptorSetCache.push(a),a.handle}var o=this._descriptorSetCache.get(t.textureHash);if(o&&o.has(t.samplerHash))return o.get(t.samplerHash);RS.layout=t.passes[0].localSetLayout;var l=hn.alloc(e.device,RS),h=hn.get(l),u=cn.SAMPLER_SPRITE;return h.bindTexture(u,t.texture),h.bindSampler(u,t.sampler),h.update(),o?this._descriptorSetCache.get(t.textureHash).set(t.samplerHash,l):this._descriptorSetCache.set(t.textureHash,new Map([[t.samplerHash,l]])),l},i.update=function(){this._localDescriptorSetCache.forEach((function(t){t.updateLocal()}))},i.reset=function(){var t=this;this._localDescriptorSetCache.forEach((function(e){t._localCachePool.free(e)})),this._localDescriptorSetCache.length=0},i.releaseDescriptorSetCache=function(t){this._descriptorSetCache.has(t)&&(this._descriptorSetCache.get(t).forEach((function(t){hn.free(t)})),this._descriptorSetCache.delete(t))},i.destroy=function(){this._descriptorSetCache.forEach((function(t){t.forEach((function(t){hn.free(t)}))})),this._descriptorSetCache.clear(),this._localDescriptorSetCache.length=0,this._localCachePool.destroy((function(t){t.destroy()}))},t}();He.internal.Batcher2D=OS;var VS,kS,NS,GS,zS,US,HS,jS,WS,XS,YS,qS,JS,KS,ZS,QS,$S,tA,eA,iA,rA,nA,sA,aA,oA,lA,hA,uA,cA,_A,fA,pA,dA,mA,yA,gA,vA,bA,SA,AA,CA,xA,TA,wA,EA,BA,DA,MA,PA,RA,IA,OA=null,FA=-1,LA="BES bswy:->@123丁ぁᄁ",VA=Object.create(null),kA=[],NA=3e3;function GA(){for(var t=!0,e=Date.now(),i=kA.length-1;i>=0;i--){var r=kA[i],n=r.fontFamilyName;if(e-r.startTime>NA)ze(4933,n),r.onComplete(null,n),kA.splice(i,1);else{var s=r.refWidth,a="40px "+n;OA.font=a,s!==s_(OA,LA,a)?(kA.splice(i,1),r.onComplete(null,n)):t=!1}}t&&(clearInterval(FA),FA=-1)}function zA(t,e,i){var r=function(t){var e=t.lastIndexOf(".ttf");if(-1===e)return t;var i,r=t.lastIndexOf("/");return-1!==(i=-1===r?t.substring(0,e)+"_LABEL":t.substring(r+1,e)+"_LABEL").indexOf(" ")&&(i='"'+i+'"'),i}(t);if(VA[r])i(null,r);else{if(!OA){var n=document.createElement("canvas");n.width=100,n.height=100,OA=n.getContext("2d")}var s=s_(OA,LA,"40px "+r),a=document.createElement("style");a.type="text/css";var o="";Number.isNaN(r)?o+="@font-face { font-family:"+r+"; src:":o+='@font-face { font-family:"'+r+'"; src:',o+='url("'+t+'");',a.textContent=o+"}",document.body.appendChild(a);var l,h,u,c,_,f,p=document.createElement("div"),d=p.style;if(d.fontFamily=r,p.innerHTML=".",d.position="absolute",d.left="-100px",d.top="-100px",document.body.appendChild(p),function(){if(void 0===VS)if("FontFace"in window){var t=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);VS=t?parseInt(t[1],10)>42:!e}else VS=!1;return VS}())l=Date.now(),h=r,u=i,c=new Promise((function(t,e){!function i(){Date.now()-l>=NA?e():document.fonts.load("40px "+h).then((function(e){e.length>=1?t():setTimeout(i,100)}),(function(){e()}))}()})),_=null,f=new Promise((function(t,e){_=setTimeout(e,NA)})),Promise.race([f,c]).then((function(){_&&(clearTimeout(_),_=null),u(null,h)}),(function(){ze(4933,h),u(null,h)}));else{var m={fontFamilyName:r,refWidth:s,onComplete:i,startTime:Date.now()};kA.push(m),-1===FA&&(FA=setInterval(GA,100))}VA[r]=a}}function UA(t,e,i,r){var n=new zc;n._nativeUrl=t,n._nativeAsset=e,r(null,n)}_n.register({".font":zA,".eot":zA,".ttf":zA,".woff":zA,".svg":zA,".ttc":zA}),fn.register({".font":UA,".eot":UA,".ttf":UA,".woff":UA,".svg":UA,".ttc":UA}),He.UI={MeshBuffer:_g,spriteAssembler:wS,graphicsAssembler:Ev,labelAssembler:Jb};var HA,jA,WA,XA=new Ui;!function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.SPRITE=2]="SPRITE",t[t.SCALE=3]="SCALE"}(HA||(HA={})),Pr(HA),function(t){t.NORMAL="normal",t.HOVER="hover",t.PRESSED="pressed",t.DISABLED="disabled"}(jA||(jA={})),function(t){t.CLICK="click"}(WA||(WA={}));var YA,qA,JA,KA=function(e){return t({Button:e,ButtonComponent:e}),e}((kS=ri("cc.Button"),NS=wi(),GS=Ei(110),zS=Bi(),US=Rr(j_),HS=bi(ur),jS=Mr(),WS=Di(),XS=Mr(),YS=Di(),qS=bi(HA),JS=Mr(),KS=Di(),ZS=Di(),QS=Di(),$S=Di(),tA=Di(),eA=mn(),iA=yn(),rA=Di(),nA=Di(),sA=bi(xc),aA=Di(),oA=bi(xc),lA=Di(),hA=bi(xc),uA=Di(),cA=bi(xc),_A=Di(),fA=bi([pn]),pA=Mr(),dA=Di(),kS(mA=NS(mA=GS(mA=zS(mA=US(mA=Si((IA=RA=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"clickEvents",gA,hi(e)),li(e,"_interactable",vA,hi(e)),li(e,"_transition",bA,hi(e)),li(e,"_normalColor",SA,hi(e)),li(e,"_hoverColor",AA,hi(e)),li(e,"_pressedColor",CA,hi(e)),li(e,"_disabledColor",xA,hi(e)),li(e,"_normalSprite",TA,hi(e)),li(e,"_hoverSprite",wA,hi(e)),li(e,"_pressedSprite",EA,hi(e)),li(e,"_disabledSprite",BA,hi(e)),li(e,"_duration",DA,hi(e)),li(e,"_zoomScale",MA,hi(e)),li(e,"_target",PA,hi(e)),e._pressed=!1,e._hovered=!1,e._fromColor=new Ui,e._toColor=new Ui,e._time=0,e._transitionFinished=!0,e._fromScale=new ii,e._toScale=new ii,e._originalScale=null,e._sprite=null,e._targetScale=new ii,e}Me(e,t);var i=e.prototype;return i.__preload=function(){this.target||(this.target=this.node);var t=this.node.getComponent(dy);t&&(this._normalSprite=t.spriteFrame),this._applyTarget(),this._resetState()},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._resetState(),this._unregisterNodeEvent()},i.update=function(t){var e=this.target;if(!this._transitionFinished&&e&&(this._transition===HA.COLOR||this._transition===HA.SCALE)){this._time+=t;var i=1;if(this._duration>0&&(i=this._time/this._duration),i>=1&&(i=1),this._transition===HA.COLOR){var r=e._uiProps.uiComp;Ui.lerp(XA,this._fromColor,this._toColor,i),r&&(r.color=XA)}else this.transition===HA.SCALE&&(e.getScale(this._targetScale),this._targetScale.x=dn(this._fromScale.x,this._toScale.x,i),this._targetScale.y=dn(this._fromScale.y,this._toScale.y,i),e.setScale(this._targetScale));1===i&&(this._transitionFinished=!0)}},i._resizeNodeToTargetNode=function(){this.target&&this.target._uiProps.uiTransformComp},i._resetState=function(){this._pressed=!1,this._hovered=!1;var t=this.target;if(t){var e=t.getComponent(Ap);if(e){var i=this._transition;i===HA.COLOR&&this._interactable?e.color=this._normalColor:i===HA.SCALE&&this._originalScale&&t.setScale(this._originalScale),this._transitionFinished=!0}}},i._registerNodeEvent=function(){this.node.on(Dr.TOUCH_START,this._onTouchBegan,this),this.node.on(Dr.TOUCH_MOVE,this._onTouchMove,this),this.node.on(Dr.TOUCH_END,this._onTouchEnded,this),this.node.on(Dr.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(Dr.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(Dr.MOUSE_LEAVE,this._onMouseMoveOut,this)},i._registerTargetEvent=function(t){t.on(Dr.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){this.node.off(Dr.TOUCH_START,this._onTouchBegan,this),this.node.off(Dr.TOUCH_MOVE,this._onTouchMove,this),this.node.off(Dr.TOUCH_END,this._onTouchEnded,this),this.node.off(Dr.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(Dr.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(Dr.MOUSE_LEAVE,this._onMouseMoveOut,this)},i._unregisterTargetEvent=function(t){t.off(Dr.TRANSFORM_CHANGED)},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(dy)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new ii),ii.copy(this._originalScale,this.target.getScale()))},i._onTargetSpriteFrameChanged=function(t){this._transition===HA.SPRITE&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case jA.NORMAL:this._normalSprite=t;break;case jA.HOVER:this._hoverSprite=t;break;case jA.PRESSED:this._pressedSprite=t;break;case jA.DISABLED:this._disabledSprite=t}},i._onTargetColorChanged=function(t){this._transition===HA.COLOR&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case jA.NORMAL:this._normalColor=t;break;case jA.HOVER:this._hoverColor=t;break;case jA.PRESSED:this._pressedColor=t;break;case jA.DISABLED:this._disabledColor=t}},i._onTargetTransformChanged=function(t){t|Ai.SCALE&&this._originalScale&&this._transition===HA.SCALE&&this._transitionFinished&&ii.copy(this._originalScale,this.target.getScale())},i._onTouchBegan=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchMove=function(t){if(this._interactable&&this.enabledInHierarchy&&this._pressed&&t){var e=t.touch;if(e){var i,r=this.node._uiProps.uiTransformComp.isHit(e.getUILocation());this._transition===HA.SCALE&&this.target&&this._originalScale?r?(ii.copy(this._fromScale,this._originalScale),ii.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=r?jA.PRESSED:jA.NORMAL,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(pn.emitEvents(this.clickEvents,t),this.node.emit(WA.CLICK,this)),this._pressed=!1,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchCancel=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},i._onMouseMoveIn=function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this._transition!==HA.SPRITE||this._hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},i._onMouseMoveOut=function(){this._hovered&&(this._hovered=!1,this._updateState())},i._updateState=function(){var t=this._getButtonState();this._applyTransition(t)},i._getButtonState=function(){var t=jA.NORMAL;return this._interactable?this._pressed?t=jA.PRESSED:this._hovered&&(t=jA.HOVER):t=jA.DISABLED,t.toString()},i._updateColorTransition=function(t){var e,i=this[t+"Color"],r=null===(e=this.target)||void 0===e?void 0:e.getComponent(Ap);r&&(t===jA.DISABLED?r.color=i:(this._fromColor=r.color.clone(),this._toColor=i,this._time=0,this._transitionFinished=!1))},i._updateSpriteTransition=function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},i._updateScaleTransition=function(t){this._interactable&&(t===jA.PRESSED?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(ii.copy(this._fromScale,this._originalScale),ii.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(ii.copy(this._fromScale,this.target.getScale()),ii.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;e===HA.COLOR?this._updateColorTransition(t):e===HA.SPRITE?this._updateSpriteTransition(t):e===HA.SCALE&&this._updateScaleTransition(t)},Pe(e,[{key:"target",get:function(){return this._target||this.node},set:function(t){this._target!==t&&(this._target&&this._unregisterTargetEvent(this._target),this._target=t,this._applyTarget())}},{key:"interactable",get:function(){return this._interactable},set:function(t){this._interactable=t,this._updateState(),this._interactable||this._resetState()}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"transition",get:function(){return this._transition},set:function(t){this._transition!==t&&(this._transition===HA.COLOR?this._updateColorTransition(jA.NORMAL):this._transition===HA.SPRITE&&this._updateSpriteTransition(jA.NORMAL),this._transition=t,this._updateState())}},{key:"normalColor",get:function(){return this._normalColor},set:function(t){this._normalColor!==t&&(this._normalColor.set(t),this._updateState())}},{key:"pressedColor",get:function(){return this._pressedColor},set:function(t){this._pressedColor!==t&&this._pressedColor.set(t)}},{key:"hoverColor",get:function(){return this._hoverColor},set:function(t){this._hoverColor!==t&&this._hoverColor.set(t)}},{key:"disabledColor",get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor.set(t),this._updateState())}},{key:"duration",get:function(){return this._duration},set:function(t){this._duration!==t&&(this._duration=t)}},{key:"zoomScale",get:function(){return this._zoomScale},set:function(t){this._zoomScale!==t&&(this._zoomScale=t)}},{key:"normalSprite",get:function(){return this._normalSprite},set:function(t){if(this._normalSprite!==t){this._normalSprite=t;var e=this.node.getComponent(dy);e&&(e.spriteFrame=t),this._updateState()}}},{key:"pressedSprite",get:function(){return this._pressedSprite},set:function(t){this._pressedSprite!==t&&(this._pressedSprite=t,this._updateState())}},{key:"hoverSprite",get:function(){return this._hoverSprite},set:function(t){this._hoverSprite!==t&&(this._hoverSprite=t,this._updateState())}},{key:"disabledSprite",get:function(){return this._disabledSprite},set:function(t){this._disabledSprite!==t&&(this._disabledSprite=t,this._updateState())}}]),e}(zi),RA.Transition=HA,RA.EventType=WA,oi((yA=IA).prototype,"target",[HS,jS,WS],Object.getOwnPropertyDescriptor(yA.prototype,"target"),yA.prototype),oi(yA.prototype,"interactable",[XS,YS],Object.getOwnPropertyDescriptor(yA.prototype,"interactable"),yA.prototype),oi(yA.prototype,"transition",[qS,JS,KS],Object.getOwnPropertyDescriptor(yA.prototype,"transition"),yA.prototype),oi(yA.prototype,"normalColor",[ZS],Object.getOwnPropertyDescriptor(yA.prototype,"normalColor"),yA.prototype),oi(yA.prototype,"pressedColor",[QS],Object.getOwnPropertyDescriptor(yA.prototype,"pressedColor"),yA.prototype),oi(yA.prototype,"hoverColor",[$S],Object.getOwnPropertyDescriptor(yA.prototype,"hoverColor"),yA.prototype),oi(yA.prototype,"disabledColor",[tA],Object.getOwnPropertyDescriptor(yA.prototype,"disabledColor"),yA.prototype),oi(yA.prototype,"duration",[eA,iA,rA],Object.getOwnPropertyDescriptor(yA.prototype,"duration"),yA.prototype),oi(yA.prototype,"zoomScale",[nA],Object.getOwnPropertyDescriptor(yA.prototype,"zoomScale"),yA.prototype),oi(yA.prototype,"normalSprite",[sA,aA],Object.getOwnPropertyDescriptor(yA.prototype,"normalSprite"),yA.prototype),oi(yA.prototype,"pressedSprite",[oA,lA],Object.getOwnPropertyDescriptor(yA.prototype,"pressedSprite"),yA.prototype),oi(yA.prototype,"hoverSprite",[hA,uA],Object.getOwnPropertyDescriptor(yA.prototype,"hoverSprite"),yA.prototype),oi(yA.prototype,"disabledSprite",[cA,_A],Object.getOwnPropertyDescriptor(yA.prototype,"disabledSprite"),yA.prototype),gA=oi(yA.prototype,"clickEvents",[fA,_i,pA,dA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),vA=oi(yA.prototype,"_interactable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),bA=oi(yA.prototype,"_transition",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return HA.NONE}}),SA=oi(yA.prototype,"_normalColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),AA=oi(yA.prototype,"_hoverColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(211,211,211,255)}}),CA=oi(yA.prototype,"_pressedColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),xA=oi(yA.prototype,"_disabledColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(124,124,124,255)}}),TA=oi(yA.prototype,"_normalSprite",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),wA=oi(yA.prototype,"_hoverSprite",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),EA=oi(yA.prototype,"_pressedSprite",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),BA=oi(yA.prototype,"_disabledSprite",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),DA=oi(yA.prototype,"_duration",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),MA=oi(yA.prototype,"_zoomScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.2}}),PA=oi(yA.prototype,"_target",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),mA=yA))||mA)||mA)||mA)||mA)||mA)||mA)),ZA=function(){function t(){}return t.add=function(t){var e=this._tabIndexList;-1===e.indexOf(t)&&e.push(t)},t.remove=function(t){var e=this._tabIndexList,i=e.indexOf(t);-1!==i&&e.splice(i,1)},t.resort=function(){this._tabIndexList.sort((function(t,e){return t._delegate.tabIndex-e._delegate.tabIndex}))},t.next=function(t){var e=this._tabIndexList,i=e.indexOf(t);if(t.setFocus(!1),-1!==i){var r=e[i+1];r&&r._delegate.tabIndex>=0&&r.setFocus(!0)}},t}();ZA._tabIndexList=[],function(t){t[t.DEFAULT=0]="DEFAULT",t[t.DONE=1]="DONE",t[t.SEND=2]="SEND",t[t.SEARCH=3]="SEARCH",t[t.GO=4]="GO",t[t.NEXT=5]="NEXT"}(YA||(YA={})),yi(YA),function(t){t[t.ANY=0]="ANY",t[t.EMAIL_ADDR=1]="EMAIL_ADDR",t[t.NUMERIC=2]="NUMERIC",t[t.PHONE_NUMBER=3]="PHONE_NUMBER",t[t.URL=4]="URL",t[t.DECIMAL=5]="DECIMAL",t[t.SINGLE_LINE=6]="SINGLE_LINE"}(qA||(qA={})),yi(qA),function(t){t[t.PASSWORD=0]="PASSWORD",t[t.SENSITIVE=1]="SENSITIVE",t[t.INITIAL_CAPS_WORD=2]="INITIAL_CAPS_WORD",t[t.INITIAL_CAPS_SENTENCE=3]="INITIAL_CAPS_SENTENCE",t[t.INITIAL_CAPS_ALL_CHARACTERS=4]="INITIAL_CAPS_ALL_CHARACTERS",t[t.DEFAULT=5]="DEFAULT"}(JA||(JA={})),yi(JA);var QA,$A,tC,eC,iC,rC,nC,sC,aC,oC,lC,hC,uC,cC,_C,fC,pC,dC,mC,yC,gC,vC,bC,SC,AC,CC,xC,TC,wC,EC,BC,DC,MC,PC,RC,IC,OC,FC,LC,VC,kC,NC,GC,zC,UC,HC,jC,WC,XC,YC,qC,JC,KC,ZC,QC,$C,tx,ex,ix,rx,nx,sx=function(){function t(){this._editing=!1,this._delegate=null}var e=t.prototype;return e.init=function(){},e.onEnable=function(){},e.update=function(){},e.onDisable=function(){this._editing&&this.endEditing()},e.clear=function(){this._delegate=null},e.setTabIndex=function(){},e.setSize=function(){},e.setFocus=function(t){t?this.beginEditing():this.endEditing()},e.isFocused=function(){return this._editing},e.beginEditing=function(){},e.endEditing=function(){},t}(),ax=new Ri,ox=new Ri,lx=new ii,hx=null,ux=0,cx=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._delegate=null,e._inputMode=-1,e._inputFlag=-1,e._returnType=-1,e.__eventListeners={},e.__fullscreen=!1,e.__autoResize=!1,e.__orientationChanged=void 0,e._edTxt=null,e._isTextArea=!1,e._textLabelFont=null,e._textLabelFontSize=null,e._textLabelFontColor=null,e._textLabelAlign=null,e._placeholderLabelFont=null,e._placeholderLabelFontSize=null,e._placeholderLabelFontColor=null,e._placeholderLabelAlign=null,e._placeholderLineHeight=null,e._placeholderStyleSheet=null,e._domId="EditBoxId_"+ ++ux,e}Me(e,t);var i=e.prototype;return i.init=function(t){t&&(this._delegate=t,t.inputMode===qA.ANY?this._createTextArea():this._createInput(),ZA.add(this),this.setTabIndex(t.tabIndex),this._initStyleSheet(),this._registerEventListeners(),this._addDomToGameContainer(),this.__fullscreen=Xr.isAutoFullScreenEnabled(),this.__autoResize=Xr._resizeWithBrowserSize)},i.clear=function(){this._removeEventListeners(),this._removeDomFromGameContainer(),ZA.remove(this),hx===this&&(hx=null),this._delegate=null},i.update=function(){this._updateMatrix()},i.setTabIndex=function(t){this._edTxt.tabIndex=t,ZA.resort()},i.setSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.beginEditing=function(){hx&&hx!==this&&hx.setFocus(!1),this._editing=!0,hx=this,this._delegate._editBoxEditingDidBegan(),this._showDom(),this._edTxt.focus()},i.endEditing=function(){this._edTxt.blur()},i._createInput=function(){this._isTextArea=!1,this._edTxt=document.createElement("input")},i._createTextArea=function(){this._isTextArea=!0,this._edTxt=document.createElement("textarea")},i._addDomToGameContainer=function(){He.GAME_VIEW&&this._edTxt?(He.gameView.container.appendChild(this._edTxt),He.gameView.head.appendChild(this._placeholderStyleSheet)):Wr.container&&this._edTxt&&(Wr.container.appendChild(this._edTxt),document.head.appendChild(this._placeholderStyleSheet))},i._removeDomFromGameContainer=function(){(He.GAME_VIEW?gn(He.gameView.container,this._edTxt):gn(Wr.container,this._edTxt))&&this._edTxt&&(He.GAME_VIEW?He.gameView.container.removeChild(this._edTxt):Wr.container.removeChild(this._edTxt)),(He.GAME_VIEW?gn(He.gameView.head,this._placeholderStyleSheet):gn(document.head,this._placeholderStyleSheet))&&(He.GAME_VIEW?He.gameView.head.removeChild(this._placeholderStyleSheet):document.head.removeChild(this._placeholderStyleSheet)),this._edTxt=null,this._placeholderStyleSheet=null},i._showDom=function(){this._updateMaxLength(),this._updateInputType(),this._updateStyleSheet(),this._edTxt&&this._delegate&&(this._edTxt.style.display="",this._delegate._hideLabels()),ke.isMobile&&this._showDomOnMobile()},i._hideDom=function(){var t=this._edTxt;t&&this._delegate&&(t.style.display="none",this._delegate._showLabels()),ke.isMobile&&this._hideDomOnMobile()},i._showDomOnMobile=function(){Le.os!==Ve.ANDROID&&Le.os!==Ve.OHOS||(this.__fullscreen&&(Xr.enableAutoFullScreen(!1),vn.exitFullScreen()),this.__autoResize&&Xr.resizeWithBrowserSize(!1),this._adjustWindowScroll())},i._hideDomOnMobile=function(){var t=this;Le.os!==Ve.ANDROID&&Le.os!==Ve.OHOS||(this.__autoResize&&Xr.resizeWithBrowserSize(!0),setTimeout((function(){hx||t.__fullscreen&&Xr.enableAutoFullScreen(!0)}),400)),this._scrollBackWindow()},i._adjustWindowScroll=function(){var t=this;setTimeout((function(){window.scrollY<40&&t._edTxt.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}),400)},i._scrollBackWindow=function(){setTimeout((function(){Le.browserType!==Ne.WECHAT||Le.os!==Ve.IOS?window.scrollTo(0,0):window.top&&window.top.scrollTo(0,0)}),400)},i._updateMatrix=function(){if(this._edTxt){var t=this._delegate.node,e=Xr.getScaleX(),i=Xr.getScaleY(),r=1,n=1;He.GAME_VIEW&&(r=He.gameView.canvas.width/He.game.canvas.width,n=He.gameView.canvas.height/He.game.canvas.height),e*=r,i*=n;var s=Xr.getViewportRect(),a=Xr.getDevicePixelRatio();t.getWorldMatrix(ax);var o=t._uiProps.uiTransformComp;if(o&&ii.set(lx,-o.anchorX*o.width,-o.anchorY*o.height,lx.z),Ri.transform(ax,ax,lx),t._uiProps.uiTransformComp){var l=wr.root.batcher2D.getFirstRenderCamera(t);if(l){l.node.getWorldRT(ox);var h=ox.m12,u=ox.m13,c=jr.center;ox.m12=c.x-(ox.m00*h+ox.m04*u),ox.m13=c.y-(ox.m01*h+ox.m05*u),Ri.multiply(ox,ox,ax),e/=a,i/=a;var _=He.GAME_VIEW?He.gameView.container:Wr.container,f=ox.m00*e,p=ax.m01,d=ax.m04,m=ox.m05*i,y=parseInt(_&&_.style.paddingLeft||"0");y+=s.x*r/a;var g=parseInt(_&&_.style.paddingBottom||"0");g+=s.y/a;var v="matrix("+f+","+-p+","+-d+","+m+","+(ox.m12*e+y)+","+-(ox.m13*i+g)+")";this._edTxt.style.transform=v,this._edTxt.style["-webkit-transform"]=v,this._edTxt.style["transform-origin"]="0px 100% 0px",this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}}}},i._updateInputType=function(){var t=this._delegate,e=t.inputMode,i=t.inputFlag,r=t.returnType,n=this._edTxt;if(this._inputMode!==e||this._inputFlag!==i||this._returnType!==r){if(this._inputMode=e,this._inputFlag=i,this._returnType=r,this._isTextArea){var s="none";return i===JA.INITIAL_CAPS_ALL_CHARACTERS?s="uppercase":i===JA.INITIAL_CAPS_WORD&&(s="capitalize"),void(n.style.textTransform=s)}if(n=n,i===JA.PASSWORD)return n.type="password",void(n.style.textTransform="none");var a=n.type;e===qA.EMAIL_ADDR?a="email":e===qA.NUMERIC||e===qA.DECIMAL?a="number":e===qA.PHONE_NUMBER?(a="number",n.pattern="[0-9]*"):e===qA.URL?a="url":(a="text",r===YA.SEARCH&&(a="search")),n.type=a;var o="none";i===JA.INITIAL_CAPS_ALL_CHARACTERS?o="uppercase":i===JA.INITIAL_CAPS_WORD&&(o="capitalize"),n.style.textTransform=o}},i._updateMaxLength=function(){var t=this._delegate.maxLength;t<0&&(t=65535),this._edTxt.maxLength=t},i._initStyleSheet=function(){if(this._edTxt){var t=this._edTxt;t.style.color="#000000",t.style.border="0px",t.style.background="transparent",t.style.width="100%",t.style.height="100%",t.style.outline="medium",t.style.padding="0",t.style.textTransform="none",t.style.display="none",t.style.position="absolute",t.style.bottom="0px",t.style.left="2px",t.className="cocosEditBox",t.style.fontFamily="Arial",t.id=this._domId,this._isTextArea?(t.style.resize="none",t.style.overflowY="scroll"):((t=t).type="text",t.style["-moz-appearance"]="textfield"),this._placeholderStyleSheet=document.createElement("style")}},i._updateStyleSheet=function(){var t=this._delegate,e=this._edTxt;e&&t&&(e.value=t.string,e.placeholder=t.placeholder,this._updateTextLabel(t.textLabel),this._updatePlaceholderLabel(t.placeholderLabel))},i._updateTextLabel=function(t){if(t){var e=t.font;e=!e||e instanceof Wc?t.fontFamily:e._fontFamily;var i=t.fontSize*t.node.scale.y;if((this._textLabelFont!==e||this._textLabelFontSize!==i||this._textLabelFontColor!==t.fontColor||this._textLabelAlign!==t.horizontalAlign)&&(this._textLabelFont=e,this._textLabelFontSize=i,this._textLabelFontColor=t.fontColor,this._textLabelAlign=t.horizontalAlign,this._edTxt)){var r=this._edTxt;switch(r.style.fontSize=i+"px",r.style.color=t.color.toCSS(),r.style.fontFamily=e,t.horizontalAlign){case wp.HorizontalAlign.LEFT:r.style.textAlign="left";break;case wp.HorizontalAlign.CENTER:r.style.textAlign="center";break;case wp.HorizontalAlign.RIGHT:r.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof Wc?t.fontFamily:t.font._fontFamily;var i=t.fontSize*t.node.scale.y;if(this._placeholderLabelFont!==e||this._placeholderLabelFontSize!==i||this._placeholderLabelFontColor!==t.fontColor||this._placeholderLabelAlign!==t.horizontalAlign||this._placeholderLineHeight!==t.fontSize){this._placeholderLabelFont=e,this._placeholderLabelFontSize=i,this._placeholderLabelFontColor=t.fontColor,this._placeholderLabelAlign=t.horizontalAlign,this._placeholderLineHeight=t.fontSize;var r=this._placeholderStyleSheet,n=t.color.toCSS(),s=t.fontSize,a="";switch(t.horizontalAlign){case wp.HorizontalAlign.LEFT:a="left";break;case wp.HorizontalAlign.CENTER:a="center";break;case wp.HorizontalAlign.RIGHT:a="right"}r.innerHTML="#"+this._domId+"::-webkit-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+n+";line-height: "+s+"px;text-align: "+a+";}#"+this._domId+"::-moz-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+n+";line-height: "+s+"px;text-align: "+a+";}#"+this._domId+"::-ms-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+n+";line-height: "+s+"px;text-align: "+a+";}",Le.browserType===Ne.EDGE&&(r.innerHTML+="#"+this._domId+"::-ms-clear{display: none;}")}}},i._registerEventListeners=function(){var t=this;if(this._edTxt){var e=this._edTxt,i=!1,r=this.__eventListeners;r.compositionStart=function(){i=!0},r.compositionEnd=function(){i=!1,t._delegate._editBoxTextChanged(e.value)},r.onInput=function(){if(!i){var r=t._delegate,n=r.maxLength;n>=0&&(e.value=e.value.slice(0,n)),r._editBoxTextChanged(e.value)}},r.onClick=function(){t._editing&&ke.isMobile&&t._adjustWindowScroll()},r.onKeydown=function(i){i.keyCode===Oe.KEY.enter?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):i.keyCode===Oe.KEY.tab&&(i.propagationStopped=!0,i.preventDefault(),ZA.next(t))},r.onBlur=function(){ke.isMobile&&i&&r.compositionEnd(),t._editing=!1,hx=null,t._hideDom(),t._delegate._editBoxEditingDidEnded()},e.addEventListener("compositionstart",r.compositionStart),e.addEventListener("compositionend",r.compositionEnd),e.addEventListener("input",r.onInput),e.addEventListener("keydown",r.onKeydown),e.addEventListener("blur",r.onBlur),e.addEventListener("touchstart",r.onClick)}},i._removeEventListeners=function(){if(this._edTxt){var t=this._edTxt,e=this.__eventListeners;t.removeEventListener("compositionstart",e.compositionStart),t.removeEventListener("compositionend",e.compositionEnd),t.removeEventListener("input",e.onInput),t.removeEventListener("keydown",e.onKeydown),t.removeEventListener("blur",e.onBlur),t.removeEventListener("touchstart",e.onClick),e.compositionStart=null,e.compositionEnd=null,e.onInput=null,e.onKeydown=null,e.onBlur=null,e.onClick=null}},e}(sx);!function(t){t.EDITING_DID_BEGAN="editing-did-began",t.EDITING_DID_ENDED="editing-did-ended",t.TEXT_CHANGED="text-changed",t.EDITING_RETURN="editing-return"}(nx||(nx={}));var _x,fx,px,dx,mx,yx,gx,vx,bx,Sx,Ax,Cx,xx,Tx,wx,Ex,Bx,Dx,Mx,Px,Rx,Ix,Ox,Fx,Lx,Vx,kx,Nx,Gx,zx,Ux,Hx,jx,Wx,Xx,Yx,qx,Jx,Kx,Zx,Qx,$x,tT,eT,iT,rT,nT,sT,aT,oT,lT,hT,uT,cT,_T=function(e){return t({EditBox:e,EditBoxComponent:e}),e}((QA=ri("cc.EditBox"),$A=wi(),tC=Ei(110),eC=Bi(),iC=Rr(j_),rC=Mr(),nC=Di(),sC=Mr(),aC=Di(),oC=bi(wp),lC=Mr(),hC=Di(),uC=bi(wp),cC=Mr(),_C=Di(),fC=bi(xc),pC=Mr(),dC=Di(),mC=bi(JA),yC=Mr(),gC=Di(),vC=bi(qA),bC=Mr(),SC=Di(),AC=bi(YA),CC=Mr(),xC=Di(),TC=Mr(),wC=Di(),EC=Mr(),BC=Di(),DC=bi([pn]),MC=Mr(),PC=Di(),RC=bi([pn]),IC=Mr(),OC=Di(),FC=bi([pn]),LC=Mr(),VC=Di(),kC=bi([pn]),NC=Mr(),GC=Di(),QA(zC=$A(zC=tC(zC=eC(zC=iC(zC=Si((rx=ix=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"editingDidBegan",HC,hi(e)),li(e,"textChanged",jC,hi(e)),li(e,"editingDidEnded",WC,hi(e)),li(e,"editingReturn",XC,hi(e)),e._impl=null,e._background=null,li(e,"_textLabel",YC,hi(e)),li(e,"_placeholderLabel",qC,hi(e)),li(e,"_returnType",JC,hi(e)),li(e,"_string",KC,hi(e)),li(e,"_tabIndex",ZC,hi(e)),li(e,"_backgroundImage",QC,hi(e)),li(e,"_inputFlag",$C,hi(e)),li(e,"_inputMode",tx,hi(e)),li(e,"_maxLength",ex,hi(e)),e._isLabelVisible=!1,e}Me(e,t);var i=e.prototype;return i.__preload=function(){this._init()},i.onEnable=function(){this._registerEvent(),this._impl&&this._impl.onEnable()},i.update=function(){this._impl&&this._impl.update()},i.onDisable=function(){this._unregisterEvent(),this._impl&&this._impl.onDisable()},i.onDestroy=function(){this._impl&&this._impl.clear()},i.setFocus=function(){this._impl&&this._impl.setFocus(!0)},i.focus=function(){this._impl&&this._impl.setFocus(!0)},i.blur=function(){this._impl&&this._impl.setFocus(!1)},i.isFocused=function(){return!!this._impl&&this._impl.isFocused()},i._editBoxEditingDidBegan=function(){pn.emitEvents(this.editingDidBegan,this),this.node.emit(nx.EDITING_DID_BEGAN,this)},i._editBoxEditingDidEnded=function(){pn.emitEvents(this.editingDidEnded,this),this.node.emit(nx.EDITING_DID_ENDED,this)},i._editBoxTextChanged=function(t){t=this._updateLabelStringStyle(t,!0),this.string=t,pn.emitEvents(this.textChanged,t,this),this.node.emit(nx.TEXT_CHANGED,this)},i._editBoxEditingReturn=function(){pn.emitEvents(this.editingReturn,this),this.node.emit(nx.EDITING_RETURN,this)},i._showLabels=function(){this._isLabelVisible=!0,this._updateLabels()},i._hideLabels=function(){this._isLabelVisible=!1,this._textLabel&&(this._textLabel.node.active=!1),this._placeholderLabel&&(this._placeholderLabel.node.active=!1)},i._onTouchBegan=function(t){t.propagationStopped=!0},i._onTouchCancel=function(t){t.propagationStopped=!0},i._onTouchEnded=function(t){this._impl&&this._impl.beginEditing(),t.propagationStopped=!0},i._init=function(){this._createBackgroundSprite(),this._updatePlaceholderLabel(),this._updateTextLabel(),this._isLabelVisible=!0,this.node.on(Dr.SIZE_CHANGED,this._resizeChildNodes,this),(this._impl=new e._EditBoxImpl).init(this),this._updateString(this._string),this._syncSize()},i._createBackgroundSprite=function(){this._background||(this._background=this.node.getComponent(dy),this._background||(this._background=this.node.addComponent(dy))),this._background.type=dy.Type.SLICED,this._background.spriteFrame=this._backgroundImage},i._updateTextLabel=function(){var t=this._textLabel;if(!t){var e=this.node.getChildByName("TEXT_LABEL");e||(e=new ur("TEXT_LABEL")),(t=e.getComponent(wp))||(t=e.addComponent(wp)),e.parent=this.node,this._textLabel=t}this._textLabel.node._uiProps.uiTransformComp.setAnchorPoint(0,1),t.overflow=wp.Overflow.CLAMP,this._inputMode===qA.ANY?(t.verticalAlign=vp.TOP,t.enableWrapText=!0):t.enableWrapText=!1,t.string=this._updateLabelStringStyle(this._string)},i._updatePlaceholderLabel=function(){var t=this._placeholderLabel;if(!t){var e=this.node.getChildByName("PLACEHOLDER_LABEL");e||(e=new ur("PLACEHOLDER_LABEL")),(t=e.getComponent(wp))||(t=e.addComponent(wp)),e.parent=this.node,this._placeholderLabel=t}this._placeholderLabel.node._uiProps.uiTransformComp.setAnchorPoint(0,1),t.overflow=wp.Overflow.CLAMP,this._inputMode===qA.ANY?(t.verticalAlign=vp.TOP,t.enableWrapText=!0):t.enableWrapText=!1,t.string=this.placeholder},i._syncSize=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(this._background){var i=this._background.node._uiProps.uiTransformComp;i.anchorPoint=t.anchorPoint,i.setContentSize(e)}this._updateLabelPosition(e),this._impl&&this._impl.setSize(e.width,e.height)},i._updateLabels=function(){if(this._isLabelVisible){var t=this._string;this._textLabel&&(this._textLabel.node.active=""!==t),this._placeholderLabel&&(this._placeholderLabel.node.active=""===t)}},i._updateString=function(t){var e=this._textLabel;if(e){var i=t;i&&(i=this._updateLabelStringStyle(i)),e.string=i,this._updateLabels()}},i._updateLabelStringStyle=function(t,e){void 0===e&&(e=!1);var i,r=this._inputFlag;if(e||r!==JA.PASSWORD)r===JA.INITIAL_CAPS_ALL_CHARACTERS?t=t.toUpperCase():r===JA.INITIAL_CAPS_WORD?t=t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()})):r===JA.INITIAL_CAPS_SENTENCE&&(t=(i=t).charAt(0).toUpperCase()+i.slice(1));else{for(var n="",s=t.length,a=0;a<s;++a)n+="●";t=n}return t},i._registerEvent=function(){this.node.on(Dr.TOUCH_START,this._onTouchBegan,this),this.node.on(Dr.TOUCH_END,this._onTouchEnded,this)},i._unregisterEvent=function(){this.node.off(Dr.TOUCH_START,this._onTouchBegan,this),this.node.off(Dr.TOUCH_END,this._onTouchEnded,this)},i._updateLabelPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=-e.anchorX*e.width,r=-e.anchorY*e.height,n=this._placeholderLabel,s=this._textLabel;s&&(s.node._uiProps.uiTransformComp.setContentSize(t.width-2,t.height),s.node.setPosition(i+2,r+t.height,s.node.position.z),this._inputMode===qA.ANY&&(s.verticalAlign=vp.TOP),s.enableWrapText=this._inputMode===qA.ANY),n&&(n.node._uiProps.uiTransformComp.setContentSize(t.width-2,t.height),n.lineHeight=t.height,n.node.setPosition(i+2,r+t.height,n.node.position.z),this._inputMode===qA.ANY&&(n.verticalAlign=vp.TOP),n.enableWrapText=this._inputMode===qA.ANY)},i._resizeChildNodes=function(){var t=this.node._uiProps.uiTransformComp,e=this._textLabel&&this._textLabel.node;e&&(e.setPosition(-t.width/2,t.height/2,e.position.z),e._uiProps.uiTransformComp.setContentSize(t.contentSize));var i=this._placeholderLabel&&this._placeholderLabel.node;i&&(i.setPosition(-t.width/2,t.height/2,i.position.z),i._uiProps.uiTransformComp.setContentSize(t.contentSize));var r=this._background&&this._background.node;r&&r._uiProps.uiTransformComp.setContentSize(t.contentSize)},Pe(e,[{key:"string",get:function(){return this._string},set:function(t){this._maxLength>=0&&t.length>=this._maxLength&&(t=t.slice(0,this._maxLength)),this._string=t,this._updateString(t)}},{key:"placeholder",get:function(){return this._placeholderLabel?this._placeholderLabel.string:""},set:function(t){this._placeholderLabel&&(this._placeholderLabel.string=t)}},{key:"textLabel",get:function(){return this._textLabel},set:function(t){this._textLabel!==t&&(this._textLabel=t,this._textLabel&&(this._updateTextLabel(),this._updateLabels()))}},{key:"placeholderLabel",get:function(){return this._placeholderLabel},set:function(t){this._placeholderLabel!==t&&(this._placeholderLabel=t,this._placeholderLabel&&(this._updatePlaceholderLabel(),this._updateLabels()))}},{key:"backgroundImage",get:function(){return this._backgroundImage},set:function(t){this._backgroundImage!==t&&(this._backgroundImage=t,this._createBackgroundSprite())}},{key:"inputFlag",get:function(){return this._inputFlag},set:function(t){this._inputFlag=t,this._updateString(this._string)}},{key:"inputMode",get:function(){return this._inputMode},set:function(t){this._inputMode!==t&&(this._inputMode=t,this._updateTextLabel(),this._updatePlaceholderLabel())}},{key:"returnType",get:function(){return this._returnType},set:function(t){this._returnType=t}},{key:"maxLength",get:function(){return this._maxLength},set:function(t){this._maxLength=t}},{key:"tabIndex",get:function(){return this._tabIndex},set:function(t){this._tabIndex!==t&&(this._tabIndex=t,this._impl&&this._impl.setTabIndex(t))}}]),e}(zi),ix._EditBoxImpl=sx,ix.KeyboardReturnType=YA,ix.InputFlag=JA,ix.InputMode=qA,ix.EventType=nx,oi((UC=rx).prototype,"string",[rC,nC],Object.getOwnPropertyDescriptor(UC.prototype,"string"),UC.prototype),oi(UC.prototype,"placeholder",[sC,aC],Object.getOwnPropertyDescriptor(UC.prototype,"placeholder"),UC.prototype),oi(UC.prototype,"textLabel",[oC,lC,hC],Object.getOwnPropertyDescriptor(UC.prototype,"textLabel"),UC.prototype),oi(UC.prototype,"placeholderLabel",[uC,cC,_C],Object.getOwnPropertyDescriptor(UC.prototype,"placeholderLabel"),UC.prototype),oi(UC.prototype,"backgroundImage",[fC,pC,dC],Object.getOwnPropertyDescriptor(UC.prototype,"backgroundImage"),UC.prototype),oi(UC.prototype,"inputFlag",[mC,yC,gC],Object.getOwnPropertyDescriptor(UC.prototype,"inputFlag"),UC.prototype),oi(UC.prototype,"inputMode",[vC,bC,SC],Object.getOwnPropertyDescriptor(UC.prototype,"inputMode"),UC.prototype),oi(UC.prototype,"returnType",[AC,CC,xC],Object.getOwnPropertyDescriptor(UC.prototype,"returnType"),UC.prototype),oi(UC.prototype,"maxLength",[TC,wC],Object.getOwnPropertyDescriptor(UC.prototype,"maxLength"),UC.prototype),oi(UC.prototype,"tabIndex",[EC,BC],Object.getOwnPropertyDescriptor(UC.prototype,"tabIndex"),UC.prototype),HC=oi(UC.prototype,"editingDidBegan",[DC,_i,MC,PC],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),jC=oi(UC.prototype,"textChanged",[RC,_i,IC,OC],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),WC=oi(UC.prototype,"editingDidEnded",[FC,_i,LC,VC],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),XC=oi(UC.prototype,"editingReturn",[kC,_i,NC,GC],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),YC=oi(UC.prototype,"_textLabel",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qC=oi(UC.prototype,"_placeholderLabel",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),JC=oi(UC.prototype,"_returnType",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return YA.DEFAULT}}),KC=oi(UC.prototype,"_string",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),ZC=oi(UC.prototype,"_tabIndex",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),QC=oi(UC.prototype,"_backgroundImage",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),$C=oi(UC.prototype,"_inputFlag",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return JA.DEFAULT}}),tx=oi(UC.prototype,"_inputMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qA.ANY}}),ex=oi(UC.prototype,"_maxLength",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 20}}),zC=UC))||zC)||zC)||zC)||zC)||zC)||zC));"object"!=typeof window||"object"!=typeof document||bn||Sn||An||(_T._EditBoxImpl=cx);var fT,pT,dT,mT,yT,gT,vT=Dr;!function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL",t[t.GRID=3]="GRID"}(fT||(fT={})),Pr(fT),function(t){t[t.NONE=0]="NONE",t[t.CONTAINER=1]="CONTAINER",t[t.CHILDREN=2]="CHILDREN"}(pT||(pT={})),Pr(pT),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(dT||(dT={})),Pr(dT),function(t){t[t.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",t[t.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(mT||(mT={})),Pr(mT),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(yT||(yT={})),Pr(yT),function(t){t[t.NONE=0]="NONE",t[t.FIXED_ROW=1]="FIXED_ROW",t[t.FIXED_COL=2]="FIXED_COL"}(gT||(gT={})),Pr(gT);var bT,ST,AT,CT,xT,TT,wT,ET,BT,DT,MT,PT,RT,IT,OT,FT,LT,VT,kT,NT,GT,zT,UT,HT=new ii,jT=function(e){return t({Layout:e,LayoutComponent:e}),e}((_x=ri("cc.Layout"),fx=wi(),px=Ei(110),dx=Bi(),mx=Rr(j_),yx=Mi(),gx=Di(),vx=Mi(),bx=Di(),Sx=bi(fT),Ax=Di(),Cx=bi(pT),xx=Mi(),Tx=Di(),wx=Mi(),Ex=Di(),Bx=bi(dT),Dx=Di(),Mx=Di(),Px=Di(),Rx=Di(),Ix=Di(),Ox=Di(),Fx=Di(),Lx=bi(mT),Vx=Di(),kx=bi(yT),Nx=Di(),Gx=bi(gT),zx=Mi(),Ux=Di(),Hx=Mi(),jx=Di(),Wx=Di(),_x(Xx=fx(Xx=px(Xx=dx(Xx=mx(Xx=Si((cT=uT=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_resizeMode",qx,hi(e)),li(e,"_layoutType",Jx,hi(e)),li(e,"_cellSize",Kx,hi(e)),li(e,"_startAxis",Zx,hi(e)),li(e,"_paddingLeft",Qx,hi(e)),li(e,"_paddingRight",$x,hi(e)),li(e,"_paddingTop",tT,hi(e)),li(e,"_paddingBottom",eT,hi(e)),li(e,"_spacingX",iT,hi(e)),li(e,"_spacingY",rT,hi(e)),li(e,"_verticalDirection",nT,hi(e)),li(e,"_horizontalDirection",sT,hi(e)),li(e,"_constraint",aT,hi(e)),li(e,"_constraintNum",oT,hi(e)),li(e,"_affectedByScale",lT,hi(e)),li(e,"_isAlign",hT,hi(e)),e._layoutSize=new vr(300,200),e._layoutDirty=!0,e._childrenDirty=!1,e._usefulLayoutObj=[],e._init=!1,e}Me(e,t);var i=e.prototype;return i.updateLayout=function(t){void 0===t&&(t=!1),(this._layoutDirty||t)&&this.node.children.length>0&&(this._doLayout(),this._layoutDirty=!1)},i.onEnable=function(){this._addEventListeners();var t=this.node._uiProps.uiTransformComp;t.contentSize.equals(vr.ZERO)&&t.setContentSize(this._layoutSize),this._childrenChanged()},i.onDisable=function(){this._usefulLayoutObj.length=0,this._removeEventListeners()},i._checkUsefulObj=function(){this._usefulLayoutObj.length=0;for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e],r=i._uiProps.uiTransformComp;i.activeInHierarchy&&r&&this._usefulLayoutObj.push(r)}},i._addEventListeners=function(){wr.on(Er.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.on(vT.SIZE_CHANGED,this._resized,this),this.node.on(vT.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.on(vT.CHILD_ADDED,this._childAdded,this),this.node.on(vT.CHILD_REMOVED,this._childRemoved,this),this.node.on(vT.SIBLING_ORDER_CHANGED,this._childrenChanged,this),this.node.on("childrenSiblingOrderChanged",this.updateLayout,this),this._addChildrenEventListeners()},i._removeEventListeners=function(){wr.off(Er.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.off(vT.SIZE_CHANGED,this._resized,this),this.node.off(vT.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.off(vT.CHILD_ADDED,this._childAdded,this),this.node.off(vT.CHILD_REMOVED,this._childRemoved,this),this.node.off(vT.SIBLING_ORDER_CHANGED,this._childrenChanged,this),this.node.off("childrenSiblingOrderChanged",this.updateLayout,this),this._removeChildrenEventListeners()},i._addChildrenEventListeners=function(){for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e];i.on(vT.SIZE_CHANGED,this._doLayoutDirty,this),i.on(vT.TRANSFORM_CHANGED,this._transformDirty,this),i.on(vT.ANCHOR_CHANGED,this._doLayoutDirty,this),i.on("active-in-hierarchy-changed",this._childrenChanged,this)}},i._removeChildrenEventListeners=function(){for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e];i.off(vT.SIZE_CHANGED,this._doLayoutDirty,this),i.off(vT.TRANSFORM_CHANGED,this._transformDirty,this),i.off(vT.ANCHOR_CHANGED,this._doLayoutDirty,this),i.off("active-in-hierarchy-changed",this._childrenChanged,this)}},i._childAdded=function(t){t.on(vT.SIZE_CHANGED,this._doLayoutDirty,this),t.on(vT.TRANSFORM_CHANGED,this._transformDirty,this),t.on(vT.ANCHOR_CHANGED,this._doLayoutDirty,this),t.on("active-in-hierarchy-changed",this._childrenChanged,this),this._childrenChanged()},i._childRemoved=function(t){t.off(vT.SIZE_CHANGED,this._doLayoutDirty,this),t.off(vT.TRANSFORM_CHANGED,this._transformDirty,this),t.off(vT.ANCHOR_CHANGED,this._doLayoutDirty,this),t.off("active-in-hierarchy-changed",this._childrenChanged,this),this._childrenChanged()},i._resized=function(){this._layoutSize.set(this.node._uiProps.uiTransformComp.contentSize),this._doLayoutDirty()},i._doLayoutHorizontally=function(t,e,i,r){var n=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),a=1,o=this._paddingLeft;this._horizontalDirection===yT.RIGHT_TO_LEFT&&(a=-1,o=this._paddingRight);var l=(this._horizontalDirection-n.x)*t+a*o,h=l-a*this._spacingX,u=0,c=0,_=0,f=0,p=!1,d=this._usefulLayoutObj.length,m=this._cellSize.width,y=this._getPaddingH();this._layoutType!==fT.GRID&&this._resizeMode===pT.CHILDREN&&(m=(t-y-(d-1)*this._spacingX)/d);for(var g=this._usefulLayoutObj,v=0;v<g.length;++v){var b=g[v],S=b.node,A=S.scale,C=this._getUsedScaleValue(A.x),x=this._getUsedScaleValue(A.y);this._resizeMode===pT.CHILDREN&&(b.width=m/C,this._layoutType===fT.GRID&&(b.height=this._cellSize.height/x));var T=Math.abs(this._horizontalDirection-b.anchorX),w=b.width*C,E=b.height*x;E>_&&(f=Math.max(_,f),c=_||E,_=E),h+=a*(T*w+this._spacingX);var B=a*(1-T)*w;if(e){if(s>0)(p=v/s>0&&v%s==0)&&(c=_>E?_:c);else if(w>t-y)h>l+a*T*w&&(p=!0);else{var D=(1-this._horizontalDirection-n.x)*t,M=h+B+a*(a>0?this._paddingRight:this._paddingLeft);p=Math.abs(M)>Math.abs(D)}p&&(h=l+a*T*w,E!==_&&(c=_),u+=c+this._spacingY,c=_=E)}var P=i(S,b,u);r&&S.setPosition(h,P),h+=B}return c=Math.max(c,_),Math.max(f,u+c)+this._getPaddingV()},i._doLayoutVertically=function(t,e,i,r){var n=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),a=1,o=this._paddingBottom;this._verticalDirection===mT.TOP_TO_BOTTOM&&(a=-1,o=this._paddingTop);var l=(this._verticalDirection-n.y)*t+a*o,h=l-a*this._spacingY,u=0,c=0,_=0,f=0,p=!1,d=this._usefulLayoutObj.length,m=this._cellSize.height,y=this._getPaddingV();this._layoutType!==fT.GRID&&this._resizeMode===pT.CHILDREN&&(m=(t-y-(d-1)*this._spacingY)/d);for(var g=this._usefulLayoutObj,v=0;v<g.length;++v){var b=g[v],S=b.node,A=S.scale,C=this._getUsedScaleValue(A.x),x=this._getUsedScaleValue(A.y);this._resizeMode===pT.CHILDREN&&(b.height=m/x,this._layoutType===fT.GRID&&(b.width=this._cellSize.width/C));var T=Math.abs(this._verticalDirection-b.anchorY),w=b.width*C,E=b.height*x;w>u&&(c=Math.max(u,c),_=u||w,u=w),h+=a*(T*E+this._spacingY);var B=a*(1-T)*E;if(e){if(s>0)(p=v/s>0&&v%s==0)&&(_=u>E?u:_);else if(E>t-y)h>l+a*T*E&&(p=!0);else{var D=(1-this._verticalDirection-n.y)*t,M=h+B+a*(a>0?this._paddingTop:this._paddingBottom);p=Math.abs(M)>Math.abs(D)}p&&(h=l+a*T*E,w!==u&&(_=u),f+=_+this._spacingX,_=u=w)}var P=i(S,b,f);r&&(S.getPosition(HT),S.setPosition(P,h,HT.z)),h+=B}return _=Math.max(_,u),Math.max(c,f+_)+this._getPaddingH()},i._doLayoutGridAxisHorizontal=function(t,e){var i=this,r=e.width,n=1,s=-t.y*e.height,a=this._paddingBottom;this._verticalDirection===mT.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*e.height,a=this._paddingTop);var o=function(t,e,r){return s+n*(r+(1-e.anchorY)*e.height*i._getUsedScaleValue(t.scale.y)+a)},l=0;this._resizeMode===pT.CONTAINER&&(l=this._doLayoutHorizontally(r,!0,o,!1),s=-t.y*l,this._verticalDirection===mT.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*l)),this._doLayoutHorizontally(r,!0,o,!0),this._resizeMode===pT.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(r,l)},i._doLayoutGridAxisVertical=function(t,e){var i=this,r=e.height,n=1,s=-t.x*e.width,a=this._paddingLeft;this._horizontalDirection===yT.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*e.width,a=this._paddingRight);var o=function(t,e,r){return s+n*(r+(1-e.anchorX)*e.width*i._getUsedScaleValue(t.scale.x)+a)},l=0;this._resizeMode===pT.CONTAINER&&(l=this._doLayoutVertically(r,!0,o,!1),s=-t.x*l,this._horizontalDirection===yT.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*l)),this._doLayoutVertically(r,!0,o,!0),this._resizeMode===pT.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(l,r)},i._doLayoutGrid=function(){var t=this.node._uiProps.uiTransformComp,e=t.anchorPoint,i=t.contentSize;this.startAxis===dT.HORIZONTAL?this._doLayoutGridAxisHorizontal(e,i):this.startAxis===dT.VERTICAL&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===pT.CONTAINER){for(var r=0;r<t.length;++r){var n=t[r],s=n.node.scale;e+=n.width*this._getUsedScaleValue(s.x)}e+=(i-1)*this._spacingX+this._getPaddingH()}else e=this.node._uiProps.uiTransformComp.width;return e},i._getVerticalBaseHeight=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===pT.CONTAINER){for(var r=0;r<t.length;++r){var n=t[r],s=n.node.scale;e+=n.height*this._getUsedScaleValue(s.y)}e+=(i-1)*this._spacingY+this._getPaddingV()}else e=this.node._uiProps.uiTransformComp.height;return e},i._doLayout=function(){var t=this;if(this._init&&!this._childrenDirty||(this._checkUsefulObj(),this._init=!0,this._childrenDirty=!1),this._layoutType===fT.HORIZONTAL){var e=this._getHorizontalBaseWidth();this._doLayoutHorizontally(e,!1,(function(e){return(t._isAlign?ii.ZERO:e.position).y}),!0),this.node._uiProps.uiTransformComp.width=e}else if(this._layoutType===fT.VERTICAL){var i=this._getVerticalBaseHeight();this._doLayoutVertically(i,!1,(function(e){return(t._isAlign?ii.ZERO:e.position).x}),!0),this.node._uiProps.uiTransformComp.height=i}else this._layoutType===fT.GRID&&this._doLayoutGrid()},i._getUsedScaleValue=function(t){return this._affectedByScale?Math.abs(t):1},i._transformDirty=function(t){t&Ai.SCALE&&t&Ai.POSITION&&this._affectedByScale&&this._doLayoutDirty()},i._doLayoutDirty=function(){this._layoutDirty=!0},i._childrenChanged=function(){this._childrenDirty=!0,this._doLayoutDirty()},i._getPaddingH=function(){return this._paddingLeft+this._paddingRight},i._getPaddingV=function(){return this._paddingTop+this._paddingBottom},i._getFixedBreakingNum=function(){if(this._layoutType!==fT.GRID||this._constraint===gT.NONE||this._constraintNum<=0)return 0;var t=this._constraint===gT.FIXED_ROW?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum;return this._startAxis===dT.VERTICAL&&(t=this._constraint===gT.FIXED_COL?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum),t},Pe(e,[{key:"alignHorizontal",get:function(){return this._isAlign},set:function(t){this._layoutType===fT.HORIZONTAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"alignVertical",get:function(){return this._isAlign},set:function(t){this._layoutType===fT.VERTICAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"type",get:function(){return this._layoutType},set:function(t){this._layoutType=t,this._doLayoutDirty()}},{key:"resizeMode",get:function(){return this._resizeMode},set:function(t){this._layoutType!==fT.NONE&&(this._resizeMode=t,this._doLayoutDirty())}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize.set(t),this._doLayoutDirty())}},{key:"startAxis",get:function(){return this._startAxis},set:function(t){this._startAxis!==t&&(this._startAxis=t,this._doLayoutDirty())}},{key:"paddingLeft",get:function(){return this._paddingLeft},set:function(t){this._paddingLeft!==t&&(this._paddingLeft=t,this._doLayoutDirty())}},{key:"paddingRight",get:function(){return this._paddingRight},set:function(t){this._paddingRight!==t&&(this._paddingRight=t,this._doLayoutDirty())}},{key:"paddingTop",get:function(){return this._paddingTop},set:function(t){this._paddingTop!==t&&(this._paddingTop=t,this._doLayoutDirty())}},{key:"paddingBottom",get:function(){return this._paddingBottom},set:function(t){this._paddingBottom!==t&&(this._paddingBottom=t,this._doLayoutDirty())}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this._doLayoutDirty())}},{key:"spacingY",get:function(){return this._spacingY},set:function(t){this._spacingY!==t&&(this._spacingY=t,this._doLayoutDirty())}},{key:"verticalDirection",get:function(){return this._verticalDirection},set:function(t){this._verticalDirection!==t&&(this._verticalDirection=t,this._doLayoutDirty())}},{key:"horizontalDirection",get:function(){return this._horizontalDirection},set:function(t){this._horizontalDirection!==t&&(this._horizontalDirection=t,this._doLayoutDirty())}},{key:"padding",get:function(){return this._paddingLeft},set:function(t){this.paddingLeft===t&&this._paddingRight===t&&this._paddingTop===t&&this._paddingBottom===t||(this._paddingLeft=this._paddingRight=this._paddingTop=this._paddingBottom=t,this._doLayoutDirty())}},{key:"constraint",get:function(){return this._constraint},set:function(t){this._layoutType!==fT.NONE&&this._constraint!==t&&(this._constraint=t,this._doLayoutDirty())}},{key:"constraintNum",get:function(){return this._constraintNum},set:function(t){this._constraint!==gT.NONE&&this._constraintNum!==t&&(t<=0&&Ue("Limit values to be greater than 0"),this._constraintNum=t,this._doLayoutDirty())}},{key:"affectedByScale",get:function(){return this._affectedByScale},set:function(t){this._affectedByScale=t,this._doLayoutDirty()}}]),e}(zi),uT.Type=fT,uT.VerticalDirection=mT,uT.HorizontalDirection=yT,uT.ResizeMode=pT,uT.AxisDirection=dT,uT.Constraint=gT,oi((Yx=cT).prototype,"alignHorizontal",[yx,gx],Object.getOwnPropertyDescriptor(Yx.prototype,"alignHorizontal"),Yx.prototype),oi(Yx.prototype,"alignVertical",[vx,bx],Object.getOwnPropertyDescriptor(Yx.prototype,"alignVertical"),Yx.prototype),oi(Yx.prototype,"type",[Sx,Ax],Object.getOwnPropertyDescriptor(Yx.prototype,"type"),Yx.prototype),oi(Yx.prototype,"resizeMode",[Cx,xx,Tx],Object.getOwnPropertyDescriptor(Yx.prototype,"resizeMode"),Yx.prototype),oi(Yx.prototype,"cellSize",[wx,Ex],Object.getOwnPropertyDescriptor(Yx.prototype,"cellSize"),Yx.prototype),oi(Yx.prototype,"startAxis",[Bx,Dx],Object.getOwnPropertyDescriptor(Yx.prototype,"startAxis"),Yx.prototype),oi(Yx.prototype,"paddingLeft",[Mx],Object.getOwnPropertyDescriptor(Yx.prototype,"paddingLeft"),Yx.prototype),oi(Yx.prototype,"paddingRight",[Px],Object.getOwnPropertyDescriptor(Yx.prototype,"paddingRight"),Yx.prototype),oi(Yx.prototype,"paddingTop",[Rx],Object.getOwnPropertyDescriptor(Yx.prototype,"paddingTop"),Yx.prototype),oi(Yx.prototype,"paddingBottom",[Ix],Object.getOwnPropertyDescriptor(Yx.prototype,"paddingBottom"),Yx.prototype),oi(Yx.prototype,"spacingX",[Ox],Object.getOwnPropertyDescriptor(Yx.prototype,"spacingX"),Yx.prototype),oi(Yx.prototype,"spacingY",[Fx],Object.getOwnPropertyDescriptor(Yx.prototype,"spacingY"),Yx.prototype),oi(Yx.prototype,"verticalDirection",[Lx,Vx],Object.getOwnPropertyDescriptor(Yx.prototype,"verticalDirection"),Yx.prototype),oi(Yx.prototype,"horizontalDirection",[kx,Nx],Object.getOwnPropertyDescriptor(Yx.prototype,"horizontalDirection"),Yx.prototype),oi(Yx.prototype,"constraint",[Gx,zx,Ux],Object.getOwnPropertyDescriptor(Yx.prototype,"constraint"),Yx.prototype),oi(Yx.prototype,"constraintNum",[Hx,jx],Object.getOwnPropertyDescriptor(Yx.prototype,"constraintNum"),Yx.prototype),oi(Yx.prototype,"affectedByScale",[Wx],Object.getOwnPropertyDescriptor(Yx.prototype,"affectedByScale"),Yx.prototype),qx=oi(Yx.prototype,"_resizeMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pT.NONE}}),Jx=oi(Yx.prototype,"_layoutType",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return fT.NONE}}),Kx=oi(Yx.prototype,"_cellSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new vr(40,40)}}),Zx=oi(Yx.prototype,"_startAxis",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dT.HORIZONTAL}}),Qx=oi(Yx.prototype,"_paddingLeft",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$x=oi(Yx.prototype,"_paddingRight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),tT=oi(Yx.prototype,"_paddingTop",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),eT=oi(Yx.prototype,"_paddingBottom",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),iT=oi(Yx.prototype,"_spacingX",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),rT=oi(Yx.prototype,"_spacingY",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),nT=oi(Yx.prototype,"_verticalDirection",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return mT.TOP_TO_BOTTOM}}),sT=oi(Yx.prototype,"_horizontalDirection",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return yT.LEFT_TO_RIGHT}}),aT=oi(Yx.prototype,"_constraint",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return gT.NONE}}),oT=oi(Yx.prototype,"_constraintNum",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),lT=oi(Yx.prototype,"_affectedByScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),hT=oi(Yx.prototype,"_isAlign",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Xx=Yx))||Xx)||Xx)||Xx)||Xx)||Xx)||Xx));!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.FILLED=2]="FILLED"}(UT||(UT={})),yi(UT);var WT,XT,YT,qT,JT,KT,ZT,QT,$T,tw,ew,iw,rw,nw,sw,aw,ow,lw,hw,uw,cw,_w,fw,pw,dw,mw=function(e){return t({ProgressBar:e,ProgressBarComponent:e}),e}((bT=ri("cc.ProgressBar"),ST=wi(),AT=Ei(110),CT=Bi(),xT=Rr(j_),TT=bi(dy),wT=Di(),ET=bi(UT),BT=Di(),DT=Di(),MT=Ni(),PT=Di(),RT=Di(),bT(IT=ST(IT=AT(IT=CT(IT=xT((zT=GT=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_barSprite",FT,hi(e)),li(e,"_mode",LT,hi(e)),li(e,"_totalLength",VT,hi(e)),li(e,"_progress",kT,hi(e)),li(e,"_reverse",NT,hi(e)),e}Me(e,t);var i=e.prototype;return i._initBarSprite=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=this.node._uiProps.uiTransformComp,i=e.contentSize,r=e.anchorPoint,n=t._uiProps.uiTransformComp.contentSize;if(this._barSprite.fillType===dy.FillType.RADIAL&&(this._mode=UT.FILLED),this._mode===UT.HORIZONTAL?this.totalLength=n.width:this._mode===UT.VERTICAL?this.totalLength=n.height:this.totalLength=this._barSprite.fillRange,t.parent===this.node){var s=-i.width*r.x;t.setPosition(s,0,0)}}},i._updateBarStatus=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=t._uiProps.uiTransformComp,i=e.anchorPoint,r=e.contentSize,n=t.getPosition(),s=new dr(0,.5),a=Cn(this._progress),o=this._totalLength*a,l=r,h=0,u=0;switch(this._mode){case UT.HORIZONTAL:this._reverse&&(s=new dr(1,.5)),l=new vr(o,r.height),h=this._totalLength,u=r.height;break;case UT.VERTICAL:s=this._reverse?new dr(.5,1):new dr(.5,0),l=new vr(r.width,o),h=r.width,u=this._totalLength}if(this._mode===UT.FILLED)this._barSprite.type!==dy.Type.FILLED?Ue("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this._reverse&&(o*=-1),this._barSprite.fillRange=o);else if(this._barSprite.type!==dy.Type.FILLED){var c=s.x-i.x,_=s.y-i.y,f=new ii(h*c,u*_,0);t.setPosition(n.x+f.x,n.y+f.y,n.z),e.setAnchorPoint(s),e.setContentSize(l)}else Ue("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},Pe(e,[{key:"barSprite",get:function(){return this._barSprite},set:function(t){this._barSprite!==t&&(this._barSprite=t,this._initBarSprite())}},{key:"mode",get:function(){return this._mode},set:function(t){if(this._mode!==t&&(this._mode=t,this._barSprite)){var e=this._barSprite.node;if(!e)return;var i=e._uiProps.uiTransformComp.contentSize;this._mode===UT.HORIZONTAL?this.totalLength=i.width:this._mode===UT.VERTICAL?this.totalLength=i.height:this._mode===UT.FILLED&&(this.totalLength=this._barSprite.fillRange)}}},{key:"totalLength",get:function(){return this._totalLength},set:function(t){this._mode===UT.FILLED&&(t=Cn(t)),this._totalLength=t,this._updateBarStatus()}},{key:"progress",get:function(){return this._progress},set:function(t){this._progress!==t&&(this._progress=t,this._updateBarStatus())}},{key:"reverse",get:function(){return this._reverse},set:function(t){this._reverse!==t&&(this._reverse=t,this._barSprite&&(this._barSprite.fillStart=1-this._barSprite.fillStart),this._updateBarStatus())}}]),e}(zi),GT.Mode=UT,oi((OT=zT).prototype,"barSprite",[TT,wT],Object.getOwnPropertyDescriptor(OT.prototype,"barSprite"),OT.prototype),oi(OT.prototype,"mode",[ET,BT],Object.getOwnPropertyDescriptor(OT.prototype,"mode"),OT.prototype),oi(OT.prototype,"totalLength",[DT],Object.getOwnPropertyDescriptor(OT.prototype,"totalLength"),OT.prototype),oi(OT.prototype,"progress",[MT,ki,PT],Object.getOwnPropertyDescriptor(OT.prototype,"progress"),OT.prototype),oi(OT.prototype,"reverse",[RT],Object.getOwnPropertyDescriptor(OT.prototype,"reverse"),OT.prototype),FT=oi(OT.prototype,"_barSprite",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),LT=oi(OT.prototype,"_mode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return UT.HORIZONTAL}}),VT=oi(OT.prototype,"_totalLength",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),kT=oi(OT.prototype,"_progress",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),NT=oi(OT.prototype,"_reverse",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),IT=OT))||IT)||IT)||IT)||IT)||IT)),yw=new ii,gw=new ii,vw=new ii,bw=new dr,Sw=new Ui,Aw=new dr;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(dw||(dw={})),Pr(dw);var Cw,xw,Tw,ww,Ew,Bw,Dw,Mw,Pw,Rw,Iw,Ow,Fw,Lw,Vw,kw,Nw,Gw,zw,Uw,Hw,jw,Ww,Xw,Yw,qw,Jw,Kw,Zw,Qw,$w,tE,eE,iE,rE,nE,sE,aE,oE,lE,hE,uE,cE,_E,fE,pE,dE,mE,yE,gE=function(e){return t({ScrollBar:e,ScrollBarComponent:e}),e}((WT=ri("cc.ScrollBar"),XT=wi(),YT=Ei(110),qT=Bi(),JT=Rr(j_),KT=bi(dy),ZT=Mr(),QT=Di(),$T=bi(dw),tw=Mr(),ew=Di(),iw=Mr(),rw=Di(),nw=Mr(),sw=Di(),WT(aw=XT(aw=YT(aw=qT(aw=JT((pw=fw=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_scrollView",lw,hi(e)),li(e,"_handle",hw,hi(e)),li(e,"_direction",uw,hi(e)),li(e,"_enableAutoHide",cw,hi(e)),li(e,"_autoHideTime",_w,hi(e)),e._touching=!1,e._opacity=255,e._autoHideRemainingTime=0,e}Me(e,t);var i=e.prototype;return i.hide=function(){this._autoHideRemainingTime=0,this._setOpacity(0)},i.show=function(){this._autoHideRemainingTime=this._autoHideTime,this._setOpacity(this._opacity)},i.onScroll=function(t){if(this._scrollView){var e=this._scrollView.content;if(e){var i=e._uiProps.uiTransformComp.contentSize,r=this._scrollView.node._uiProps.uiTransformComp.contentSize,n=this.node._uiProps.uiTransformComp.contentSize;if(!this._conditionalDisableScrollBar(i,r)){this._enableAutoHide&&(this._autoHideRemainingTime=this._autoHideTime,this._setOpacity(this._opacity));var s=0,a=0,o=0,l=0,h=0,u=Aw;u.set(0,0),this._direction===dw.HORIZONTAL?(s=i.width,a=r.width,h=n.width,o=t.x,this._convertToScrollViewSpace(u,e),l=-u.x):this._direction===dw.VERTICAL&&(s=i.height,a=r.height,h=n.height,o=t.y,this._convertToScrollViewSpace(u,e),l=-u.y);var c=this._calculateLength(s,a,h,o),_=Aw;this._calculatePosition(_,s,a,h,l,o,c),this._updateLength(c),this._updateHandlerPosition(_)}}}},i.setScrollView=function(t){this._scrollView=t},i.onTouchBegan=function(){this._enableAutoHide&&(this._touching=!0)},i.onTouchEnded=function(){if(this._enableAutoHide&&(this._touching=!1,!(this._autoHideTime<=0))){if(this._scrollView){var t=this._scrollView.content;if(t){var e=t._uiProps.uiTransformComp.contentSize,i=this._scrollView.node._uiProps.uiTransformComp.contentSize;if(this._conditionalDisableScrollBar(e,i))return}}this._autoHideRemainingTime=this._autoHideTime}},i.onEnable=function(){var t=this.node.getComponent(dy);t&&(this._opacity=t.color.a)},i.start=function(){this._enableAutoHide&&this._setOpacity(0)},i.update=function(t){this._processAutoHide(t)},i._convertToScrollViewSpace=function(t,e){var i=this._scrollView&&this._scrollView.node._uiProps.uiTransformComp,r=e._uiProps.uiTransformComp;if(i&&r){yw.set(-r.anchorX*r.width,-r.anchorY*r.height,0),r.convertToWorldSpaceAR(yw,gw);var n=i.convertToNodeSpaceAR(gw);n.x+=i.anchorX*i.width,n.y+=i.anchorY*i.height,t.set(n.x,n.y)}else t.set(dr.ZERO)},i._setOpacity=function(t){if(this._handle){var e=this.node.getComponent(dy);e&&(Sw.set(e.color),Sw.a=t,e.color=Sw),(e=this._handle.getComponent(dy))&&(Sw.set(e.color),Sw.a=t,e.color=Sw)}},i._updateHandlerPosition=function(t){if(this._handle){var e=vw;this._fixupHandlerPosition(e),this._handle.node.setPosition(t.x+e.x,t.y+e.y,e.z)}},i._fixupHandlerPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,r=e.anchorPoint,n=this.handle.node._uiProps.uiTransformComp.contentSize,s=this.handle.node.parent;ii.set(yw,-i.width*r.x,-i.height*r.y,0);var a=this.node._uiProps.uiTransformComp.convertToWorldSpaceAR(yw,gw),o=t;o.set(0,0,0),s._uiProps.uiTransformComp.convertToNodeSpaceAR(a,o),this.direction===dw.HORIZONTAL?o.set(o.x,o.y+(i.height-n.height)/2,o.z):this.direction===dw.VERTICAL&&o.set(o.x+(i.width-n.width)/2,o.y,o.z),this.handle.node.setPosition(o)},i._conditionalDisableScrollBar=function(t,e){return t.width<=e.width&&this._direction===dw.HORIZONTAL||t.height<=e.height&&this._direction===dw.VERTICAL},i._calculateLength=function(t,e,i,r){var n=t;return r&&(n+=20*(r>0?r:-r)),i*(e/n)},i._calculatePosition=function(t,e,i,r,n,s,a){var o=e-i;s&&(o+=Math.abs(s));var l=0;o&&(l=Cn(l=n/o));var h=(r-a)*l;this._direction===dw.VERTICAL?t.set(0,h):t.set(h,0)},i._updateLength=function(t){if(this._handle){var e=this._handle.node._uiProps.uiTransformComp,i=e.contentSize,r=e.anchorPoint;r.x===bw.x&&r.y===bw.y||e.setAnchorPoint(bw),this._direction===dw.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},i._processAutoHide=function(t){if(this._enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this._autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this._autoHideTime);this._setOpacity(e)}},Pe(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t,this.onScroll(dr.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(dr.ZERO))}},{key:"enableAutoHide",get:function(){return this._enableAutoHide},set:function(t){this._enableAutoHide!==t&&(this._enableAutoHide=t,this._enableAutoHide&&this._setOpacity(0))}},{key:"autoHideTime",get:function(){return this._autoHideTime},set:function(t){this._autoHideTime!==t&&(this._autoHideTime=t)}}]),e}(zi),fw.Direction=dw,oi((ow=pw).prototype,"handle",[KT,ZT,QT],Object.getOwnPropertyDescriptor(ow.prototype,"handle"),ow.prototype),oi(ow.prototype,"direction",[$T,tw,ew],Object.getOwnPropertyDescriptor(ow.prototype,"direction"),ow.prototype),oi(ow.prototype,"enableAutoHide",[iw,rw],Object.getOwnPropertyDescriptor(ow.prototype,"enableAutoHide"),ow.prototype),oi(ow.prototype,"autoHideTime",[nw,sw],Object.getOwnPropertyDescriptor(ow.prototype,"autoHideTime"),ow.prototype),lw=oi(ow.prototype,"_scrollView",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),hw=oi(ow.prototype,"_handle",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),uw=oi(ow.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dw.HORIZONTAL}}),cw=oi(ow.prototype,"_enableAutoHide",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),_w=oi(ow.prototype,"_autoHideTime",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),aw=ow))||aw)||aw)||aw)||aw)||aw)),vE=t("ViewGroup",ri("cc.ViewGroup")(Cw=Ei(110)(Cw=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e}(zi))||Cw)||Cw);He.ViewGroup=vE;var bE,SE=1e-4,AE=new ii,CE=new ii,xE=new dr,TE=new dr,wE=function(){return(new Date).getMilliseconds()},EE={"scroll-to-top":0,"scroll-to-bottom":1,"scroll-to-left":2,"scroll-to-right":3,scrolling:4,"bounce-bottom":6,"bounce-left":7,"bounce-right":8,"bounce-top":5,"scroll-ended":9,"touch-up":10,"scroll-ended-with-threshold":11,"scroll-began":12};!function(t){t.SCROLL_TO_TOP="scroll-to-top",t.SCROLL_TO_BOTTOM="scroll-to-bottom",t.SCROLL_TO_LEFT="scroll-to-left",t.SCROLL_TO_RIGHT="scroll-to-right",t.SCROLL_BEGAN="scroll-began",t.SCROLL_ENDED="scroll-ended",t.BOUNCE_TOP="bounce-top",t.BOUNCE_BOTTOM="bounce-bottom",t.BOUNCE_LEFT="bounce-left",t.BOUNCE_RIGHT="bounce-right",t.SCROLLING="scrolling",t.SCROLL_ENG_WITH_THRESHOLD="scroll-ended-with-threshold",t.TOUCH_UP="touch-up"}(bE||(bE={}));var BE,DE,ME,PE,RE,IE,OE,FE,LE,VE,kE,NE,GE,zE,UE,HE,jE,WE,XE,YE,qE,JE,KE=function(e){return t({ScrollView:e,ScrollViewComponent:e}),e}((xw=ri("cc.ScrollView"),Tw=wi(),ww=Ei(110),Ew=Bi(),Bw=Rr(j_),Dw=Ni(),Mw=Mr(),Pw=Di(),Rw=Ni(),Iw=Mr(),Ow=Di(),Fw=Mr(),Lw=Di(),Vw=Mr(),kw=Di(),Nw=bi(ur),Gw=Mr(),zw=Di(),Uw=Mr(),Hw=Di(),jw=bi(gE),Ww=Mr(),Xw=Di(),Yw=Mr(),qw=Di(),Jw=bi(gE),Kw=Mr(),Zw=Di(),Qw=Mr(),$w=Di(),tE=bi([pn]),eE=Mr(),iE=Di(),xw(rE=Tw(rE=ww(rE=Ew(rE=Bw((yE=mE=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"bounceDuration",sE,hi(e)),li(e,"brake",aE,hi(e)),li(e,"elastic",oE,hi(e)),li(e,"inertia",lE,hi(e)),li(e,"horizontal",hE,hi(e)),li(e,"vertical",uE,hi(e)),li(e,"cancelInnerEvents",cE,hi(e)),li(e,"scrollEvents",_E,hi(e)),e._autoScrolling=!1,e._scrolling=!1,li(e,"_content",fE,hi(e)),li(e,"_horizontalScrollBar",pE,hi(e)),li(e,"_verticalScrollBar",dE,hi(e)),e._topBoundary=0,e._bottomBoundary=0,e._leftBoundary=0,e._rightBoundary=0,e._touchMoveDisplacements=[],e._touchMoveTimeDeltas=[],e._touchMovePreviousTimestamp=0,e._touchMoved=!1,e._autoScrollAttenuate=!1,e._autoScrollStartPosition=new ii,e._autoScrollTargetDelta=new ii,e._autoScrollTotalTime=0,e._autoScrollAccumulatedTime=0,e._autoScrollCurrentlyOutOfBoundary=!1,e._autoScrollBraking=!1,e._autoScrollBrakingStartPosition=new ii,e._outOfBoundaryAmount=new ii,e._outOfBoundaryAmountDirty=!0,e._stopMouseWheel=!1,e._mouseWheelEventElapsedTime=0,e._isScrollEndedWithThresholdEventFired=!1,e._scrollEventEmitMask=0,e._isBouncing=!1,e._contentPos=new ii,e._deltaPos=new ii,e}Me(e,t);var i=e.prototype;return i.scrollToBottom=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},i.scrollToTop=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new dr(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToOffset=function(t,e,i){void 0===i&&(i=!0);var r=this.getMaxScrollOffset(),n=new dr(0,0);0===r.x?n.x=0:n.x=t.x/r.x,0===r.y?n.y=1:n.y=(r.y-t.y)/r.y,this.scrollTo(n,e,i)},i.getScrollOffset=function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return new dr(e,t)},i.getMaxScrollOffset=function(){if(!this._content||!this.view)return dr.ZERO;var t=this._content._uiProps.uiTransformComp.contentSize,e=t.width-this.view.width,i=t.height-this.view.height;return new dr(e=e>=0?e:0,i=i>=0?i:0)},i.scrollToPercentHorizontal=function(t,e,i){var r=this._calculateMovePercentDelta({anchor:new dr(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(r,e,!1!==i):this._moveContent(r)},i.scrollTo=function(t,e,i){var r=this._calculateMovePercentDelta({anchor:new dr(t),applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(r,e,i):this._moveContent(r)},i.scrollToPercentVertical=function(t,e,i){var r=this._calculateMovePercentDelta({anchor:new dr(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(r,e,i):this._moveContent(r)},i.stopAutoScroll=function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},i.setContentPosition=function(t){this._setContentPosition(t)},i._setContentPosition=function(t){if(this._content){var e=this._getContentPosition();Math.abs(t.x-e.x)<SE&&Math.abs(t.y-e.y)<SE||(this._content.setPosition(t),this._outOfBoundaryAmountDirty=!0)}},i.getContentPosition=function(){return this._getContentPosition()},i._getContentPosition=function(){return this._content?(this._contentPos.set(this._content.position),this._contentPos):ii.ZERO},i.isScrolling=function(){return this._scrolling},i.isAutoScrolling=function(){return this._autoScrolling},i.getScrollEndedEventTiming=function(){return SE},i.start=function(){this._calculateBoundary(),this._content&&wr.once(Er.EVENT_BEFORE_DRAW,this._adjustContentOutOfBoundary,this)},i.onEnable=function(){this._registerEvent(),this._content&&(this._content.on(ur.EventType.SIZE_CHANGED,this._calculateBoundary,this),this._content.on(ur.EventType.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.on(ur.EventType.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.on(ur.EventType.SIZE_CHANGED,this._calculateBoundary,this))),this._calculateBoundary(),this._updateScrollBarState()},i.update=function(t){this._autoScrolling&&this._processAutoScrolling(t)},i.onDisable=function(){this._unregisterEvent(),this._content&&(this._content.off(ur.EventType.SIZE_CHANGED,this._calculateBoundary,this),this._content.off(ur.EventType.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.off(ur.EventType.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.off(ur.EventType.SIZE_CHANGED,this._calculateBoundary,this))),this._hideScrollBar(),this.stopAutoScroll()},i._registerEvent=function(){this.node.on(ur.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(ur.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(ur.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(ur.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(ur.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},i._unregisterEvent=function(){this.node.off(ur.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(ur.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(ur.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(ur.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(ur.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},i._onMouseWheel=function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=new ii,r=t.getScrollY();this.vertical?i.set(0,-.1*r,0):this.horizontal&&i.set(-.1*r,0,0),this._mouseWheelEventElapsedTime=0,this._processDeltaMove(i),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60,NaN,0),this._stopMouseWheel=!0),this._stopPropagationIfTargetIsMe(t)}},i._onTouchBegan=function(t,e){this.enabledInHierarchy&&this._content&&(this._hasNestedViewGroup(t,e)||(this._handlePressLogic(),this._touchMoved=!1,this._stopPropagationIfTargetIsMe(t)))},i._onTouchMoved=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){var i=t.touch;if(this._handleMoveLogic(i),this.cancelInnerEvents){var r=i.getUILocation(xE);if(r.subtract(i.getUIStartLocation(TE)),r.length()>7&&!this._touchMoved&&t.target!==this.node){var n=new xn(t.getTouches(),t.bubbles);n.type=ur.EventType.TOUCH_CANCEL,n.touch=t.touch,n.simulate=!0,t.target.dispatchEvent(n),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},i._onTouchEnded=function(t,e){if(this.enabledInHierarchy&&this._content&&t&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent(bE.TOUCH_UP);var i=t.touch;this._handleReleaseLogic(i),this._touchMoved?t.propagationStopped=!0:this._stopPropagationIfTargetIsMe(t)}},i._onTouchCancelled=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){if(t&&!t.simulate){var i=t.touch;this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},i._calculateBoundary=function(){if(this._content&&this.view){var t=this._content.getComponent(jT);t&&t.enabledInHierarchy&&t.updateLayout();var e=this.view,i=e.width*e.anchorX,r=e.height*e.anchorY;this._leftBoundary=-i,this._bottomBoundary=-r,this._rightBoundary=this._leftBoundary+e.width,this._topBoundary=this._bottomBoundary+e.height,this._moveContentToTopLeft(e.contentSize)}},i._hasNestedViewGroup=function(t,e){if(!t||t.eventPhase!==Tn.CAPTURING_PHASE)return!1;if(e)for(var i,r=Fe(e);!(i=r()).done;){var n=i.value;if(this.node===n)return!(!t.target||!t.target.getComponent(vE));if(n.getComponent(vE))return!0}return!1},i._startInertiaScroll=function(t){var e=new ii(t);e.multiplyScalar(.7),this._startAttenuatingAutoScroll(e,t)},i._calculateAttenuatedFactor=function(t){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},i._startAttenuatingAutoScroll=function(t,e){var i=t.clone();if(i.normalize(),this._content&&this.view){var r=this._content._uiProps.uiTransformComp.contentSize,n=this.view.contentSize,s=r.width-n.width,a=r.height-n.height,o=this._calculateAttenuatedFactor(s),l=this._calculateAttenuatedFactor(a);i.x=i.x*s*(1-this.brake)*o,i.y=i.y*a*l*(1-this.brake),i.z=0}var h=t.length(),u=i.length()/h;if(i.add(t),this.brake>0&&u>7){u=Math.sqrt(u);var c=t.clone();c.multiplyScalar(u),i.set(c),i.add(t)}var _=this._calculateAutoScrollTimeByInitialSpeed(e.length());this.brake>0&&u>3&&(_*=u=3),0===this.brake&&u>1&&(_*=u),this._startAutoScroll(i,_,!0)},i._calculateAutoScrollTimeByInitialSpeed=function(t){return Math.sqrt(Math.sqrt(t/5))},i._startAutoScroll=function(t,e,i){void 0===i&&(i=!1);var r=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=r,this._autoScrollAttenuate=i,ii.copy(this._autoScrollStartPosition,this._getContentPosition()),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition.set(0,0,0),this._getHowMuchOutOfBoundary().equals(ii.ZERO,SE)||(this._autoScrollCurrentlyOutOfBoundary=!0)},i._calculateTouchMoveVelocity=function(){var t=new ii,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(ii.ZERO);else{var i=new ii;i=this._touchMoveDisplacements.reduce((function(t,e){return t.add(e),t}),i),t.set(i.x*(1-this.brake)/e,i.y*(1-this.brake)/e,i.z)}return t},i._flattenVectorByDirection=function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},i._moveContent=function(t,e){var i=this._flattenVectorByDirection(t);AE.set(this._getContentPosition()),AE.add(i),AE.set(Math.floor(1e4*AE.x)*SE,Math.floor(1e4*AE.y)*SE,AE.z),this._setContentPosition(AE);var r=this._getHowMuchOutOfBoundary();xE.set(r.x,r.y),this._updateScrollBar(xE),this.elastic&&e&&this._startBounceBackIfNeeded()},i._getContentLeftBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.x-e.anchorX*e.width},i._getContentRightBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentLeftBoundary()+t.width},i._getContentTopBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentBottomBoundary()+t.height},i._getContentBottomBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.y-e.anchorY*e.height},i._getHowMuchOutOfBoundary=function(t){if((t=t||new ii).equals(ii.ZERO,SE)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new ii;return this._getContentLeftBoundary()+t.x>this._leftBoundary?e.x=this._leftBoundary-(this._getContentLeftBoundary()+t.x):this._getContentRightBoundary()+t.x<this._rightBoundary&&(e.x=this._rightBoundary-(this._getContentRightBoundary()+t.x)),this._getContentTopBoundary()+t.y<this._topBoundary?e.y=this._topBoundary-(this._getContentTopBoundary()+t.y):this._getContentBottomBoundary()+t.y>this._bottomBoundary&&(e.y=this._bottomBoundary-(this._getContentBottomBoundary()+t.y)),t.equals(ii.ZERO,SE)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),this._clampDelta(e),e},i._updateScrollBar=function(t){this._horizontalScrollBar&&this._horizontalScrollBar.onScroll(t),this.verticalScrollBar&&this.verticalScrollBar.onScroll(t)},i._onScrollBarTouchBegan=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar.onTouchBegan()},i._onScrollBarTouchEnded=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar.onTouchEnded()},i._dispatchEvent=function(t){if(t===bE.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(t===bE.SCROLL_TO_TOP||t===bE.SCROLL_TO_BOTTOM||t===bE.SCROLL_TO_LEFT||t===bE.SCROLL_TO_RIGHT){var e=1<<EE[t];if(this._scrollEventEmitMask&e)return;this._scrollEventEmitMask|=e}pn.emitEvents(this.scrollEvents,this,EE[t]),this.node.emit(t,this)},i._adjustContentOutOfBoundary=function(){if(this._content&&(this._outOfBoundaryAmountDirty=!0,this._isOutOfBoundary())){var t=this._getHowMuchOutOfBoundary();AE.set(this._getContentPosition()),AE.add(t),this._content.setPosition(AE),this._updateScrollBar(dr.ZERO)}},i._hideScrollBar=function(){this._horizontalScrollBar&&this._horizontalScrollBar.hide(),this._verticalScrollBar&&this._verticalScrollBar.hide()},i._updateScrollBarState=function(){if(this._content&&this.view){var t=this.view,e=this._content._uiProps.uiTransformComp;this.verticalScrollBar&&(e.height<t.height?this.verticalScrollBar.hide():this.verticalScrollBar.show()),this.horizontalScrollBar&&(e.width<t.width?this.horizontalScrollBar.hide():this.horizontalScrollBar.show())}},i._stopPropagationIfTargetIsMe=function(t){t.eventPhase===Tn.AT_TARGET&&t.target===this.node&&(t.propagationStopped=!0)},i._processDeltaMove=function(t){this._scrollChildren(t),this._gatherTouchMove(t)},i._handleMoveLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._processDeltaMove(this._deltaPos)},i._handleReleaseLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._gatherTouchMove(this._deltaPos),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(bE.SCROLL_ENDED))},i._getLocalAxisAlignDelta=function(t,e){var i=this.node._uiProps.uiTransformComp,r=new ii;i&&(e.getUILocation(xE),e.getUIPreviousLocation(TE),AE.set(xE.x,xE.y,0),CE.set(TE.x,TE.y,0),i.convertToNodeSpaceAR(AE,AE),i.convertToNodeSpaceAR(CE,CE),ii.subtract(r,AE,CE)),t.set(r)},i._scrollChildren=function(t){this._clampDelta(t);var e,i,r=t;if(this.elastic&&(e=this._getHowMuchOutOfBoundary(),r.x*=0===e.x?1:.5,r.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(r),r.add(e)),this._content){var n=this._content._uiProps.uiTransformComp,s=n.anchorX,a=n.anchorY,o=n.width,l=n.height,h=this._content.position||ii.ZERO;r.y>0?h.y-a*l+r.y>=this._bottomBoundary&&(i=bE.SCROLL_TO_BOTTOM):r.y<0&&h.y-a*l+l+r.y<=this._topBoundary&&(i=bE.SCROLL_TO_TOP),r.x<0?h.x-s*o+o+r.x<=this._rightBoundary&&(i=bE.SCROLL_TO_RIGHT):r.x>0&&h.x-s*o+r.x>=this._leftBoundary&&(i=bE.SCROLL_TO_LEFT)}this._moveContent(r,!1),0===r.x&&0===r.y||(this._scrolling||(this._scrolling=!0,this._dispatchEvent(bE.SCROLL_BEGAN)),this._dispatchEvent(bE.SCROLLING)),i&&i.length>0&&this._dispatchEvent(i)},i._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(bE.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=wE(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},i._clampDelta=function(t){if(this._content&&this.view){var e=this.view.contentSize,i=this._content._uiProps.uiTransformComp;i.width<e.width&&(t.x=0),i.height<e.height&&(t.y=0)}},i._gatherTouchMove=function(t){var e=t.clone();for(this._clampDelta(e);this._touchMoveDisplacements.length>=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(e);var i=wE();this._touchMoveTimeDeltas.push((i-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=i},i._startBounceBackIfNeeded=function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(this._clampDelta(t),t.equals(ii.ZERO,SE))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent(bE.BOUNCE_TOP),t.y<0&&this._dispatchEvent(bE.BOUNCE_BOTTOM),t.x>0&&this._dispatchEvent(bE.BOUNCE_RIGHT),t.x<0&&this._dispatchEvent(bE.BOUNCE_LEFT),this._isBouncing=!0),!0},i._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(AE,SE)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},i._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(ii.ZERO,SE)},i._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,this._autoScrollBrakingStartPosition=this._getContentPosition(),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},i._processAutoScrolling=function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var r,n=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(r=n,n=(r-=1)*r*r*r*r+1);var s=this._autoScrollTargetDelta.clone();s.multiplyScalar(n);var a=this._autoScrollStartPosition.clone();a.add(s);var o=Math.abs(n-1)<=SE;if(Math.abs(n-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(bE.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var l=a.clone();l.subtract(this._autoScrollBrakingStartPosition),e&&l.multiplyScalar(i),a.set(this._autoScrollBrakingStartPosition),a.add(l)}else{var h=a.clone();h.subtract(this.getContentPosition());var u=this._getHowMuchOutOfBoundary(h);u.equals(ii.ZERO,SE)||(a.add(u),o=!0)}o&&(this._autoScrolling=!1);var c=a.clone();c.subtract(this._getContentPosition()),this._clampDelta(c),this._moveContent(c,o),this._dispatchEvent(bE.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(bE.SCROLL_ENDED))},i._checkMouseWheel=function(t){if(!this._getHowMuchOutOfBoundary().equals(ii.ZERO,SE))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(bE.SCROLL_ENDED),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(bE.SCROLL_ENDED),this._stopMouseWheel=!1)},i._calculateMovePercentDelta=function(t){var e=t.anchor,i=t.applyToHorizontal,r=t.applyToVertical;this._calculateBoundary(),e.clampf(dr.ZERO,dr.ONE);var n=this._getContentBottomBoundary()-this._bottomBoundary;n=-n;var s=this._getContentLeftBoundary()-this._leftBoundary;s=-s;var a=new ii;if(this._content&&this.view){var o=0,l=this._content._uiProps.uiTransformComp.contentSize,h=this.view.contentSize;i&&(o=l.width-h.width,a.x=s-o*e.x),r&&(o=l.height-h.height,a.y=n-o*e.y)}return a},i._moveContentToTopLeft=function(t){var e=this._getContentBottomBoundary()-this._bottomBoundary;e=-e;var i=new ii,r=0,n=this._getContentLeftBoundary()-this._leftBoundary;if(n=-n,this._content){var s=this._content._uiProps.uiTransformComp.contentSize;s.height<t.height&&(r=s.height-t.height,i.y=e-r),s.width<t.width&&(r=s.width-t.width,i.x=n)}this._updateScrollBarState(),this._moveContent(i),this._adjustContentOutOfBoundary()},i._scaleChanged=function(t){t===Ai.SCALE&&this._calculateBoundary()},Pe(e,[{key:"content",get:function(){return this._content},set:function(t){if(this._content!==t){var e=t&&t.parent&&t.parent._uiProps.uiTransformComp;!t||t&&e?(this._content=t,this._calculateBoundary()):an(4302)}}},{key:"horizontalScrollBar",get:function(){return this._horizontalScrollBar},set:function(t){this._horizontalScrollBar!==t&&(this._horizontalScrollBar=t,this._horizontalScrollBar&&(this._horizontalScrollBar.setScrollView(this),this._updateScrollBar(dr.ZERO)))}},{key:"verticalScrollBar",get:function(){return this._verticalScrollBar},set:function(t){this._verticalScrollBar!==t&&(this._verticalScrollBar=t,this._verticalScrollBar&&(this._verticalScrollBar.setScrollView(this),this._updateScrollBar(dr.ZERO)))}},{key:"view",get:function(){var t=this._content&&this._content.parent;return t?t._uiProps.uiTransformComp:null}}]),e}(vE),mE.EventType=bE,sE=oi((nE=yE).prototype,"bounceDuration",[_i,Dw,Mw,Pw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),aE=oi(nE.prototype,"brake",[_i,Rw,Iw,Ow],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),oE=oi(nE.prototype,"elastic",[_i,Fw,Lw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),lE=oi(nE.prototype,"inertia",[_i,Vw,kw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(nE.prototype,"content",[Nw,Gw,zw],Object.getOwnPropertyDescriptor(nE.prototype,"content"),nE.prototype),hE=oi(nE.prototype,"horizontal",[_i,Uw,Hw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(nE.prototype,"horizontalScrollBar",[jw,Ww,Xw],Object.getOwnPropertyDescriptor(nE.prototype,"horizontalScrollBar"),nE.prototype),uE=oi(nE.prototype,"vertical",[_i,Yw,qw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(nE.prototype,"verticalScrollBar",[Jw,Kw,Zw],Object.getOwnPropertyDescriptor(nE.prototype,"verticalScrollBar"),nE.prototype),cE=oi(nE.prototype,"cancelInnerEvents",[_i,Qw,$w],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),_E=oi(nE.prototype,"scrollEvents",[tE,_i,eE,iE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),fE=oi(nE.prototype,"_content",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),pE=oi(nE.prototype,"_horizontalScrollBar",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),dE=oi(nE.prototype,"_verticalScrollBar",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),rE=nE))||rE)||rE)||rE)||rE)||rE)),ZE=new ii;!function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(JE||(JE={})),Pr(JE);var QE,$E,tB,eB,iB,rB,nB,sB,aB,oB,lB,hB,uB,cB,_B,fB,pB,dB,mB,yB,gB=function(e){return t({Slider:e,SliderComponent:e}),e}((BE=ri("cc.Slider"),DE=wi(),ME=Ei(110),PE=Bi(),RE=Rr(j_),IE=bi(dy),OE=Di(),FE=bi(JE),LE=Di(),VE=Ni(),kE=Di(),NE=bi([pn]),GE=Di(),BE(zE=DE(zE=ME(zE=PE(zE=RE((qE=YE=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"slideEvents",HE,hi(e)),li(e,"_handle",jE,hi(e)),li(e,"_direction",WE,hi(e)),li(e,"_progress",XE,hi(e)),e._offset=new ii,e._dragging=!1,e._touchHandle=!1,e._handleLocalPos=new ii,e._touchPos=new ii,e}Me(e,t);var i=e.prototype;return i.__preload=function(){this._updateHandlePosition()},i.onEnable=function(){this._updateHandlePosition(),this.node.on(Dr.TOUCH_START,this._onTouchBegan,this),this.node.on(Dr.TOUCH_MOVE,this._onTouchMoved,this),this.node.on(Dr.TOUCH_END,this._onTouchEnded,this),this.node.on(Dr.TOUCH_CANCEL,this._onTouchCancelled,this),this._handle&&this._handle.isValid&&(this._handle.node.on(Dr.TOUCH_START,this._onHandleDragStart,this),this._handle.node.on(Dr.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.on(Dr.TOUCH_END,this._onTouchEnded,this))},i.onDisable=function(){this.node.off(Dr.TOUCH_START,this._onTouchBegan,this),this.node.off(Dr.TOUCH_MOVE,this._onTouchMoved,this),this.node.off(Dr.TOUCH_END,this._onTouchEnded,this),this.node.off(Dr.TOUCH_CANCEL,this._onTouchCancelled,this),this._handle&&this._handle.isValid&&(this._handle.node.off(Dr.TOUCH_START,this._onHandleDragStart,this),this._handle.node.off(Dr.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.off(Dr.TOUCH_END,this._onTouchEnded,this))},i._onHandleDragStart=function(t){if(t&&this._handle&&this._handle.node._uiProps.uiTransformComp){this._dragging=!0,this._touchHandle=!0;var e=t.touch.getUILocation();ii.set(this._touchPos,e.x,e.y,0),this._handle.node._uiProps.uiTransformComp.convertToNodeSpaceAR(this._touchPos,this._offset),t.propagationStopped=!0}},i._onTouchBegan=function(t){this._handle&&t&&(this._dragging=!0,this._touchHandle||this._handleSliderLogic(t.touch),t.propagationStopped=!0)},i._onTouchMoved=function(t){this._dragging&&t&&(this._handleSliderLogic(t.touch),t.propagationStopped=!0)},i._onTouchEnded=function(t){this._dragging=!1,this._touchHandle=!1,this._offset=new ii,t&&(t.propagationStopped=!0)},i._onTouchCancelled=function(t){this._dragging=!1,t&&(t.propagationStopped=!0)},i._handleSliderLogic=function(t){this._updateProgress(t),this._emitSlideEvent()},i._emitSlideEvent=function(){pn.emitEvents(this.slideEvents,this),this.node.emit("slide",this)},i._updateProgress=function(t){if(this._handle&&t){var e=t.getUILocation();ii.set(this._touchPos,e.x,e.y,0);var i=this.node._uiProps.uiTransformComp,r=i.convertToNodeSpaceAR(this._touchPos,ZE);this.direction===JE.Horizontal?this.progress=Cn(.5+(r.x-this._offset.x)/i.width):this.progress=Cn(.5+(r.y-this._offset.y)/i.height)}},i._updateHandlePosition=function(){if(this._handle){this._handleLocalPos.set(this._handle.node.getPosition());var t=this.node._uiProps.uiTransformComp;this._direction===JE.Horizontal?this._handleLocalPos.x=-t.width*t.anchorX+this.progress*t.width:this._handleLocalPos.y=-t.height*t.anchorY+this.progress*t.height,this._handle.node.setPosition(this._handleLocalPos)}},i._changeLayout=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(t.setContentSize(e.height,e.width),this._handle){var i=this._handle.node.position;this._direction===JE.Horizontal?this._handle.node.setPosition(i.x,0,i.z):this._handle.node.setPosition(0,i.y,i.z),this._updateHandlePosition()}},Pe(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this._changeLayout())}},{key:"progress",get:function(){return this._progress},set:function(t){this._progress!==t&&(this._progress=t,this._updateHandlePosition())}}]),e}(zi),YE.Direction=JE,oi((UE=qE).prototype,"handle",[IE,OE],Object.getOwnPropertyDescriptor(UE.prototype,"handle"),UE.prototype),oi(UE.prototype,"direction",[FE,LE],Object.getOwnPropertyDescriptor(UE.prototype,"direction"),UE.prototype),oi(UE.prototype,"progress",[ki,VE,kE],Object.getOwnPropertyDescriptor(UE.prototype,"progress"),UE.prototype),HE=oi(UE.prototype,"slideEvents",[NE,_i,GE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),jE=oi(UE.prototype,"_handle",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),WE=oi(UE.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return JE.Horizontal}}),XE=oi(UE.prototype,"_progress",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),zE=UE))||zE)||zE)||zE)||zE)||zE));function vB(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return Object.assign.apply(Object,[{}].concat(e))}!function(t){t.TOGGLE="toggle"}(yB||(yB={}));var bB,SB,AB,CB,xB,TB,wB,EB,BB,DB,MB,PB,RB,IB,OB,FB,LB,VB,kB,NB,GB,zB,UB,HB,jB,WB,XB,YB,qB,JB,KB,ZB,QB,$B,tD,eD,iD,rD,nD,sD,aD,oD,lD,hD,uD,cD,_D,fD,pD,dD,mD,yD,gD,vD,bD,SD,AD,CD,xD,TD=function(e){return t({Toggle:e,ToggleComponent:e}),e}((QE=ri("cc.Toggle"),$E=wi(),tB=Ei(110),eB=Bi(),iB=Rr(j_),rB=Mr(),nB=Di(),sB=bi(dy),aB=Mr(),oB=Di(),lB=bi([pn]),hB=Di(),QE(uB=$E(uB=tB(uB=eB(uB=iB((mB=dB=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"checkEvents",_B,hi(e)),li(e,"_isChecked",fB,hi(e)),li(e,"_checkMark",pB,hi(e)),e}Me(e,t);var i=e.prototype;return i._internalToggle=function(){this.isChecked=!this.isChecked},i._set=function(t,e){if(void 0===e&&(e=!0),this._isChecked!=t){this._isChecked=t;var i=this._toggleContainer;i&&i.enabled&&this.enabled&&(t||!i.anyTogglesChecked()&&!i.allowSwitchOff)&&(this._isChecked=!0,i.notifyToggleCheck(this,e)),this.playEffect(),e&&this._emitToggleEvents()}},i.playEffect=function(){this._checkMark&&(this._checkMark.node.active=this._isChecked)},i.setIsCheckedWithoutNotify=function(t){this._set(t,!1)},i.onEnable=function(){t.prototype.onEnable.call(this),this.playEffect(),this.node.on(e.EventType.CLICK,this._internalToggle,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(e.EventType.CLICK,this._internalToggle,this)},i.OnDestroy=function(){var t=this._toggleContainer;t&&t.ensureValidState()},i._emitToggleEvents=function(){this.node.emit(e.EventType.TOGGLE,this),this.checkEvents&&pn.emitEvents(this.checkEvents,this)},Pe(e,[{key:"isChecked",get:function(){return this._isChecked},set:function(t){this._set(t)}},{key:"checkMark",get:function(){return this._checkMark},set:function(t){this._checkMark!==t&&(this._checkMark=t)}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"_toggleContainer",get:function(){var t=this.node.parent;return He.Node.isNode(t)?t.getComponent("cc.ToggleContainer"):null}}]),e}(KA),dB.EventType=vB(yB,WA),oi((cB=mB).prototype,"isChecked",[rB,nB],Object.getOwnPropertyDescriptor(cB.prototype,"isChecked"),cB.prototype),oi(cB.prototype,"checkMark",[sB,aB,oB],Object.getOwnPropertyDescriptor(cB.prototype,"checkMark"),cB.prototype),_B=oi(cB.prototype,"checkEvents",[lB,_i,hB],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),fB=oi(cB.prototype,"_isChecked",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),pB=oi(cB.prototype,"_checkMark",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),uB=cB))||uB)||uB)||uB)||uB)||uB)),wD=function(e){return t({ToggleContainer:e,ToggleContainerComponent:e}),e}((bB=ri("cc.ToggleContainer"),SB=wi(),AB=Ei(110),CB=Bi(),xB=Di(),TB=bi([pn]),wB=Di(),bB(EB=SB(EB=AB(EB=CB(EB=Si((PB=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_allowSwitchOff",DB,hi(e)),li(e,"checkEvents",MB,hi(e)),e}Me(e,t);var i=e.prototype;return i.onEnable=function(){this.ensureValidState(),this.node.on(Dr.CHILD_ADDED,this.ensureValidState,this),this.node.on(Dr.CHILD_REMOVED,this.ensureValidState,this)},i.onDisable=function(){this.node.off(Dr.CHILD_ADDED,this.ensureValidState,this),this.node.off(Dr.CHILD_REMOVED,this.ensureValidState,this)},i.activeToggles=function(){return this.toggleItems.filter((function(t){return t.isChecked}))},i.anyTogglesChecked=function(){return!!this.toggleItems.find((function(t){return t.isChecked}))},i.notifyToggleCheck=function(t,e){if(void 0===e&&(e=!0),this.enabledInHierarchy){for(var i=0;i<this.toggleItems.length;i++){var r=this.toggleItems[i];r!==t&&(e?r.isChecked=!1:r.setIsCheckedWithoutNotify(!1))}this.checkEvents&&He.Component.EventHandler.emitEvents(this.checkEvents,t)}},i.ensureValidState=function(){var t=this.toggleItems;if(!this._allowSwitchOff&&!this.anyTogglesChecked()&&0!==t.length){var e=t[0];e.isChecked=!0,this.notifyToggleCheck(e)}var i=this.activeToggles();if(i.length>1)for(var r=i[0],n=0;n<i.length;++n){var s=i[n];s!==r&&(s.isChecked=!1)}},Pe(e,[{key:"allowSwitchOff",get:function(){return this._allowSwitchOff},set:function(t){this._allowSwitchOff=t}},{key:"toggleItems",get:function(){return this.node.children.map((function(t){var e=t.getComponent("cc.Toggle");return e&&e.enabled?e:null})).filter(Boolean)}}]),e}(zi),DB=oi((BB=PB).prototype,"_allowSwitchOff",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(BB.prototype,"allowSwitchOff",[xB],Object.getOwnPropertyDescriptor(BB.prototype,"allowSwitchOff"),BB.prototype),MB=oi(BB.prototype,"checkEvents",[TB,_i,wB],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),EB=BB))||EB)||EB)||EB)||EB)||EB)),ED=new dr;function BD(t){return t instanceof wn?jr:t._uiProps.uiTransformComp?t._uiProps.uiTransformComp.contentSize:vr.ZERO}function DD(t,e,i,r){t.parent?ED.set(t.parent.getScale().x,t.parent.getScale().y):ED.set(0,0);for(var n=ED.x,s=ED.y,a=0,o=0,l=t.parent;;){if(!l)return i.x=i.y=0,void(r.x=r.y=1);var h=l.getPosition();if(a+=h.x,o+=h.y,(l=l.parent)===e)break;l?ED.set(l.getScale().x,l.getScale().y):ED.set(0,0);var u=ED.x,c=ED.y;a*=u,o*=c,n*=u,s*=c}r.x=0!==n?1/n:1,r.y=0!==s?1/s:1,i.x=-a,i.y=-o}!function(t){t[t.ONCE=0]="ONCE",t[t.ALWAYS=1]="ALWAYS",t[t.ON_WINDOW_RESIZE=2]="ON_WINDOW_RESIZE"}(CD||(CD={})),Pr(CD),function(t){t[t.TOP=1]="TOP",t[t.MID=2]="MID",t[t.BOT=4]="BOT",t[t.LEFT=8]="LEFT",t[t.CENTER=16]="CENTER",t[t.RIGHT=32]="RIGHT",t[t.HORIZONTAL=56]="HORIZONTAL",t[t.VERTICAL=7]="VERTICAL"}(xD||(xD={}));var MD,PD,RD,ID,OD,FD,LD,VD,kD,ND,GD,zD,UD,HD,jD,WD,XD,YD,qD,JD=xD.TOP|xD.BOT,KD=xD.LEFT|xD.RIGHT,ZD=function(e){return t({Widget:e,WidgetComponent:e}),e}((RB=ri("cc.Widget"),IB=wi(),OB=Ei(110),FB=Bi(),LB=Rr(j_),VB=bi(ur),kB=Di(),NB=Di(),GB=Di(),zB=Di(),UB=Di(),HB=Di(),jB=Di(),WB=Mi(),XB=Mi(),YB=Di(),qB=Di(),JB=Di(),KB=Di(),ZB=Di(),QB=Di(),$B=bi(CD),tD=Di(),RB(eD=IB(eD=OB(eD=FB(eD=LB(eD=Si((AD=SD=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._lastPos=new ii,e._lastSize=new vr,e._dirty=!0,e._hadAlignOnce=!1,li(e,"_alignFlags",rD,hi(e)),li(e,"_target",nD,hi(e)),li(e,"_left",sD,hi(e)),li(e,"_right",aD,hi(e)),li(e,"_top",oD,hi(e)),li(e,"_bottom",lD,hi(e)),li(e,"_horizontalCenter",hD,hi(e)),li(e,"_verticalCenter",uD,hi(e)),li(e,"_isAbsLeft",cD,hi(e)),li(e,"_isAbsRight",_D,hi(e)),li(e,"_isAbsTop",fD,hi(e)),li(e,"_isAbsBottom",pD,hi(e)),li(e,"_isAbsHorizontalCenter",dD,hi(e)),li(e,"_isAbsVerticalCenter",mD,hi(e)),li(e,"_originalWidth",yD,hi(e)),li(e,"_originalHeight",gD,hi(e)),li(e,"_alignMode",vD,hi(e)),li(e,"_lockFlags",bD,hi(e)),e}Me(e,t);var i=e.prototype;return i.updateAlignment=function(){He._widgetManager.updateAlignment(this.node)},i._validateTargetInDEV=function(){},i.setDirty=function(){this._recursiveDirty()},i.onEnable=function(){this.node.getPosition(this._lastPos),this._lastSize.set(this.node._uiProps.uiTransformComp.contentSize),He._widgetManager.add(this),this._hadAlignOnce=!1,this._registerEvent(),this._registerTargetEvents()},i.onDisable=function(){He._widgetManager.remove(this),this._unregisterEvent(),this._unregisterTargetEvents()},i.onDestroy=function(){this._removeParentEvent()},i._adjustWidgetToAllowMovingInEditor=function(){},i._adjustWidgetToAllowResizingInEditor=function(){},i._adjustWidgetToAnchorChanged=function(){this.setDirty()},i._adjustTargetToParentChanged=function(t){t&&this._unregisterOldParentEvents(t),this.node.getParent()&&this._registerTargetEvents(),this._setDirtyByMode()},i._registerEvent=function(){this.node.on(Dr.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.on(Dr.SIZE_CHANGED,this._setDirtyByMode,this),this.node.on(Dr.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this),this.node.on(Dr.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._unregisterEvent=function(){this.node.off(Dr.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.off(Dr.SIZE_CHANGED,this._setDirtyByMode,this),this.node.off(Dr.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this)},i._removeParentEvent=function(){this.node.off(Dr.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._autoChangedValue=function(t,e){if((this._alignFlags&t)>0){var i=this.node.parent&&this.node.parent._uiProps,r=i&&i.uiTransformComp,n=r?r.contentSize:jr;this.isAlignLeft&&t===xD.LEFT?this._left=e?this._left*n.width:this._left/n.width:this.isAlignRight&&t===xD.RIGHT?this._right=e?this._right*n.width:this._right/n.width:this.isAlignHorizontalCenter&&t===xD.CENTER?this._horizontalCenter=e?this._horizontalCenter*n.width:this._horizontalCenter/n.width:this.isAlignTop&&t===xD.TOP?this._top=e?this._top*n.height:this._top/n.height:this.isAlignBottom&&t===xD.BOT?this._bottom=e?this._bottom*n.height:this._bottom/n.height:this.isAbsoluteVerticalCenter&&t===xD.MID&&(this._verticalCenter=this._verticalCenter/n.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(j_)&&(t.on(Dr.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.on(Dr.SIZE_CHANGED,this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off(Dr.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(Dr.SIZE_CHANGED,this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off(Dr.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(Dr.SIZE_CHANGED,this._setDirtyByMode,this))},i._setDirtyByMode=function(){this.alignMode===CD.ALWAYS&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&KD)>0,r=this.node._uiProps.uiTransformComp;e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=r.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=r.height))):(i?this.isStretchWidth&&(r.width=this._originalWidth):this.isStretchHeight&&(r.height=this._originalHeight),this._alignFlags&=~t)}},i._recursiveDirty=function(){this._dirty||(this._dirty=!0)},Pe(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._unregisterTargetEvents(),this._target=t,this._registerTargetEvents(),this._validateTargetInDEV(),this._recursiveDirty())}},{key:"isAlignTop",get:function(){return(this._alignFlags&xD.TOP)>0},set:function(t){this._setAlign(xD.TOP,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&xD.BOT)>0},set:function(t){this._setAlign(xD.BOT,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&xD.LEFT)>0},set:function(t){this._setAlign(xD.LEFT,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&xD.RIGHT)>0},set:function(t){this._setAlign(xD.RIGHT,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&xD.MID)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=xD.MID):this._alignFlags&=~xD.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&xD.CENTER)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=xD.CENTER):this._alignFlags&=~xD.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&KD)===KD}},{key:"isStretchHeight",get:function(){return(this._alignFlags&JD)===JD}},{key:"top",get:function(){return this._top},set:function(t){this._top=t,this._recursiveDirty()}},{key:"editorTop",get:function(){return this._isAbsTop?this._top:100*this._top},set:function(t){this._top=this._isAbsTop?t:t/100,this._recursiveDirty()}},{key:"bottom",get:function(){return this._bottom},set:function(t){this._bottom=t,this._recursiveDirty()}},{key:"editorBottom",get:function(){return this._isAbsBottom?this._bottom:100*this._bottom},set:function(t){this._bottom=this._isAbsBottom?t:t/100,this._recursiveDirty()}},{key:"left",get:function(){return this._left},set:function(t){this._left=t,this._recursiveDirty()}},{key:"editorLeft",get:function(){return this._isAbsLeft?this._left:100*this._left},set:function(t){this._left=this._isAbsLeft?t:t/100,this._recursiveDirty()}},{key:"right",get:function(){return this._right},set:function(t){this._right=t,this._recursiveDirty()}},{key:"editorRight",get:function(){return this._isAbsRight?this._right:100*this._right},set:function(t){this._right=this._isAbsRight?t:t/100,this._recursiveDirty()}},{key:"horizontalCenter",get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t,this._recursiveDirty()}},{key:"editorHorizontalCenter",get:function(){return this._isAbsHorizontalCenter?this._horizontalCenter:100*this._horizontalCenter},set:function(t){this._horizontalCenter=this._isAbsHorizontalCenter?t:t/100,this._recursiveDirty()}},{key:"verticalCenter",get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t,this._recursiveDirty()}},{key:"editorVerticalCenter",get:function(){return this._isAbsVerticalCenter?this._verticalCenter:100*this._verticalCenter},set:function(t){this._verticalCenter=this._isAbsVerticalCenter?t:t/100,this._recursiveDirty()}},{key:"isAbsoluteTop",get:function(){return this._isAbsTop},set:function(t){this._isAbsTop!==t&&(this._isAbsTop=t,this._autoChangedValue(xD.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(xD.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(xD.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(xD.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(xD.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(xD.MID,this._isAbsVerticalCenter))}},{key:"alignMode",get:function(){return this._alignMode},set:function(t){this._alignMode=t,this._recursiveDirty()}},{key:"alignFlags",get:function(){return this._alignFlags},set:function(t){this._alignFlags!==t&&(this._alignFlags=t,this._recursiveDirty())}}]),e}(zi),SD.AlignMode=CD,oi((iD=AD).prototype,"target",[VB,kB],Object.getOwnPropertyDescriptor(iD.prototype,"target"),iD.prototype),oi(iD.prototype,"isAlignTop",[NB],Object.getOwnPropertyDescriptor(iD.prototype,"isAlignTop"),iD.prototype),oi(iD.prototype,"isAlignBottom",[GB],Object.getOwnPropertyDescriptor(iD.prototype,"isAlignBottom"),iD.prototype),oi(iD.prototype,"isAlignLeft",[zB],Object.getOwnPropertyDescriptor(iD.prototype,"isAlignLeft"),iD.prototype),oi(iD.prototype,"isAlignRight",[UB],Object.getOwnPropertyDescriptor(iD.prototype,"isAlignRight"),iD.prototype),oi(iD.prototype,"isAlignVerticalCenter",[HB],Object.getOwnPropertyDescriptor(iD.prototype,"isAlignVerticalCenter"),iD.prototype),oi(iD.prototype,"isAlignHorizontalCenter",[jB],Object.getOwnPropertyDescriptor(iD.prototype,"isAlignHorizontalCenter"),iD.prototype),oi(iD.prototype,"isStretchWidth",[WB],Object.getOwnPropertyDescriptor(iD.prototype,"isStretchWidth"),iD.prototype),oi(iD.prototype,"isStretchHeight",[XB],Object.getOwnPropertyDescriptor(iD.prototype,"isStretchHeight"),iD.prototype),oi(iD.prototype,"top",[YB],Object.getOwnPropertyDescriptor(iD.prototype,"top"),iD.prototype),oi(iD.prototype,"editorTop",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"editorTop"),iD.prototype),oi(iD.prototype,"bottom",[qB],Object.getOwnPropertyDescriptor(iD.prototype,"bottom"),iD.prototype),oi(iD.prototype,"editorBottom",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"editorBottom"),iD.prototype),oi(iD.prototype,"left",[JB],Object.getOwnPropertyDescriptor(iD.prototype,"left"),iD.prototype),oi(iD.prototype,"editorLeft",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"editorLeft"),iD.prototype),oi(iD.prototype,"right",[KB],Object.getOwnPropertyDescriptor(iD.prototype,"right"),iD.prototype),oi(iD.prototype,"editorRight",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"editorRight"),iD.prototype),oi(iD.prototype,"horizontalCenter",[ZB],Object.getOwnPropertyDescriptor(iD.prototype,"horizontalCenter"),iD.prototype),oi(iD.prototype,"editorHorizontalCenter",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"editorHorizontalCenter"),iD.prototype),oi(iD.prototype,"verticalCenter",[QB],Object.getOwnPropertyDescriptor(iD.prototype,"verticalCenter"),iD.prototype),oi(iD.prototype,"editorVerticalCenter",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"editorVerticalCenter"),iD.prototype),oi(iD.prototype,"isAbsoluteTop",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"isAbsoluteTop"),iD.prototype),oi(iD.prototype,"isAbsoluteBottom",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"isAbsoluteBottom"),iD.prototype),oi(iD.prototype,"isAbsoluteLeft",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"isAbsoluteLeft"),iD.prototype),oi(iD.prototype,"isAbsoluteRight",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"isAbsoluteRight"),iD.prototype),oi(iD.prototype,"isAbsoluteHorizontalCenter",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"isAbsoluteHorizontalCenter"),iD.prototype),oi(iD.prototype,"isAbsoluteVerticalCenter",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"isAbsoluteVerticalCenter"),iD.prototype),oi(iD.prototype,"alignMode",[$B,tD],Object.getOwnPropertyDescriptor(iD.prototype,"alignMode"),iD.prototype),oi(iD.prototype,"alignFlags",[vi],Object.getOwnPropertyDescriptor(iD.prototype,"alignFlags"),iD.prototype),rD=oi(iD.prototype,"_alignFlags",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),nD=oi(iD.prototype,"_target",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),sD=oi(iD.prototype,"_left",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),aD=oi(iD.prototype,"_right",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oD=oi(iD.prototype,"_top",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),lD=oi(iD.prototype,"_bottom",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),hD=oi(iD.prototype,"_horizontalCenter",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),uD=oi(iD.prototype,"_verticalCenter",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),cD=oi(iD.prototype,"_isAbsLeft",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),_D=oi(iD.prototype,"_isAbsRight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),fD=oi(iD.prototype,"_isAbsTop",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),pD=oi(iD.prototype,"_isAbsBottom",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),dD=oi(iD.prototype,"_isAbsHorizontalCenter",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),mD=oi(iD.prototype,"_isAbsVerticalCenter",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),yD=oi(iD.prototype,"_originalWidth",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),gD=oi(iD.prototype,"_originalHeight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),vD=oi(iD.prototype,"_alignMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return CD.ON_WINDOW_RESIZE}}),bD=oi(iD.prototype,"_lockFlags",[_i,En],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),eD=iD))||eD)||eD)||eD)||eD)||eD)||eD));He.internal.computeInverseTransForTarget=DD,He.internal.getReadonlyNodeSize=BD;var QD,$D=new Ui;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(QD||(QD={})),Pr(QD);var tM,eM,iM,rM,nM,sM,aM,oM,lM,hM,uM,cM,_M,fM,pM,dM,mM,yM,gM,vM,bM,SM,AM,CM,xM,TM,wM,EM,BM,DM,MM,PM,RM,IM,OM,FM,LM,VM,kM,NM,GM,zM,UM,HM,jM,WM=function(e){return t({PageViewIndicator:e,PageViewIndicatorComponent:e}),e}((MD=ri("cc.PageViewIndicator"),PD=wi(),RD=Ei(110),ID=Bi(),OD=bi(xc),FD=Di(),LD=bi(QD),VD=Di(),kD=bi(vr),ND=Di(),GD=Di(),MD(zD=PD(zD=RD(zD=ID((qD=YD=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"spacing",HD,hi(e)),li(e,"_spriteFrame",jD,hi(e)),li(e,"_direction",WD,hi(e)),li(e,"_cellSize",XD,hi(e)),e._layout=null,e._pageView=null,e._indicators=[],e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._updateLayout()},i.setPageView=function(t){this._pageView=t,this._refresh()},i._updateLayout=function(){this._layout=this.getComponent(jT),this._layout||(this._layout=this.addComponent(jT));var t=this._layout;this.direction===QD.HORIZONTAL?(t.type=jT.Type.HORIZONTAL,t.spacingX=this.spacing):this.direction===QD.VERTICAL&&(t.type=jT.Type.VERTICAL,t.spacingY=this.spacing),t.resizeMode=jT.ResizeMode.CONTAINER},i._createIndicator=function(){var t=new ur;t.layer=this.node.layer;var e=t.addComponent(dy);return e.spriteFrame=this.spriteFrame,e.sizeMode=dy.SizeMode.CUSTOM,t.parent=this.node,t._uiProps.uiTransformComp.setContentSize(this._cellSize),t},i._changedState=function(){var t=this._indicators;if(0!==t.length&&this._pageView){var e=this._pageView.curPageIdx;if(!(e>=t.length)){for(var i=0;i<t.length;++i){var r=t[i];if(r._uiProps.uiComp){var n=r._uiProps.uiComp;$D.set(n.color),$D.a=127.5,n.color=$D}}if(t[e]._uiProps.uiComp){var s=t[e]._uiProps.uiComp;$D.set(s.color),$D.a=255,s.color=$D}}}},i._refresh=function(){if(this._pageView){var t=this._indicators,e=this._pageView.getPages();if(e.length!==t.length){var i=0;if(e.length>t.length)for(i=0;i<e.length;++i)t[i]||(t[i]=this._createIndicator());else for(i=t.length-e.length;i>0;--i){var r=t[i-1];this.node.removeChild(r),t.splice(i-1,1)}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}},Pe(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t)}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize=t)}}]),e}(zi),YD.Direction=QD,oi((UD=qD).prototype,"spriteFrame",[OD,FD],Object.getOwnPropertyDescriptor(UD.prototype,"spriteFrame"),UD.prototype),oi(UD.prototype,"direction",[LD,VD],Object.getOwnPropertyDescriptor(UD.prototype,"direction"),UD.prototype),oi(UD.prototype,"cellSize",[kD,ND],Object.getOwnPropertyDescriptor(UD.prototype,"cellSize"),UD.prototype),HD=oi(UD.prototype,"spacing",[_i,GD],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),jD=oi(UD.prototype,"_spriteFrame",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),WD=oi(UD.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return QD.HORIZONTAL}}),XD=oi(UD.prototype,"_cellSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new vr(20,20)}}),zD=UD))||zD)||zD)||zD)||zD)),XM=new dr;!function(t){t[t.Unified=0]="Unified",t[t.Free=1]="Free"}(UM||(UM={})),Pr(UM),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(HM||(HM={})),Pr(HM),function(t){t.PAGE_TURNING="page-turning"}(jM||(jM={}));var YM=function(e){return t({PageView:e,PageViewComponent:e}),e}((tM=ri("cc.PageView"),eM=wi(),iM=Ei(110),rM=Bi(),nM=bi(UM),sM=Di(),aM=bi(HM),oM=Di(),lM=Ni(),hM=Di(),uM=Ni(),cM=Di(),_M=bi(WM),fM=Di(),pM=Di(),dM=bi(gE),mM=Mi(),yM=bi(gE),gM=Mi(),vM=Mi(),bM=Mi(),SM=Mi(),AM=bi([pn]),CM=Mi(),xM=bi([pn]),TM=Di(),tM(wM=eM(wM=iM(wM=rM((zM=GM=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"autoPageTurningThreshold",BM,hi(e)),li(e,"horizontal",DM,hi(e)),li(e,"vertical",MM,hi(e)),li(e,"cancelInnerEvents",PM,hi(e)),li(e,"scrollEvents",RM,hi(e)),li(e,"pageTurningSpeed",IM,hi(e)),li(e,"pageEvents",OM,hi(e)),li(e,"_sizeMode",FM,hi(e)),li(e,"_direction",LM,hi(e)),li(e,"_scrollThreshold",VM,hi(e)),li(e,"_pageTurningEventTiming",kM,hi(e)),li(e,"_indicator",NM,hi(e)),e._curPageIdx=0,e._lastPageIdx=0,e._pages=[],e._initContentPos=new ii,e._scrollCenterOffsetX=[],e._scrollCenterOffsetY=[],e._touchBeganPosition=new dr,e._touchEndPosition=new dr,e}Me(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(Dr.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.on(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(Dr.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.off(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onLoad=function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},i.getCurrentPageIndex=function(){return this._curPageIdx},i.setCurrentPageIndex=function(t){this.scrollToPage(t,1)},i.getPages=function(){return this._pages},i.addPage=function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(t._uiProps.uiTransformComp?(this.content.addChild(t),this._pages.push(t),this._updatePageView()):an(4301))},i.insertPage=function(t,e){if(!(e<0)&&t&&-1===this._pages.indexOf(t)&&this.content)if(e>=this._pages.length)this.addPage(t);else{if(!t._uiProps.uiTransformComp)return void an(4301);this._pages.splice(e,0,t),this.content.insertChild(t,e),this._updatePageView()}},i.removePage=function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):ze(4300,t.name)}},i.removePageAtIndex=function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&this.content&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},i.removeAllPages=function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e<i;e++)this.content.removeChild(t[e]);this._pages.length=0,this._updatePageView()}},i.scrollToPage=function(t,e){void 0===e&&(e=.3),t<0||t>=this._pages.length||(this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},i.getScrollEndedEventTiming=function(){return this.pageTurningEventTiming},i._updatePageView=function(){if(this.content){var t=this.content.getComponent(jT);t&&t.enabled&&t.updateLayout();var e=this._pages.length;this._curPageIdx>=e&&(this._curPageIdx=0===e?0:e-1,this._lastPageIdx=this._curPageIdx);for(var i=this._initContentPos,r=0;r<e;++r){var n=this._pages[r].position;this.direction===HM.Horizontal?this._scrollCenterOffsetX[r]=Math.abs(i.x+n.x):this._scrollCenterOffsetY[r]=Math.abs(i.y+n.y)}this.indicator&&this.indicator._refresh()}},i._updateAllPagesSize=function(){var t=this.view;if(this.content&&t&&this._sizeMode===UM.Unified)for(var e=this._pages,i=t.contentSize,r=0,n=e.length;r<n;r++)e[r]._uiProps.uiTransformComp.setContentSize(i)},i._handleReleaseLogic=function(){this._autoScrollToPage(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(e.EventType.SCROLL_ENDED))},i._onTouchBegan=function(e,i){e.touch.getUILocation(XM),dr.set(this._touchBeganPosition,XM.x,XM.y),t.prototype._onTouchBegan.call(this,e,i)},i._onTouchMoved=function(e,i){t.prototype._onTouchMoved.call(this,e,i)},i._onTouchEnded=function(e,i){e.touch.getUILocation(XM),dr.set(this._touchEndPosition,XM.x,XM.y),t.prototype._onTouchEnded.call(this,e,i)},i._onTouchCancelled=function(e,i){e.touch.getUILocation(XM),dr.set(this._touchEndPosition,XM.x,XM.y),t.prototype._onTouchCancelled.call(this,e,i)},i._onMouseWheel=function(){},i._syncScrollDirection=function(){this.horizontal=this.direction===HM.Horizontal,this.vertical=this.direction===HM.Vertical},i._syncSizeMode=function(){var t=this.view;if(this.content&&t){var e=this.content.getComponent(jT);if(e){if(this._sizeMode===UM.Free&&this._pages.length>0){var i=this._pages[0]._uiProps.uiTransformComp,r=this._pages[this._pages.length-1]._uiProps.uiTransformComp;this.direction===HM.Horizontal?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-r.width)/2):this.direction===HM.Vertical&&(e.paddingTop=(t.height-i.height)/2,e.paddingBottom=(t.height-r.height)/2)}e.updateLayout()}}},i._initPages=function(){if(this.content){this._initContentPos=this.content.position;for(var t=this.content.children,e=0;e<t.length;++e){var i=t[e];this._pages.indexOf(i)>=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},i._dispatchPageTurningEvent=function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,pn.emitEvents(this.pageEvents,this,jM.PAGE_TURNING),this.node.emit(jM.PAGE_TURNING,this))},i._isQuicklyScrollable=function(t){if(this.direction===HM.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===HM.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},i._moveOffsetValue=function(t){var e=new dr;if(this._sizeMode===UM.Free)this.direction===HM.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===HM.Vertical&&(e.y=this._scrollCenterOffsetY[t]);else{var i=this.view;if(!i)return e;this.direction===HM.Horizontal?e.x=t*i.width:this.direction===HM.Vertical&&(e.y=t*i.height)}return e},i._getDragDirection=function(t){return this._direction===HM.Horizontal?0===t.x?0:t.x>0?1:-1:0===t.y?0:t.y<0?1:-1},i._isScrollable=function(t,e,i){if(this._sizeMode===UM.Free){var r=0,n=0;if(this.direction===HM.Horizontal)return r=this._scrollCenterOffsetX[e],n=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(r-n)*this.scrollThreshold;if(this.direction===HM.Vertical)return r=this._scrollCenterOffsetY[e],n=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(r-n)*this.scrollThreshold}else{var s=this.view;if(!s)return!1;if(this.direction===HM.Horizontal)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(this.direction===HM.Vertical)return Math.abs(t.y)>=s.height*this.scrollThreshold}return!1},i._autoScrollToPage=function(){if(this._startBounceBackIfNeeded()){var t=this._getHowMuchOutOfBoundary();this._clampDelta(t),(t.x>0||t.y<0)&&(this._curPageIdx=0===this._pages.length?0:this._pages.length-1),(t.x<0||t.y>0)&&(this._curPageIdx=0),this.indicator&&this.indicator._changedState()}else{var e=new dr;dr.subtract(e,this._touchBeganPosition,this._touchEndPosition);var i=this._curPageIdx,r=i+this._getDragDirection(e),n=this.pageTurningSpeed*Math.abs(i-r);if(r<this._pages.length){if(this._isScrollable(e,i,r))return void this.scrollToPage(r,n);var s=this._calculateTouchMoveVelocity();if(this._isQuicklyScrollable(s))return void this.scrollToPage(r,n)}this.scrollToPage(i,n)}},Pe(e,[{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,this._syncSizeMode())}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this._syncScrollDirection())}},{key:"scrollThreshold",get:function(){return this._scrollThreshold},set:function(t){this._scrollThreshold!==t&&(this._scrollThreshold=t)}},{key:"pageTurningEventTiming",get:function(){return this._pageTurningEventTiming},set:function(t){this._pageTurningEventTiming!==t&&(this._pageTurningEventTiming=t)}},{key:"indicator",get:function(){return this._indicator},set:function(t){this._indicator!==t&&(this._indicator=t,this.indicator&&this.indicator.setPageView(this))}},{key:"curPageIdx",get:function(){return this._curPageIdx}},{key:"verticalScrollBar",get:function(){return t.prototype.verticalScrollBar},set:function(t){this.verticalScrollBar=t}},{key:"horizontalScrollBar",get:function(){return t.prototype.horizontalScrollBar},set:function(t){this.horizontalScrollBar=t}}]),e}(KE),GM.SizeMode=UM,GM.Direction=HM,GM.EventType=vB(jM,bE),oi((EM=zM).prototype,"sizeMode",[nM,sM],Object.getOwnPropertyDescriptor(EM.prototype,"sizeMode"),EM.prototype),oi(EM.prototype,"direction",[aM,oM],Object.getOwnPropertyDescriptor(EM.prototype,"direction"),EM.prototype),oi(EM.prototype,"scrollThreshold",[ki,lM,hM],Object.getOwnPropertyDescriptor(EM.prototype,"scrollThreshold"),EM.prototype),oi(EM.prototype,"pageTurningEventTiming",[ki,uM,cM],Object.getOwnPropertyDescriptor(EM.prototype,"pageTurningEventTiming"),EM.prototype),oi(EM.prototype,"indicator",[_M,fM],Object.getOwnPropertyDescriptor(EM.prototype,"indicator"),EM.prototype),BM=oi(EM.prototype,"autoPageTurningThreshold",[_i,pM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 100}}),oi(EM.prototype,"verticalScrollBar",[dM,pr,mM],Object.getOwnPropertyDescriptor(EM.prototype,"verticalScrollBar"),EM.prototype),oi(EM.prototype,"horizontalScrollBar",[yM,pr,gM],Object.getOwnPropertyDescriptor(EM.prototype,"horizontalScrollBar"),EM.prototype),DM=oi(EM.prototype,"horizontal",[pr,_i,vM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),MM=oi(EM.prototype,"vertical",[pr,_i,bM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),PM=oi(EM.prototype,"cancelInnerEvents",[pr,_i,SM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),RM=oi(EM.prototype,"scrollEvents",[AM,_i,pr,CM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),IM=oi(EM.prototype,"pageTurningSpeed",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),OM=oi(EM.prototype,"pageEvents",[xM,_i,TM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),FM=oi(EM.prototype,"_sizeMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return UM.Unified}}),LM=oi(EM.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return HM.Horizontal}}),VM=oi(EM.prototype,"_scrollThreshold",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),kM=oi(EM.prototype,"_pageTurningEventTiming",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),NM=oi(EM.prototype,"_indicator",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),wM=EM))||wM)||wM)||wM)||wM)),qM=new ii,JM=new dr,KM=new dr,ZM=new dr(1,1),QM=new dr,$M=new dr;function tP(t,e){if(!e._hadAlignOnce){e.alignMode===CD.ONCE&&(e._hadAlignOnce=!0);var i,r=e.target,n=KM,s=ZM;r?DD(t,i=r,n,s):i=t.parent;var a=BD(i),o=i instanceof wn||!i.getComponent(j_),l=o?JM:i.getComponent(j_).anchorPoint,h=o;t.getPosition(qM);var u=t._uiProps.uiTransformComp,c=qM.x,_=qM.y,f=u.anchorPoint,p=t.getScale();if(e.alignFlags&xD.HORIZONTAL){var d=0,m=0,y=a.width;h?(d=jr.left.x,m=jr.right.x):m=(d=-l.x*y)+y,d+=e.isAbsoluteLeft?e.left:e.left*y,m-=e.isAbsoluteRight?e.right:e.right*y,r&&(d+=n.x,d*=s.x,m+=n.x,m*=s.x);var g=0,v=f.x,b=p.x;if(b<0&&(v=1-v,b=-b),e.isStretchWidth)g=m-d,0!==b&&(u.width=g/b),c=d+v*g;else if(g=u.width*b,e.isAlignHorizontalCenter){var S=e.isAbsoluteHorizontalCenter?e.horizontalCenter:e.horizontalCenter*y,A=(.5-l.x)*a.width;r&&(S*=s.x,A+=n.x,A*=s.x),c=A+(v-.5)*g+S}else c=e.isAlignLeft?d+v*g:m+(v-1)*g;e._lastSize.width=g}if(e.alignFlags&xD.VERTICAL){var C=0,x=0,T=a.height;h?(x=jr.bottom.y,C=jr.top.y):C=(x=-l.y*T)+T,x+=e.isAbsoluteBottom?e.bottom:e.bottom*T,C-=e.isAbsoluteTop?e.top:e.top*T,r&&(x+=n.y,x*=s.y,C+=n.y,C*=s.y);var w=0,E=f.y,B=p.y;if(B<0&&(E=1-E,B=-B),e.isStretchHeight)w=C-x,0!==B&&(u.height=w/B),_=x+E*w;else if(w=u.height*B,e.isAlignVerticalCenter){var D=e.isAbsoluteVerticalCenter?e.verticalCenter:e.verticalCenter*T,M=(.5-l.y)*a.height;r&&(D*=s.y,M+=n.y,M*=s.y),_=M+(E-.5)*w+D}else _=e.isAlignBottom?x+E*w:C+(E-1)*w;e._lastSize.height=w}t.setPosition(c,_,qM.z),ii.set(e._lastPos,c,_,qM.z)}}function eP(t){var e=t.getComponent(ZD);if(e&&e.enabled){if(!He.isValid(t,!0))return;hP.push(e)}for(var i,r=t.children,n=Fe(r);!(i=n()).done;){var s=i.value;s.active&&eP(s)}}function iP(){var t=wr.getScene();if(t){uP.isAligning=!0,uP._nodesOrderDirty&&(hP.length=0,eP(t),uP._nodesOrderDirty=!1);var e=null,i=uP._activeWidgetsIterator;for(i.i=0;i.i<hP.length;++i.i)(e=hP[i.i])._dirty&&(tP(e.node,e),e._dirty=!1);uP.isAligning=!1}}var rP,nP,sP,aP,oP,lP,hP=[],uP=t("widgetManager",He._widgetManager={isAligning:!1,_nodesOrderDirty:!1,_activeWidgetsIterator:new Bn.MutableForwardIterator(hP),animationState:null,init:function(){wr.on(Er.EVENT_AFTER_UPDATE,iP),Dn.instance.on("design-resolution-changed",this.onResized,this);var t=this.onResized.bind(this);Dn.instance.on("canvas-resize",t),Le.onOrientationChange(t)},add:function(){this._nodesOrderDirty=!0},remove:function(t){this._activeWidgetsIterator.remove(t)},onResized:function(){var t=wr.getScene();t&&this.refreshWidgetOnResized(t)},refreshWidgetOnResized:function(t){var e=ur.isNode(t)&&t.getComponent(ZD);e&&e.enabled&&(e.alignMode===CD.ON_WINDOW_RESIZE||e.alignMode===CD.ALWAYS)&&e.setDirty();for(var i,r=t.children,n=Fe(r);!(i=n()).done;){var s=i.value;this.refreshWidgetOnResized(s)}},updateOffsetsToStayPut:function(t,e){function i(t,e){return Math.abs(t-e)>1e-10?e:t}var r=t.node,n=r.parent;if(n){var s=QM;s.set(0,0);var a=$M;if(a.set(1,1),t.target&&DD(r,n=t.target,s,a),!e)return;var o=n._uiProps&&n._uiProps.uiTransformComp,l=o?o.anchorPoint:JM,h=r._uiProps.uiTransformComp,u=BD(n),c=h.anchorPoint,_=r.getPosition(),f=xD,p=r.getScale(),d=0;if(e&f.LEFT){var m=-l.x*u.width;m+=s.x,m*=a.x,d=_.x-c.x*h.width*p.x-m,t.isAbsoluteLeft||(d/=u.width),d/=a.x,t.left=i(t.left,d)}if(e&f.RIGHT){var y=(1-l.x)*u.width;y+=s.x,d=(y*=a.x)-(_.x+(1-c.x)*h.width*p.x),t.isAbsoluteRight||(d/=u.width),d/=a.x,t.right=i(t.right,d)}if(e&f.TOP){var g=(1-l.y)*u.height;g+=s.y,d=(g*=a.y)-(_.y+(1-c.y)*h.height*p.y),t.isAbsoluteTop||(d/=u.height),d/=a.y,t.top=i(t.top,d)}if(e&f.BOT){var v=-l.y*u.height;v+=s.y,v*=a.y,d=_.y-c.y*h.height*p.y-v,t.isAbsoluteBottom||(d/=u.height),d/=a.y,t.bottom=i(t.bottom,d)}}},updateAlignment:function t(e){var i=e.parent;i&&ur.isNode(i)&&t(i);var r=e.getComponent(ZD);r&&i&&tP(e,r)},AlignMode:CD,AlignFlags:xD});wr.on(Er.EVENT_INIT,(function(){uP.init()}));var cP,_P,fP,pP,dP,mP,yP,gP,vP,bP,SP,AP,CP,xP,TP,wP,EP,BP,DP,MP,PP,RP=function(e){return t({SafeArea:e,SafeAreaComponent:e}),e}((rP=ri("cc.SafeArea"),nP=wi(),sP=Ei(110),aP=Bi(),oP=Rr(ZD),rP(lP=nP(lP=sP(lP=Si(lP=aP(lP=oP(lP=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._boundUpdateArea=this.updateArea.bind(this)},i.onEnable=function(){this.updateArea(),Le.onViewResize(this._boundUpdateArea),Le.onOrientationChange(this._boundUpdateArea)},i.onDisable=function(){Le.offViewResize(this._boundUpdateArea),Le.offOrientationChange(this._boundUpdateArea)},i.updateArea=function(){var t=this.node.getComponent(ZD),e=this.node.getComponent(j_);if(t&&e){t.updateAlignment();var i=this.node.position.clone(),r=e.anchorPoint.clone();t.isAlignTop=t.isAlignBottom=t.isAlignLeft=t.isAlignRight=!0;var n=He.winSize.width,s=He.winSize.height,a=ke.getSafeAreaRect();t.top=s-a.y-a.height,t.bottom=a.y,t.left=a.x,t.right=n-a.x-a.width,t.updateAlignment();var o=this.node.position.clone(),l=r.x-(o.x-i.x)/e.width,h=r.y-(o.y-i.y)/e.height;e.setAnchorPoint(l,h),uP.add(t)}},e}(zi))||lP)||lP)||lP)||lP)||lP)||lP)),IP=function(e){return t({UICoordinateTracker:e,UICoordinateTrackerComponent:e}),e}((cP=ri("cc.UICoordinateTracker"),_P=wi(),fP=Bi(),pP=Ei(110),dP=bi(ur),mP=Di(),yP=bi(Hr),gP=Di(),vP=Di(),bP=Di(),SP=bi([pn]),AP=Di(),cP(CP=_P(CP=fP(CP=pP((MP=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"syncEvents",TP,hi(e)),li(e,"_target",wP,hi(e)),li(e,"_camera",EP,hi(e)),li(e,"_useScale",BP,hi(e)),li(e,"_distance",DP,hi(e)),e._transformPos=new ii,e._viewPos=new ii,e._canMove=!0,e._lastWPos=new ii,e._lastCameraPos=new ii,e}Me(e,t);var i=e.prototype;return i.onEnable=function(){this._checkCanMove()},i.update=function(){var t=this.node.worldPosition,e=this._camera;if(this._canMove&&e&&e.camera&&(!this._lastWPos.equals(t)||!this._lastCameraPos.equals(e.node.worldPosition))&&(this._lastWPos.set(t),this._lastCameraPos.set(e.node.worldPosition),e.camera.update(),e.convertToUINode(t,this._target,this._transformPos),this._useScale&&ii.transformMat4(this._viewPos,this.node.worldPosition,e.camera.matView),this.syncEvents.length>0)){var i=this._distance/Math.abs(this._viewPos.z);pn.emitEvents(this.syncEvents,this._transformPos,i)}},i._checkCanMove=function(){this._canMove=!(!this._camera||!this._target)},Pe(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._target=t,this._checkCanMove())}},{key:"camera",get:function(){return this._camera},set:function(t){this._camera!==t&&(this._camera=t,this._checkCanMove())}},{key:"useScale",get:function(){return this._useScale},set:function(t){this._useScale!==t&&(this._useScale=t)}},{key:"distance",get:function(){return this._distance},set:function(t){this._distance!==t&&(this._distance=t)}}]),e}(zi),oi((xP=MP).prototype,"target",[dP,mP],Object.getOwnPropertyDescriptor(xP.prototype,"target"),xP.prototype),oi(xP.prototype,"camera",[yP,gP],Object.getOwnPropertyDescriptor(xP.prototype,"camera"),xP.prototype),oi(xP.prototype,"useScale",[vP],Object.getOwnPropertyDescriptor(xP.prototype,"useScale"),xP.prototype),oi(xP.prototype,"distance",[bP],Object.getOwnPropertyDescriptor(xP.prototype,"distance"),xP.prototype),TP=oi(xP.prototype,"syncEvents",[SP,_i,AP],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),wP=oi(xP.prototype,"_target",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),EP=oi(xP.prototype,"_camera",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),BP=oi(xP.prototype,"_useScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),DP=oi(xP.prototype,"_distance",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),CP=xP))||CP)||CP)||CP)||CP)),OP=[Dr.TOUCH_START,Dr.TOUCH_END,Dr.TOUCH_MOVE,Dr.MOUSE_DOWN,Dr.MOUSE_MOVE,Dr.MOUSE_UP,Dr.MOUSE_ENTER,Dr.MOUSE_LEAVE,Dr.MOUSE_WHEEL];function FP(t){t.propagationStopped=!0}var LP,VP,kP,NP,GP,zP,UP,HP,jP,WP,XP,YP,qP,JP=function(e){return t({BlockInputEvents:e,BlockInputEventsComponent:e}),e}(ri("cc.BlockInputEvents")(PP=wi()(PP=Bi()(PP=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.onEnable=function(){for(var t=0;t<OP.length;t++)this.node.on(OP[t],FP,this)},i.onDisable=function(){for(var t=0;t<OP.length;t++)this.node.off(OP[t],FP,this)},e}(zi))||PP)||PP)||PP),KP={},ZP=t("SubContextView",(LP=ri("cc.SubContextView"),VP=wi(),kP=Ei(110),NP=Rr(j_),GP=Bi(),zP=Di(),UP=Di(),LP(HP=VP(HP=kP(HP=NP(HP=GP((YP=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_fps",WP,hi(e)),e._sprite=void 0,e._imageAsset=void 0,e._updatedTime=0,e._updateInterval=0,e._openDataContext=void 0,e._content=void 0,li(e,"_designResolutionSize",XP,hi(e)),e._content=new ur("content"),e._content.hideFlags|=Lr.Flags.DontSave|Lr.Flags.HideInHierarchy,e._sprite=null,e._imageAsset=new Ye,e._openDataContext=null,e._updatedTime=performance.now(),e}Me(e,t);var i=e.prototype;return i.onLoad=function(){KP.getOpenDataContext?(this._updateInterval=1e3/this._fps,this._openDataContext=KP.getOpenDataContext(),this._initSharedCanvas(),this._initContentNode(),this._updateSubContextView(),this._updateContentLayer()):this.enabled=!1},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._unregisterNodeEvent()},i._initSharedCanvas=function(){if(this._openDataContext){var t=this._openDataContext.canvas;t.width=this._designResolutionSize.width,t.height=this._designResolutionSize.height}},i._initContentNode=function(){if(this._openDataContext){var t=this._openDataContext.canvas,e=this._imageAsset;if(e.reset(t),e._texture.create(t.width,t.height),this._sprite=this._content.getComponent(dy),this._sprite||(this._sprite=this._content.addComponent(dy)),this._sprite.spriteFrame)this._sprite.spriteFrame.texture=this._imageAsset._texture;else{var i=new xc;i.texture=this._imageAsset._texture,this._sprite.spriteFrame=i}this._content.parent=this.node}},i._updateSubContextView=function(){if(this._openDataContext&&KP.getSystemInfoSync){var t=this.node.getComponent(j_),e=this._content.getComponent(j_),i=t.width/e.width,r=t.height/e.height,n=i>r?r:i;e.width*=n,e.height*=n;var s=KP.getSystemInfoSync(),a=e.getBoundingBoxToWorld(),o=Xr.getVisibleSize(),l=s.screenWidth*(a.x/o.width),h=s.screenHeight*(a.y/o.height),u=s.screenWidth*(a.width/o.width),c=s.screenHeight*(a.height/o.height);this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:l,y:h,width:u,height:c})}},i._updateSubContextTexture=function(){var t=this._imageAsset;if(t&&this._openDataContext&&!(t.width<=0||t.height<=0)){var e=this._openDataContext.canvas;t.reset(e),(e.width>t.width||e.height>t.height)&&this._imageAsset._texture.create(e.width,e.height),this._imageAsset._texture.uploadData(e)}},i._registerNodeEvent=function(){this.node.on(ur.EventType.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(ur.EventType.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(Dr.LAYER_CHANGED,this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off(ur.EventType.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(ur.EventType.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(Dr.LAYER_CHANGED,this._updateContentLayer,this)},i._updateContentLayer=function(){this._content.layer=this.node.layer},i.update=function(t){void 0===t?this._updateSubContextTexture():performance.now()-this._updatedTime>=this._updateInterval&&(this._updatedTime+=this._updateInterval,this._updateSubContextTexture())},Pe(e,[{key:"designResolutionSize",get:function(){return this._designResolutionSize},set:function(){}},{key:"fps",get:function(){return this._fps},set:function(t){this._fps!==t&&(this._fps=t,this._updateInterval=1e3/t)}}]),e}(zi),oi((jP=YP).prototype,"designResolutionSize",[zP],Object.getOwnPropertyDescriptor(jP.prototype,"designResolutionSize"),jP.prototype),oi(jP.prototype,"fps",[UP],Object.getOwnPropertyDescriptor(jP.prototype,"fps"),jP.prototype),WP=oi(jP.prototype,"_fps",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),XP=oi(jP.prototype,"_designResolutionSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new vr(640,960)}}),HP=jP))||HP)||HP)||HP)||HP)||HP));He.SubContextView=ZP;var QP,$P,tR,eR,iR,rR,nR,sR,aR,oR,lR,hR,uR,cR,_R,fR,pR=t("UIReorderComponent",ri("cc.UIReorderComponent")(qP=function(){ze(1408,"UIReorderComponent")})||qP);He.UIReorderComponent=pR,He.ButtonComponent=KA,Li.setClassAlias(KA,"cc.ButtonComponent"),He.EditBoxComponent=_T,Li.setClassAlias(_T,"cc.EditBoxComponent"),He.LayoutComponent=jT,Li.setClassAlias(jT,"cc.LayoutComponent"),He.ProgressBarComponent=mw,Li.setClassAlias(mw,"cc.ProgressBarComponent"),He.ScrollViewComponent=KE,Li.setClassAlias(KE,"cc.ScrollViewComponent"),He.ScrollBarComponent=gE,Li.setClassAlias(gE,"cc.ScrollBarComponent"),He.SliderComponent=gB,Li.setClassAlias(gB,"cc.SliderComponent"),He.ToggleComponent=TD,Li.setClassAlias(TD,"cc.ToggleComponent"),He.ToggleContainerComponent=wD,Li.setClassAlias(wD,"cc.ToggleContainerComponent"),He.WidgetComponent=ZD,Li.setClassAlias(ZD,"cc.WidgetComponent"),He.PageViewComponent=YM,Li.setClassAlias(YM,"cc.PageViewComponent"),He.PageViewIndicatorComponent=WM,Li.setClassAlias(WM,"cc.PageViewIndicatorComponent"),He.SafeAreaComponent=RP,Li.setClassAlias(RP,"cc.SafeAreaComponent"),Li.setClassAlias(IP,"cc.UICoordinateTrackerComponent"),He.BlockInputEventsComponent=JP,Li.setClassAlias(JP,"cc.BlockInputEventsComponent");var dR,mR,yR,gR,vR,bR,SR,AR,CR,xR,TR,wR,ER,BR,DR,MR,PR,RR,IR,OR,FR,LR,VR,kR,NR,GR,zR,UR,HR,jR,WR,XR,YR=function(e){return t({Billboard:e,BillboardComponent:e}),e}((QP=ri("cc.Billboard"),$P=wi(),tR=Bi(),eR=bi(qe),iR=bi(qe),rR=Di(),nR=Di(),sR=Di(),aR=Di(),QP(oR=$P(oR=tR(oR=Si((fR=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_texture",hR,hi(e)),li(e,"_height",uR,hi(e)),li(e,"_width",cR,hi(e)),li(e,"_rotation",_R,hi(e)),e._model=null,e._mesh=null,e._material=null,e._uniform=new Ti(1,1,0,0),e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this.createModel()},i.onEnable=function(){this.attachToScene(),this._model.enabled=!0,this.width=this._width,this.height=this._height,this.rotation=this.rotation,this.texture=this.texture},i.onDisable=function(){this.detachFromScene()},i.attachToScene=function(){this._model&&this.node&&this.node.scene&&(this._model.scene&&this.detachFromScene(),this._getRenderScene().addModel(this._model))},i.detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},i.createModel=function(){this._mesh=Ya({primitiveMode:F.TRIANGLE_LIST,positions:[0,0,0,0,0,0,0,0,0,0,0,0],uvs:[0,0,1,0,0,1,1,1],colors:[Ui.WHITE.r,Ui.WHITE.g,Ui.WHITE.b,Ui.WHITE.a,Ui.WHITE.r,Ui.WHITE.g,Ui.WHITE.b,Ui.WHITE.a,Ui.WHITE.r,Ui.WHITE.g,Ui.WHITE.b,Ui.WHITE.a,Ui.WHITE.r,Ui.WHITE.g,Ui.WHITE.b,Ui.WHITE.a],attributes:[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RG32F),new St(Ut.ATTR_COLOR,_.RGBA8UI,!0)],indices:[0,1,2,1,2,3]},void 0,{calculateBounds:!1});var t=this._model=He.director.root.createModel(mi,this.node);t.node=t.transform=this.node,null==this._material&&(this._material=new cr,this._material.copy(Ci.get("default-billboard-material"))),t.initSubModel(0,this._mesh.renderingSubMeshes[0],this._material)},Pe(e,[{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this._material&&this._material.setProperty("mainTexture",t)}},{key:"height",get:function(){return this._height},set:function(t){this._height=t,this._material&&(this._uniform.y=t,this._material.setProperty("cc_size_rotation",this._uniform))}},{key:"width",get:function(){return this._width},set:function(t){this._width=t,this._material&&(this._uniform.x=t,this._material.setProperty("cc_size_rotation",this._uniform))}},{key:"rotation",get:function(){return Math.round(100*Mn(this._rotation))/100},set:function(t){this._rotation=qi(t),this._material&&(this._uniform.z=this._rotation,this._material.setProperty("cc_size_rotation",this._uniform))}}]),e}(zi),hR=oi((lR=fR).prototype,"_texture",[eR],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(lR.prototype,"texture",[iR,rR],Object.getOwnPropertyDescriptor(lR.prototype,"texture"),lR.prototype),uR=oi(lR.prototype,"_height",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(lR.prototype,"height",[nR],Object.getOwnPropertyDescriptor(lR.prototype,"height"),lR.prototype),cR=oi(lR.prototype,"_width",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(lR.prototype,"width",[sR],Object.getOwnPropertyDescriptor(lR.prototype,"width"),lR.prototype),_R=oi(lR.prototype,"_rotation",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(lR.prototype,"rotation",[aR],Object.getOwnPropertyDescriptor(lR.prototype,"rotation"),lR.prototype),oR=lR))||oR)||oR)||oR)||oR)),qR=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RGBA32F),new St(Ut.ATTR_TEX_COORD1,_.RGB32F),new St(Ut.ATTR_COLOR,_.RGBA8,!0)],JR=new ii,KR=new ii,ZR=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._vertSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._iaInfo=void 0,e._iaInfoBuffer=void 0,e._subMeshData=null,e._vertCount=0,e._indexCount=0,e._material=null,e.type=ar.LINE,e._capacity=100,e._iaInfo=new lt([new at]),e._iaInfoBuffer=e._device.createBuffer(new nt(d.INDIRECT,g.HOST|g.DEVICE,Yt,Yt)),e}Me(e,t);var i=e.prototype;return i.setCapacity=function(t){this._capacity=t,this.createBuffer()},i.createBuffer=function(){this._vertSize=0;for(var t,e=Fe(qR);!(t=e()).done;){var i=t.value;i.offset=this._vertSize,this._vertSize+=Ht[i.format].size}this._vertAttrsFloatCount=this._vertSize/4,this._vBuffer=this.createSubMeshData(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer)},i.updateMaterial=function(e){this._material=e,t.prototype.setSubModelMaterial.call(this,0,e)},i.createSubMeshData=function(){this._subMeshData&&this.destroySubMeshData(),this._vertCount=2,this._indexCount=6;var t=this._device.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.HOST|g.DEVICE,this._vertSize*this._capacity*this._vertCount,this._vertSize)),e=new ArrayBuffer(this._vertSize*this._capacity*this._vertCount);t.update(e);for(var i=new Uint16Array((this._capacity-1)*this._indexCount),r=0,n=0;n<this._capacity-1;++n){var s=2*n;i[r++]=s,i[r++]=s+1,i[r++]=s+2,i[r++]=s+3,i[r++]=s+2,i[r++]=s+1}var a=this._device.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.HOST|g.DEVICE,(this._capacity-1)*this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));return a.update(i),this._iaInfo.drawInfos[0].vertexCount=this._capacity*this._vertCount,this._iaInfo.drawInfos[0].indexCount=(this._capacity-1)*this._indexCount,this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new ui([t],qR,F.TRIANGLE_LIST,a,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material),e},i.addLineVertexData=function(t,e,i){if(t.length>1){var r=0;ii.subtract(JR,t[1],t[0]),this._vdataF32[r++]=t[0].x,this._vdataF32[r++]=t[0].y,this._vdataF32[r++]=t[0].z,this._vdataF32[r++]=0,this._vdataF32[r++]=e.evaluate(0,1),this._vdataF32[r++]=0,this._vdataF32[r++]=0,this._vdataF32[r++]=JR.x,this._vdataF32[r++]=JR.y,this._vdataF32[r++]=JR.z,this._vdataUint32[r++]=i.evaluate(0,1)._val,this._vdataF32[r++]=t[0].x,this._vdataF32[r++]=t[0].y,this._vdataF32[r++]=t[0].z,this._vdataF32[r++]=1,this._vdataF32[r++]=e.evaluate(0,1),this._vdataF32[r++]=0,this._vdataF32[r++]=1,this._vdataF32[r++]=JR.x,this._vdataF32[r++]=JR.y,this._vdataF32[r++]=JR.z,this._vdataUint32[r++]=i.evaluate(0,1)._val;for(var n=1;n<t.length-1;n++){ii.subtract(JR,t[n-1],t[n]),ii.subtract(KR,t[n+1],t[n]),ii.subtract(KR,KR,JR);var s=n/t.length;this._vdataF32[r++]=t[n].x,this._vdataF32[r++]=t[n].y,this._vdataF32[r++]=t[n].z,this._vdataF32[r++]=0,this._vdataF32[r++]=e.evaluate(s,1),this._vdataF32[r++]=s,this._vdataF32[r++]=0,this._vdataF32[r++]=KR.x,this._vdataF32[r++]=KR.y,this._vdataF32[r++]=KR.z,this._vdataUint32[r++]=i.evaluate(s,1)._val,this._vdataF32[r++]=t[n].x,this._vdataF32[r++]=t[n].y,this._vdataF32[r++]=t[n].z,this._vdataF32[r++]=1,this._vdataF32[r++]=e.evaluate(s,1),this._vdataF32[r++]=s,this._vdataF32[r++]=1,this._vdataF32[r++]=KR.x,this._vdataF32[r++]=KR.y,this._vdataF32[r++]=KR.z,this._vdataUint32[r++]=i.evaluate(s,1)._val}ii.subtract(JR,t[t.length-1],t[t.length-2]),this._vdataF32[r++]=t[t.length-1].x,this._vdataF32[r++]=t[t.length-1].y,this._vdataF32[r++]=t[t.length-1].z,this._vdataF32[r++]=0,this._vdataF32[r++]=e.evaluate(1,1),this._vdataF32[r++]=1,this._vdataF32[r++]=0,this._vdataF32[r++]=JR.x,this._vdataF32[r++]=JR.y,this._vdataF32[r++]=JR.z,this._vdataUint32[r++]=i.evaluate(1,1)._val,this._vdataF32[r++]=t[t.length-1].x,this._vdataF32[r++]=t[t.length-1].y,this._vdataF32[r++]=t[t.length-1].z,this._vdataF32[r++]=1,this._vdataF32[r++]=e.evaluate(1,1),this._vdataF32[r++]=1,this._vdataF32[r++]=1,this._vdataF32[r++]=JR.x,this._vdataF32[r++]=JR.y,this._vdataF32[r++]=JR.z,this._vdataUint32[r++]=i.evaluate(1,1)._val}this.updateIA(Math.max(0,t.length-1))},i.updateIA=function(t){this._subModels[0].inputAssembler.vertexBuffers[0].update(this._vdataF32),this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=this._indexCount*t,this._iaInfoBuffer.update(this._iaInfo)},i.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null)},e}(mi),QR=Rn,$R=yi({Constant:0,Curve:1,TwoCurves:2,TwoConstants:3}),tI=t("CurveRange",(dR=ri("cc.CurveRange"),mR=bi($R),yR=bi(Pn),gR=bi(Pn),vR=bi(Pn),dR((PR=MR=function(){function t(){li(this,"mode",AR,this),li(this,"curve",CR,this),li(this,"curveMin",xR,this),li(this,"curveMax",TR,this),li(this,"constant",wR,this),li(this,"constantMin",ER,this),li(this,"constantMax",BR,this),li(this,"multiplier",DR,this)}var e=t.prototype;return e.evaluate=function(t,e){switch(this.mode){case $R.Constant:return this.constant;case $R.Curve:return this.curve.evaluate(t)*this.multiplier;case $R.TwoCurves:return dn(this.curveMin.evaluate(t),this.curveMax.evaluate(t),e)*this.multiplier;case $R.TwoConstants:return dn(this.constantMin,this.constantMax,e)}},e.getMax=function(){switch(this.mode){case $R.Constant:return this.constant;case $R.Curve:return this.multiplier;case $R.TwoConstants:return this.constantMax;case $R.TwoCurves:return this.multiplier}return 0},e._onBeforeSerialize=function(){return QR[this.mode]},t}(),MR.Mode=$R,AR=oi((SR=PR).prototype,"mode",[mR],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return $R.Constant}}),CR=oi(SR.prototype,"curve",[yR],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn}}),xR=oi(SR.prototype,"curveMin",[gR],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn}}),TR=oi(SR.prototype,"curveMax",[vR],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn}}),wR=oi(SR.prototype,"constant",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ER=oi(SR.prototype,"constantMin",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),BR=oi(SR.prototype,"constantMax",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),DR=oi(SR.prototype,"multiplier",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),bR=SR))||bR));function eI(t,e,i){switch(t.mode){case $R.Constant:return t.constant;case $R.Curve:return t.curve.evaluate(e)*t.multiplier;case $R.TwoCurves:return 0===i?t.curveMin.evaluate(e)*t.multiplier:t.curveMax.evaluate(e)*t.multiplier;case $R.TwoConstants:return 0===i?t.constantMin:t.constantMax;default:return 0}}function iI(t){switch(t.mode){case $R.TwoConstants:case $R.TwoCurves:return 2;default:return 1}}function rI(t,e,i){var r=new Ye({width:e,height:i,_data:t,_compressed:!1,format:fr.RGBA32F}),n=new qe;return n.setFilters(_r.NEAREST,_r.NEAREST),n.setMipFilter(_r.NONE),n.setWrapMode(In.CLAMP_TO_EDGE,In.CLAMP_TO_EDGE,In.CLAMP_TO_EDGE),n.image=r,n}function nI(t,e,i,r,n){for(var s=Math.max(iI(e),iI(i),iI(r)),a=new Float32Array(t*s*4),o=[e,i,r],l=1/(t-1),h=0;h<s;h++)for(var u=0;u<3;u++)for(var c=o[u],_=0,f=0,p=0;p<t;p++){var d=eI(c,l*p,h);f=n?d:(_+=d)/(p+1),a[4*p+u]=f}return rI(a,t,s)}var sI,aI,oI,lI,hI,uI,cI,_I,fI,pI,dI,mI,yI,gI,vI,bI,SI,AI,CI,xI,TI,wI,EI,BI,DI,MI,PI,RI,II,OI,FI,LI,VI,kI,NI,GI,zI,UI,HI,jI,WI,XI,YI,qI,JI,KI,ZI,QI,$I,tO,eO,iO,rO,nO,sO=yi({Blend:0,Fixed:1}),aO=(t("ColorKey",ri("cc.ColorKey")((OR=oi((IR=function(){li(this,"color",OR,this),li(this,"time",FR,this)}).prototype,"color",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),FR=oi(IR.prototype,"time",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),RR=IR))||RR),t("AlphaKey",ri("cc.AlphaKey")((kR=oi((VR=function(){li(this,"alpha",kR,this),li(this,"time",NR,this)}).prototype,"alpha",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),NR=oi(VR.prototype,"time",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),LR=VR))||LR),t("Gradient",ri("cc.Gradient")((XR=WR=function(){function t(){li(this,"colorKeys",UR,this),li(this,"alphaKeys",HR,this),li(this,"mode",jR,this),this._color=void 0,this._color=Ui.WHITE.clone()}var e=t.prototype;return e.setKeys=function(t,e){this.colorKeys=t,this.alphaKeys=e},e.sortKeys=function(){this.colorKeys.length>1&&this.colorKeys.sort((function(t,e){return t.time-e.time})),this.alphaKeys.length>1&&this.alphaKeys.sort((function(t,e){return t.time-e.time}))},e.evaluate=function(t){return this.getRGB(t),this._color._set_a_unsafe(this.getAlpha(t)),this._color},e.randomColor=function(){var t=this.colorKeys[Math.trunc(Math.random()*this.colorKeys.length)],e=this.alphaKeys[Math.trunc(Math.random()*this.alphaKeys.length)];return this._color.set(t.color),this._color._set_a_unsafe(e.alpha),this._color},e.getRGB=function(t){if(!(this.colorKeys.length>1))return 1===this.colorKeys.length?(this._color.set(this.colorKeys[0].color),this._color):(this._color.set(Ui.WHITE),this._color);t=On(t,1);for(var e=1;e<this.colorKeys.length;++e){var i=this.colorKeys[e-1].time,r=this.colorKeys[e].time;if(t>=i&&t<r){if(this.mode===sO.Fixed)return this.colorKeys[e].color;var n=(t-i)/(r-i);return Ui.lerp(this._color,this.colorKeys[e-1].color,this.colorKeys[e].color,n),this._color}}var s=this.colorKeys.length-1;t<this.colorKeys[0].time?Ui.lerp(this._color,Ui.BLACK,this.colorKeys[0].color,t/this.colorKeys[0].time):t>this.colorKeys[s].time&&Ui.lerp(this._color,this.colorKeys[s].color,Ui.BLACK,(t-this.colorKeys[s].time)/(1-this.colorKeys[s].time))},e.getAlpha=function(t){if(!(this.alphaKeys.length>1))return 1===this.alphaKeys.length?this.alphaKeys[0].alpha:255;t=On(t,1);for(var e=1;e<this.alphaKeys.length;++e){var i=this.alphaKeys[e-1].time,r=this.alphaKeys[e].time;if(t>=i&&t<r){if(this.mode===sO.Fixed)return this.alphaKeys[e].alpha;var n=(t-i)/(r-i);return dn(this.alphaKeys[e-1].alpha,this.alphaKeys[e].alpha,n)}}var s=this.alphaKeys.length-1;return t<this.alphaKeys[0].time?dn(255,this.alphaKeys[0].alpha,t/this.alphaKeys[0].time):t>this.alphaKeys[s].time?dn(this.alphaKeys[s].alpha,255,(t-this.alphaKeys[s].time)/(1-this.alphaKeys[s].time)):void 0},t}(),WR.Mode=sO,UR=oi((zR=XR).prototype,"colorKeys",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Array}}),HR=oi(zR.prototype,"alphaKeys",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Array}}),jR=oi(zR.prototype,"mode",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sO.Blend}}),GR=zR))||GR)),oO=Rn,lO=yi({Color:0,Gradient:1,TwoColors:2,TwoGradients:3,RandomColor:4}),hO=t("GradientRange",(sI=ri("cc.GradientRange"),aI=bi(lO),oI=bi(aO),lI=bi(aO),hI=bi(aO),uI=bi(lO),sI((SI=bI=function(){function t(){li(this,"color",fI,this),li(this,"colorMin",pI,this),li(this,"colorMax",dI,this),li(this,"gradient",mI,this),li(this,"gradientMin",yI,this),li(this,"gradientMax",gI,this),li(this,"_mode",vI,this),this._color=Ui.WHITE.clone()}var e=t.prototype;return e.evaluate=function(t,e){switch(this._mode){case lO.Color:return this.color;case lO.TwoColors:return Ui.lerp(this._color,this.colorMin,this.colorMax,e),this._color;case lO.RandomColor:return this.gradient.randomColor();case lO.Gradient:return this.gradient.evaluate(t);case lO.TwoGradients:return Ui.lerp(this._color,this.gradientMin.evaluate(t),this.gradientMax.evaluate(t),e),this._color;default:return this.color}},e._onBeforeSerialize=function(){return oO[this._mode]},Pe(t,[{key:"mode",get:function(){return this._mode},set:function(t){this._mode=t}}]),t}(),bI.Mode=lO,oi((_I=SI).prototype,"mode",[aI],Object.getOwnPropertyDescriptor(_I.prototype,"mode"),_I.prototype),fI=oi(_I.prototype,"color",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),pI=oi(_I.prototype,"colorMin",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),dI=oi(_I.prototype,"colorMax",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ui.WHITE.clone()}}),mI=oi(_I.prototype,"gradient",[oI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new aO}}),yI=oi(_I.prototype,"gradientMin",[lI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new aO}}),gI=oi(_I.prototype,"gradientMax",[hI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new aO}}),vI=oi(_I.prototype,"_mode",[uI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return lO.Color}}),cI=_I))||cI));function uO(t,e,i){switch(t.mode){case lO.Color:return t.color;case lO.TwoColors:return 0===i?t.colorMin:t.colorMax;case lO.RandomColor:return t.gradient.randomColor();case lO.Gradient:return t.gradient.evaluate(e);case lO.TwoGradients:return 0===i?t.gradientMin.evaluate(e):t.gradientMax.evaluate(e);default:return t.color}}var cO,_O,fO,pO,dO,mO,yO,gO,vO,bO,SO,AO,CO,xO,TO,wO,EO,BO,DO,MO,PO,RO,IO,OO,FO,LO,VO,kO,NO,GO,zO,UO,HO,jO,WO={parent:null,owner:null,subModelIdx:0},XO={CC_USE_WORLD_SPACE:!1},YO=function(e){return t({Line:e,LineComponent:e}),e}((AI=ri("cc.Line"),CI=wi(),xI=Bi(),TI=bi(qe),wI=bi(qe),EI=Mr(),BI=Di(),DI=Mr(),MI=Di(),PI=bi([ii]),RI=bi([ii]),II=Mr(),OI=Di(),FI=bi(tI),LI=bi(tI),VI=Mr(),kI=Di(),NI=bi(dr),GI=Mr(),zI=Di(),UI=bi(dr),HI=Mr(),jI=Di(),WI=bi(hO),XI=bi(hO),YI=Mr(),qI=Di(),AI(JI=CI(JI=xI(JI=Si((nO=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_texture",ZI,hi(e)),e._material=null,e._materialInstance=null,li(e,"_worldSpace",QI,hi(e)),li(e,"_positions",$I,hi(e)),li(e,"_width",tO,hi(e)),li(e,"_tile",eO,hi(e)),li(e,"_offset",iO,hi(e)),li(e,"_color",rO,hi(e)),e._model=null,e._tile_offset=new Ti,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){var t=this._model=He.director.root.createModel(ZR);t.node=t.transform=this.node,null===this._material&&(this._material=new cr,this._material.copy(Ci.get("default-trail-material")),XO.CC_USE_WORLD_SPACE=this.worldSpace,WO.parent=this._material,WO.subModelIdx=0,this._materialInstance=new Vr(WO),this._materialInstance.recompileShaders(XO)),t.updateMaterial(this._materialInstance),t.setCapacity(100)},i.onEnable=function(){this._model&&(this._attachToScene(),this.texture=this._texture,this.tile=this._tile,this.offset=this._offset,this._model.addLineVertexData(this._positions,this._width,this._color))},i.onDisable=function(){this._model&&this._detachFromScene()},i._attachToScene=function(){this._model&&this.node&&this.node.scene&&(this._model.scene&&this._detachFromScene(),this._getRenderScene().addModel(this._model))},i._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},Pe(e,[{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this._materialInstance&&this._materialInstance.setProperty("mainTexture",t)}},{key:"worldSpace",get:function(){return this._worldSpace},set:function(t){this._worldSpace=t,this._materialInstance&&(XO.CC_USE_WORLD_SPACE=this.worldSpace,this._materialInstance.recompileShaders(XO),this._model&&this._model.setSubModelMaterial(0,this._materialInstance))}},{key:"positions",get:function(){return this._positions},set:function(t){this._positions=t,this._model&&this._model.addLineVertexData(this._positions,this._width,this._color)}},{key:"width",get:function(){return this._width},set:function(t){this._width=t,this._model&&this._model.addLineVertexData(this._positions,this._width,this._color)}},{key:"tile",get:function(){return this._tile},set:function(t){this._tile.set(t),this._materialInstance&&(this._tile_offset.x=this._tile.x,this._tile_offset.y=this._tile.y,this._materialInstance.setProperty("mainTiling_Offset",this._tile_offset))}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t),this._materialInstance&&(this._tile_offset.z=this._offset.x,this._tile_offset.w=this._offset.y,this._materialInstance.setProperty("mainTiling_Offset",this._tile_offset))}},{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._model&&this._model.addLineVertexData(this._positions,this._width,this._color)}}]),e}(zi),ZI=oi((KI=nO).prototype,"_texture",[TI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(KI.prototype,"texture",[wI,EI,BI],Object.getOwnPropertyDescriptor(KI.prototype,"texture"),KI.prototype),QI=oi(KI.prototype,"_worldSpace",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(KI.prototype,"worldSpace",[DI,MI],Object.getOwnPropertyDescriptor(KI.prototype,"worldSpace"),KI.prototype),$I=oi(KI.prototype,"_positions",[PI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),oi(KI.prototype,"positions",[RI,II,OI],Object.getOwnPropertyDescriptor(KI.prototype,"positions"),KI.prototype),tO=oi(KI.prototype,"_width",[FI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),oi(KI.prototype,"width",[LI,VI,kI],Object.getOwnPropertyDescriptor(KI.prototype,"width"),KI.prototype),eO=oi(KI.prototype,"_tile",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(1,1)}}),oi(KI.prototype,"tile",[NI,GI,zI],Object.getOwnPropertyDescriptor(KI.prototype,"tile"),KI.prototype),iO=oi(KI.prototype,"_offset",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr(0,0)}}),oi(KI.prototype,"offset",[UI,HI,jI],Object.getOwnPropertyDescriptor(KI.prototype,"offset"),KI.prototype),rO=oi(KI.prototype,"_color",[WI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new hO}}),oi(KI.prototype,"color",[XI,YI,qI],Object.getOwnPropertyDescriptor(KI.prototype,"color"),KI.prototype),JI=KI))||JI)||JI)||JI)||JI)),qO=function(t){this.particleSystem=void 0,this.position=void 0,this.velocity=void 0,this.animatedVelocity=void 0,this.ultimateVelocity=void 0,this.angularVelocity=void 0,this.axisOfRotation=void 0,this.rotation=void 0,this.startSize=void 0,this.size=void 0,this.startColor=void 0,this.color=void 0,this.randomSeed=void 0,this.remainingLifetime=void 0,this.startLifetime=void 0,this.emitAccumulator0=void 0,this.emitAccumulator1=void 0,this.frameIndex=void 0,this.startRow=void 0,this.particleSystem=t,this.position=new ii(0,0,0),this.velocity=new ii(0,0,0),this.animatedVelocity=new ii(0,0,0),this.ultimateVelocity=new ii(0,0,0),this.angularVelocity=new ii(0,0,0),this.axisOfRotation=new ii(0,0,0),this.rotation=new ii(0,0,0),this.startSize=new ii(0,0,0),this.size=new ii(0,0,0),this.startColor=Ui.WHITE.clone(),this.color=Ui.WHITE.clone(),this.randomSeed=0,this.remainingLifetime=0,this.startLifetime=0,this.emitAccumulator0=0,this.emitAccumulator1=0,this.frameIndex=0,this.startRow=0},JO="colorModule",KO="rotationModule",ZO="sizeModule",QO="textureModule",$O=["sizeModule","colorModule","forceModule","velocityModule","limitModule","rotationModule","textureModule"],tF=["_colorOverLifetimeModule","_shapeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_trailModule"],eF=function(){function t(){this.target=null,this.needUpdate=!1,this.needAnimate=!0,this.name=void 0}var e=t.prototype;return e.bindTarget=function(t){this.target=t},e.update=function(){},t}(),iF=yi({World:0,Local:1,Custom:2}),rF=yi({Billboard:0,StrecthedBillboard:1,HorizontalBillboard:2,VerticalBillboard:3,Mesh:4}),nF=yi({Box:0,Circle:1,Cone:2,Sphere:3,Hemisphere:4}),sF=yi({Base:0,Edge:1,Shell:2,Volume:3}),aF=yi({Random:0,Loop:1,PingPong:2}),oF=yi({Particles:0}),lF=yi({Stretch:0}),hF=(cO=ri("cc.ColorOvertimeModule"),_O=Mr(),fO=bi(hO),pO=Mr(),cO((vO=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_enable",yO,hi(e)),li(e,"color",gO,hi(e)),e.name=JO,e}return Me(e,t),e.prototype.animate=function(t){t.color.set(t.startColor),t.color.multiply(this.color.evaluate(1-t.remainingLifetime/t.startLifetime,Fn(t.randomSeed+91041)))},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(eF),yO=oi((mO=vO).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(mO.prototype,"enable",[_O],Object.getOwnPropertyDescriptor(mO.prototype,"enable"),mO.prototype),gO=oi(mO.prototype,"color",[fO,_i,pO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new hO}}),dO=mO))||dO),uF=new ii(0,0,-1);function cF(t,e,i,r){return e!==t?(t===iF.World||Ri.invert(i,i),Ri.getRotation(r,i),!0):(si.set(r,0,0,0,1),!1)}function _F(t,e){dr.set(t,Math.cos(e),Math.sin(e))}function fF(t){var e=Vn(-1,1),i=Vn(0,2*Math.PI),r=Math.sqrt(1-e*e),n=r*Math.cos(i),s=r*Math.sin(i);ii.set(t,n,s,e)}function pF(t,e,i){fF(t),ii.multiplyScalar(t,t,e+(i-e)*Ln())}function dF(t,e,i,r){_F(t,r),t.z=0,ii.multiplyScalar(t,t,e+(i-e)*Ln())}function mF(t){for(var e=0;e<t.length;e++){var i=e+kn(0,t.length-e),r=t[i];t[i]=t[e],t[e]=r}}function yF(){var t=Vn(-1,1);return 0===t&&t++,Nn(t)}var gF,vF,bF,SF,AF,CF,xF,TF,wF,EF,BF,DF,MF,PF,RF,IF,OF,FF,LF,VF,kF,NF,GF,zF,UF,HF,jF,WF,XF,YF,qF,JF,KF,ZF,QF,$F,tL,eL,iL,rL,nL,sL,aL,oL,lL,hL,uL,cL,_L,fL,pL,dL,mL,yL,gL,vL,bL,SL,AL,CL,xL=212165,TL=new ii,wL=(bO=ri("cc.ForceOvertimeModule"),SO=Mr(),AO=bi(tI),CO=Ni(),xO=Mr(),TO=Di(),wO=bi(tI),EO=Ni(),BO=Mr(),DO=Di(),MO=bi(tI),PO=Ni(),RO=Mr(),IO=Di(),OO=bi(iF),FO=Mr(),LO=Di(),bO((jO=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_enable",NO,hi(e)),li(e,"x",GO,hi(e)),li(e,"y",zO,hi(e)),li(e,"z",UO,hi(e)),li(e,"space",HO,hi(e)),e.randomized=!1,e.rotation=void 0,e.needTransform=void 0,e.name="forceModule",e.rotation=new si,e.needTransform=!1,e.needUpdate=!0,e}Me(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=cF(t,this.space,e,this.rotation)},i.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime,r=ii.set(TL,this.x.evaluate(i,Fn(t.randomSeed+xL)),this.y.evaluate(i,Fn(t.randomSeed+xL)),this.z.evaluate(i,Fn(t.randomSeed+xL)));this.needTransform&&ii.transformQuat(r,r,this.rotation),ii.scaleAndAdd(t.velocity,t.velocity,r,e),ii.copy(t.ultimateVelocity,t.velocity)},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(eF),NO=oi((kO=jO).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(kO.prototype,"enable",[SO],Object.getOwnPropertyDescriptor(kO.prototype,"enable"),kO.prototype),GO=oi(kO.prototype,"x",[AO,_i,CO,xO,TO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),zO=oi(kO.prototype,"y",[wO,_i,EO,BO,DO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),UO=oi(kO.prototype,"z",[MO,_i,PO,RO,IO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),HO=oi(kO.prototype,"space",[OO,_i,FO,LO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return iF.Local}}),VO=kO))||VO),EL=23541,BL=new ii,DL=new ii,ML=(gF=ri("cc.LimitVelocityOvertimeModule"),vF=Mr(),bF=bi(tI),SF=Ni(),AF=Mr(),CF=Di(),xF=bi(tI),TF=Ni(),wF=Mr(),EF=Di(),BF=bi(tI),DF=Ni(),MF=Mr(),PF=Di(),RF=bi(tI),IF=Ni(),OF=Mr(),FF=Di(),LF=Mr(),VF=Di(),kF=Mr(),NF=Di(),GF=bi(iF),zF=Mr(),UF=Di(),gF(($F=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_enable",WF,hi(e)),li(e,"limitX",XF,hi(e)),li(e,"limitY",YF,hi(e)),li(e,"limitZ",qF,hi(e)),li(e,"limit",JF,hi(e)),li(e,"dampen",KF,hi(e)),li(e,"separateAxes",ZF,hi(e)),li(e,"space",QF,hi(e)),e.drag=null,e.multiplyDragByParticleSize=!1,e.multiplyDragByParticleVelocity=!1,e.name="limitModule",e.rotation=void 0,e.needTransform=void 0,e.rotation=new si,e.needTransform=!1,e.needUpdate=!0,e}Me(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=cF(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=BL;this.separateAxes?(ii.set(DL,this.limitX.evaluate(e,Fn(t.randomSeed+EL)),this.limitY.evaluate(e,Fn(t.randomSeed+EL)),this.limitZ.evaluate(e,Fn(t.randomSeed+EL))),this.needTransform&&ii.transformQuat(DL,DL,this.rotation),ii.set(i,PL(t.ultimateVelocity.x,DL.x,this.dampen),PL(t.ultimateVelocity.y,DL.y,this.dampen),PL(t.ultimateVelocity.z,DL.z,this.dampen))):(ii.normalize(i,t.ultimateVelocity),ii.multiplyScalar(i,i,PL(t.ultimateVelocity.length(),this.limit.evaluate(e,Fn(t.randomSeed+EL)),this.dampen))),ii.copy(t.ultimateVelocity,i)},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(eF),WF=oi((jF=$F).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(jF.prototype,"enable",[vF],Object.getOwnPropertyDescriptor(jF.prototype,"enable"),jF.prototype),XF=oi(jF.prototype,"limitX",[bF,_i,SF,AF,CF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),YF=oi(jF.prototype,"limitY",[xF,_i,TF,wF,EF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),qF=oi(jF.prototype,"limitZ",[BF,_i,DF,MF,PF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),JF=oi(jF.prototype,"limit",[RF,_i,IF,OF,FF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),KF=oi(jF.prototype,"dampen",[_i,LF,VF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 3}}),ZF=oi(jF.prototype,"separateAxes",[_i,kF,NF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),QF=oi(jF.prototype,"space",[GF,_i,zF,UF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return iF.Local}}),HF=jF))||HF);function PL(t,e,i){var r=Math.sign(t),n=Math.abs(t);return n>e&&(n=dn(n,e,i)),n*r}var RL,IL,OL,FL,LL,VL,kL,NL,GL,zL,UL,HL,jL,WL,XL,YL,qL,JL,KL,ZL,QL,$L,tV,eV,iV,rV,nV,sV,aV,oV,lV,hV,uV,cV,_V,fV,pV,dV,mV,yV,gV,vV,bV,SV,AV,CV,xV,TV,wV,EV,BV,DV,MV,PV,RV,IV,OV,FV,LV,VV,kV,NV,GV,zV,UV,HV,jV,WV,XV,YV,qV,JV,KV,ZV,QV,$V,tk,ek,ik,rk,nk,sk,ak,ok,lk,hk,uk,ck,_k,fk,pk,dk,mk,yk,gk,vk,bk,Sk,Ak,Ck,xk,Tk,wk,Ek,Bk,Dk,Mk,Pk,Rk,Ik,Ok,Fk,Lk,Vk,kk,Nk,Gk,zk,Uk,Hk,jk,Wk,Xk,Yk,qk,Jk,Kk,Zk,Qk,$k,tN,eN,iN,rN,nN,sN,aN,oN,lN,hN,uN,cN,_N,fN,pN,dN,mN,yN,gN,vN,bN,SN,AN,CN,xN,TN,wN,EN,BN,DN,MN,PN,RN,IN,ON,FN,LN,VN,kN,NN,GN,zN,UN,HN=125292,jN=(tL=ri("cc.RotationOvertimeModule"),eL=Mr(),iL=Mr(),rL=Di(),nL=bi(tI),sL=Ni(),aL=Mr(),oL=Di(),lL=bi(tI),hL=Ni(),uL=Mr(),cL=Di(),_L=bi(tI),fL=Ni(),pL=Mr(),dL=Di(),tL((CL=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_enable",gL,hi(e)),li(e,"_separateAxes",vL,hi(e)),li(e,"x",bL,hi(e)),li(e,"y",SL,hi(e)),li(e,"z",AL,hi(e)),e.name=KO,e}return Me(e,t),e.prototype.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime;if(this._separateAxes){var r=Fn(t.randomSeed+HN);t.rotation.x+=this.x.evaluate(i,r)*e,t.rotation.y+=this.y.evaluate(i,r)*e,t.rotation.z+=this.z.evaluate(i,r)*e}else t.rotation.z+=this.z.evaluate(i,Fn(t.randomSeed+HN))*e},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}},{key:"separateAxes",get:function(){return this._separateAxes},set:function(t){this._separateAxes=t}}]),e}(eF),gL=oi((yL=CL).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(yL.prototype,"enable",[eL],Object.getOwnPropertyDescriptor(yL.prototype,"enable"),yL.prototype),vL=oi(yL.prototype,"_separateAxes",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(yL.prototype,"separateAxes",[iL,rL],Object.getOwnPropertyDescriptor(yL.prototype,"separateAxes"),yL.prototype),bL=oi(yL.prototype,"x",[nL,_i,sL,Gn,aL,oL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),SL=oi(yL.prototype,"y",[lL,_i,hL,Gn,uL,cL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),AL=oi(yL.prototype,"z",[_L,_i,fL,Gn,pL,dL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),mL=yL))||mL),WN=(RL=ri("cc.SizeOvertimeModule"),IL=Mr(),OL=Mr(),FL=Di(),LL=bi(tI),VL=Mr(),kL=Di(),NL=bi(tI),GL=Mr(),zL=Di(),UL=bi(tI),HL=Mr(),jL=Di(),WL=bi(tI),XL=Mr(),YL=Di(),RL((iV=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_enable",KL,hi(e)),li(e,"separateAxes",ZL,hi(e)),li(e,"size",QL,hi(e)),li(e,"x",$L,hi(e)),li(e,"y",tV,hi(e)),li(e,"z",eV,hi(e)),e.name=ZO,e}return Me(e,t),e.prototype.animate=function(t){if(this.separateAxes){var e=1-t.remainingLifetime/t.startLifetime,i=Fn(t.randomSeed+39825);t.size.x=t.startSize.x*this.x.evaluate(e,i),t.size.y=t.startSize.y*this.y.evaluate(e,i),t.size.z=t.startSize.z*this.z.evaluate(e,i)}else ii.multiplyScalar(t.size,t.startSize,this.size.evaluate(1-t.remainingLifetime/t.startLifetime,Fn(t.randomSeed+39825)))},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(eF),KL=oi((JL=iV).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(JL.prototype,"enable",[IL],Object.getOwnPropertyDescriptor(JL.prototype,"enable"),JL.prototype),ZL=oi(JL.prototype,"separateAxes",[_i,OL,FL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),QL=oi(JL.prototype,"size",[LL,_i,VL,kL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),$L=oi(JL.prototype,"x",[NL,_i,GL,zL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),tV=oi(JL.prototype,"y",[UL,_i,HL,jL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),eV=oi(JL.prototype,"z",[WL,_i,XL,YL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),qL=JL))||qL),XN=90794,YN=yi({Grid:0}),qN=yi({WholeSheet:0,SingleRow:1}),JN=(rV=ri("cc.TextureAnimationModule"),nV=gi("numTilesX"),sV=gi("numTilesY"),aV=Mr(),oV=bi(YN),lV=bi(YN),hV=Mr(),uV=Di(),cV=Mr(),_V=Di(),fV=Mr(),pV=Di(),dV=bi(qN),mV=Mr(),yV=Di(),gV=bi(tI),vV=Mr(),bV=Di(),SV=bi(tI),AV=Mr(),CV=Di(),xV=Mr(),TV=Di(),wV=Mr(),EV=Di(),BV=Mr(),DV=Di(),rV((WV=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_enable",RV,hi(e)),li(e,"_numTilesX",IV,hi(e)),li(e,"_numTilesY",OV,hi(e)),li(e,"_mode",FV,hi(e)),li(e,"animation",LV,hi(e)),li(e,"frameOverTime",VV,hi(e)),li(e,"startFrame",kV,hi(e)),li(e,"cycleCount",NV,hi(e)),li(e,"_flipU",GV,hi(e)),li(e,"_flipV",zV,hi(e)),li(e,"_uvChannelMask",UV,hi(e)),li(e,"randomRow",HV,hi(e)),li(e,"rowIndex",jV,hi(e)),e.name=QO,e}Me(e,t);var i=e.prototype;return i.init=function(t){t.startRow=Math.floor(Math.random()*this.numTilesY)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=this.startFrame.evaluate(e,Fn(t.randomSeed+XN))/(this.numTilesX*this.numTilesY);if(this.animation===qN.WholeSheet)t.frameIndex=On(this.cycleCount*(this.frameOverTime.evaluate(e,Fn(t.randomSeed+XN))+i),1);else if(this.animation===qN.SingleRow){var r=1/this.numTilesY;if(this.randomRow){var n=On(this.cycleCount*(this.frameOverTime.evaluate(e,Fn(t.randomSeed+XN))+i),1),s=t.startRow*r,a=s+r;t.frameIndex=dn(s,a,n)}else{var o=this.rowIndex*r,l=o+r;t.frameIndex=dn(o,l,On(this.cycleCount*(this.frameOverTime.evaluate(e,Fn(t.randomSeed+XN))+i),1))}}},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&(this.target.updateMaterialParams(),this.target.enableModule(this.name,t,this)))}},{key:"mode",get:function(){return this._mode},set:function(t){t!==YN.Grid&&console.error("particle texture animation's sprites is not supported!")}},{key:"numTilesX",get:function(){return this._numTilesX},set:function(t){this._numTilesX!==t&&(this._numTilesX=t,this.target.updateMaterialParams())}},{key:"numTilesY",get:function(){return this._numTilesY},set:function(t){this._numTilesY!==t&&(this._numTilesY=t,this.target.updateMaterialParams())}},{key:"flipU",get:function(){return this._flipU},set:function(){console.error("particle texture animation's flipU is not supported!")}},{key:"flipV",get:function(){return this._flipV},set:function(){console.error("particle texture animation's flipV is not supported!")}},{key:"uvChannelMask",get:function(){return this._uvChannelMask},set:function(){console.error("particle texture animation's uvChannelMask is not supported!")}}]),e}(eF),RV=oi((PV=WV).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),IV=oi(PV.prototype,"_numTilesX",[nV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),OV=oi(PV.prototype,"_numTilesY",[sV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(PV.prototype,"enable",[aV],Object.getOwnPropertyDescriptor(PV.prototype,"enable"),PV.prototype),FV=oi(PV.prototype,"_mode",[oV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return YN.Grid}}),oi(PV.prototype,"mode",[lV,hV,uV],Object.getOwnPropertyDescriptor(PV.prototype,"mode"),PV.prototype),oi(PV.prototype,"numTilesX",[cV,_V],Object.getOwnPropertyDescriptor(PV.prototype,"numTilesX"),PV.prototype),oi(PV.prototype,"numTilesY",[fV,pV],Object.getOwnPropertyDescriptor(PV.prototype,"numTilesY"),PV.prototype),LV=oi(PV.prototype,"animation",[dV,_i,mV,yV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qN.WholeSheet}}),VV=oi(PV.prototype,"frameOverTime",[gV,_i,vV,bV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),kV=oi(PV.prototype,"startFrame",[SV,_i,AV,CV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),NV=oi(PV.prototype,"cycleCount",[_i,xV,TV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),GV=oi(PV.prototype,"_flipU",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),zV=oi(PV.prototype,"_flipV",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),UV=oi(PV.prototype,"_uvChannelMask",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),HV=oi(PV.prototype,"randomRow",[_i,wV,EV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),jV=oi(PV.prototype,"rowIndex",[_i,BV,DV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),MV=PV))||MV),KN=197866,ZN=new ii,QN=(XV=ri("cc.VelocityOvertimeModule"),YV=Mr(),qV=bi(tI),JV=Ni(),KV=Mr(),ZV=Di(),QV=bi(tI),$V=Ni(),tk=Mr(),ek=Di(),ik=bi(tI),rk=Ni(),nk=Mr(),sk=Di(),ak=bi(tI),ok=Ni(),lk=Mr(),hk=Di(),uk=bi(iF),ck=Mr(),_k=Di(),XV((Sk=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_enable",dk,hi(e)),li(e,"x",mk,hi(e)),li(e,"y",yk,hi(e)),li(e,"z",gk,hi(e)),li(e,"speedModifier",vk,hi(e)),li(e,"space",bk,hi(e)),e.rotation=void 0,e.needTransform=void 0,e.name="velocityModule",e.rotation=new si,e.speedModifier.constant=1,e.needTransform=!1,e.needUpdate=!0,e}Me(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=cF(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=ii.set(ZN,this.x.evaluate(e,Fn(t.randomSeed^KN)),this.y.evaluate(e,Fn(156497^t.randomSeed)),this.z.evaluate(e,Fn(984136^t.randomSeed)));this.needTransform&&ii.transformQuat(i,i,this.rotation),ii.add(t.animatedVelocity,t.animatedVelocity,i),ii.add(t.ultimateVelocity,t.velocity,t.animatedVelocity),ii.multiplyScalar(t.ultimateVelocity,t.ultimateVelocity,this.speedModifier.evaluate(1-t.remainingLifetime/t.startLifetime,Fn(t.randomSeed+KN)))},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(eF),dk=oi((pk=Sk).prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(pk.prototype,"enable",[YV],Object.getOwnPropertyDescriptor(pk.prototype,"enable"),pk.prototype),mk=oi(pk.prototype,"x",[qV,_i,JV,KV,ZV],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),yk=oi(pk.prototype,"y",[QV,_i,$V,tk,ek],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),gk=oi(pk.prototype,"z",[ik,_i,rk,nk,sk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),vk=oi(pk.prototype,"speedModifier",[ak,_i,ok,lk,hk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),bk=oi(pk.prototype,"space",[uk,_i,ck,_k],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return iF.Local}}),fk=pk))||fk),$N=t("Burst",(Ak=ri("cc.Burst"),Ck=bi(tI),Ak((Mk=function(){function t(){li(this,"_time",wk,this),li(this,"_repeatCount",Ek,this),li(this,"repeatInterval",Bk,this),li(this,"count",Dk,this),this._remainingCount=void 0,this._curTime=void 0,this._remainingCount=0,this._curTime=0}var e=t.prototype;return e.update=function(t,e){if(0===this._remainingCount&&(this._remainingCount=this._repeatCount,this._curTime=this._time),this._remainingCount>0){var i=On(t._time-t.startDelay.evaluate(0,1),t.duration)-e;i=i>0?i:0;var r=On(t.time-t.startDelay.evaluate(0,1),t.duration);this._curTime>=i&&this._curTime<r&&(t.emit(this.count.evaluate(this._curTime/t.duration,1),e-(r-this._curTime)),this._curTime+=this.repeatInterval,--this._remainingCount)}},e.getMaxCount=function(t){return this.count.getMax()*Math.min(Math.ceil(t.duration/this.repeatInterval),this.repeatCount)},Pe(t,[{key:"time",get:function(){return this._time},set:function(t){this._time=t,this._curTime=t}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t,this._remainingCount=t}}]),t}(),wk=oi((Tk=Mk).prototype,"_time",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(Tk.prototype,"time",[vi],Object.getOwnPropertyDescriptor(Tk.prototype,"time"),Tk.prototype),Ek=oi(Tk.prototype,"_repeatCount",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),oi(Tk.prototype,"repeatCount",[vi],Object.getOwnPropertyDescriptor(Tk.prototype,"repeatCount"),Tk.prototype),Bk=oi(Tk.prototype,"repeatInterval",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Dk=oi(Tk.prototype,"count",[Ck],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),xk=Tk))||xk)),tG=new ii(0,0,0),eG=[],iG=new ii(.5,.5,.5),rG=(Pk=ri("cc.ShapeModule"),Rk=Mr(),Ik=Di(),Ok=Mr(),Fk=Di(),Lk=Mr(),Vk=Di(),kk=Mr(),Nk=Di(),Gk=Mr(),zk=Di(),Uk=Mr(),Hk=bi(nF),jk=gi("shapeType"),Wk=Mr(),Xk=bi(nF),Yk=Di(),qk=bi(sF),Jk=Mr(),Kk=Di(),Zk=Mr(),Qk=Di(),$k=Mr(),tN=Di(),eN=Mr(),iN=Di(),rN=Mr(),nN=Di(),sN=Mr(),aN=Di(),oN=Mr(),lN=Di(),hN=bi(aF),uN=Mr(),cN=Di(),_N=Mr(),fN=Di(),pN=bi(tI),dN=Mr(),mN=Di(),yN=Mr(),gN=Di(),vN=Mr(),bN=Di(),Pk((UN=function(){function t(){li(this,"_enable",CN,this),li(this,"_shapeType",xN,this),li(this,"emitFrom",TN,this),li(this,"alignToDirection",wN,this),li(this,"randomDirectionAmount",EN,this),li(this,"sphericalDirectionAmount",BN,this),li(this,"randomPositionAmount",DN,this),li(this,"radius",MN,this),li(this,"radiusThickness",PN,this),li(this,"arcMode",RN,this),li(this,"arcSpread",IN,this),li(this,"arcSpeed",ON,this),li(this,"length",FN,this),li(this,"boxThickness",LN,this),li(this,"_position",VN,this),li(this,"_rotation",kN,this),li(this,"_scale",NN,this),li(this,"_arc",GN,this),li(this,"_angle",zN,this),this.mat=void 0,this.quat=void 0,this.particleSystem=void 0,this.lastTime=void 0,this.totalAngle=void 0,this.mat=new Ri,this.quat=new si,this.particleSystem=null,this.lastTime=0,this.totalAngle=0}var e=t.prototype;return e.onInit=function(t){this.particleSystem=t,this.constructMat(),this.lastTime=this.particleSystem._time},e.emit=function(t){switch(this.shapeType){case nF.Box:!function(t,e,i,r){switch(t){case sF.Volume:n=i,s=iG,ii.set(n,Vn(-s.x,s.x),Vn(-s.y,s.y),Vn(-s.z,s.z));break;case sF.Shell:eG.splice(0,eG.length),eG.push(Vn(-.5,.5)),eG.push(Vn(-.5,.5)),eG.push(.5*yF()),mF(eG),nG(eG,e),ii.set(i,eG[0],eG[1],eG[2]);break;case sF.Edge:eG.splice(0,eG.length),eG.push(Vn(-.5,.5)),eG.push(.5*yF()),eG.push(.5*yF()),mF(eG),nG(eG,e),ii.set(i,eG[0],eG[1],eG[2]);break;default:console.warn(t+" is not supported for box emitter.")}var n,s;ii.copy(r,uF)}(this.emitFrom,this.boxThickness,t.position,t.velocity);break;case nF.Circle:e=this.radius,i=this.radiusThickness,r=this.generateArcAngle(),n=t.position,s=t.velocity,dF(n,e*(1-i),e,r),ii.normalize(s,n);break;case nF.Cone:!function(t,e,i,r,n,s,a,o){switch(t){case sF.Base:dF(a,e*(1-i),e,r),dr.multiplyScalar(o,a,Math.sin(n)),o.z=-Math.cos(n)*e,ii.normalize(o,o),a.z=0;break;case sF.Shell:_F(a,r),dr.multiplyScalar(o,a,Math.sin(n)),o.z=-Math.cos(n),ii.normalize(o,o),dr.multiplyScalar(a,a,e),a.z=0;break;case sF.Volume:dF(a,e*(1-i),e,r),dr.multiplyScalar(o,a,Math.sin(n)),o.z=-Math.cos(n)*e,ii.normalize(o,o),a.z=0,ii.add(a,a,ii.multiplyScalar(tG,o,s*Ln()/-o.z));break;default:console.warn(t+" is not supported for cone emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,this.generateArcAngle(),this._angle,this.length,t.position,t.velocity);break;case nF.Sphere:!function(t,e,i,r,n){switch(t){case sF.Volume:pF(r,e*(1-i),e),ii.normalize(n,r);break;case sF.Shell:fF(r),ii.multiplyScalar(r,r,e),ii.normalize(n,r);break;default:console.warn(t+" is not supported for sphere emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,t.position,t.velocity);break;case nF.Hemisphere:!function(t,e,i,r,n){switch(t){case sF.Volume:pF(r,e*(1-i),e),r.z>0&&(r.z*=-1),ii.normalize(n,r);break;case sF.Shell:fF(r),ii.multiplyScalar(r,r,e),r.z>0&&(r.z*=-1),ii.normalize(n,r);break;default:console.warn(t+" is not supported for hemisphere emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,t.position,t.velocity);break;default:console.warn(this.shapeType+" shapeType is not supported by ShapeModule.")}var e,i,r,n,s;if(this.randomPositionAmount>0&&(t.position.x+=Vn(-this.randomPositionAmount,this.randomPositionAmount),t.position.y+=Vn(-this.randomPositionAmount,this.randomPositionAmount),t.position.z+=Vn(-this.randomPositionAmount,this.randomPositionAmount)),ii.transformQuat(t.velocity,t.velocity,this.quat),ii.transformMat4(t.position,t.position,this.mat),this.sphericalDirectionAmount>0){var a=ii.normalize(tG,t.position);ii.lerp(t.velocity,t.velocity,a,this.sphericalDirectionAmount)}this.lastTime=this.particleSystem._time},e.constructMat=function(){si.fromEuler(this.quat,this._rotation.x,this._rotation.y,this._rotation.z),Ri.fromRTS(this.mat,this.quat,this._position,this._scale)},e.generateArcAngle=function(){if(this.arcMode===aF.Random)return Vn(0,this._arc);var t=this.totalAngle+2*Math.PI*this.arcSpeed.evaluate(this.particleSystem._time,1)*(this.particleSystem._time-this.lastTime);switch(this.totalAngle=t,0!==this.arcSpread&&(t=Math.floor(t/(this._arc*this.arcSpread))*this._arc*this.arcSpread),this.arcMode){case aF.Loop:return On(t,this._arc);case aF.PingPong:return zn(t,this._arc)}},Pe(t,[{key:"position",get:function(){return this._position},set:function(t){this._position=t,this.constructMat()}},{key:"rotation",get:function(){return this._rotation},set:function(t){this._rotation=t,this.constructMat()}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale=t,this.constructMat()}},{key:"arc",get:function(){return Mn(this._arc)},set:function(t){this._arc=qi(t)}},{key:"angle",get:function(){return Math.round(100*Mn(this._angle))/100},set:function(t){this._angle=qi(t)}},{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"shapeType",get:function(){return this._shapeType},set:function(t){switch(this._shapeType=t,this._shapeType){case nF.Box:this.emitFrom===sF.Base&&(this.emitFrom=sF.Volume);break;case nF.Cone:this.emitFrom===sF.Edge&&(this.emitFrom=sF.Base);break;case nF.Sphere:case nF.Hemisphere:this.emitFrom!==sF.Base&&this.emitFrom!==sF.Edge||(this.emitFrom=sF.Volume)}}}]),t}(),oi((AN=UN).prototype,"position",[Rk,Ik],Object.getOwnPropertyDescriptor(AN.prototype,"position"),AN.prototype),oi(AN.prototype,"rotation",[Ok,Fk],Object.getOwnPropertyDescriptor(AN.prototype,"rotation"),AN.prototype),oi(AN.prototype,"scale",[Lk,Vk],Object.getOwnPropertyDescriptor(AN.prototype,"scale"),AN.prototype),oi(AN.prototype,"arc",[kk,Nk],Object.getOwnPropertyDescriptor(AN.prototype,"arc"),AN.prototype),oi(AN.prototype,"angle",[Gk,zk],Object.getOwnPropertyDescriptor(AN.prototype,"angle"),AN.prototype),CN=oi(AN.prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(AN.prototype,"enable",[Uk],Object.getOwnPropertyDescriptor(AN.prototype,"enable"),AN.prototype),xN=oi(AN.prototype,"_shapeType",[Hk,jk,Wk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return nF.Cone}}),oi(AN.prototype,"shapeType",[Xk,Yk],Object.getOwnPropertyDescriptor(AN.prototype,"shapeType"),AN.prototype),TN=oi(AN.prototype,"emitFrom",[qk,_i,Jk,Kk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return sF.Volume}}),wN=oi(AN.prototype,"alignToDirection",[_i,Zk,Qk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),EN=oi(AN.prototype,"randomDirectionAmount",[_i,$k,tN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),BN=oi(AN.prototype,"sphericalDirectionAmount",[_i,eN,iN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),DN=oi(AN.prototype,"randomPositionAmount",[_i,rN,nN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),MN=oi(AN.prototype,"radius",[_i,sN,aN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),PN=oi(AN.prototype,"radiusThickness",[_i,oN,lN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),RN=oi(AN.prototype,"arcMode",[hN,_i,uN,cN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return aF.Random}}),IN=oi(AN.prototype,"arcSpread",[_i,_N,fN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ON=oi(AN.prototype,"arcSpeed",[pN,_i,dN,mN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),FN=oi(AN.prototype,"length",[_i,yN,gN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),LN=oi(AN.prototype,"boxThickness",[_i,vN,bN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(0,0,0)}}),VN=oi(AN.prototype,"_position",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(0,0,0)}}),kN=oi(AN.prototype,"_rotation",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(0,0,0)}}),NN=oi(AN.prototype,"_scale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(1,1,1)}}),GN=oi(AN.prototype,"_arc",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qi(360)}}),zN=oi(AN.prototype,"_angle",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qi(25)}}),SN=AN))||SN);function nG(t,e){e.x>0&&(t[0]+=.5*Vn(-e.x,e.x),t[0]=Gr(t[0],-.5,.5)),e.y>0&&(t[1]+=.5*Vn(-e.y,e.y),t[1]=Gr(t[1],-.5,.5)),e.z>0&&(t[2]+=.5*Vn(-e.z,e.z),t[2]=Gr(t[2],-.5,.5))}var sG,aG,oG,lG,hG,uG,cG,_G,fG,pG,dG,mG,yG,gG,vG,bG,SG,AG,CG,xG,TG,wG,EG,BG,DG,MG,PG,RG,IG,OG=[0,0,1,0,0,1,1,1],FG=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._vertAttrs=void 0,e._vertSize=void 0,e._vBuffer=void 0,e._vertAttrsFloatCount=void 0,e._vdataF32=void 0,e._vdataUint32=void 0,e._iaInfo=void 0,e._iaInfoBuffer=void 0,e._subMeshData=void 0,e._mesh=void 0,e._vertCount=0,e._indexCount=0,e._startTimeOffset=0,e._lifeTimeOffset=0,e._material=null,e.type=ar.PARTICLE_BATCH,e._capacity=0,e._vertAttrs=null,e._vertSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._iaInfo=new lt([new at]),e._iaInfoBuffer=e._device.createBuffer(new nt(d.INDIRECT,g.HOST|g.DEVICE,Yt,Yt)),e._subMeshData=null,e._mesh=null,e}Me(e,t);var i=e.prototype;return i.setCapacity=function(t){var e=this._capacity!==t;this._capacity=t,this._subMeshData&&e&&this.rebuild()},i.setVertexAttributes=function(t,e){if(this._mesh!==t||this._vertAttrs!==e){this._mesh=t,this._vertAttrs=e,this._vertSize=0;for(var i,r=Fe(this._vertAttrs);!(i=r()).done;){var n=i.value;n.offset=this._vertSize,this._vertSize+=Ht[n.format].size}this._vertAttrsFloatCount=this._vertSize/4,this.rebuild()}},i.createSubMeshData=function(){this.destroySubMeshData(),this._vertCount=4,this._indexCount=6,this._mesh&&(this._vertCount=this._mesh.struct.vertexBundles[this._mesh.struct.primitives[0].vertexBundelIndices[0]].view.count,this._indexCount=this._mesh.struct.primitives[0].indexView.count);var t=this._device.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.HOST|g.DEVICE,this._vertSize*this._capacity*this._vertCount,this._vertSize)),e=new ArrayBuffer(this._vertSize*this._capacity*this._vertCount);if(this._mesh){var i=this._vertAttrs[this._vertAttrs.findIndex((function(t){return t.name===Ut.ATTR_TEX_COORD}))].offset;this._mesh.copyAttribute(0,Ut.ATTR_TEX_COORD,e,this._vertSize,i);var r=this._vertAttrs.findIndex((function(t){return t.name===Ut.ATTR_TEX_COORD3}));if(i=this._vertAttrs[r++].offset,this._mesh.copyAttribute(0,Ut.ATTR_POSITION,e,this._vertSize,i),i=this._vertAttrs[r++].offset,this._mesh.copyAttribute(0,Ut.ATTR_NORMAL,e,this._vertSize,i),i=this._vertAttrs[r++].offset,!this._mesh.copyAttribute(0,Ut.ATTR_COLOR,e,this._vertSize,i))for(var n=new Uint32Array(e),s=0;s<this._vertCount;++s)n[s*this._vertAttrsFloatCount+i/4]=Ui.WHITE._val;for(var a=new Float32Array(e),o=1;o<this._capacity;o++)a.copyWithin(o*this._vertSize*this._vertCount/4,0,this._vertSize*this._vertCount/4)}t.update(e);var l=new Uint16Array(this._capacity*this._indexCount);if(this._mesh){this._mesh.copyIndices(0,l);for(var h=1;h<this._capacity;h++)for(var u=0;u<this._indexCount;u++)l[h*this._indexCount+u]=l[u]+h*this._vertCount}else for(var c=0,_=0;_<this._capacity;++_){var f=4*_;l[c++]=f,l[c++]=f+1,l[c++]=f+2,l[c++]=f+3,l[c++]=f+2,l[c++]=f+1}var p=this._device.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.HOST|g.DEVICE,this._capacity*this._indexCount*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));return p.update(l),this._iaInfo.drawInfos[0].vertexCount=this._capacity*this._vertCount,this._iaInfo.drawInfos[0].indexCount=this._capacity*this._indexCount,this._iaInfoBuffer||(this._iaInfoBuffer=this._device.createBuffer(new nt(d.INDIRECT,g.HOST|g.DEVICE,Yt,Yt))),this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new ui([t],this._vertAttrs,F.TRIANGLE_LIST,p,this._iaInfoBuffer),this.initSubModel(0,this._subMeshData,this._material),e},i.updateMaterial=function(t){this._material=t,this.setSubModelMaterial(0,t)},i.addParticleVertexData=function(t,e){if(this._mesh)for(var i=0;i<this._vertCount;i++){var r=(t*this._vertCount+i)*this._vertAttrsFloatCount;this._vdataF32[r++]=e[0].x,this._vdataF32[r++]=e[0].y,this._vdataF32[r++]=e[0].z,r+=2,this._vdataF32[r++]=e[1].z,this._vdataF32[r++]=e[2].x,this._vdataF32[r++]=e[2].y,this._vdataF32[r++]=e[2].z,this._vdataF32[r++]=e[3].x,this._vdataF32[r++]=e[3].y,this._vdataF32[r++]=e[3].z,this._vdataUint32[r++]=e[4]}else{var n=t*this._vertAttrsFloatCount;this._vdataF32[n++]=e[0].x,this._vdataF32[n++]=e[0].y,this._vdataF32[n++]=e[0].z,this._vdataF32[n++]=e[1].x,this._vdataF32[n++]=e[1].y,this._vdataF32[n++]=e[1].z,this._vdataF32[n++]=e[2].x,this._vdataF32[n++]=e[2].y,this._vdataF32[n++]=e[2].z,this._vdataF32[n++]=e[3].x,this._vdataF32[n++]=e[3].y,this._vdataF32[n++]=e[3].z,this._vdataUint32[n++]=e[4],e[5]&&(this._vdataF32[n++]=e[5].x,this._vdataF32[n++]=e[5].y,this._vdataF32[n++]=e[5].z)}},i.addGPUParticleVertexData=function(t,e,i){for(var r=e*this._vertAttrsFloatCount*this._vertCount,n=0;n<this._vertCount;n++){var s=r;this._vdataF32[s++]=t.position.x,this._vdataF32[s++]=t.position.y,this._vdataF32[s++]=t.position.z,this._vdataF32[s++]=i,this._vdataF32[s++]=t.startSize.x,this._vdataF32[s++]=t.startSize.y,this._vdataF32[s++]=t.startSize.z,this._vdataF32[s++]=OG[2*n],this._vdataF32[s++]=t.rotation.x,this._vdataF32[s++]=t.rotation.y,this._vdataF32[s++]=t.rotation.z,this._vdataF32[s++]=OG[2*n+1],this._vdataF32[s++]=t.startColor.r/255,this._vdataF32[s++]=t.startColor.g/255,this._vdataF32[s++]=t.startColor.b/255,this._vdataF32[s++]=t.startColor.a/255,this._vdataF32[s++]=t.velocity.x,this._vdataF32[s++]=t.velocity.y,this._vdataF32[s++]=t.velocity.z,this._vdataF32[s++]=t.startLifetime,this._vdataF32[s++]=t.randomSeed,r+=this._vertAttrsFloatCount}},i.updateGPUParticles=function(t,e,i){for(var r=this._vertAttrsFloatCount*this._vertCount,n=0,s=0,a=0,o=0;o<t;++o)n=o*r,s=this._vdataF32[n+this._startTimeOffset],this._vdataF32[n+this._lifeTimeOffset]-(e-s)<i&&(a=--t*r,this._vdataF32.copyWithin(n,a,a+r),o--);return t},i.constructAttributeIndex=function(){if(this._vertAttrs){var t=this._vertAttrs.findIndex((function(t){return"a_position_starttime"===t.name})),e=this._vertAttrs[t].offset;this._startTimeOffset=e/4+3,t=this._vertAttrs.findIndex((function(t){return"a_dir_life"===t.name})),e=this._vertAttrs[t].offset,this._lifeTimeOffset=e/4+3}},i.updateIA=function(t){this._subModels[0].inputAssembler.vertexBuffers[0].update(this._vdataF32),this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=this._indexCount*t,this._iaInfoBuffer.update(this._iaInfo)},i.clear=function(){this._subModels[0].inputAssembler.indexCount=0},i.destroy=function(){t.prototype.destroy.call(this),this._vBuffer=null,this._vdataF32=null,this.destroySubMeshData(),this._iaInfoBuffer&&(this._iaInfoBuffer.destroy(),this._iaInfoBuffer=null)},i.rebuild=function(){this._vBuffer=this.createSubMeshData(),this._vdataF32=new Float32Array(this._vBuffer),this._vdataUint32=new Uint32Array(this._vBuffer)},i.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null,this._iaInfoBuffer=null)},e}(mi),LG=function(){function t(t){this._particleSystem=null,this._model=null,this._renderInfo=null,this._vertAttrs=[],this._renderInfo=t}var e=t.prototype;return e.onInit=function(t){this._particleSystem=t},e.onEnable=function(){if(this._particleSystem){this.attachToScene();var t=this._model;t&&(t.node=t.transform=this._particleSystem.node,t.enabled=this._particleSystem.enabledInHierarchy)}},e.onDisable=function(){this.detachFromScene()},e.onDestroy=function(){this._model&&(He.director.root.destroyModel(this._model),this._model=null)},e.attachToScene=function(){this._model&&(this._model.scene&&this.detachFromScene(),this._particleSystem._getRenderScene().addModel(this._model))},e.detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},e.setVertexAttributes=function(){this._model&&this._model.setVertexAttributes(this._renderInfo.renderMode===rF.Mesh?this._renderInfo.mesh:null,this._vertAttrs)},e.clear=function(){this._model&&(this._model.enabled=!1)},e._initModel=function(){this._model||(this._model=He.director.root.createModel(FG),this._model.setCapacity(this._particleSystem.capacity),this._model.visFlags=this._particleSystem.visibility)},e.updateTrailMaterial=function(){},e.getDefaultTrailMaterial=function(){return null},t}(),VG=new ii,kG=new Ri,NG=["_colorOverLifetimeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule"],GG=[0,0,1,0,0,1,1,1],zG=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RGB32F),new St(Ut.ATTR_TEX_COORD1,_.RGB32F),new St(Ut.ATTR_TEX_COORD2,_.RGB32F),new St(Ut.ATTR_COLOR,_.RGBA8,!0)],UG=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RGB32F),new St(Ut.ATTR_TEX_COORD1,_.RGB32F),new St(Ut.ATTR_TEX_COORD2,_.RGB32F),new St(Ut.ATTR_COLOR,_.RGBA8,!0),new St(Ut.ATTR_COLOR1,_.RGB32F)],HG=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RGB32F),new St(Ut.ATTR_TEX_COORD1,_.RGB32F),new St(Ut.ATTR_TEX_COORD2,_.RGB32F),new St(Ut.ATTR_COLOR,_.RGBA8,!0),new St(Ut.ATTR_TEX_COORD3,_.RGB32F),new St(Ut.ATTR_NORMAL,_.RGB32F),new St(Ut.ATTR_COLOR1,_.RGBA8,!0)],jG={parent:null,owner:null,subModelIdx:0},WG=function(t){function e(e){var i;return(i=t.call(this,e)||this)._defines=void 0,i._trailDefines=void 0,i._frameTile_velLenScale=void 0,i._defaultMat=null,i._node_scale=void 0,i._attrs=void 0,i._particles=null,i._defaultTrailMat=null,i._updateList=new Map,i._animateList=new Map,i._runAnimateList=new Array,i._fillDataFunc=null,i._uScaleHandle=0,i._uLenHandle=0,i._inited=!1,i._model=null,i._frameTile_velLenScale=new Ti(1,1,0,0),i._node_scale=new Ti,i._attrs=new Array(5),i._defines={CC_USE_WORLD_SPACE:!0,CC_USE_BILLBOARD:!0,CC_USE_STRETCHED_BILLBOARD:!1,CC_USE_HORIZONTAL_BILLBOARD:!1,CC_USE_VERTICAL_BILLBOARD:!1},i._trailDefines={CC_USE_WORLD_SPACE:!0},i}Me(e,t);var r=e.prototype;return r.onInit=function(e){var r=this;t.prototype.onInit.call(this,e),this._particles=new i((function(){return new qO(r)}),16),this._setVertexAttrib(),this._setFillFunc(),this._initModuleList(),this._initModel(),this.updateMaterialParams(),this.updateTrailMaterial(),this.setVertexAttributes(),this._inited=!0},r.clear=function(){t.prototype.clear.call(this),this._particles.reset(),this._particleSystem._trailModule&&this._particleSystem._trailModule.clear(),this.updateRenderData(),this._model.enabled=!1},r.updateRenderMode=function(){this._setVertexAttrib(),this._setFillFunc(),this.updateMaterialParams(),this.setVertexAttributes()},r.getFreeParticle=function(){return this._particles.length>=this._particleSystem.capacity?null:this._particles.add()},r.getDefaultTrailMaterial=function(){return this._defaultTrailMat},r.setNewParticle=function(){},r._initModuleList=function(){var t=this;NG.forEach((function(e){var i=t._particleSystem[e];i&&i.enable&&(i.needUpdate&&(t._updateList[i.name]=i),i.needAnimate&&(t._animateList[i.name]=i))})),this._runAnimateList.length=0;for(var e=0,i=$O.length;e<i;e++){var r=this._animateList[$O[e]];r&&this._runAnimateList.push(r)}},r.enableModule=function(t,e,i){e?(i.needUpdate&&(this._updateList[i.name]=i),i.needAnimate&&(this._animateList[i.name]=i)):(delete this._animateList[t],delete this._updateList[t]),this._runAnimateList.length=0;for(var r=0,n=$O.length;r<n;r++){var s=this._animateList[$O[r]];s&&this._runAnimateList.push(s)}},r.updateParticles=function(t){var e=this,i=this._particleSystem;if(!i)return this._particles.length;switch(i.node.getWorldMatrix(kG),i.scaleSpace){case iF.Local:i.node.getScale(this._node_scale);break;case iF.World:i.node.getWorldScale(this._node_scale)}(i.getMaterialInstance(0)||this._defaultMat).passes[0].setUniform(this._uScaleHandle,this._node_scale),this._updateList.forEach((function(t){t.update(i._simulationSpace,kG)}));var r=i._trailModule,n=r&&r.enable;n&&r.update();for(var s=function(s){var o=e._particles.data[s];if(o.remainingLifetime-=t,ii.set(o.animatedVelocity,0,0,0),o.remainingLifetime<0)return n&&r.removeParticle(o),e._particles.removeAt(s),--s,a=s,"continue";o.velocity.y-=9.8*i.gravityModifier.evaluate(1-o.remainingLifetime/o.startLifetime,Fn(o.randomSeed))*t,ii.copy(o.ultimateVelocity,o.velocity),e._runAnimateList.forEach((function(e){e.animate(o,t)})),ii.scaleAndAdd(o.position,o.position,o.ultimateVelocity,t),n&&r.animate(o,t),a=s},a=0;a<this._particles.length;++a)s(a);return this._model.enabled=this._particles.length>0,this._particles.length},r.updateRenderData=function(){for(var t=0,e=0;e<this._particles.length;++e){var i=this._particles.data[e],r=0,n=this._particleSystem._textureAnimationModule;n&&n.enable&&(r=i.frameIndex),t=4*e,this._fillDataFunc(i,t,r)}},r.beforeRender=function(){this._model.updateIA(this._particles.length)},r.getParticleCount=function(){return this._particles.length},r.onMaterialModified=function(t){this._inited&&(0===t?this.updateMaterialParams():this.updateTrailMaterial())},r.onRebuildPSO=function(t,e){this._model&&0===t&&this._model.setSubModelMaterial(0,e);var i=this._particleSystem._trailModule;i&&i._trailModel&&1===t&&i._trailModel.setSubModelMaterial(0,e)},r._setFillFunc=function(){this._renderInfo.renderMode===rF.Mesh?this._fillDataFunc=this._fillMeshData:this._renderInfo.renderMode===rF.StrecthedBillboard?this._fillDataFunc=this._fillStrecthedData:this._fillDataFunc=this._fillNormalData},r._fillMeshData=function(t,e,i){var r=e/4,n=0;this._attrs[n++]=t.position,VG.z=i,this._attrs[n++]=VG,this._attrs[n++]=t.size,this._attrs[n++]=t.rotation,this._attrs[n++]=t.color._val,this._model.addParticleVertexData(r,this._attrs)},r._fillStrecthedData=function(t,e,i){for(var r=0,n=0;n<4;++n)r=0,this._attrs[r++]=t.position,VG.x=GG[2*n],VG.y=GG[2*n+1],VG.z=i,this._attrs[r++]=VG,this._attrs[r++]=t.size,this._attrs[r++]=t.rotation,this._attrs[r++]=t.color._val,this._attrs[r++]=t.ultimateVelocity,this._attrs[r++]=t.ultimateVelocity,this._model.addParticleVertexData(e++,this._attrs)},r._fillNormalData=function(t,e,i){for(var r=0,n=0;n<4;++n)r=0,this._attrs[r++]=t.position,VG.x=GG[2*n],VG.y=GG[2*n+1],VG.z=i,this._attrs[r++]=VG,this._attrs[r++]=t.size,this._attrs[r++]=t.rotation,this._attrs[r++]=t.color._val,this._attrs[r++]=null,this._model.addParticleVertexData(e++,this._attrs)},r._setVertexAttrib=function(){switch(this._renderInfo.renderMode){case rF.StrecthedBillboard:this._vertAttrs=UG.slice();break;case rF.Mesh:this._vertAttrs=HG.slice();break;default:this._vertAttrs=zG.slice()}},r.updateMaterialParams=function(){if(this._particleSystem){var t=this._particleSystem,e=t.sharedMaterial;if(null!=e){var i=e._effectAsset._name;this._renderInfo.mainTexture=e.getProperty("mainTexture",0),-1!==i.indexOf("particle")&&-1===i.indexOf("particle-gpu")||t.setMaterial(null,0)}null==t.sharedMaterial&&null==this._defaultMat&&(jG.parent=Ci.get("default-particle-material"),jG.owner=this._particleSystem,jG.subModelIdx=0,this._defaultMat=new Vr(jG),null!==this._renderInfo.mainTexture&&this._defaultMat.setProperty("mainTexture",this._renderInfo.mainTexture));var r=t.getMaterialInstance(0)||this._defaultMat;t._simulationSpace===iF.World?this._defines.CC_USE_WORLD_SPACE=!0:this._defines.CC_USE_WORLD_SPACE=!1;var n=r.passes[0];this._uScaleHandle=n.getHandle("scale"),this._uLenHandle=n.getHandle("frameTile_velLenScale");var s=this._renderInfo.renderMode,a=this._frameTile_velLenScale;s===rF.Billboard?this._defines.CC_RENDER_MODE=0:s===rF.StrecthedBillboard?(this._defines.CC_RENDER_MODE=1,a.z=this._renderInfo.velocityScale,a.w=this._renderInfo.lengthScale):s===rF.HorizontalBillboard?this._defines.CC_RENDER_MODE=2:s===rF.VerticalBillboard?this._defines.CC_RENDER_MODE=3:s===rF.Mesh?this._defines.CC_RENDER_MODE=4:console.warn("particle system renderMode "+s+" not support.");var o=t._textureAnimationModule;o&&o.enable?(dr.set(a,o.numTilesX,o.numTilesY),n.setUniform(this._uLenHandle,a)):n.setUniform(this._uLenHandle,a),r.recompileShaders(this._defines),this._model&&this._model.updateMaterial(r)}},r.updateTrailMaterial=function(){if(this._particleSystem){var t=this._particleSystem,e=t._trailModule;if(e&&e.enable){t.simulationSpace===iF.World||e.space===iF.World?this._trailDefines.CC_USE_WORLD_SPACE=!0:this._trailDefines.CC_USE_WORLD_SPACE=!1;var i=t.getMaterialInstance(1);null===i&&null===this._defaultTrailMat&&(jG.parent=Ci.get("default-trail-material"),jG.owner=this._particleSystem,jG.subModelIdx=1,this._defaultTrailMat=new Vr(jG)),(i=i||this._defaultTrailMat).recompileShaders(this._trailDefines),e.updateMaterial()}}},e}(LG),XG=new Ri,YG=new Ti,qG=new si,JG=32,KG="a_position_starttime",ZG="a_size_uv",QG="a_rotation_uv",$G="a_color",tz="a_dir_life",ez="a_rndSeed",iz=[new St(KG,_.RGBA32F),new St(ZG,_.RGBA32F),new St(QG,_.RGBA32F),new St($G,_.RGBA32F),new St(tz,_.RGBA32F),new St(ez,_.R32F)],rz=[new St(KG,_.RGBA32F),new St(ZG,_.RGBA32F),new St(QG,_.RGBA32F),new St($G,_.RGBA32F),new St(tz,_.RGBA32F),new St(ez,_.R32F),new St(Ut.ATTR_TEX_COORD,_.RGB32F),new St(Ut.ATTR_TEX_COORD3,_.RGB32F),new St(Ut.ATTR_NORMAL,_.RGB32F),new St(Ut.ATTR_COLOR1,_.RGBA8,!0)],nz={parent:null,owner:null,subModelIdx:0},sz=function(t){function e(e){var i;return(i=t.call(this,e)||this)._defines=void 0,i._frameTile_velLenScale=void 0,i._node_scale=void 0,i._vertAttrs=[],i._defaultMat=null,i._particleNum=0,i._tempParticle=null,i._colorTexture=null,i._forceTexture=null,i._velocityTexture=null,i._rotationTexture=null,i._sizeTexture=null,i._animTexture=null,i._uTimeHandle=0,i._uRotHandle=0,i._inited=!1,i._frameTile_velLenScale=new Ti(1,1,0,0),i._node_scale=new Ti,i._defines={CC_USE_WORLD_SPACE:!0,CC_USE_BILLBOARD:!0,CC_USE_STRETCHED_BILLBOARD:!1,CC_USE_HORIZONTAL_BILLBOARD:!1,CC_USE_VERTICAL_BILLBOARD:!1,COLOR_OVER_TIME_MODULE_ENABLE:!1},i._tempParticle=new qO(null),i._particleNum=0,i}Me(e,t);var i=e.prototype;return i.onInit=function(e){t.prototype.onInit.call(this,e),this._setVertexAttrib(),this._initModel(),this.updateMaterialParams(),this.setVertexAttributes(),this._inited=!0},i.updateRenderMode=function(){this._setVertexAttrib(),this.updateMaterialParams(),this.setVertexAttributes()},i.setVertexAttributes=function(){t.prototype.setVertexAttributes.call(this),this._model.constructAttributeIndex()},i.clear=function(){t.prototype.clear.call(this),this._particleNum=0,this.updateRenderData()},i.onDestroy=function(){t.prototype.onDestroy.call(this),this._forceTexture&&this._forceTexture.destroy(),this._velocityTexture&&this._velocityTexture.destroy(),this._colorTexture&&this._colorTexture.destroy(),this._sizeTexture&&this._sizeTexture.destroy(),this._rotationTexture&&this._rotationTexture.destroy(),this._animTexture&&this._animTexture.destroy()},i.enableModule=function(){var t=this._particleSystem.getMaterialInstance(0)||this._defaultMat;t&&(this.initShaderUniform(t),t.recompileShaders(this._defines),this._model&&this._model.setSubModelMaterial(0,t))},i.getFreeParticle=function(){return this._particleNum>=this._particleSystem._capacity?null:this._tempParticle},i.setNewParticle=function(t){this._model.addGPUParticleVertexData(t,this._particleNum,this._particleSystem._time),this._particleNum++},i.updateParticles=function(t){return this._particleNum=this._model.updateGPUParticles(this._particleNum,this._particleSystem._time,t),this.updateShaderUniform(t),this._model.enabled=this._particleNum>0,this._particleNum},i.updateRenderData=function(){},i.beforeRender=function(){this._model.updateIA(this._particleNum)},i.updateShaderUniform=function(t){var e=this._particleSystem.getMaterialInstance(0)||this._defaultMat;if(e){var i=e.passes[0];YG.x=this._particleSystem._time,YG.y=t,i.setUniform(this._uTimeHandle,YG),this._particleSystem.node.getWorldRotation(qG),i.setUniform(this._uRotHandle,qG)}},i.initShaderUniform=function(t){var e=t.passes[0];this._uTimeHandle=e.getHandle("u_timeDelta"),this._uRotHandle=e.getHandle("u_worldRot"),e.setUniform(e.getHandle("scale"),this._node_scale),e.setUniform(e.getHandle("frameTile_velLenScale"),this._frameTile_velLenScale),YG.x=JG,YG.y=.03125,e.setUniform(e.getHandle("u_sampleInfo"),YG);var i=!1,r=this._particleSystem._forceOvertimeModule;if(i=r&&r.enable,this._defines.FORCE_OVER_TIME_MODULE_ENABLE=i,i){this._forceTexture&&this._forceTexture.destroy(),this._forceTexture=nI(JG,r.x,r.y,r.z);var n=e.getHandle("force_over_time_tex0"),s=en.getBindingFromHandle(n);e.bindSampler(s,this._forceTexture.getGFXSampler()),e.bindTexture(s,this._forceTexture.getGFXTexture());var a=e.getHandle("u_force_space");e.setUniform(a,r.space);var o=e.getHandle("u_force_mode");e.setUniform(o,this._forceTexture.height)}var l=this._particleSystem._velocityOvertimeModule;if(i=l&&l.enable,this._defines.VELOCITY_OVER_TIME_MODULE_ENABLE=i,i){this._velocityTexture&&this._velocityTexture.destroy(),this._velocityTexture=function(t,e,i,r,n){for(var s=Math.max(iI(e),iI(i),iI(r),iI(n)),a=new Float32Array(128*s),o=[e,i,r,n],l=0;l<s;l++)for(var h=0;h<4;h++)for(var u=o[h],c=0,_=0,f=0;f<32;f++){var p=eI(u,.03225806451612903*f,l);_=(c+=p)/(f+1),a[4*f+h]=_}return rI(a,32,s)}(0,l.x,l.y,l.z,l.speedModifier);var h=e.getHandle("velocity_over_time_tex0"),u=en.getBindingFromHandle(h);e.bindSampler(u,this._velocityTexture.getGFXSampler()),e.bindTexture(u,this._velocityTexture.getGFXTexture());var c=e.getHandle("u_velocity_space");e.setUniform(c,l.space);var _=e.getHandle("u_velocity_mode");e.setUniform(_,this._velocityTexture.height)}var f=this._particleSystem._colorOverLifetimeModule;if(i=f&&f.enable,this._defines.COLOR_OVER_TIME_MODULE_ENABLE=i,i){this._colorTexture&&this._colorTexture.destroy(),this._colorTexture=function(t,e){for(var i=function(t){switch(t.mode){case lO.TwoColors:case lO.TwoGradients:return 2;default:return 1}}(e),r=new Uint8Array(t*i*4),n=1/(t-1),s=0,a=0;a<i;a++)for(var o=0;o<t;o++){var l=uO(e,n*o,a);r[s]=l.r,r[s+1]=l.g,r[s+2]=l.b,r[s+3]=l.a,s+=4}var h=new qe;return h.create(t,i,fr.RGBA8888),h.setFilters(_r.LINEAR,_r.LINEAR),h.setWrapMode(In.CLAMP_TO_EDGE,In.CLAMP_TO_EDGE),h.uploadData(r),h}(JG,f.color);var p=e.getHandle("color_over_time_tex0"),d=en.getBindingFromHandle(p);e.bindSampler(d,this._colorTexture.getGFXSampler()),e.bindTexture(d,this._colorTexture.getGFXTexture());var m=e.getHandle("u_color_mode");e.setUniform(m,this._colorTexture.height)}var y=this._particleSystem._rotationOvertimeModule;if(i=y&&y.enable,this._defines.ROTATION_OVER_TIME_MODULE_ENABLE=i,i){this._rotationTexture&&this._rotationTexture.destroy(),y.separateAxes?this._rotationTexture=nI(JG,y.x,y.y,y.z):this._rotationTexture=function(t,e){for(var i=iI(e),r=new Float32Array(128*i),n=0,s=0;s<i;s++)for(var a=0;a<32;a++){var o=eI(e,.03225806451612903*a,s);r[n+2]=o,n+=4}return rI(r,32,i)}(0,y.z);var g=e.getHandle("rotation_over_time_tex0"),v=en.getBindingFromHandle(g);e.bindSampler(v,this._rotationTexture.getGFXSampler()),e.bindTexture(v,this._rotationTexture.getGFXTexture());var b=e.getHandle("u_rotation_mode");e.setUniform(b,this._rotationTexture.height)}var S=this._particleSystem._sizeOvertimeModule;if(i=S&&S.enable,this._defines.SIZE_OVER_TIME_MODULE_ENABLE=i,i){this._sizeTexture&&this._sizeTexture.destroy(),S.separateAxes?this._sizeTexture=nI(JG,S.x,S.y,S.z,!0):this._sizeTexture=function(t,e){for(var i=iI(e),r=new Float32Array(128*i),n=0,s=0,a=0;a<i;a++){0;for(var o=0;o<32;o++){var l=eI(e,.03225806451612903*o,a);n=l,r[s]=n,r[s+1]=n,r[s+2]=n,s+=4}}return rI(r,32,i)}(0,S.size);var A=e.getHandle("size_over_time_tex0"),C=en.getBindingFromHandle(A);e.bindSampler(C,this._sizeTexture.getGFXSampler()),e.bindTexture(C,this._sizeTexture.getGFXTexture());var x=e.getHandle("u_size_mode");e.setUniform(x,this._sizeTexture.height)}var T=this._particleSystem._textureAnimationModule;if(i=T&&T.enable,this._defines.TEXTURE_ANIMATION_MODULE_ENABLE=i,i){this._animTexture&&this._animTexture.destroy(),this._animTexture=function(t,e,i){for(var r=Math.max(iI(e),iI(i)),n=new Float32Array(128*r),s=[e,i],a=0;a<r;a++)for(var o=0;o<2;o++)for(var l=s[o],h=0,u=0,c=0;c<32;c++){var _=eI(l,.03225806451612903*c,a);u=(h+=_)/(c+1),n[4*c+o]=u}return rI(n,32,r)}(0,T.startFrame,T.frameOverTime);var w=e.getHandle("texture_animation_tex0"),E=en.getBindingFromHandle(w);e.bindSampler(E,this._animTexture.getGFXSampler()),e.bindTexture(E,this._animTexture.getGFXTexture());var B=e.getHandle("u_anim_info");YG.x=this._animTexture.height,YG.y=T.numTilesX*T.numTilesY,YG.z=T.cycleCount,e.setUniform(B,YG)}},i.getParticleCount=function(){return this._particleNum},i.onMaterialModified=function(){this._inited&&this.updateMaterialParams()},i.onRebuildPSO=function(t,e){this._model&&0===t&&this._model.setSubModelMaterial(0,e)},i._setVertexAttrib=function(){switch(this._renderInfo.renderMode){case rF.StrecthedBillboard:this._vertAttrs=iz.slice();break;case rF.Mesh:this._vertAttrs=rz.slice();break;default:this._vertAttrs=iz.slice()}},i.updateMaterialParams=function(){if(this._particleSystem){var t=this._particleSystem,e=t.sharedMaterial;if(null!==e){var i=e._effectAsset._name;this._renderInfo.mainTexture=e.getProperty("mainTexture",0),-1===i.indexOf("particle-gpu")&&(this._renderInfo.mainTexture=e.getProperty("mainTexture",0),this._particleSystem.setMaterial(null,0))}null==t.sharedMaterial&&null==this._defaultMat&&(nz.parent=Ci.get("default-particle-gpu-material"),nz.owner=t,nz.subModelIdx=0,this._defaultMat=new Vr(nz),null!==this._renderInfo.mainTexture&&this._defaultMat.setProperty("mainTexture",this._renderInfo.mainTexture));var r=t.getMaterialInstance(0)||this._defaultMat;switch(t.node.getWorldMatrix(XG),t.scaleSpace){case iF.Local:t.node.getScale(this._node_scale);break;case iF.World:t.node.getWorldScale(this._node_scale)}t._simulationSpace===iF.World?this._defines.CC_USE_WORLD_SPACE=!0:this._defines.CC_USE_WORLD_SPACE=!1;var n=this._renderInfo.renderMode;n===rF.Billboard?this._defines.CC_RENDER_MODE=0:n===rF.StrecthedBillboard?(this._defines.CC_RENDER_MODE=1,this._frameTile_velLenScale.z=this._renderInfo.velocityScale,this._frameTile_velLenScale.w=this._renderInfo.lengthScale):n===rF.HorizontalBillboard?this._defines.CC_RENDER_MODE=2:n===rF.VerticalBillboard?this._defines.CC_RENDER_MODE=3:n===rF.Mesh?this._defines.CC_RENDER_MODE=4:console.warn("particle system renderMode "+n+" not support.");var s=t._textureAnimationModule;s&&s.enable&&dr.set(this._frameTile_velLenScale,s.numTilesX,s.numTilesY),this.initShaderUniform(r),r.recompileShaders(this._defines),this._model&&this._model.updateMaterial(r)}},e}(LG);function az(){var t=wr.root.device;return!!(t.capabilities.maxVertexTextureUnits>=8&&t.hasFeature(c.TEXTURE_FLOAT))||(He.warn("Maybe the device has restrictions on vertex textures or does not support float textures."),!1)}var oz,lz,hz,uz,cz,_z,fz,pz,dz,mz,yz,gz,vz,bz,Sz,Az,Cz,xz,Tz,wz,Ez,Bz,Dz,Mz,Pz,Rz,Iz,Oz,Fz,Lz,Vz,kz,Nz,Gz,zz,Uz,Hz,jz,Wz,Xz,Yz,qz,Jz,Kz,Zz,Qz,$z,tU,eU,iU,rU,nU,sU,aU,oU,lU,hU,uU,cU,_U,fU,pU,dU,mU,yU,gU,vU,bU,SU,AU,CU,xU,TU,wU,EU,BU,DU,MU,PU,RU,IU,OU,FU,LU,VU,kU,NU,GU,zU,UU,HU,jU,WU,XU,YU,qU,JU,KU,ZU,QU,$U,tH,eH,iH,rH,nH,sH,aH,oH,lH,hH,uH,cH,_H,fH,pH,dH,mH,yH,gH,vH,bH,SH,AH,CH,xH,TH,wH,EH,BH,DH,MH,PH,RH,IH,OH,FH,LH,VH,kH,NH,GH,zH,UH,HH,jH,WH,XH,YH,qH,JH,KH,ZH,QH,$H,tj,ej,ij,rj,nj,sj,aj,oj,lj,hj,uj,cj,_j,fj,pj,dj,mj,yj,gj,vj,bj,Sj,Aj,Cj,xj,Tj,wj,Ej,Bj,Dj,Mj,Pj,Rj,Ij,Oj,Fj,Lj,Vj,kj,Nj,Gj,zj,Uj,Hj,jj,Wj,Xj,Yj,qj=(sG=ri("cc.ParticleSystemRenderer"),aG=bi(rF),oG=Mr(),lG=Di(),hG=Mr(),uG=Di(),cG=Mr(),_G=Di(),fG=bi(rF),pG=bi(Na),dG=Mr(),mG=Di(),yG=bi(cr),gG=Mr(),vG=Di(),bG=bi(cr),SG=Mr(),AG=Di(),CG=Mr(),xG=Di(),sG((IG=function(){function t(){li(this,"_renderMode",EG,this),li(this,"_velocityScale",BG,this),li(this,"_lengthScale",DG,this),li(this,"_mesh",MG,this),li(this,"_mainTexture",PG,this),li(this,"_useGPU",RG,this),this._particleSystem=null}var e=t.prototype;return e.onInit=function(t){this._particleSystem=t;var e=this._useGPU&&az();this._particleSystem.processor=e?new sz(this):new WG(this),this._particleSystem.processor.onInit(t)},e._switchProcessor=function(){this._particleSystem&&(this._particleSystem.processor&&(this._particleSystem.processor.detachFromScene(),this._particleSystem.processor.clear(),this._particleSystem.processor=null),this._particleSystem.processor=this._useGPU?new sz(this):new WG(this),this._particleSystem.processor.onInit(this._particleSystem),this._particleSystem.processor.onEnable(),this._particleSystem.bindModule())},Pe(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){this._renderMode!==t&&(this._renderMode=t,this._particleSystem&&this._particleSystem.processor.updateRenderMode())}},{key:"velocityScale",get:function(){return this._velocityScale},set:function(t){this._velocityScale=t,this._particleSystem&&this._particleSystem.processor.updateMaterialParams()}},{key:"lengthScale",get:function(){return this._lengthScale},set:function(t){this._lengthScale=t,this._particleSystem&&this._particleSystem.processor.updateMaterialParams()}},{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh=t,this._particleSystem&&this._particleSystem.processor.setVertexAttributes()}},{key:"particleMaterial",get:function(){return this._particleSystem?this._particleSystem.getMaterial(0):null},set:function(t){this._particleSystem&&this._particleSystem.setMaterial(t,0)}},{key:"trailMaterial",get:function(){return this._particleSystem?this._particleSystem.getMaterial(1):null},set:function(t){this._particleSystem&&this._particleSystem.setMaterial(t,1)}},{key:"mainTexture",get:function(){return this._mainTexture},set:function(t){this._mainTexture=t}},{key:"useGPU",get:function(){return this._useGPU},set:function(t){this._useGPU!==t&&(az()?this._useGPU=t:this._useGPU=!1,this._switchProcessor())}}]),t}(),oi((wG=IG).prototype,"renderMode",[aG,oG,lG],Object.getOwnPropertyDescriptor(wG.prototype,"renderMode"),wG.prototype),oi(wG.prototype,"velocityScale",[hG,uG],Object.getOwnPropertyDescriptor(wG.prototype,"velocityScale"),wG.prototype),oi(wG.prototype,"lengthScale",[cG,_G],Object.getOwnPropertyDescriptor(wG.prototype,"lengthScale"),wG.prototype),EG=oi(wG.prototype,"_renderMode",[fG,_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return rF.Billboard}}),BG=oi(wG.prototype,"_velocityScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),DG=oi(wG.prototype,"_lengthScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),MG=oi(wG.prototype,"_mesh",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(wG.prototype,"mesh",[pG,dG,mG],Object.getOwnPropertyDescriptor(wG.prototype,"mesh"),wG.prototype),oi(wG.prototype,"particleMaterial",[yG,gG,vG],Object.getOwnPropertyDescriptor(wG.prototype,"particleMaterial"),wG.prototype),oi(wG.prototype,"trailMaterial",[bG,SG,AG],Object.getOwnPropertyDescriptor(wG.prototype,"trailMaterial"),wG.prototype),PG=oi(wG.prototype,"_mainTexture",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),RG=oi(wG.prototype,"_useGPU",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(wG.prototype,"useGPU",[CG,xG],Object.getOwnPropertyDescriptor(wG.prototype,"useGPU"),wG.prototype),TG=wG))||TG),Jj=Math.cos(qi(100)),Kj={position:new ii,velocity:new ii},Zj=new si,Qj=new Ri,$j=new ii,tW=new ii,eW=new Ui,iW=function(){function t(t){for(this.start=void 0,this.end=void 0,this.trailElements=void 0,this.start=-1,this.end=-1,this.trailElements=[];t--;)this.trailElements.push({position:new ii,lifetime:0,width:0,velocity:new ii,direction:0,color:new Ui})}var e=t.prototype;return e.getElement=function(t){return-1===this.start?null:(t<0&&(t=(t+this.trailElements.length)%this.trailElements.length),t>=this.trailElements.length&&(t%=this.trailElements.length),this.trailElements[t])},e.addElement=function(){if(0===this.trailElements.length)return null;if(-1===this.start)return this.start=0,this.end=1,this.trailElements[0];this.start===this.end&&(this.trailElements.splice(this.end,0,{position:new ii,lifetime:0,width:0,velocity:new ii,direction:0,color:new Ui}),this.start++,this.start%=this.trailElements.length);var t=this.end++;return this.end%=this.trailElements.length,this.trailElements[t]},e.iterateElement=function(t,e,i,r){for(var n=this.start>=this.end?this.end+this.trailElements.length:this.end,s=this.start;s<n;s++)e(t,this.trailElements[s%this.trailElements.length],i,r)&&(this.start++,this.start%=this.trailElements.length);this.start===n&&(this.start=-1,this.end=-1)},e.count=function(){return this.start<this.end?this.end-this.start:this.trailElements.length+this.end-this.start},e.clear=function(){this.start=-1,this.end=-1},t}(),rW=(oz=ri("cc.TrailModule"),lz=Mr(),hz=bi(oF),uz=Mr(),cz=Di(),_z=bi(tI),fz=Mr(),pz=Di(),dz=Mr(),mz=Di(),yz=bi(iF),gz=Mr(),vz=Di(),bz=bi(lF),Sz=Mr(),Az=Di(),Cz=Mr(),xz=Di(),Tz=bi(tI),wz=Mr(),Ez=Di(),Bz=Mr(),Dz=Di(),Mz=bi(hO),Pz=Mr(),Rz=Di(),Iz=bi(hO),Oz=Mr(),Fz=Di(),Lz=bi(iF),oz((Qz=function(){function t(){li(this,"_enable",Nz,this),li(this,"mode",Gz,this),li(this,"lifeTime",zz,this),li(this,"_minParticleDistance",Uz,this),li(this,"existWithParticles",Hz,this),li(this,"textureMode",jz,this),li(this,"widthFromParticle",Wz,this),li(this,"widthRatio",Xz,this),li(this,"colorFromParticle",Yz,this),li(this,"colorOverTrail",qz,this),li(this,"colorOvertime",Jz,this),li(this,"_space",Kz,this),li(this,"_particleSystem",Zz,this),this._minSquaredDistance=0,this._vertSize=void 0,this._trailNum=0,this._trailLifetime=0,this.vbOffset=0,this.ibOffset=0,this._trailSegments=null,this._particleTrail=void 0,this._trailModel=null,this._iaInfo=void 0,this._iaInfoBuffer=null,this._subMeshData=null,this._vertAttrs=void 0,this._vbF32=null,this._vbUint32=null,this._iBuffer=null,this._needTransform=!1,this._material=null,this._iaInfo=new lt([new at]),this._vertAttrs=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RGBA32F),new St(Ut.ATTR_TEX_COORD1,_.RGB32F),new St(Ut.ATTR_COLOR,_.RGBA8,!0)],this._vertSize=0;for(var t,e=Fe(this._vertAttrs);!(t=e()).done;){var i=t.value;this._vertSize+=Ht[i.format].size}this._particleTrail=new Map}var i=t.prototype;return i.onInit=function(t){this._particleSystem=t,this.minParticleDistance=this._minParticleDistance;for(var i=0,r=t.startLifetime.getMax(),n=t.rateOverTime.getMax(),s=t.duration,a=0,o=t.bursts.length;a<o;a++)i+=t.bursts[a].getMaxCount(t)*Math.ceil(r/s);this._trailNum=Math.ceil(r*this.lifeTime.getMax()*60*(n*s+i)),this._trailSegments=new e((function(){return new iW(10)}),Math.ceil(n*s)),this._enable&&(this.enable=this._enable)},i.onEnable=function(){this._attachToScene()},i.onDisable=function(){this._particleTrail.clear(),this._detachFromScene()},i._attachToScene=function(){this._trailModel&&(this._trailModel.scene&&this._detachFromScene(),this._particleSystem._getRenderScene().addModel(this._trailModel))},i._detachFromScene=function(){this._trailModel&&this._trailModel.scene&&this._trailModel.scene.removeModel(this._trailModel)},i.destroy=function(){this.destroySubMeshData(),this._trailModel&&(wr.root.destroyModel(this._trailModel),this._trailModel=null),this._trailSegments&&(this._trailSegments.destroy((function(t){t.trailElements.length=0})),this._trailSegments=null)},i.play=function(){this._trailModel&&this._enable&&(this._trailModel.enabled=!0)},i.clear=function(){if(this.enable){for(var t=this._particleTrail.values(),e=t.next();!e.done;)e.value.clear(),e=t.next();this._particleTrail.clear(),this.updateRenderData(),this._trailModel&&(this._trailModel.enabled=!1)}},i.updateMaterial=function(){this._particleSystem&&(this._material=this._particleSystem.getMaterialInstance(1)||this._particleSystem.processor._defaultTrailMat,this._trailModel&&this._trailModel.setSubModelMaterial(0,this._material))},i.update=function(){this._trailLifetime=this.lifeTime.evaluate(this._particleSystem._time,1),this.space===iF.World&&this._particleSystem._simulationSpace===iF.Local?(this._needTransform=!0,this._particleSystem.node.getWorldMatrix(Qj),this._particleSystem.node.getWorldRotation(Zj)):this._needTransform=!1},i.animate=function(t,e){if(this._trailSegments){var i=this._particleTrail.get(t);if(!i)return i=this._trailSegments.alloc(),void this._particleTrail.set(t,i);var r=i.getElement(i.end-1);if(this._needTransform?ii.transformMat4($j,t.position,Qj):ii.copy($j,t.position),!(r&&(i.iterateElement(this,this._updateTrailElement,t,e),ii.squaredDistance(r.position,$j)<this._minSquaredDistance))&&(r=i.addElement())){ii.copy(r.position,$j),r.lifetime=0,this.widthFromParticle?r.width=t.size.x*this.widthRatio.evaluate(0,1):r.width=this.widthRatio.evaluate(0,1);var n=i.count();if(2===n){var s=i.getElement(i.end-2);ii.subtract(s.velocity,r.position,s.position)}else if(n>2){var a=i.getElement(i.end-2),o=i.getElement(i.end-3);ii.subtract($j,o.position,a.position),ii.subtract(tW,r.position,a.position),ii.subtract(a.velocity,tW,$j),ii.equals(ii.ZERO,a.velocity)&&ii.copy(a.velocity,$j),ii.normalize(a.velocity,a.velocity),this._checkDirectionReverse(a,o)}this.colorFromParticle?r.color.set(t.color):r.color.set(this.colorOvertime.evaluate(0,1))}}},i.removeParticle=function(t){var e=this._particleTrail.get(t);e&&this._trailSegments&&(e.clear(),this._trailSegments.free(e),this._particleTrail.delete(t))},i.updateRenderData=function(){this.vbOffset=0,this.ibOffset=0;for(var t,e=Fe(this._particleTrail.keys());!(t=e()).done;){var i=t.value,r=this._particleTrail.get(i);if(-1!==r.start){var n=4*this.vbOffset/this._vertSize,s=r.start>=r.end?r.end+r.trailElements.length:r.end,a=s-r.start,o=1/a,l=r.trailElements[r.start];this._fillVertexBuffer(l,this.colorOverTrail.evaluate(1,1),n,1,0,4);for(var h=r.start+1;h<s;h++){var u=r.trailElements[h%r.trailElements.length],c=h-r.start;this._fillVertexBuffer(u,this.colorOverTrail.evaluate(1-c/a,1),n,1-c*o,c,5)}if(this._needTransform?ii.transformMat4(Kj.position,i.position,Qj):ii.copy(Kj.position,i.position),1===a||2===a){var _=r.getElement(r.end-1);ii.subtract(_.velocity,Kj.position,_.position),this._vbF32[this.vbOffset-this._vertSize/4-4]=_.velocity.x,this._vbF32[this.vbOffset-this._vertSize/4-3]=_.velocity.y,this._vbF32[this.vbOffset-this._vertSize/4-2]=_.velocity.z,this._vbF32[this.vbOffset-4]=_.velocity.x,this._vbF32[this.vbOffset-3]=_.velocity.y,this._vbF32[this.vbOffset-2]=_.velocity.z,ii.subtract(Kj.velocity,Kj.position,_.position),this._checkDirectionReverse(Kj,_)}else if(a>2){var f=r.getElement(r.end-1),p=r.getElement(r.end-2);ii.subtract($j,p.position,f.position),ii.subtract(tW,Kj.position,f.position),ii.normalize($j,$j),ii.normalize(tW,tW),ii.subtract(f.velocity,tW,$j),ii.normalize(f.velocity,f.velocity),this._checkDirectionReverse(f,p),this.vbOffset-=this._vertSize/4*2,this.ibOffset-=6,this._fillVertexBuffer(f,this.colorOverTrail.evaluate(o,1),n,o,a-1,5),ii.subtract(Kj.velocity,Kj.position,f.position),ii.normalize(Kj.velocity,Kj.velocity),this._checkDirectionReverse(Kj,f)}this.widthFromParticle?Kj.width=i.size.x*this.widthRatio.evaluate(0,1):Kj.width=this.widthRatio.evaluate(0,1),Kj.color=i.color,ii.equals(Kj.velocity,ii.ZERO)?this.ibOffset-=3:this._fillVertexBuffer(Kj,this.colorOverTrail.evaluate(0,1),n,0,a,1)}}this._trailModel.enabled=this.ibOffset>0},i.updateIA=function(t){var e=this._trailModel&&this._trailModel.subModels;if(e&&e.length>0){var i=e[0];i.inputAssembler.vertexBuffers[0].update(this._vbF32),i.inputAssembler.indexBuffer.update(this._iBuffer),this._iaInfo.drawInfos[0].firstIndex=0,this._iaInfo.drawInfos[0].indexCount=t,this._iaInfoBuffer.update(this._iaInfo)}},i.beforeRender=function(){this.updateIA(this.ibOffset)},i._createModel=function(){this._trailModel||(this._trailModel=He.director.root.createModel(mi))},i.rebuild=function(){var t=wr.root.device,e=t.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.HOST|g.DEVICE,this._vertSize*(this._trailNum+1)*2,this._vertSize)),i=new ArrayBuffer(this._vertSize*(this._trailNum+1)*2);this._vbF32=new Float32Array(i),this._vbUint32=new Uint32Array(i),e.update(i);var r=t.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.HOST|g.DEVICE,6*this._trailNum*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));this._iBuffer=new Uint16Array(6*this._trailNum),r.update(this._iBuffer),this._iaInfoBuffer=t.createBuffer(new nt(d.INDIRECT,g.HOST|g.DEVICE,Yt,Yt)),this._iaInfo.drawInfos[0].vertexCount=2*(this._trailNum+1),this._iaInfo.drawInfos[0].indexCount=6*this._trailNum,this._iaInfoBuffer.update(this._iaInfo),this._subMeshData=new ui([e],this._vertAttrs,F.TRIANGLE_LIST,r,this._iaInfoBuffer);var n=this._trailModel;n&&(n.node=n.transform=this._particleSystem.node,n.visFlags=this._particleSystem.visibility,n.initSubModel(0,this._subMeshData,this._material),n.enabled=!0)},i._updateTrailElement=function(t,e,i,r){return e.lifetime+=r,t.colorFromParticle?(e.color.set(i.color),e.color.multiply(t.colorOvertime.evaluate(1-i.remainingLifetime/i.startLifetime,1))):e.color.set(t.colorOvertime.evaluate(1-i.remainingLifetime/i.startLifetime,1)),t.widthFromParticle?e.width=i.size.x*t.widthRatio.evaluate(e.lifetime/t._trailLifetime,1):e.width=t.widthRatio.evaluate(e.lifetime/t._trailLifetime,1),e.lifetime>t._trailLifetime},i._fillVertexBuffer=function(t,e,i,r,n,s){this._vbF32[this.vbOffset++]=t.position.x,this._vbF32[this.vbOffset++]=t.position.y,this._vbF32[this.vbOffset++]=t.position.z,this._vbF32[this.vbOffset++]=t.direction,this._vbF32[this.vbOffset++]=t.width,this._vbF32[this.vbOffset++]=r,this._vbF32[this.vbOffset++]=0,this._vbF32[this.vbOffset++]=t.velocity.x,this._vbF32[this.vbOffset++]=t.velocity.y,this._vbF32[this.vbOffset++]=t.velocity.z,eW.set(t.color),eW.multiply(e),this._vbUint32[this.vbOffset++]=eW._val,this._vbF32[this.vbOffset++]=t.position.x,this._vbF32[this.vbOffset++]=t.position.y,this._vbF32[this.vbOffset++]=t.position.z,this._vbF32[this.vbOffset++]=1-t.direction,this._vbF32[this.vbOffset++]=t.width,this._vbF32[this.vbOffset++]=r,this._vbF32[this.vbOffset++]=1,this._vbF32[this.vbOffset++]=t.velocity.x,this._vbF32[this.vbOffset++]=t.velocity.y,this._vbF32[this.vbOffset++]=t.velocity.z,this._vbUint32[this.vbOffset++]=eW._val,1&s&&(this._iBuffer[this.ibOffset++]=i+2*n,this._iBuffer[this.ibOffset++]=i+2*n-1,this._iBuffer[this.ibOffset++]=i+2*n+1),4&s&&(this._iBuffer[this.ibOffset++]=i+2*n,this._iBuffer[this.ibOffset++]=i+2*n+1,this._iBuffer[this.ibOffset++]=i+2*n+2)},i._checkDirectionReverse=function(t,e){ii.dot(t.velocity,e.velocity)<Jj?t.direction=1-e.direction:t.direction=e.direction},i.destroySubMeshData=function(){this._subMeshData&&(this._subMeshData.destroy(),this._subMeshData=null)},Pe(t,[{key:"enable",get:function(){return this._enable},set:function(t){t===this._enable&&this._trailModel||(t&&!this._enable&&(this._enable=t,this._particleSystem.processor&&this._particleSystem.processor.updateTrailMaterial()),t&&!this._trailModel&&(this._createModel(),this.rebuild()),this._enable=t,this._trailModel&&(this._trailModel.enabled=t),t?this.onEnable():this.onDisable())}},{key:"minParticleDistance",get:function(){return this._minParticleDistance},set:function(t){this._minParticleDistance=t,this._minSquaredDistance=t*t}},{key:"space",get:function(){return this._space},set:function(t){this._space=t;var e=this._particleSystem;e&&e.processor&&e.processor.updateTrailMaterial()}}]),t}(),oi((kz=Qz).prototype,"enable",[lz],Object.getOwnPropertyDescriptor(kz.prototype,"enable"),kz.prototype),Nz=oi(kz.prototype,"_enable",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Gz=oi(kz.prototype,"mode",[hz,_i,uz,cz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return oF.Particles}}),zz=oi(kz.prototype,"lifeTime",[_z,_i,fz,pz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Uz=oi(kz.prototype,"_minParticleDistance",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),oi(kz.prototype,"minParticleDistance",[dz,mz],Object.getOwnPropertyDescriptor(kz.prototype,"minParticleDistance"),kz.prototype),oi(kz.prototype,"space",[yz,gz,vz],Object.getOwnPropertyDescriptor(kz.prototype,"space"),kz.prototype),Hz=oi(kz.prototype,"existWithParticles",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),jz=oi(kz.prototype,"textureMode",[bz,_i,Sz,Az],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return lF.Stretch}}),Wz=oi(kz.prototype,"widthFromParticle",[_i,Cz,xz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Xz=oi(kz.prototype,"widthRatio",[Tz,_i,wz,Ez],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Yz=oi(kz.prototype,"colorFromParticle",[_i,Bz,Dz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),qz=oi(kz.prototype,"colorOverTrail",[Mz,_i,Pz,Rz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new hO}}),Jz=oi(kz.prototype,"colorOvertime",[Iz,_i,Oz,Fz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new hO}}),Kz=oi(kz.prototype,"_space",[Lz],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return iF.World}}),Zz=oi(kz.prototype,"_particleSystem",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Vz=kz))||Vz),nW=new Ri,sW=new si,aW=Object.getOwnPropertyDescriptor(Pi.prototype,"sharedMaterials"),oW=function(e){return t({ParticleSystem:e,ParticleSystemComponent:e}),e}(($z=ri("cc.ParticleSystem"),tU=wi(),eU=Bi(),iU=Ei(99),rU=Mr(),nU=Di(),sU=bi(hO),aU=Mr(),oU=Di(),lU=bi(iF),hU=Mr(),uU=Di(),cU=Mr(),_U=Di(),fU=gi("startSize"),pU=bi(tI),dU=Mr(),mU=Di(),yU=bi(tI),gU=Mr(),vU=Di(),bU=bi(tI),SU=Mr(),AU=Di(),CU=bi(tI),xU=Ni(),TU=Mr(),wU=Di(),EU=Mr(),BU=Di(),DU=bi(tI),MU=Ni(),PU=Mr(),RU=Di(),IU=bi(tI),OU=Ni(),FU=Mr(),LU=Di(),VU=bi(tI),kU=gi("startRotation"),NU=Ni(),GU=Mr(),zU=Di(),UU=bi(tI),HU=Mr(),jU=Di(),WU=bi(tI),XU=Mr(),YU=Di(),qU=Mr(),JU=Di(),KU=Mr(),ZU=Di(),QU=Mr(),$U=Di(),tH=bi(iF),eH=Mr(),iH=Di(),rH=Mr(),nH=Di(),sH=Mr(),aH=Di(),oH=bi(tI),lH=Ni(),hH=Mr(),uH=Di(),cH=bi(tI),_H=Mr(),fH=Di(),pH=bi(tI),dH=Mr(),mH=Di(),yH=bi([$N]),gH=Mr(),vH=Di(),bH=Mi(),SH=bi(cr),AH=Ir(),CH=bi(hF),xH=bi(hF),TH=Mr(),wH=Di(),EH=bi(rG),BH=bi(rG),DH=Mr(),MH=Di(),PH=bi(WN),RH=bi(WN),IH=Mr(),OH=Di(),FH=bi(QN),LH=bi(QN),VH=Mr(),kH=Di(),NH=bi(wL),GH=bi(wL),zH=Mr(),UH=Di(),HH=bi(ML),jH=bi(ML),WH=Mr(),XH=Di(),YH=bi(jN),qH=bi(jN),JH=Mr(),KH=Di(),ZH=bi(JN),QH=bi(JN),$H=Mr(),tj=Di(),ej=bi(rW),ij=bi(rW),rj=Mr(),nj=Di(),sj=bi(qj),aj=Mr(),oj=Di(),lj=Mr(),hj=Di(),$z(uj=tU(uj=eU(uj=iU(uj=Si((Yj=function(t){function e(){var e;return e=t.call(this)||this,li(e,"startColor",_j,hi(e)),li(e,"scaleSpace",fj,hi(e)),li(e,"startSize3D",pj,hi(e)),li(e,"startSizeX",dj,hi(e)),li(e,"startSizeY",mj,hi(e)),li(e,"startSizeZ",yj,hi(e)),li(e,"startSpeed",gj,hi(e)),li(e,"startRotation3D",vj,hi(e)),li(e,"startRotationX",bj,hi(e)),li(e,"startRotationY",Sj,hi(e)),li(e,"startRotationZ",Aj,hi(e)),li(e,"startDelay",Cj,hi(e)),li(e,"startLifetime",xj,hi(e)),li(e,"duration",Tj,hi(e)),li(e,"loop",wj,hi(e)),li(e,"simulationSpeed",Ej,hi(e)),li(e,"playOnAwake",Bj,hi(e)),li(e,"gravityModifier",Dj,hi(e)),li(e,"rateOverTime",Mj,hi(e)),li(e,"rateOverDistance",Pj,hi(e)),li(e,"bursts",Rj,hi(e)),li(e,"_colorOverLifetimeModule",Ij,hi(e)),li(e,"_shapeModule",Oj,hi(e)),li(e,"_sizeOvertimeModule",Fj,hi(e)),li(e,"_velocityOvertimeModule",Lj,hi(e)),li(e,"_forceOvertimeModule",Vj,hi(e)),li(e,"_limitVelocityOvertimeModule",kj,hi(e)),li(e,"_rotationOvertimeModule",Nj,hi(e)),li(e,"_textureAnimationModule",Gj,hi(e)),li(e,"_trailModule",zj,hi(e)),li(e,"renderer",Uj,hi(e)),li(e,"enableCulling",Hj,hi(e)),e._isPlaying=void 0,e._isPaused=void 0,e._isStopped=void 0,e._isEmitting=void 0,e._time=void 0,e._emitRateTimeCounter=void 0,e._emitRateDistanceCounter=void 0,e._oldWPos=void 0,e._curWPos=void 0,e._customData1=void 0,e._customData2=void 0,e._subEmitters=void 0,li(e,"_prewarm",jj,hi(e)),li(e,"_capacity",Wj,hi(e)),li(e,"_simulationSpace",Xj,hi(e)),e.processor=null,e.rateOverTime.constant=10,e.startLifetime.constant=5,e.startSizeX.constant=1,e.startSpeed.constant=5,e._isPlaying=!1,e._isPaused=!1,e._isStopped=!0,e._isEmitting=!1,e._time=0,e._emitRateTimeCounter=0,e._emitRateDistanceCounter=0,e._oldWPos=new ii,e._curWPos=new ii,e._customData1=new dr,e._customData2=new dr,e._subEmitters=[],e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this.renderer.onInit(this),this._shapeModule&&this._shapeModule.onInit(this),this._trailModule&&this._trailModule.onInit(this),this.bindModule(),this._resetPosition()},i._onMaterialModified=function(t,e){this.processor.onMaterialModified(t,e)},i._onRebuildPSO=function(t,e){this.processor.onRebuildPSO(t,e)},i._collectModels=function(){return this._models.length=0,this._models.push(this.processor._model),this._trailModule&&this._trailModule.enable&&this._trailModule._trailModel&&this._models.push(this._trailModule._trailModel),this._models},i._attachToScene=function(){this.processor.attachToScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._attachToScene()},i._detachFromScene=function(){this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene()},i.bindModule=function(){this._colorOverLifetimeModule&&this._colorOverLifetimeModule.bindTarget(this.processor),this._sizeOvertimeModule&&this._sizeOvertimeModule.bindTarget(this.processor),this._rotationOvertimeModule&&this._rotationOvertimeModule.bindTarget(this.processor),this._forceOvertimeModule&&this._forceOvertimeModule.bindTarget(this.processor),this._limitVelocityOvertimeModule&&this._limitVelocityOvertimeModule.bindTarget(this.processor),this._velocityOvertimeModule&&this._velocityOvertimeModule.bindTarget(this.processor),this._textureAnimationModule&&this._textureAnimationModule.bindTarget(this.processor)},i.play=function(){this._isPaused&&(this._isPaused=!1),this._isStopped&&(this._isStopped=!1),this._isPlaying=!0,this._isEmitting=!0,this._resetPosition(),this._prewarm&&this._prewarmSystem(),this._trailModule&&this._trailModule.play()},i.pause=function(){this._isStopped?console.warn("pause(): particle system is already stopped."):(this._isPlaying&&(this._isPlaying=!1),this._isPaused=!0)},i.stop=function(){(this._isPlaying||this._isPaused)&&this.clear(),this._isPlaying&&(this._isPlaying=!1),this._isPaused&&(this._isPaused=!1),this._time=0,this._emitRateTimeCounter=0,this._emitRateDistanceCounter=0,this._isStopped=!0},i.clear=function(){this.enabledInHierarchy&&(this.processor.clear(),this._trailModule&&this._trailModule.clear())},i.getParticleCount=function(){return this.processor.getParticleCount()},i.setCustomData1=function(t,e){dr.set(this._customData1,t,e)},i.setCustomData2=function(t,e){dr.set(this._customData2,t,e)},i.onDestroy=function(){He.director.off(He.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.processor.onDestroy(),this._trailModule&&this._trailModule.destroy()},i.onEnable=function(){He.director.on(He.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.playOnAwake&&this.play(),this.processor.onEnable(),this._trailModule&&this._trailModule.onEnable()},i.onDisable=function(){He.director.off(He.Director.EVENT_BEFORE_COMMIT,this.beforeRender,this),this.processor.onDisable(),this._trailModule&&this._trailModule.onDisable()},i.update=function(t){var e=t*this.simulationSpeed;this._isPlaying&&(this._time+=e,this._emit(e),0!==this.processor.updateParticles(e)||this._isEmitting||this.stop()),this.processor.updateRenderData(),this._trailModule&&this._trailModule.enable&&this._trailModule.updateRenderData()},i.beforeRender=function(){this._isPlaying&&(this.processor.beforeRender(),this._trailModule&&this._trailModule.enable&&this._trailModule.beforeRender())},i._onVisibilityChange=function(t){this.processor._model&&(this.processor._model.visFlags=t)},i.emit=function(t,e){var i=this._time/this.duration;this._simulationSpace===iF.World&&(this.node.getWorldMatrix(nW),this.node.getWorldRotation(sW));for(var r=0;r<t;++r){var n=this.processor.getFreeParticle();if(null===n)return;var s=Fn(kn(0,Un));this._shapeModule&&this._shapeModule.enable?this._shapeModule.emit(n):(ii.set(n.position,0,0,0),ii.copy(n.velocity,uF)),this._textureAnimationModule&&this._textureAnimationModule.enable&&this._textureAnimationModule.init(n),ii.multiplyScalar(n.velocity,n.velocity,this.startSpeed.evaluate(i,s)),this._simulationSpace===iF.World&&(ii.transformMat4(n.position,n.position,nW),ii.transformQuat(n.velocity,n.velocity,sW)),ii.copy(n.ultimateVelocity,n.velocity),this.startRotation3D?ii.set(n.rotation,this.startRotationX.evaluate(i,s),this.startRotationY.evaluate(i,s),this.startRotationZ.evaluate(i,s)):ii.set(n.rotation,0,0,this.startRotationZ.evaluate(i,s)),this.startSize3D?ii.set(n.startSize,this.startSizeX.evaluate(i,s),this.startSizeY.evaluate(i,s),this.startSizeZ.evaluate(i,s)):(ii.set(n.startSize,this.startSizeX.evaluate(i,s),1,1),n.startSize.y=n.startSize.x),ii.copy(n.size,n.startSize),n.startColor.set(this.startColor.evaluate(i,s)),n.color.set(n.startColor),n.startLifetime=this.startLifetime.evaluate(i,s)+e,n.remainingLifetime=n.startLifetime,n.randomSeed=kn(0,233280),this.processor.setNewParticle(n)}},i._prewarmSystem=function(){this.startDelay.mode=$R.Constant,this.startDelay.constant=0;for(var t=this.duration/1,e=0;e<t;++e)this._time+=1,this._emit(1),this.processor.updateParticles(1)},i._emit=function(t){var e=this.startDelay.evaluate(0,1);if(this._time>e){if(this._time>this.duration+e&&!this.loop)return void(this._isEmitting=!1);if(this._emitRateTimeCounter+=this.rateOverTime.evaluate(this._time/this.duration,1)*t,this._emitRateTimeCounter>1&&this._isEmitting){var i=Math.floor(this._emitRateTimeCounter);this._emitRateTimeCounter-=i,this.emit(i,t)}this.node.getWorldPosition(this._curWPos);var r=ii.distance(this._curWPos,this._oldWPos);if(ii.copy(this._oldWPos,this._curWPos),this._emitRateDistanceCounter+=r*this.rateOverDistance.evaluate(this._time/this.duration,1),this._emitRateDistanceCounter>1&&this._isEmitting){var n=Math.floor(this._emitRateDistanceCounter);this._emitRateDistanceCounter-=n,this.emit(n,t)}for(var s,a=Fe(this.bursts);!(s=a()).done;)s.value.update(this,t)}},i._resetPosition=function(){this.node.getWorldPosition(this._oldWPos),ii.copy(this._curWPos,this._oldWPos)},i.addSubEmitter=function(t){this._subEmitters.push(t)},i.removeSubEmitter=function(t){this._subEmitters.splice(this._subEmitters.indexOf(t),1)},i.addBurst=function(t){this.bursts.push(t)},i.removeBurst=function(t){this.bursts.splice(this.bursts.indexOf(t),1)},i._onBeforeSerialize=function(t){var e=this;return this.enableCulling?t.filter((function(t){return!tF.includes(t)||e[t]&&e[t].enable})):t},Pe(e,[{key:"capacity",get:function(){return this._capacity},set:function(t){this._capacity=Math.floor(t),this.processor&&this.processor._model&&this.processor._model.setCapacity(this._capacity)}},{key:"prewarm",get:function(){return this._prewarm},set:function(t){!0===t&&this.loop,this._prewarm=t}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(t){t!==this._simulationSpace&&(this._simulationSpace=t,this.processor&&(this.processor.updateMaterialParams(),this.processor.updateTrailMaterial()))}},{key:"sharedMaterials",get:function(){return aW.get.call(this)},set:function(t){aW.set.call(this,t)}},{key:"colorOverLifetimeModule",get:function(){return this._colorOverLifetimeModule},set:function(t){t&&(this._colorOverLifetimeModule=t)}},{key:"shapeModule",get:function(){return this._shapeModule},set:function(t){t&&(this._shapeModule=t)}},{key:"sizeOvertimeModule",get:function(){return this._sizeOvertimeModule},set:function(t){t&&(this._sizeOvertimeModule=t)}},{key:"velocityOvertimeModule",get:function(){return this._velocityOvertimeModule},set:function(t){t&&(this._velocityOvertimeModule=t)}},{key:"forceOvertimeModule",get:function(){return this._forceOvertimeModule},set:function(t){t&&(this._forceOvertimeModule=t)}},{key:"limitVelocityOvertimeModule",get:function(){return this._limitVelocityOvertimeModule},set:function(t){t&&(this._limitVelocityOvertimeModule=t)}},{key:"rotationOvertimeModule",get:function(){return this._rotationOvertimeModule},set:function(t){t&&(this._rotationOvertimeModule=t)}},{key:"textureAnimationModule",get:function(){return this._textureAnimationModule},set:function(t){t&&(this._textureAnimationModule=t)}},{key:"trailModule",get:function(){return this._trailModule},set:function(t){t&&(this._trailModule=t)}},{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isStopped",get:function(){return this._isStopped}},{key:"isEmitting",get:function(){return this._isEmitting}},{key:"time",get:function(){return this._time}}]),e}(Pi),oi((cj=Yj).prototype,"capacity",[rU,nU],Object.getOwnPropertyDescriptor(cj.prototype,"capacity"),cj.prototype),_j=oi(cj.prototype,"startColor",[sU,_i,aU,oU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new hO}}),fj=oi(cj.prototype,"scaleSpace",[lU,_i,hU,uU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return iF.Local}}),pj=oi(cj.prototype,"startSize3D",[_i,cU,_U],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),dj=oi(cj.prototype,"startSizeX",[fU,pU,dU,mU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),mj=oi(cj.prototype,"startSizeY",[yU,_i,gU,vU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),yj=oi(cj.prototype,"startSizeZ",[bU,_i,SU,AU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),gj=oi(cj.prototype,"startSpeed",[CU,_i,xU,TU,wU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),vj=oi(cj.prototype,"startRotation3D",[_i,EU,BU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),bj=oi(cj.prototype,"startRotationX",[DU,_i,MU,Gn,PU,RU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Sj=oi(cj.prototype,"startRotationY",[IU,_i,OU,Gn,FU,LU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Aj=oi(cj.prototype,"startRotationZ",[VU,kU,NU,Gn,GU,zU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Cj=oi(cj.prototype,"startDelay",[UU,_i,HU,jU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),xj=oi(cj.prototype,"startLifetime",[WU,_i,XU,YU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Tj=oi(cj.prototype,"duration",[_i,qU,JU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),wj=oi(cj.prototype,"loop",[_i,KU,ZU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(cj.prototype,"prewarm",[QU,$U],Object.getOwnPropertyDescriptor(cj.prototype,"prewarm"),cj.prototype),oi(cj.prototype,"simulationSpace",[tH,_i,eH,iH],Object.getOwnPropertyDescriptor(cj.prototype,"simulationSpace"),cj.prototype),Ej=oi(cj.prototype,"simulationSpeed",[_i,rH,nH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Bj=oi(cj.prototype,"playOnAwake",[_i,sH,aH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Dj=oi(cj.prototype,"gravityModifier",[oH,_i,lH,hH,uH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Mj=oi(cj.prototype,"rateOverTime",[cH,_i,_H,fH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Pj=oi(cj.prototype,"rateOverDistance",[pH,_i,dH,mH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tI}}),Rj=oi(cj.prototype,"bursts",[yH,_i,gH,vH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),oi(cj.prototype,"sharedMaterials",[pr,bH,SH,_i,AH],Object.getOwnPropertyDescriptor(cj.prototype,"sharedMaterials"),cj.prototype),Ij=oi(cj.prototype,"_colorOverLifetimeModule",[CH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"colorOverLifetimeModule",[xH,TH,wH],Object.getOwnPropertyDescriptor(cj.prototype,"colorOverLifetimeModule"),cj.prototype),Oj=oi(cj.prototype,"_shapeModule",[EH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"shapeModule",[BH,DH,MH],Object.getOwnPropertyDescriptor(cj.prototype,"shapeModule"),cj.prototype),Fj=oi(cj.prototype,"_sizeOvertimeModule",[PH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"sizeOvertimeModule",[RH,IH,OH],Object.getOwnPropertyDescriptor(cj.prototype,"sizeOvertimeModule"),cj.prototype),Lj=oi(cj.prototype,"_velocityOvertimeModule",[FH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"velocityOvertimeModule",[LH,VH,kH],Object.getOwnPropertyDescriptor(cj.prototype,"velocityOvertimeModule"),cj.prototype),Vj=oi(cj.prototype,"_forceOvertimeModule",[NH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"forceOvertimeModule",[GH,zH,UH],Object.getOwnPropertyDescriptor(cj.prototype,"forceOvertimeModule"),cj.prototype),kj=oi(cj.prototype,"_limitVelocityOvertimeModule",[HH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"limitVelocityOvertimeModule",[jH,WH,XH],Object.getOwnPropertyDescriptor(cj.prototype,"limitVelocityOvertimeModule"),cj.prototype),Nj=oi(cj.prototype,"_rotationOvertimeModule",[YH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"rotationOvertimeModule",[qH,JH,KH],Object.getOwnPropertyDescriptor(cj.prototype,"rotationOvertimeModule"),cj.prototype),Gj=oi(cj.prototype,"_textureAnimationModule",[ZH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"textureAnimationModule",[QH,$H,tj],Object.getOwnPropertyDescriptor(cj.prototype,"textureAnimationModule"),cj.prototype),zj=oi(cj.prototype,"_trailModule",[ej],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(cj.prototype,"trailModule",[ij,rj,nj],Object.getOwnPropertyDescriptor(cj.prototype,"trailModule"),cj.prototype),Uj=oi(cj.prototype,"renderer",[sj,_i,aj,oj],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qj}}),Hj=oi(cj.prototype,"enableCulling",[_i,lj,hj],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),jj=oi(cj.prototype,"_prewarm",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Wj=oi(cj.prototype,"_capacity",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 100}}),Xj=oi(cj.prototype,"_simulationSpace",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return iF.Local}}),uj=cj))||uj)||uj)||uj)||uj)||uj)),lW=t("ParticleUtils",function(){function t(){}return t.instantiate=function(t){return this.registeredSceneEvent||(wr.on(Er.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneUnload,this),this.registeredSceneEvent=!0),this.particleSystemPool.has(t._uuid)||this.particleSystemPool.set(t._uuid,new e((function(){return Hn(t)||new ur}),1)),this.particleSystemPool.get(t._uuid).alloc()},t.destroy=function(t){this.particleSystemPool.has(t._prefab.asset._uuid)&&(this.stop(t),this.particleSystemPool.get(t._prefab.asset._uuid).free(t))},t.play=function(t){for(var e,i=Fe(t.getComponentsInChildren(oW));!(e=i()).done;)e.value.play()},t.stop=function(t){for(var e,i=Fe(t.getComponentsInChildren(oW));!(e=i()).done;)e.value.stop()},t.onSceneUnload=function(){this.particleSystemPool.forEach((function(t){t.destroy((function(t){t.destroy()}))})),this.particleSystemPool.clear()},t}());lW.particleSystemPool=new Map,lW.registeredSceneEvent=!1,Oi($N.prototype,"Burst.prototype",[{name:"minCount"},{name:"maxCount"}]),He.ParticleSystemComponent=oW,Li.setClassAlias(oW,"cc.ParticleSystemComponent"),He.BillboardComponent=YR,Li.setClassAlias(YR,"cc.BillboardComponent"),He.LineComponent=YO,Li.setClassAlias(YO,"cc.LineComponent"),He.ParticleUtils=lW;var hW,uW,cW,_W,fW,pW,dW={id:"",select:function(t,e){He._global.CC_PHYSICS_BUILTIN="builtin"===t,He._global.CC_PHYSICS_CANNON="cannon.js"===t,He._global.CC_PHYSICS_AMMO="ammo.js"===t,console.info("[PHYSICS]: Using "+t+"."),dW.id=t,dW.wrapper=e,null!=t&&(dW.backend[t]=e)},wrapper:{},backend:{}};function mW(t,e){return t.setValue(e.x,e.y,e.z),t}function yW(t,e){return t.x=e.x(),t.y=e.y(),t.z=e.z(),t}function gW(t,e){return t.setValue(e.x,e.y,e.z,e.w),t}function vW(t,e){return t.x=e.x(),t.y=e.y(),t.z=e.z(),t.w=e.w(),t}function bW(t,e){delete jn.getCache(e)[jn.getPointer(t)]}function SW(t,e){for(var i=e.renderingSubMeshes.length,r=0;r<i;r++){var n=e.renderingSubMeshes[r],s=n.geometricInfo;if(s){var a=n.primitiveMode,o=s.positions,l=s.indices,h=new jn.btVector3,u=new jn.btVector3,c=new jn.btVector3;if(a===F.TRIANGLE_LIST)for(var _=l.length,f=0;f<_;f+=3){var p=3*l[f],d=3*l[f+1],m=3*l[f+2];h.setValue(o[p],o[p+1],o[p+2]),u.setValue(o[d],o[d+1],o[d+2]),c.setValue(o[m],o[m+1],o[m+2]),t.addTriangle(h,u,c)}else if(a===F.TRIANGLE_STRIP)for(var y=l.length-2,g=0,v=0;v<y;v+=1){var b=3*l[v-g],S=3*l[v+g+1],A=3*l[v+2];g=~g,h.setValue(o[b],o[b+1],o[b+2]),u.setValue(o[S],o[S+1],o[S+2]),c.setValue(o[A],o[A+1],o[A+2]),t.addTriangle(h,u,c)}else if(a===F.TRIANGLE_FAN){var C=l.length-1,x=3*l[0];h.setValue(o[x],o[x+1],o[x+2]);for(var T=1;T<C;T+=1){var w=3*l[T],E=3*l[T+1];u.setValue(o[w],o[w+1],o[w+2]),c.setValue(o[E],o[E+1],o[E+2]),t.addTriangle(h,u,c)}}jn.destroy(h),jn.destroy(u),jn.destroy(c)}}return t}!function(t){t[t.DYNAMIC=1]="DYNAMIC",t[t.STATIC=2]="STATIC",t[t.KINEMATIC=4]="KINEMATIC"}(hW||(hW=t("ERigidBodyType",{}))),yi(hW),function(t){t[t.X_AXIS=0]="X_AXIS",t[t.Y_AXIS=1]="Y_AXIS",t[t.Z_AXIS=2]="Z_AXIS"}(uW||(uW=t("EAxisDirection",{}))),yi(uW),function(t){t[t.VERTEX=1]="VERTEX",t[t.LINE=2]="LINE",t[t.TRIANGLE=3]="TRIANGLE",t[t.TETRAHEDRON=4]="TETRAHEDRON"}(cW||(cW={})),yi(cW),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CAPSULE=2]="CAPSULE",t[t.CYLINDER=3]="CYLINDER",t[t.CONE=4]="CONE",t[t.MESH=5]="MESH",t[t.PLANE=6]="PLANE",t[t.SIMPLEX=7]="SIMPLEX",t[t.TERRAIN=8]="TERRAIN"}(_W||(_W={})),yi(_W),function(t){t[t.POINT_TO_POINT=0]="POINT_TO_POINT",t[t.HINGE=1]="HINGE",t[t.CONE_TWIST=2]="CONE_TWIST"}(fW||(fW={})),yi(fW),function(t){t[t.DEFAULT=1]="DEFAULT"}(pW||(pW={})),yi(pW);var AW,CW=function(){return 0},xW={impl:null,setGravity:CW,setAllowSleep:CW,setDefaultMaterial:CW,step:CW,syncAfterEvents:CW,syncSceneToPhysics:CW,raycast:CW,raycastClosest:CW,emitEvents:CW,destroy:CW};function TW(t,e){return!He.GAME_VIEW&&null==t&&(dW.id?Ue(dW.id+" physics does not support "+AW[e]):Re(9600),!0)}!function(t){t[t.World=0]="World",t[t.RigidBody=1]="RigidBody",t[t.BoxCollider=2]="BoxCollider",t[t.SphereCollider=3]="SphereCollider",t[t.CapsuleCollider=4]="CapsuleCollider",t[t.MeshCollider=5]="MeshCollider",t[t.CylinderCollider=6]="CylinderCollider",t[t.ConeCollider=7]="ConeCollider",t[t.TerrainCollider=8]="TerrainCollider",t[t.SimplexCollider=9]="SimplexCollider",t[t.PlaneCollider=10]="PlaneCollider",t[t.PointToPointConstraint=11]="PointToPointConstraint",t[t.HingeConstraint=12]="HingeConstraint",t[t.ConeTwistConstraint=13]="ConeTwistConstraint"}(AW||(AW={}));var wW={impl:null,rigidBody:null,isAwake:!1,isSleepy:!1,isSleeping:!1,initialize:CW,onEnable:CW,onDisable:CW,onDestroy:CW,setType:CW,setMass:CW,setLinearDamping:CW,setAngularDamping:CW,useGravity:CW,setLinearFactor:CW,setAngularFactor:CW,setAllowSleep:CW,wakeUp:CW,sleep:CW,clearState:CW,clearForces:CW,clearVelocity:CW,setSleepThreshold:CW,getSleepThreshold:CW,getLinearVelocity:CW,setLinearVelocity:CW,getAngularVelocity:CW,setAngularVelocity:CW,applyForce:CW,applyLocalForce:CW,applyImpulse:CW,applyLocalImpulse:CW,applyTorque:CW,applyLocalTorque:CW,setGroup:CW,getGroup:CW,addGroup:CW,removeGroup:CW,setMask:CW,getMask:CW,addMask:CW,removeMask:CW},EW={INITED:!1},BW={impl:null,collider:null,attachedRigidBody:null,initialize:CW,onLoad:CW,onEnable:CW,onDisable:CW,onDestroy:CW,setGroup:CW,getGroup:CW,addGroup:CW,removeGroup:CW,setMask:CW,getMask:CW,addMask:CW,removeMask:CW,setMaterial:CW,setAsTrigger:CW,setCenter:CW,getAABB:CW,getBoundingSphere:CW,setSize:CW,setRadius:CW,setCylinderHeight:CW,setDirection:CW,setHeight:CW,setShapeType:CW,setVertices:CW,setMesh:CW,setTerrain:CW,setNormal:CW,setConstant:CW,updateEventListener:CW};var DW,MW,PW,RW,IW,OW,FW,LW,VW={INITED:!1},kW={impl:null,initialize:CW,onLoad:CW,onEnable:CW,onDisable:CW,onDestroy:CW,setEnableCollision:CW,setConnectedBody:CW,setPivotA:CW,setPivotB:CW,setAxis:CW};var NW=function(e){return t({PhysicsMaterial:e,PhysicMaterial:e}),e}(ri("cc.PhysicsMaterial")((LW=FW=function(t){function e(){var i;return(i=t.call(this)||this).id=void 0,li(i,"_friction",PW,hi(i)),li(i,"_rollingFriction",RW,hi(i)),li(i,"_spinningFriction",IW,hi(i)),li(i,"_restitution",OW,hi(i)),e.allMaterials.push(hi(i)),i.id=e._idCounter++,i._uuid||(i._uuid="pm_"+i.id),i}Me(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return t._friction=this._friction,t._restitution=this._restitution,t._rollingFriction=this._rollingFriction,t._spinningFriction=this._spinningFriction,t},i.destroy=function(){if(t.prototype.destroy.call(this)){var i=e.allMaterials.indexOf(this);return i>=0&&e.allMaterials.splice(i,1),!0}return!1},Pe(e,[{key:"friction",get:function(){return this._friction},set:function(t){Wn(this._friction,t)||(this._friction=t,this.emit("physics_material_update"))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){Wn(this._rollingFriction,t)||(this._rollingFriction=t,this.emit("physics_material_update"))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){Wn(this._spinningFriction,t)||(this._spinningFriction=t,this.emit("physics_material_update"))}},{key:"restitution",get:function(){return this._restitution},set:function(t){Wn(this._restitution,t)||(this._restitution=t,this.emit("physics_material_update"))}}]),e}(ai),FW.allMaterials=[],FW._idCounter=0,oi((MW=LW).prototype,"friction",[vi],Object.getOwnPropertyDescriptor(MW.prototype,"friction"),MW.prototype),oi(MW.prototype,"rollingFriction",[vi],Object.getOwnPropertyDescriptor(MW.prototype,"rollingFriction"),MW.prototype),oi(MW.prototype,"spinningFriction",[vi],Object.getOwnPropertyDescriptor(MW.prototype,"spinningFriction"),MW.prototype),oi(MW.prototype,"restitution",[vi],Object.getOwnPropertyDescriptor(MW.prototype,"restitution"),MW.prototype),PW=oi(MW.prototype,"_friction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.6}}),RW=oi(MW.prototype,"_rollingFriction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),IW=oi(MW.prototype,"_spinningFriction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),OW=oi(MW.prototype,"_restitution",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),DW=MW))||DW),GW=t("PhysicsRayResult",function(){function t(){this._hitPoint=new ii,this._hitNormal=new ii,this._distance=0,this._collider=null}var e=t.prototype;return e._assign=function(t,e,i,r){ii.copy(this._hitPoint,t),ii.copy(this._hitNormal,r),this._distance=e,this._collider=i},e.clone=function(){var e=new t;return ii.copy(e._hitPoint,this._hitPoint),ii.copy(e._hitNormal,this._hitNormal),e._distance=this._distance,e._collider=this._collider,e},Pe(t,[{key:"hitPoint",get:function(){return this._hitPoint}},{key:"distance",get:function(){return this._distance}},{key:"collider",get:function(){return this._collider}},{key:"hitNormal",get:function(){return this._hitNormal}}]),t}()),zW=function(t){if(1===t){for(var e=this,i=function(t){var i="_"+(1<<t);e[i]=0,e.updateArray=[],Object.defineProperty(e,1<<t,{get:function(){return this[i]},set:function(e){this[i]!==e&&(this[i]=e,this.updateArray.indexOf(t)<0&&this.updateArray.push(t))}})},r=0;r<32;r++)i(r);this._1=pW.DEFAULT}else{for(var n=0;n<32;n++)this[""+(1<<n)]=0;this[1]=pW.DEFAULT}};He.internal.PhysicsGroup=pW;var UW,HW,jW,WW,XW,YW,qW,JW,KW,ZW,QW,$W,tX,eX,iX,rX,nX,sX,aX,oX,lX,hX,uX,cX,_X,fX,pX,dX,mX,yX,gX,vX,bX,SX,AX,CX,xX,TX,wX,EX,BX,DX,MX,PX,RX=t("PhysicsSystem",function(t){function e(){var e;(e=t.call(this)||this).physicsWorld=void 0,e.raycastClosestResult=new GW,e.raycastResults=[],e.collisionMatrix=new zW(1),e.useNodeChains=void 0,e._enable=!0,e._allowSleep=!0,e._maxSubSteps=1,e._subStepCount=0,e._fixedTimeStep=1/60,e._autoSimulation=!0,e._accumulator=0,e._sleepThreshold=.1,e._gravity=new ii(0,-10,0),e._material=new NW,e.raycastOptions={group:-1,mask:-1,queryTrigger:!0,maxDistance:1e7},e.raycastResultPool=new i((function(){return new GW}),1);var r=Wr.config?Wr.config.physics:null;if(r&&r.physicsEngine){if(ii.copy(e._gravity,r.gravity),e._allowSleep=r.allowSleep,e._fixedTimeStep=r.fixedTimeStep,e._maxSubSteps=r.maxSubSteps,e._sleepThreshold=r.sleepThreshold,e.autoSimulation=r.autoSimulation,e.useNodeChains=r.useNodeChains,r.defaultMaterial&&(e._material.friction=r.defaultMaterial.friction,e._material.rollingFriction=r.defaultMaterial.rollingFriction,e._material.spinningFriction=r.defaultMaterial.spinningFriction,e._material.restitution=r.defaultMaterial.restitution),r.collisionMatrix)for(var n in r.collisionMatrix){var s=1<<parseInt(n);e.collisionMatrix[""+s]=r.collisionMatrix[n]}}else e.useNodeChains=!1;return e._material.on("physics_material_update",e._updateMaterial,hi(e)),e.physicsWorld=TW(dW.wrapper.PhysicsWorld,AW.World)?xW:new dW.wrapper.PhysicsWorld,e.physicsWorld.setGravity(e._gravity),e.physicsWorld.setAllowSleep(e._allowSleep),e.physicsWorld.setDefaultMaterial(e._material),e}Me(e,t);var r=e.prototype;return r.postUpdate=function(t){if(this._enable){if(this._autoSimulation){for(this._subStepCount=0,this._accumulator+=t,wr.emit(Er.EVENT_BEFORE_PHYSICS);this._subStepCount<this._maxSubSteps;){if(!(this._accumulator>this._fixedTimeStep)){this.physicsWorld.syncSceneToPhysics();break}this.physicsWorld.syncSceneToPhysics(),this.physicsWorld.step(this._fixedTimeStep),this._accumulator-=this._fixedTimeStep,this._subStepCount++,this.physicsWorld.emitEvents(),this.physicsWorld.syncAfterEvents()}wr.emit(Er.EVENT_AFTER_PHYSICS)}}else this.physicsWorld.syncSceneToPhysics()},r.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},r.step=function(t,e,i){this.physicsWorld.step(t,e,i)},r.syncSceneToPhysics=function(){this.physicsWorld.syncSceneToPhysics()},r.emitEvents=function(){this.physicsWorld.emitEvents()},r.raycast=function(t,e,i,r){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===r&&(r=!0),this.raycastResultPool.reset(),this.raycastResults.length=0,this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=r,this.physicsWorld.raycast(t,this.raycastOptions,this.raycastResultPool,this.raycastResults)},r.raycastClosest=function(t,e,i,r){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===r&&(r=!0),this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=r,this.physicsWorld.raycastClosest(t,this.raycastOptions,this.raycastClosestResult)},r._updateMaterial=function(){this.physicsWorld.setDefaultMaterial(this._material)},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this.physicsWorld.setAllowSleep(t)}},{key:"maxSubSteps",get:function(){return this._maxSubSteps},set:function(t){this._maxSubSteps=t}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=t}},{key:"gravity",get:function(){return this._gravity},set:function(t){this._gravity.set(t),this.physicsWorld.setGravity(t)}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(t){this._sleepThreshold=t}},{key:"autoSimulation",get:function(){return this._autoSimulation},set:function(t){this._autoSimulation=t}},{key:"defaultMaterial",get:function(){return this._material}}],[{key:"PHYSICS_NONE",get:function(){return!dW.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===dW.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===dW.id}},{key:"PHYSICS_AMMO",get:function(){return"ammo.js"===dW.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===dW.id}},{key:"PhysicsGroup",get:function(){return pW}},{key:"instance",get:function(){return e._instance}}]),e}(Xn));RX.ID="PHYSICS",RX._instance=void 0,wr.once(Er.EVENT_INIT,(function(){!function(){var t=Wr.config.physics;if(t){var e=t.collisionGroups;e instanceof Array&&(e.forEach((function(t){pW[t.name]=1<<t.index})),yi.update(pW))}var i=RX.instance;i&&(wr.unregisterSystem(i),i.physicsWorld.destroy());var r=new He.PhysicsSystem;He.PhysicsSystem._instance=r,wr.registerSystem(RX.ID,r,0)}()}));var IX,OX,FX,LX,VX,kX,NX,GX,zX,UX,HX,jX,WX,XX,YX,qX,JX,KX,ZX,QX,$X,tY,eY=function(e){return t({RigidBody:e,RigidBodyComponent:e}),e}((UW=ri("cc.RigidBody"),HW=wi(),jW=Bi(),WW=Ei(-1),XW=bi(RX.PhysicsGroup),YW=Mr(),qW=Di(),JW=bi(hW),KW=Mr(),ZW=Di(),QW=Mi(),$W=Mr(),tX=Di(),eX=Mi(),iX=Mr(),rX=Di(),nX=Mi(),sX=Mr(),aX=Di(),oX=Mi(),lX=Mr(),hX=Di(),uX=Mi(),cX=Mr(),_X=Di(),fX=Mi(),pX=Mr(),dX=Di(),mX=Mi(),yX=Mr(),gX=Di(),UW(vX=HW(vX=jW(vX=Si(vX=Br(vX=WW((PX=MX=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._body=null,li(e,"_group",SX,hi(e)),li(e,"_type",AX,hi(e)),li(e,"_mass",CX,hi(e)),li(e,"_allowSleep",xX,hi(e)),li(e,"_linearDamping",TX,hi(e)),li(e,"_angularDamping",wX,hi(e)),li(e,"_useGravity",EX,hi(e)),li(e,"_linearFactor",BX,hi(e)),li(e,"_angularFactor",DX,hi(e)),e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._body=TW(dW.wrapper.RigidBody,AW.RigidBody)?wW:new dW.wrapper.RigidBody,this._body.initialize(this)},i.onEnable=function(){this._body&&this._body.onEnable()},i.onDisable=function(){this._body&&this._body.onDisable()},i.onDestroy=function(){this._body&&this._body.onDestroy()},i.applyForce=function(t,e){this._assertOnLoadCalled&&this._body.applyForce(t,e)},i.applyLocalForce=function(t,e){this._assertOnLoadCalled&&this._body.applyLocalForce(t,e)},i.applyImpulse=function(t,e){this._assertOnLoadCalled&&this._body.applyImpulse(t,e)},i.applyLocalImpulse=function(t,e){this._assertOnLoadCalled&&this._body.applyLocalImpulse(t,e)},i.applyTorque=function(t){this._assertOnLoadCalled&&this._body.applyTorque(t)},i.applyLocalTorque=function(t){this._assertOnLoadCalled&&this._body.applyLocalTorque(t)},i.wakeUp=function(){this._assertOnLoadCalled&&this._body.wakeUp()},i.sleep=function(){this._assertOnLoadCalled&&this._body.sleep()},i.clearState=function(){this._assertOnLoadCalled&&this._body.clearState()},i.clearForces=function(){this._assertOnLoadCalled&&this._body.clearForces()},i.clearVelocity=function(){this._assertOnLoadCalled&&this._body.clearVelocity()},i.getLinearVelocity=function(t){this._assertOnLoadCalled&&this._body.getLinearVelocity(t)},i.setLinearVelocity=function(t){this._assertOnLoadCalled&&this._body.setLinearVelocity(t)},i.getAngularVelocity=function(t){this._assertOnLoadCalled&&this._body.getAngularVelocity(t)},i.setAngularVelocity=function(t){this._assertOnLoadCalled&&this._body.setAngularVelocity(t)},i.getGroup=function(){return this._assertOnLoadCalled?this._body.getGroup():0},i.setGroup=function(t){this._assertOnLoadCalled&&this._body.setGroup(t)},i.addGroup=function(t){this._assertOnLoadCalled&&this._body.addGroup(t)},i.removeGroup=function(t){this._assertOnLoadCalled&&this._body.removeGroup(t)},i.getMask=function(){return this._assertOnLoadCalled?this._body.getMask():0},i.setMask=function(t){this._assertOnLoadCalled&&this._body.setMask(t)},i.addMask=function(t){this._assertOnLoadCalled&&this._body.addMask(t)},i.removeMask=function(t){this._assertOnLoadCalled&&this._body.removeMask(t)},Pe(e,[{key:"group",get:function(){return this.getGroup()},set:function(t){this._group=t,this.getGroup()!==t&&this._body&&this._body.setGroup(t)}},{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._body&&this._body.setType(t))}},{key:"mass",get:function(){return this._mass},set:function(t){this._mass!==t&&(t=t<=0?1e-4:t,this._mass=t,this._body&&this._body.setMass(t))}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this._body&&this._body.setAllowSleep(t)}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._body&&this._body.setLinearDamping(t)}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._body&&this._body.setAngularDamping(t)}},{key:"useGravity",get:function(){return this._useGravity},set:function(t){this._useGravity=t,this._body&&this._body.useGravity(t)}},{key:"linearFactor",get:function(){return this._linearFactor},set:function(t){ii.copy(this._linearFactor,t),this._body&&this._body.setLinearFactor(this._linearFactor)}},{key:"angularFactor",get:function(){return this._angularFactor},set:function(t){ii.copy(this._angularFactor,t),this._body&&this._body.setAngularFactor(this._angularFactor)}},{key:"sleepThreshold",get:function(){return this._assertOnLoadCalled?this._body.getSleepThreshold():0},set:function(t){this._assertOnLoadCalled&&this._body.setSleepThreshold(t)}},{key:"isAwake",get:function(){return!!this._assertOnLoadCalled&&this._body.isAwake}},{key:"isSleepy",get:function(){return!!this._assertOnLoadCalled&&this._body.isSleepy}},{key:"isSleeping",get:function(){return!!this._assertOnLoadCalled&&this._body.isSleeping}},{key:"isStatic",get:function(){return this._type===hW.STATIC},set:function(t){t&&this.isStatic||!t&&!this.isStatic||(this.type=t?hW.STATIC:hW.DYNAMIC)}},{key:"isDynamic",get:function(){return this._type===hW.DYNAMIC},set:function(t){t&&this.isDynamic||!t&&!this.isDynamic||(this.type=t?hW.DYNAMIC:hW.KINEMATIC)}},{key:"isKinematic",get:function(){return this._type===hW.KINEMATIC},set:function(t){t&&this.isKinematic||!t&&!this.isKinematic||(this.type=t?hW.KINEMATIC:hW.DYNAMIC)}},{key:"body",get:function(){return this._body}},{key:"_assertOnLoadCalled",get:function(){var t=0===this._isOnLoadCalled;return t&&Ie("[Physics]: Please make sure that the node has been added to the scene"),!t}}]),e}(zi),MX.Type=hW,oi((bX=PX).prototype,"group",[XW,YW,qW],Object.getOwnPropertyDescriptor(bX.prototype,"group"),bX.prototype),oi(bX.prototype,"type",[JW,KW,ZW],Object.getOwnPropertyDescriptor(bX.prototype,"type"),bX.prototype),oi(bX.prototype,"mass",[QW,$W,tX],Object.getOwnPropertyDescriptor(bX.prototype,"mass"),bX.prototype),oi(bX.prototype,"allowSleep",[eX,iX,rX],Object.getOwnPropertyDescriptor(bX.prototype,"allowSleep"),bX.prototype),oi(bX.prototype,"linearDamping",[nX,sX,aX],Object.getOwnPropertyDescriptor(bX.prototype,"linearDamping"),bX.prototype),oi(bX.prototype,"angularDamping",[oX,lX,hX],Object.getOwnPropertyDescriptor(bX.prototype,"angularDamping"),bX.prototype),oi(bX.prototype,"useGravity",[uX,cX,_X],Object.getOwnPropertyDescriptor(bX.prototype,"useGravity"),bX.prototype),oi(bX.prototype,"linearFactor",[fX,pX,dX],Object.getOwnPropertyDescriptor(bX.prototype,"linearFactor"),bX.prototype),oi(bX.prototype,"angularFactor",[mX,yX,gX],Object.getOwnPropertyDescriptor(bX.prototype,"angularFactor"),bX.prototype),SX=oi(bX.prototype,"_group",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return RX.PhysicsGroup.DEFAULT}}),AX=oi(bX.prototype,"_type",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return hW.DYNAMIC}}),CX=oi(bX.prototype,"_mass",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),xX=oi(bX.prototype,"_allowSleep",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),TX=oi(bX.prototype,"_linearDamping",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),wX=oi(bX.prototype,"_angularDamping",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),EX=oi(bX.prototype,"_useGravity",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),BX=oi(bX.prototype,"_linearFactor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(1,1,1)}}),DX=oi(bX.prototype,"_angularFactor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(1,1,1)}}),vX=bX))||vX)||vX)||vX)||vX)||vX)||vX));eY||(eY=function(e){return t({RigidBody:e,RigidBodyComponent:e}),e}({}));var iY,rY,nY,sY,aY,oY,lY,hY,uY,cY=function(e){return t({Collider:e,ColliderComponent:e}),e}((IX=ri("cc.Collider"),OX=bi(eY),FX=Ir(),LX=Mr(),VX=Di(),kX=bi(NW),NX=Ir(),GX=Mr(),zX=Di(),UX=Mr(),HX=Di(),jX=bi(ii),WX=Mr(),XX=Di(),YX=bi(NW),IX((tY=$X=function(t){function e(e){var i;return(i=t.call(this)||this).type=void 0,i._shape=null,i._aabb=null,i._boundingSphere=null,i._isSharedMaterial=!0,i._needTriggerEvent=!1,i._needCollisionEvent=!1,li(i,"_material",KX,hi(i)),li(i,"_isTrigger",ZX,hi(i)),li(i,"_center",QX,hi(i)),i.type=e,i}Me(e,t);var i=e.prototype;return i.on=function(e,i,r,n){var s=t.prototype.on.call(this,e,i,r,n);return this._updateNeedEvent(e),s},i.off=function(e,i,r){t.prototype.off.call(this,e,i,r),this._updateNeedEvent()},i.once=function(e,i,r){var n=t.prototype.once.call(this,e,i,r);return this._updateNeedEvent(e),n},i.removeAll=function(e){t.prototype.removeAll.call(this,e),this._updateNeedEvent()},i.getGroup=function(){return this._assertOnLoadCalled?this._shape.getGroup():0},i.setGroup=function(t){this._assertOnLoadCalled&&this._shape.setGroup(t)},i.addGroup=function(t){this._assertOnLoadCalled&&this._shape.addGroup(t)},i.removeGroup=function(t){this._assertOnLoadCalled&&this._shape.removeGroup(t)},i.getMask=function(){return this._assertOnLoadCalled?this._shape.getMask():0},i.setMask=function(t){this._assertOnLoadCalled&&this._shape.setMask(t)},i.addMask=function(t){this._assertOnLoadCalled&&this._shape.addMask(t)},i.removeMask=function(t){this._assertOnLoadCalled&&this._shape.removeMask(t)},i.onLoad=function(){this.sharedMaterial=null==this._material?RX.instance.defaultMaterial:this._material,this._shape=function(t){return EW.INITED||(EW.INITED=!0,EW[_W.BOX]=function(){return TW(dW.wrapper.BoxShape,AW.BoxCollider)?BW:new dW.wrapper.BoxShape},EW[_W.SPHERE]=function(){return TW(dW.wrapper.SphereShape,AW.SphereCollider)?BW:new dW.wrapper.SphereShape},EW[_W.CAPSULE]=function(){return TW(dW.wrapper.CapsuleShape,AW.CapsuleCollider)?BW:new dW.wrapper.CapsuleShape},EW[_W.CYLINDER]=function(){return TW(dW.wrapper.CylinderShape,AW.CylinderCollider)?BW:new dW.wrapper.CylinderShape},EW[_W.CONE]=function(){return TW(dW.wrapper.ConeShape,AW.ConeCollider)?BW:new dW.wrapper.ConeShape},EW[_W.MESH]=function(){return TW(dW.wrapper.TrimeshShape,AW.MeshCollider)?BW:new dW.wrapper.TrimeshShape},EW[_W.TERRAIN]=function(){return TW(dW.wrapper.TerrainShape,AW.TerrainCollider)?BW:new dW.wrapper.TerrainShape},EW[_W.SIMPLEX]=function(){return TW(dW.wrapper.SimplexShape,AW.SimplexCollider)?BW:new dW.wrapper.SimplexShape},EW[_W.PLANE]=function(){return TW(dW.wrapper.PlaneShape,AW.PlaneCollider)?BW:new dW.wrapper.PlaneShape}),EW[t]()}(this.type),this._shape.initialize(this),this._shape.onLoad()},i.onEnable=function(){this._shape&&this._shape.onEnable()},i.onDisable=function(){this._shape&&this._shape.onDisable()},i.onDestroy=function(){this._shape&&(this._material&&this._material.off("physics_material_update",this._updateMaterial,this),this._shape.onDestroy()),this._boundingSphere&&this._boundingSphere.destroy()},i._updateMaterial=function(){this._shape&&this._shape.setMaterial(this._material)},i._updateNeedEvent=function(t){this.isValid&&(void 0!==t?("onCollisionEnter"!==t&&"onCollisionStay"!==t&&"onCollisionExit"!==t||(this._needCollisionEvent=!0),"onTriggerEnter"!==t&&"onTriggerStay"!==t&&"onTriggerExit"!==t||(this._needTriggerEvent=!0)):(this.hasEventListener("onTriggerEnter")||this.hasEventListener("onTriggerStay")||this.hasEventListener("onTriggerExit")||(this._needTriggerEvent=!1),this.hasEventListener("onCollisionEnter")||this.hasEventListener("onCollisionStay")||this.hasEventListener("onCollisionExit")||(this._needCollisionEvent=!1)),this._shape&&this._shape.updateEventListener())},Pe(e,[{key:"attachedRigidBody",get:function(){return t=this.node,(e=t.getComponent(eY))&&e.isValid?e:null;var t,e}},{key:"sharedMaterial",get:function(){return this._material},set:function(t){this.material=t}},{key:"material",get:function(){return this._isSharedMaterial&&null!=this._material&&(this._material.off("physics_material_update",this._updateMaterial,this),this._material=this._material.clone(),this._material.on("physics_material_update",this._updateMaterial,this),this._isSharedMaterial=!1),this._material},set:function(t){this._shape?(null!=t&&null!=this._material?this._material.id!==t.id&&(this._material.off("physics_material_update",this._updateMaterial,this),t.on("physics_material_update",this._updateMaterial,this),this._isSharedMaterial=!1,this._material=t):null!=t&&null==this._material?(t.on("physics_material_update",this._updateMaterial,this),this._material=t):null==t&&null!=this._material&&(this._material.off("physics_material_update",this._updateMaterial,this),this._material=t),this._updateMaterial()):this._material=t}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(t){this._isTrigger=t,this._shape&&this._shape.setAsTrigger(this._isTrigger)}},{key:"center",get:function(){return this._center},set:function(t){ii.copy(this._center,t),this._shape&&this._shape.setCenter(this._center)}},{key:"shape",get:function(){return this._shape}},{key:"worldBounds",get:function(){return null==this._aabb&&(this._aabb=new ni),this._shape&&this._shape.getAABB(this._aabb),this._aabb}},{key:"boundingSphere",get:function(){return null==this._boundingSphere&&(this._boundingSphere=new Jn),this._shape&&this._shape.getBoundingSphere(this._boundingSphere),this._boundingSphere}},{key:"needTriggerEvent",get:function(){return this._needTriggerEvent}},{key:"needCollisionEvent",get:function(){return this._needCollisionEvent}},{key:"_assertOnLoadCalled",get:function(){var t=0===this._isOnLoadCalled;return t&&Ie("[Physics]: Please make sure that the node has been added to the scene"),!t}}]),e}(Yn(zi)),$X.Type=_W,$X.Axis=uW,oi((JX=tY).prototype,"attachedRigidBody",[OX,qn,FX,LX,VX],Object.getOwnPropertyDescriptor(JX.prototype,"attachedRigidBody"),JX.prototype),oi(JX.prototype,"sharedMaterial",[kX,NX,GX,zX],Object.getOwnPropertyDescriptor(JX.prototype,"sharedMaterial"),JX.prototype),oi(JX.prototype,"isTrigger",[UX,HX],Object.getOwnPropertyDescriptor(JX.prototype,"isTrigger"),JX.prototype),oi(JX.prototype,"center",[jX,WX,XX],Object.getOwnPropertyDescriptor(JX.prototype,"center"),JX.prototype),KX=oi(JX.prototype,"_material",[YX],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ZX=oi(JX.prototype,"_isTrigger",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),QX=oi(JX.prototype,"_center",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),qX=JX))||qX));cY||(cY=function(e){return t({Collider:e,ColliderComponent:e}),e}({}));var _Y,fY,pY,dY,mY,yY,gY,vY,bY,SY,AY,CY,xY,TY,wY,EY,BY,DY,MY,PY,RY,IY,OY,FY,LY,VY,kY,NY,GY,zY,UY,HY,jY,WY,XY,YY,qY,JY,KY,ZY,QY,$Y,tq,eq,iq,rq,nq,sq,aq,oq,lq,hq,uq,cq,_q,fq,pq,dq,mq,yq,gq,vq,bq,Sq,Aq,Cq,xq,Tq,wq,Eq,Bq,Dq,Mq,Pq,Rq,Iq,Oq,Fq,Lq,Vq,kq,Nq,Gq,zq,Uq,Hq,jq,Wq,Xq,Yq,qq,Jq,Kq,Zq,Qq,$q,tJ,eJ,iJ,rJ,nJ,sJ,aJ,oJ,lJ,hJ,uJ,cJ,_J,fJ,pJ,dJ,mJ,yJ,gJ,vJ,bJ,SJ,AJ,CJ,xJ,TJ,wJ,EJ,BJ,DJ,MJ,PJ,RJ=function(e){return t({BoxCollider:e,BoxColliderComponent:e}),e}((iY=ri("cc.BoxCollider"),rY=wi(),nY=Bi(),sY=bi(ii),aY=Di(),iY(oY=rY(oY=nY(oY=Si((uY=function(t){function e(){var e;return e=t.call(this,_W.BOX)||this,li(e,"_size",hY,hi(e)),e}return Me(e,t),Pe(e,[{key:"size",get:function(){return this._size},set:function(t){ii.copy(this._size,t),this._shape&&this.shape.setSize(this._size)}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((lY=uY).prototype,"size",[sY,aY],Object.getOwnPropertyDescriptor(lY.prototype,"size"),lY.prototype),hY=oi(lY.prototype,"_size",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(1,1,1)}}),oY=lY))||oY)||oY)||oY)||oY)),IJ=function(e){return t({SphereCollider:e,SphereColliderComponent:e}),e}((_Y=ri("cc.SphereCollider"),fY=wi(),pY=Bi(),dY=Di(),_Y(mY=fY(mY=pY(mY=Si((vY=function(t){function e(){var e;return e=t.call(this,_W.SPHERE)||this,li(e,"_radius",gY,hi(e)),e}return Me(e,t),Pe(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius=t,this.shape.setRadius(this._radius)}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((yY=vY).prototype,"radius",[dY],Object.getOwnPropertyDescriptor(yY.prototype,"radius"),yY.prototype),gY=oi(yY.prototype,"_radius",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),mY=yY))||mY)||mY)||mY)||mY)),OJ=function(e){return t({CapsuleCollider:e,CapsuleColliderComponent:e}),e}((bY=ri("cc.CapsuleCollider"),SY=wi(),AY=Bi(),CY=Di(),xY=Di(),TY=bi(uW),wY=Di(),bY(EY=SY(EY=AY(EY=Si((RY=function(t){function e(){var e;return e=t.call(this,_W.CAPSULE)||this,li(e,"_radius",DY,hi(e)),li(e,"_cylinderHeight",MY,hi(e)),li(e,"_direction",PY,hi(e)),e}Me(e,t);var i=e.prototype;return i._getRadiusScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===uW.Y_AXIS?Math.abs(Kn(t.x,t.z)):this._direction===uW.X_AXIS?Math.abs(Kn(t.y,t.z)):Math.abs(Kn(t.x,t.y))},i._getHeightScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===uW.Y_AXIS?Math.abs(t.y):this._direction===uW.X_AXIS?Math.abs(t.x):Math.abs(t.z)},Pe(e,[{key:"radius",get:function(){return this._radius},set:function(t){t<0&&(t=0),this._radius=t,this.shape.setRadius(t)}},{key:"cylinderHeight",get:function(){return this._cylinderHeight},set:function(t){t<0&&(t=0),this._cylinderHeight=t,this.shape.setCylinderHeight(t)}},{key:"direction",get:function(){return this._direction},set:function(t){(t=Math.floor(t))<uW.X_AXIS||t>uW.Z_AXIS||(this._direction=t,this.shape.setDirection(t))}},{key:"height",get:function(){return 2*this._radius+this._cylinderHeight},set:function(t){var e=t-2*this._radius;e<0&&(e=0),this.cylinderHeight=e}},{key:"worldHeight",get:function(){return 2*this._radius*this._getRadiusScale()+this._cylinderHeight*this._getHeightScale()}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((BY=RY).prototype,"radius",[CY],Object.getOwnPropertyDescriptor(BY.prototype,"radius"),BY.prototype),oi(BY.prototype,"cylinderHeight",[xY],Object.getOwnPropertyDescriptor(BY.prototype,"cylinderHeight"),BY.prototype),oi(BY.prototype,"direction",[TY,wY],Object.getOwnPropertyDescriptor(BY.prototype,"direction"),BY.prototype),DY=oi(BY.prototype,"_radius",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),MY=oi(BY.prototype,"_cylinderHeight",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),PY=oi(BY.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return uW.Y_AXIS}}),EY=BY))||EY)||EY)||EY)||EY)),FJ=function(e){return t({CylinderCollider:e,CylinderColliderComponent:e}),e}((IY=ri("cc.CylinderCollider"),OY=wi(),FY=Bi(),LY=Di(),VY=Di(),kY=bi(uW),NY=Di(),IY(GY=OY(GY=FY(GY=Si((WY=function(t){function e(){var e;return e=t.call(this,_W.CYLINDER)||this,li(e,"_radius",UY,hi(e)),li(e,"_height",HY,hi(e)),li(e,"_direction",jY,hi(e)),e}return Me(e,t),Pe(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(t<0&&(t=0),this._radius=t,this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(t<0&&(t=0),this._height=t,this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<uW.X_AXIS||t>uW.Z_AXIS||(this._direction=t,this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((zY=WY).prototype,"radius",[LY],Object.getOwnPropertyDescriptor(zY.prototype,"radius"),zY.prototype),oi(zY.prototype,"height",[VY],Object.getOwnPropertyDescriptor(zY.prototype,"height"),zY.prototype),oi(zY.prototype,"direction",[kY,NY],Object.getOwnPropertyDescriptor(zY.prototype,"direction"),zY.prototype),UY=oi(zY.prototype,"_radius",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),HY=oi(zY.prototype,"_height",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),jY=oi(zY.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return uW.Y_AXIS}}),GY=zY))||GY)||GY)||GY)||GY)),LJ=t("ConeCollider",(XY=ri("cc.ConeCollider"),YY=wi(),qY=Bi(),JY=Di(),KY=Di(),ZY=bi(uW),QY=Di(),XY($Y=YY($Y=qY($Y=Si((nq=function(t){function e(){var e;return e=t.call(this,_W.CONE)||this,li(e,"_radius",eq,hi(e)),li(e,"_height",iq,hi(e)),li(e,"_direction",rq,hi(e)),e}return Me(e,t),Pe(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(t<0&&(t=0),this._radius=t,this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(t<0&&(t=0),this._height=t,this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<uW.X_AXIS||t>uW.Z_AXIS||(this._direction=t,this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((tq=nq).prototype,"radius",[JY],Object.getOwnPropertyDescriptor(tq.prototype,"radius"),tq.prototype),oi(tq.prototype,"height",[KY],Object.getOwnPropertyDescriptor(tq.prototype,"height"),tq.prototype),oi(tq.prototype,"direction",[ZY,QY],Object.getOwnPropertyDescriptor(tq.prototype,"direction"),tq.prototype),eq=oi(tq.prototype,"_radius",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),iq=oi(tq.prototype,"_height",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),rq=oi(tq.prototype,"_direction",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return uW.Y_AXIS}}),$Y=tq))||$Y)||$Y)||$Y)||$Y)),VJ=function(e){return t({MeshCollider:e,MeshColliderComponent:e}),e}((sq=ri("cc.MeshCollider"),aq=wi(),oq=Bi(),lq=bi(Na),hq=Di(),uq=Di(),sq(cq=aq(cq=oq(cq=Si((dq=function(t){function e(){var e;return e=t.call(this,_W.MESH)||this,li(e,"_mesh",fq,hi(e)),li(e,"_convex",pq,hi(e)),e}return Me(e,t),Pe(e,[{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh=t,this.shape.setMesh(this._mesh))}},{key:"convex",get:function(){return this._convex},set:function(t){this._convex!==t&&(this._convex=t)}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((_q=dq).prototype,"mesh",[lq,hq],Object.getOwnPropertyDescriptor(_q.prototype,"mesh"),_q.prototype),oi(_q.prototype,"convex",[vi,uq],Object.getOwnPropertyDescriptor(_q.prototype,"convex"),_q.prototype),fq=oi(_q.prototype,"_mesh",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),pq=oi(_q.prototype,"_convex",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),cq=_q))||cq)||cq)||cq)||cq)),kJ=t("ConstantForce",(mq=ri("cc.ConstantForce"),yq=wi(),gq=Rr(eY),vq=Bi(),bq=Mr(),Sq=Di(),Aq=Mr(),Cq=Di(),xq=Mr(),Tq=Di(),wq=Mr(),Eq=Di(),mq(Bq=yq(Bq=gq(Bq=vq(Bq=Br(Bq=Si((Oq=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._rigidBody=null,li(e,"_force",Mq,hi(e)),li(e,"_localForce",Pq,hi(e)),li(e,"_torque",Rq,hi(e)),li(e,"_localTorque",Iq,hi(e)),e._mask=0,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._rigidBody=this.node.getComponent(eY),this._maskUpdate(this._force,1),this._maskUpdate(this._localForce,2),this._maskUpdate(this._torque,4),this._maskUpdate(this._localTorque,8)},i.lateUpdate=function(){null!=this._rigidBody&&0!==this._mask&&(1&this._mask&&this._rigidBody.applyForce(this._force),2&this._mask&&this._rigidBody.applyLocalForce(this.localForce),4&this._mask&&this._rigidBody.applyTorque(this._torque),8&this._mask&&this._rigidBody.applyLocalTorque(this._localTorque))},i._maskUpdate=function(t,e){t.strictEquals(ii.ZERO)?this._mask&=~e:this._mask|=e},Pe(e,[{key:"force",get:function(){return this._force},set:function(t){ii.copy(this._force,t),this._maskUpdate(this._force,1)}},{key:"localForce",get:function(){return this._localForce},set:function(t){ii.copy(this._localForce,t),this._maskUpdate(this.localForce,2)}},{key:"torque",get:function(){return this._torque},set:function(t){ii.copy(this._torque,t),this._maskUpdate(this._torque,4)}},{key:"localTorque",get:function(){return this._localTorque},set:function(t){ii.copy(this._localTorque,t),this._maskUpdate(this._localTorque,8)}}]),e}(zi),Mq=oi((Dq=Oq).prototype,"_force",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),Pq=oi(Dq.prototype,"_localForce",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),Rq=oi(Dq.prototype,"_torque",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),Iq=oi(Dq.prototype,"_localTorque",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),oi(Dq.prototype,"force",[bq,Sq],Object.getOwnPropertyDescriptor(Dq.prototype,"force"),Dq.prototype),oi(Dq.prototype,"localForce",[Aq,Cq],Object.getOwnPropertyDescriptor(Dq.prototype,"localForce"),Dq.prototype),oi(Dq.prototype,"torque",[xq,Tq],Object.getOwnPropertyDescriptor(Dq.prototype,"torque"),Dq.prototype),oi(Dq.prototype,"localTorque",[wq,Eq],Object.getOwnPropertyDescriptor(Dq.prototype,"localTorque"),Dq.prototype),Bq=Dq))||Bq)||Bq)||Bq)||Bq)||Bq)||Bq)),NJ=(t("TERRAIN_MAX_LEVELS",4),t("TERRAIN_MAX_BLEND_LAYERS",4)),GJ=t("TERRAIN_MAX_LAYER_COUNT",256),zJ=t("TERRAIN_BLOCK_TILE_COMPLEXITY",32),UJ=t("TERRAIN_BLOCK_VERTEX_COMPLEXITY",33),HJ=t("TERRAIN_BLOCK_VERTEX_SIZE",8),jJ=t("TERRAIN_HEIGHT_BASE",32768),WJ=t("TERRAIN_HEIGHT_FACTORY",1/512),XJ=t("TERRAIN_HEIGHT_FMIN",-jJ*WJ),YJ=t("TERRAIN_HEIGHT_FMAX",(65535-jJ)*WJ),qJ=(t("TERRAIN_NORTH_INDEX",0),t("TERRAIN_SOUTH_INDEX",1),t("TERRAIN_WEST_INDEX",2),t("TERRAIN_EAST_INDEX",3),t("TERRAIN_DATA_VERSION",16842753)),JJ=t("TERRAIN_DATA_VERSION2",16842754),KJ=t("TERRAIN_DATA_VERSION3",16842755),ZJ=t("TERRAIN_DATA_VERSION4",16842756),QJ=t("TERRAIN_DATA_VERSION5",16842757),$J=t("TERRAIN_DATA_VERSION_DEFAULT",16843025),tK=function(){function t(){this.length=0,this.buffer=new Uint8Array(2048),this._buffView=new DataView(this.buffer.buffer),this._seekPos=0}var e=t.prototype;return e.reserve=function(t){if(!(this.buffer.byteLength>t)){for(var e=this.buffer.byteLength;e<t;)e+=e;for(var i=new Uint8Array(e),r=0;r<this.length;++r)i[r]=this.buffer[r];this.buffer=i,this._buffView=new DataView(this.buffer.buffer)}},e.assign=function(t){this.buffer=t,this.length=t.length,this._seekPos=t.byteOffset,this._buffView=new DataView(t.buffer)},e.writeInt8=function(t){this.reserve(this.length+1),this._buffView.setInt8(this.length,t),this.length+=1},e.writeInt16=function(t){this.reserve(this.length+2),this._buffView.setInt16(this.length,t,!0),this.length+=2},e.writeInt32=function(t){this.reserve(this.length+4),this._buffView.setInt32(this.length,t,!0),this.length+=4},e.writeIntArray=function(t){this.reserve(this.length+4*t.length);for(var e=0;e<t.length;++e)this._buffView.setInt32(this.length+4*e,t[e],!0);this.length+=4*t.length},e.writeFloat=function(t){this.reserve(this.length+4),this._buffView.setFloat32(this.length,t,!0),this.length+=4},e.writeFloatArray=function(t){this.reserve(this.length+4*t.length);for(var e=0;e<t.length;++e)this._buffView.setFloat32(this.length+4*e,t[e],!0);this.length+=4*t.length},e.writeString=function(t){this.reserve(this.length+t.length+4),this._buffView.setInt32(this.length,t.length,!0);for(var e=0;e<t.length;++e)this._buffView.setInt8(this.length+4+e,t.charCodeAt(e));this.length+=t.length+4},e.readInt8=function(){var t=this._buffView.getInt8(this._seekPos);return this._seekPos+=1,t},e.readInt16=function(){var t=this._buffView.getInt16(this._seekPos,!0);return this._seekPos+=2,t},e.readInt=function(){var t=this._buffView.getInt32(this._seekPos,!0);return this._seekPos+=4,t},e.readIntArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getInt32(this._seekPos+4*e,!0);return this._seekPos+=4*t.length,t},e.readFloat=function(){var t=this._buffView.getFloat32(this._seekPos,!0);return this._seekPos+=4,t},e.readFloatArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getFloat32(this._seekPos+4*e,!0);return this._seekPos+=4*t.length,t},e.readString=function(){for(var t=this.readInt(),e="",i=0;i<t;++i)e+=String.fromCharCode(this.readInt8());return e},t}(),eK=t("TerrainLayerInfo",ri("cc.TerrainLayerInfo")((Vq=oi((Lq=function(){li(this,"slot",Vq,this),li(this,"tileSize",kq,this),li(this,"detailMap",Nq,this),li(this,"normalMap",Gq,this),li(this,"roughness",zq,this),li(this,"metallic",Uq,this)}).prototype,"slot",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),kq=oi(Lq.prototype,"tileSize",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Nq=oi(Lq.prototype,"detailMap",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Gq=oi(Lq.prototype,"normalMap",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zq=oi(Lq.prototype,"roughness",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Uq=oi(Lq.prototype,"metallic",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Fq=Lq))||Fq),iK=t("TerrainLayerBinaryInfo",ri("cc.TerrainLayerBinaryInfo")(Hq=function(){this.slot=0,this.tileSize=1,this.roughness=1,this.metallic=0,this.detailMapId="",this.normalMapId=""})||Hq),rK=t("TerrainAsset",ri("cc.TerrainAsset")((Yq=function(t){function e(){var e;return(e=t.call(this)||this)._version=0,e._data=null,e._tileSize=1,e._blockCount=[1,1],e._weightMapSize=128,e._lightMapSize=128,e._heights=new Uint16Array,e._weights=new Uint8Array,e._layerBuffer=[-1,-1,-1,-1],e._layerBinaryInfos=[],li(e,"_layerInfos",Xq,hi(e)),e.loaded=!1,e}Me(e,t);var i=e.prototype;return i.getLayer=function(t,e,i){var r=4*(e*this.blockCount[0]+t)+i;return t<this.blockCount[0]&&e<this.blockCount[1]&&r<this._layerBuffer.length?this._layerBuffer[r]:-1},i.getHeight=function(t,e){var i=this._blockCount[0]*zJ+1;return(this._heights[e*i+t]-jJ)*WJ},i.getVertexCountI=function(){return this._blockCount.length<1?0:this._blockCount[0]*zJ+1},i.getVertexCountJ=function(){return this._blockCount.length<2?0:this._blockCount[1]*zJ+1},i._setNativeData=function(t){this._data=t},i._loadNativeData=function(t){var e=new tK;if(e.assign(t),this._version=e.readInt(),this._version===$J)return!0;if(this._version!==qJ&&this._version!==JJ&&this._version!==KJ&&this._version!==ZJ&&this._version!==QJ)return!1;this.tileSize=e.readFloat(),e.readIntArray(this._blockCount),this.weightMapSize=e.readInt16(),this.lightMapSize=e.readInt16();var i=e.readInt();this.heights=new Uint16Array(i);for(var r=0;r<this.heights.length;++r)this.heights[r]=e.readInt16();var n=e.readInt();this.weights=new Uint8Array(n);for(var s=0;s<this.weights.length;++s)this.weights[s]=e.readInt8();if(this._version>=JJ){var a=e.readInt();this.layerBuffer=new Array(a);for(var o=0;o<this.layerBuffer.length;++o)this.layerBuffer[o]=e.readInt16()}if(this._version>=KJ){var l=e.readInt();this._layerBinaryInfos=new Array(l);for(var h=0;h<this._layerBinaryInfos.length;++h)this._layerBinaryInfos[h]=new iK,this._layerBinaryInfos[h].slot=e.readInt(),this._layerBinaryInfos[h].tileSize=e.readFloat(),this._layerBinaryInfos[h].detailMapId=e.readString(),this._version>=ZJ&&(this._layerBinaryInfos[h].normalMapId=e.readString(),this._layerBinaryInfos[h].roughness=e.readFloat(),this._layerBinaryInfos[h].metallic=e.readFloat())}return!0},i._exportNativeData=function(){var t=new tK;t.writeInt32(QJ),t.writeFloat(this.tileSize),t.writeIntArray(this._blockCount),t.writeInt16(this.weightMapSize),t.writeInt16(this.lightMapSize),t.writeInt32(this.heights.length);for(var e=0;e<this.heights.length;++e)t.writeInt16(this.heights[e]);t.writeInt32(this.weights.length);for(var i=0;i<this.weights.length;++i)t.writeInt8(this.weights[i]);t.writeInt32(this.layerBuffer.length);for(var r=0;r<this.layerBuffer.length;++r)t.writeInt16(this.layerBuffer[r]);var n=[];n.length=this.layerInfos.length;for(var s=0;s<n.length;++s){var a=this.layerInfos[s],o=new iK;o.slot=s,o.tileSize=a.tileSize,o.detailMapId=a.detailMap?a.detailMap._uuid:"",o.normalMapId=a.normalMap?a.normalMap._uuid:"",o.metallic=a.metallic,o.roughness=a.roughness,n[s]=o}t.writeInt32(n.length);for(var l=0;l<n.length;++l)t.writeInt32(n[l].slot),t.writeFloat(n[l].tileSize),t.writeString(n[l].detailMapId),t.writeString(n[l].normalMapId),t.writeFloat(n[l].roughness),t.writeFloat(n[l].metallic);return t.buffer},i._exportDefaultNativeData=function(){var t=new tK;return t.writeInt32($J),t.buffer},Pe(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data&&this._data.byteLength===t.byteLength?this._data.set(new Uint8Array(t)):this._data=new Uint8Array(t),this._loadNativeData(this._data),this.loaded=!0,this.emit("load")}},{key:"version",get:function(){return this._version}},{key:"tileSize",get:function(){return this._tileSize},set:function(t){this._tileSize=t}},{key:"blockCount",get:function(){return this._blockCount},set:function(t){this._blockCount=t}},{key:"lightMapSize",get:function(){return this._lightMapSize},set:function(t){this._lightMapSize=t}},{key:"weightMapSize",get:function(){return this._weightMapSize},set:function(t){this._weightMapSize=t}},{key:"heights",get:function(){return this._heights},set:function(t){this._heights=t}},{key:"weights",get:function(){return this._weights},set:function(t){this._weights=t}},{key:"layerBuffer",get:function(){return this._layerBuffer},set:function(t){this._layerBuffer=t}},{key:"layerInfos",get:function(){return this._layerInfos},set:function(t){this._layerInfos=t}},{key:"layerBinaryInfos",get:function(){return this._layerBinaryInfos}}]),e}(ai),Xq=oi((Wq=Yq).prototype,"_layerInfos",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),jq=Wq))||jq),nK=t("TerrainCollider",(qq=ri("cc.TerrainCollider"),Jq=wi(),Kq=Bi(),Zq=bi(rK),Qq=Di(),qq($q=Jq($q=Kq($q=Si((iJ=function(t){function e(){var e;return e=t.call(this,_W.TERRAIN)||this,li(e,"_terrain",eJ,hi(e)),e}return Me(e,t),Pe(e,[{key:"terrain",get:function(){return this._terrain},set:function(t){this._terrain=t,this.shape.setTerrain(this._terrain)}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((tJ=iJ).prototype,"terrain",[Zq,Qq],Object.getOwnPropertyDescriptor(tJ.prototype,"terrain"),tJ.prototype),eJ=oi(tJ.prototype,"_terrain",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),$q=tJ))||$q)||$q)||$q)||$q)),sK=t("SimplexCollider",(rJ=ri("cc.SimplexCollider"),nJ=wi(),sJ=Bi(),aJ=bi(cW),oJ=Di(),lJ=Di(),hJ=Mi(),uJ=Di(),cJ=Mi(),_J=Di(),fJ=Mi(),pJ=Di(),rJ(dJ=nJ(dJ=sJ(dJ=Si((bJ=vJ=function(t){function e(){var e;return e=t.call(this,_W.SIMPLEX)||this,li(e,"_shapeType",yJ,hi(e)),li(e,"_vertices",gJ,hi(e)),e}return Me(e,t),e.prototype.updateVertices=function(){this.shape.setVertices(this._vertices)},Pe(e,[{key:"shapeType",get:function(){return this._shapeType},set:function(t){this._shapeType=t,this.shape.setShapeType(t)}},{key:"vertex0",get:function(){return this._vertices[0]},set:function(t){ii.copy(this._vertices[0],t),this.updateVertices()}},{key:"vertex1",get:function(){return this._vertices[1]},set:function(t){ii.copy(this._vertices[1],t),this.updateVertices()}},{key:"vertex2",get:function(){return this._vertices[2]},set:function(t){ii.copy(this._vertices[2],t),this.updateVertices()}},{key:"vertex3",get:function(){return this._vertices[3]},set:function(t){ii.copy(this._vertices[3],t),this.updateVertices()}},{key:"shape",get:function(){return this._shape}},{key:"vertices",get:function(){return this._vertices}}]),e}(cY),vJ.ESimplexType=cW,oi((mJ=bJ).prototype,"shapeType",[aJ,oJ],Object.getOwnPropertyDescriptor(mJ.prototype,"shapeType"),mJ.prototype),oi(mJ.prototype,"vertex0",[vi,lJ],Object.getOwnPropertyDescriptor(mJ.prototype,"vertex0"),mJ.prototype),oi(mJ.prototype,"vertex1",[hJ,uJ],Object.getOwnPropertyDescriptor(mJ.prototype,"vertex1"),mJ.prototype),oi(mJ.prototype,"vertex2",[cJ,_J],Object.getOwnPropertyDescriptor(mJ.prototype,"vertex2"),mJ.prototype),oi(mJ.prototype,"vertex3",[fJ,pJ],Object.getOwnPropertyDescriptor(mJ.prototype,"vertex3"),mJ.prototype),yJ=oi(mJ.prototype,"_shapeType",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return cW.TETRAHEDRON}}),gJ=oi(mJ.prototype,"_vertices",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[new ii(0,0,0),new ii(0,0,1),new ii(1,0,0),new ii(0,1,0)]}}),dJ=mJ))||dJ)||dJ)||dJ)||dJ));sK||(sK=t("SimplexCollider",{}));var aK,oK,lK,hK,uK,cK,_K,fK,pK,dK,mK,yK,gK,vK,bK,SK,AK,CK,xK,TK,wK,EK,BK,DK,MK,PK,RK,IK,OK,FK=t("PlaneCollider",(SJ=ri("cc.PlaneCollider"),AJ=wi(),CJ=Bi(),xJ=bi(ii),TJ=Di(),wJ=Di(),SJ(EJ=AJ(EJ=CJ(EJ=Si((PJ=function(t){function e(){var e;return e=t.call(this,_W.PLANE)||this,li(e,"_normal",DJ,hi(e)),li(e,"_constant",MJ,hi(e)),e}return Me(e,t),Pe(e,[{key:"normal",get:function(){return this._normal},set:function(t){ii.copy(this._normal,t),this.shape.setNormal(this._normal)}},{key:"constant",get:function(){return this._constant},set:function(t){this._constant=t,this.shape.setConstant(this._constant)}},{key:"shape",get:function(){return this._shape}}]),e}(cY),oi((BJ=PJ).prototype,"normal",[xJ,TJ],Object.getOwnPropertyDescriptor(BJ.prototype,"normal"),BJ.prototype),oi(BJ.prototype,"constant",[vi,wJ],Object.getOwnPropertyDescriptor(BJ.prototype,"constant"),BJ.prototype),DJ=oi(BJ.prototype,"_normal",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii(0,1,0)}}),MJ=oi(BJ.prototype,"_constant",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),EJ=BJ))||EJ)||EJ)||EJ)||EJ)),LK=t("Constraint",(aK=ri("cc.Constraint"),oK=Rr(eY),lK=bi(eY),hK=Mr(),uK=bi(eY),cK=Mr(),_K=Mr(),fK=bi(eY),aK(pK=oK((vK=gK=function(t){function e(e){var i;return(i=t.call(this)||this).TYPE=void 0,li(i,"_enableCollision",mK,hi(i)),li(i,"_connectedBody",yK,hi(i)),i._constraint=null,i.TYPE=e,i}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._constraint=function(t){return VW.INITED||(VW.INITED=!0,VW[fW.POINT_TO_POINT]=function(){return TW(dW.wrapper.PointToPointConstraint,AW.PointToPointConstraint)?kW:new dW.wrapper.PointToPointConstraint},VW[fW.HINGE]=function(){return TW(dW.wrapper.HingeConstraint,AW.HingeConstraint)?kW:new dW.wrapper.HingeConstraint},VW[fW.CONE_TWIST]=function(){return TW(dW.wrapper.ConeTwistConstraint,AW.ConeTwistConstraint)?kW:new dW.wrapper.ConeTwistConstraint}),VW[t]()}(this.TYPE),this._constraint.initialize(this)},i.onEnable=function(){this._constraint&&this._constraint.onEnable()},i.onDisable=function(){this._constraint&&this._constraint.onDisable()},i.onDestroy=function(){this._constraint&&this._constraint.onDestroy()},Pe(e,[{key:"attachedBody",get:function(){return this.getComponent(eY)}},{key:"connectedBody",get:function(){return this._connectedBody},set:function(t){this._connectedBody=t,this._constraint&&this._constraint.setConnectedBody(t)}},{key:"enableCollision",get:function(){return this._enableCollision},set:function(t){this._enableCollision=t,this._constraint&&this._constraint.setEnableCollision(t)}}]),e}(Yn(zi)),gK.Type=fW,oi((dK=vK).prototype,"attachedBody",[lK,qn,hK],Object.getOwnPropertyDescriptor(dK.prototype,"attachedBody"),dK.prototype),oi(dK.prototype,"connectedBody",[uK,cK],Object.getOwnPropertyDescriptor(dK.prototype,"connectedBody"),dK.prototype),oi(dK.prototype,"enableCollision",[_K],Object.getOwnPropertyDescriptor(dK.prototype,"enableCollision"),dK.prototype),mK=oi(dK.prototype,"_enableCollision",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),yK=oi(dK.prototype,"_connectedBody",[fK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),pK=dK))||pK)||pK));LK||(LK=t("Constraint",{}));var VK,kK,NK,GK,zK,UK,HK,jK,WK,XK,YK=t("HingeConstraint",(bK=ri("cc.HingeConstraint"),SK=wi(),AK=Bi(),CK=bi(ii),xK=bi(ii),TK=bi(ii),wK=gi("axisA"),EK=gi("pivotA"),BK=gi("pivotB"),bK(DK=SK(DK=AK((OK=function(t){function e(){var e;return e=t.call(this,fW.HINGE)||this,li(e,"_axis",PK,hi(e)),li(e,"_pivotA",RK,hi(e)),li(e,"_pivotB",IK,hi(e)),e}return Me(e,t),Pe(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){ii.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){ii.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"axis",get:function(){return this._axis},set:function(t){ii.copy(this._axis,t),this.constraint.setAxis(this._axis)}},{key:"constraint",get:function(){return this._constraint}}]),e}(LK),oi((MK=OK).prototype,"pivotA",[CK],Object.getOwnPropertyDescriptor(MK.prototype,"pivotA"),MK.prototype),oi(MK.prototype,"pivotB",[xK],Object.getOwnPropertyDescriptor(MK.prototype,"pivotB"),MK.prototype),oi(MK.prototype,"axis",[TK],Object.getOwnPropertyDescriptor(MK.prototype,"axis"),MK.prototype),PK=oi(MK.prototype,"_axis",[_i,wK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),RK=oi(MK.prototype,"_pivotA",[_i,EK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),IK=oi(MK.prototype,"_pivotB",[_i,BK],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),DK=MK))||DK)||DK)||DK)),qK=t("PointToPointConstraint",(VK=ri("cc.PointToPointConstraint"),kK=wi(),NK=Bi(),GK=bi(ii),zK=bi(ii),VK(UK=kK(UK=NK((XK=function(t){function e(){var e;return e=t.call(this,fW.POINT_TO_POINT)||this,li(e,"_pivotA",jK,hi(e)),li(e,"_pivotB",WK,hi(e)),e}return Me(e,t),Pe(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){ii.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){ii.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"constraint",get:function(){return this._constraint}}]),e}(LK),oi((HK=XK).prototype,"pivotA",[GK],Object.getOwnPropertyDescriptor(HK.prototype,"pivotA"),HK.prototype),oi(HK.prototype,"pivotB",[zK],Object.getOwnPropertyDescriptor(HK.prototype,"pivotB"),HK.prototype),jK=oi(HK.prototype,"_pivotA",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),WK=oi(HK.prototype,"_pivotB",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ii}}),UK=HK))||UK)||UK)||UK));function JK(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}var KK=new ii,ZK=new ii,QK=new ii,$K=new ii,tZ=new ii,eZ=new ii,iZ=new ii,rZ=new ii,nZ=new ii,sZ=new ii,aZ=new ii,oZ=new ii,lZ=new ii(0,0,0),hZ=new ii(0,0,0);function uZ(t,e,i,r){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===r&&(r={});var n=.5*i,s=r.radialSegments||32,a=r.heightSegments||1,o=void 0===r.capped||r.capped,l=r.arc||2*Math.PI,h=0;o||(t>0&&h++,e>0&&h++);var u=(s+1)*(a+1);o&&(u+=(s+1)*h+s*h);var c=s*a*6;o&&(c+=s*h*3);var _=new Array(c),f=new Array(3*u),p=new Array(3*u),d=new Array(2*u),m=Math.max(t,e),y=new ii(-m,-n,-m),g=new ii(m,n,m),v=Math.sqrt(m*m+n*n),b=0,S=0;return function(){for(var r=[],o=t-e,h=o*o/i*Math.sign(o),u=0;u<=a;u++){for(var c=[],m=u/a,y=m*o+e,g=0;g<=s;++g){var v=g/s,A=v*l,C=Math.sin(A),x=Math.cos(A);f[3*b]=y*C,f[3*b+1]=m*i-n,f[3*b+2]=y*x,ii.normalize(lZ,ii.set(hZ,C,-h,x)),p[3*b]=lZ.x,p[3*b+1]=lZ.y,p[3*b+2]=lZ.z,d[2*b]=2*(1-v)%1,d[2*b+1]=m,c.push(b),++b}r.push(c)}for(var T=0;T<a;++T)for(var w=0;w<s;++w){var E=r[T][w],B=r[T+1][w],D=r[T+1][w+1],M=r[T][w+1];_[S]=E,++S,_[S]=M,++S,_[S]=B,++S,_[S]=M,++S,_[S]=D,++S,_[S]=B,++S}}(),o&&(e>0&&A(!1),t>0&&A(!0)),{positions:f,normals:p,uvs:d,indices:_,minPos:y,maxPos:g,boundingRadius:v};function A(i){for(var r=i?t:e,a=i?1:-1,o=b,h=1;h<=s;++h)f[3*b]=0,f[3*b+1]=n*a,f[3*b+2]=0,p[3*b]=0,p[3*b+1]=a,p[3*b+2]=0,d[2*b]=.5,d[2*b+1]=.5,++b;for(var u=b,c=0;c<=s;++c){var m=c/s*l,y=Math.cos(m),g=Math.sin(m);f[3*b]=r*g,f[3*b+1]=n*a,f[3*b+2]=r*y,p[3*b]=0,p[3*b+1]=a,p[3*b+2]=0,d[2*b]=.5-.5*g*a,d[2*b+1]=.5+.5*y,++b}for(var v=0;v<s;++v){var A=o+v,C=u+v;i?(_[S]=C+1,++S,_[S]=A,++S,_[S]=C,++S):(_[S]=A,++S,_[S]=C+1,++S,_[S]=C,++S)}}}var cZ=new ii(0,0,0),_Z=new ii(0,0,0),fZ=new ii(0,0,0),pZ=new ii(0,0,0),dZ=new ii(0,0,0),mZ=new ii(0,0,0),yZ=new ii(0,0,0),gZ=new ii(0,0,0),vZ=new ii(0,0,0),bZ=Object.freeze({__proto__:null,box:function(t){var e=(t=t||{}).widthSegments||1,i=t.heightSegments||1,r=t.lengthSegments||1,n=(t.width||1)/2,s=(t.height||1)/2,a=(t.length||1)/2,o=[ii.set(tZ,-n,-s,a),ii.set(eZ,n,-s,a),ii.set(iZ,n,s,a),ii.set(rZ,-n,s,a),ii.set(nZ,n,-s,-a),ii.set(sZ,-n,-s,-a),ii.set(aZ,-n,s,-a),ii.set(oZ,n,s,-a)],l=[[2,3,1],[4,5,7],[7,6,2],[1,0,4],[1,4,2],[5,0,6]],h=[[0,0,1],[0,0,-1],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0]],u=[[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[0,0,-1,1],[0,0,1,1]],c=[],_=[],f=[],p=[],d=[],m=new ii(-n,-s,-a),y=new ii(n,s,a),g=Math.sqrt(n*n+s*s+a*a);function v(t,e,i){var r,n,s,a,m=c.length/3,y=l[t],g=h[t],v=u[t];for(a=0;a<=i;a++)for(s=0;s<=e;s++)if(r=s/e,n=a/i,ii.lerp(KK,o[y[0]],o[y[1]],r),ii.lerp(ZK,o[y[0]],o[y[2]],n),ii.subtract(QK,ZK,o[y[0]]),ii.add($K,KK,QK),c.push($K.x,$K.y,$K.z),_.push(g[0],g[1],g[2]),f.push(r,n),p.push(v[0],v[1],v[2],v[3]),s<e&&a<i){var b=e+1,S=s+a*b,A=s+(a+1)*b,C=s+1+(a+1)*b,x=s+1+a*b;d.push(m+S,m+x,m+A),d.push(m+A,m+x,m+C)}}return v(0,e,i),v(4,r,i),v(1,e,i),v(5,r,i),v(3,e,r),v(2,e,r),{positions:c,normals:_,uvs:f,tangents:p,indices:d,minPos:m,maxPos:y,boundingRadius:g}},cone:function(t,e,i){return void 0===t&&(t=.5),void 0===e&&(e=1),void 0===i&&(i={}),uZ(0,t,e,i)},cylinder:uZ,plane:function(t){var e=function(t){return(t=JK(t)).width=t.width||10,t.length=t.length||10,t.widthSegments=t.widthSegments||10,t.lengthSegments=t.lengthSegments||10,t}(t),i=e.width,r=e.length,n=e.widthSegments,s=e.lengthSegments,a=.5*i,o=.5*r,l=[],h=[],u=[],c=new ii(-a,0,-o),_=new ii(a,0,o),f=Math.sqrt(i*i+r*r);ii.set(dZ,-a,0,o),ii.set(mZ,a,0,o),ii.set(yZ,-a,0,-o);for(var p=0;p<=s;p++)for(var d=0;d<=n;d++){var m=d/n,y=p/s;if(ii.lerp(cZ,dZ,mZ,m),ii.lerp(_Z,dZ,yZ,y),ii.subtract(fZ,_Z,dZ),ii.add(pZ,cZ,fZ),l.push(pZ.x,pZ.y,pZ.z),e.includeUV&&h.push(m,y),d<n&&p<s){var g=n+1,v=d+p*g,b=d+(p+1)*g,S=d+1+(p+1)*g,A=d+1+p*g;u.push(v,A,b),u.push(A,S,b)}}var C={positions:l,indices:u,minPos:c,maxPos:_,boundingRadius:f};if(e.includeNormal){var x=(s+1)*(n+1),T=new Array(3*x);C.normals=T;for(var w=0;w<x;++w)T[3*w+0]=0,T[3*w+1]=1,T[3*w+2]=0}return e.includeUV&&(C.uvs=h),C},quad:function(t){var e=JK(t),i={positions:[-.5,-.5,0,-.5,.5,0,.5,.5,0,.5,-.5,0],indices:[0,3,1,3,2,1],minPos:{x:-.5,y:-.5,z:0},maxPos:{x:.5,y:.5,z:0},boundingRadius:Math.sqrt(.5)};return!1!==e.includeNormal&&(i.normals=[0,0,1,0,0,1,0,0,1,0,0,1]),!1!==e.includeUV&&(i.uvs=[0,0,0,1,1,1,1,0]),i},sphere:function(t,e){void 0===t&&(t=.5),void 0===e&&(e={});for(var i=void 0!==e.segments?e.segments:32,r=[],n=[],s=[],a=[],o=new ii(-t,-t,-t),l=new ii(t,t,t),h=t,u=0;u<=i;++u)for(var c=u*Math.PI/i,_=Math.sin(c),f=-Math.cos(c),p=0;p<=i;++p){var d=2*p*Math.PI/i-Math.PI/2,m=Math.sin(d)*_,y=f,g=Math.cos(d)*_,v=p/i,b=u/i;if(r.push(m*t,y*t,g*t),n.push(m,y,g),s.push(v,b),u<i&&p<i){var S=i+1,A=S*u+p,C=S*(u+1)+p,x=S*(u+1)+p+1,T=S*u+p+1;a.push(A,T,C),a.push(T,x,C)}}return{positions:r,indices:a,normals:n,uvs:s,minPos:o,maxPos:l,boundingRadius:h}},torus:function(t,e,i){void 0===t&&(t=.4),void 0===e&&(e=.1),void 0===i&&(i={});for(var r=i.radialSegments||32,n=i.tubularSegments||32,s=i.arc||2*Math.PI,a=[],o=[],l=[],h=[],u=new ii(-t-e,-e,-t-e),c=new ii(t+e,e,t+e),_=t+e,f=0;f<=r;f++)for(var p=0;p<=n;p++){var d=p/n,m=f/r,y=d*s,g=m*Math.PI*2,v=(t+e*Math.cos(g))*Math.sin(y),b=e*Math.sin(g),S=(t+e*Math.cos(g))*Math.cos(y),A=Math.sin(y)*Math.cos(g),C=Math.sin(g),x=Math.cos(y)*Math.cos(g);if(a.push(v,b,S),o.push(A,C,x),l.push(d,m),p<n&&f<r){var T=n+1,w=T*f+p,E=T*(f+1)+p,B=T*(f+1)+p+1,D=T*f+p+1;h.push(w,D,E),h.push(D,B,E)}}return{positions:a,normals:o,uvs:l,indices:h,minPos:u,maxPos:c,boundingRadius:_}},capsule:function(t,e,i,r){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===r&&(r={});var n=i-t-e,s=r.sides||32,a=r.heightSegments||32,o=e/i,l=n/i,h=t/i,u=Math.floor(a*o),c=Math.floor(a*h),_=Math.floor(a*l),f=n+e-i/2,p=e-i/2,d=e-i/2,m=r.arc||2*Math.PI,y=[],g=[],v=[],b=[],S=Math.max(t,e),A=new ii(-S,-i/2,-S),C=new ii(S,i/2,S),x=i/2,T=0,w=[];return function(){for(var t=0;t<=u;++t)for(var i=t*Math.PI/u/2,r=Math.sin(i),n=-Math.cos(i),o=0;o<=s;++o){var l=2*o*Math.PI/s-Math.PI/2,h=Math.sin(l)*r,c=n,_=Math.cos(l)*r,f=o/s,p=t/a;if(y.push(h*e,c*e+d,_*e),g.push(h,c,_),v.push(f,p),t<u&&o<s){var m=s+1,S=m*t+o,A=m*(t+1)+o,C=m*(t+1)+o+1,x=m*t+o+1;b.push(S,x,A),b.push(x,C,A)}++T}}(),function(){for(var i=(t-e)/n,r=0;r<=_;r++){for(var a=[],h=r/_,u=h*(t-e)+e,c=0;c<=s;++c){var f=c/s,d=h*l+o,S=f*m-m/4,A=Math.sin(S),C=Math.cos(S);y.push(u*A),y.push(h*n+p),y.push(u*C),ii.normalize(gZ,ii.set(vZ,A,-i,C)),g.push(gZ.x),g.push(gZ.y),g.push(gZ.z),v.push(f,d),a.push(T),++T}w.push(a)}for(var x=0;x<_;++x)for(var E=0;E<s;++E){var B=w[x][E],D=w[x+1][E],M=w[x+1][E+1],P=w[x][E+1];b.push(B),b.push(P),b.push(D),b.push(P),b.push(M),b.push(D)}}(),function(){for(var e=0;e<=c;++e)for(var i=e*Math.PI/c/2+Math.PI/2,r=Math.sin(i),n=-Math.cos(i),o=0;o<=s;++o){var l=2*o*Math.PI/s-Math.PI/2,u=Math.sin(l)*r,p=n,d=Math.cos(l)*r,m=o/s,S=e/a+(1-h);if(y.push(u*t,p*t+f,d*t),g.push(u,p,d),v.push(m,S),e<c&&o<s){var A=s+1,C=A*e+o+w[_][s]+1,x=A*(e+1)+o+w[_][s]+1,T=A*(e+1)+o+1+w[_][s]+1,E=A*e+o+1+w[_][s]+1;b.push(C,E,x),b.push(E,T,x)}}}(),{positions:y,normals:g,uvs:v,indices:b,minPos:A,maxPos:C,boundingRadius:x}},circle:function(t){var e=function(t){return(t=JK(t)).segments=64,t}(t).segments,i=new Array(3*(e+1));i[0]=0,i[1]=0,i[2]=0;var r=new Array(1+2*e);r[0]=0;for(var n=2*Math.PI/e,s=0;s<e;++s){var a=n*s,o=Math.cos(a),l=Math.sin(a),h=3*(s+1);i[h+0]=o,i[h+1]=l,i[h+2]=0;var u=2*s;r[1+u]=s+1,r[1+(u+1)]=s+2}return e>0&&(r[r.length-1]=1),{positions:i,indices:r,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:F.TRIANGLE_FAN}},translate:function(t,e){for(var i=e.x||0,r=e.y||0,n=e.z||0,s=Math.floor(t.positions.length/3),a=0;a<s;++a){var o=3*a,l=3*a+1,h=3*a+2;t.positions[o]+=i,t.positions[l]+=r,t.positions[h]+=n}return t.minPos&&(t.minPos.x+=i,t.minPos.y+=r,t.minPos.z+=n),t.maxPos&&(t.maxPos.x+=i,t.maxPos.y+=r,t.maxPos.z+=n),t},scale:function(t,e){for(var i=e.x||0,r=e.y||0,n=e.z||0,s=Math.floor(t.positions.length/3),a=0;a<s;++a){var o=3*a,l=3*a+1,h=3*a+2;t.positions[o]*=i,t.positions[l]*=r,t.positions[h]*=n}return t.minPos&&(t.minPos.x*=i,t.minPos.y*=r,t.minPos.z*=n),t.maxPos&&(t.maxPos.x*=i,t.maxPos.y*=r,t.maxPos.z*=n),t.boundingRadius=Math.max(Math.max(i,r),n),t},wireframed:function(t){var e=t.indices;if(!e)return t;if(t.primitiveMode&&t.primitiveMode!==F.TRIANGLE_LIST)return t;for(var i=[[0,1],[1,2],[2,0]],r=[],n={},s=0;s<e.length;s+=3)for(var a=0;a<3;++a){var o=e[s+i[a][0]],l=e[s+i[a][1]],h=o>l?l<<16|o:o<<16|l;void 0===n[h]&&(n[h]=0,r.push(o,l))}return t.indices=r,t.primitiveMode=F.LINE_LIST,t},wireframe:function(t){for(var e=[[0,1],[1,2],[2,0]],i=[],r={},n=0;n<t.length;n+=3)for(var s=0;s<3;++s){var a=t[n+e[s][0]],o=t[n+e[s][1]],l=a>o?o<<16|a:a<<16|o;void 0===r[l]&&(r[l]=0,i.push(a,o))}return i},invWinding:function(t){for(var e=[],i=0;i<t.length;i+=3)e.push(t[i],t[i+2],t[i+1]);return e},toWavefrontOBJ:function(t,e){if(void 0===e&&(e=1),!t.indices||!t.uvs||!t.normals||void 0!==t.primitiveMode&&t.primitiveMode!==F.TRIANGLE_LIST)return"";for(var i=t.positions,r=t.uvs,n=t.normals,s=t.indices,a=function(t){return s[t]+1+"/"+(s[t]+1)+"/"+(s[t]+1)},o="",l=0;l<i.length;l+=3)o+="v "+i[l]*e+" "+i[l+1]*e+" "+i[l+2]*e+"\n";for(var h=0;h<r.length;h+=2)o+="vt "+r[h]+" "+r[h+1]+"\n";for(var u=0;u<n.length;u+=3)o+="vn "+n[u]+" "+n[u+1]+" "+n[u+2]+"\n";for(var c=0;c<s.length;c+=3)o+="f "+a(c)+" "+a(c+1)+" "+a(c+2)+"\n";return o},normals:function(t,e,i){void 0===i&&(i=1);for(var r=new Array(2*t.length),n=0;n<t.length/3;++n){var s=3*n,a=6*n;r[a+0]=t[s+0],r[a+1]=t[s+1],r[a+2]=t[s+2],r[a+3]=t[s+0]+e[s+0]*i,r[a+4]=t[s+1]+e[s+1]*i,r[a+5]=t[s+2]+e[s+2]*i}return r},applyDefaultGeometryOptions:JK});t("primitives",bZ);var SZ=new ii,AZ=Object.freeze({__proto__:null,setWrap:function(t,e){t.__cc_wrapper__=e},getWrap:function(t){return t.__cc_wrapper__},maxComponent:function(t){return Math.max(t.x,Math.max(t.y,t.z))},VEC3_0:SZ,TriggerEventObject:{type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},CollisionEventObject:{type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},shrinkPositions:function(t){var e=[];if(t.length>=3){e[0]=t[0],e[1]=t[1],e[2]=t[2];for(var i=t.length,r=3;r<i;r+=3){for(var n=t[r],s=t[r+1],a=t[r+2],o=e.length,l=!0,h=0;h<o;h+=3)if(Wn(n,e[h])&&Wn(s,e[h+1])&&Wn(a,e[h+2])){l=!1;break}l&&(e.push(n),e.push(s),e.push(a))}}return e},cylinder:uZ});He.PhysicsSystem=RX,He.PhysicsMaterial=NW,He.PhysicsRayResult=GW,He.ConstantForce=kJ;var CZ,xZ,TZ,wZ,EZ,BZ,DZ,MZ,PZ,RZ=Object.freeze({__proto__:null,PhysicsSystem:RX,PhysicsRayResult:GW,get Collider(){return cY},BoxCollider:RJ,SphereCollider:IJ,CapsuleCollider:OJ,MeshCollider:VJ,CylinderCollider:FJ,ConeCollider:LJ,TerrainCollider:nK,get SimplexCollider(){return sK},PlaneCollider:FK,get Constraint(){return LK},HingeConstraint:YK,PointToPointConstraint:qK,get RigidBody(){return eY},PhysicsMaterial:NW,ConstantForce:kJ,selector:dW,utils:AZ,get ERigidBodyType(){return hW},get EAxisDirection(){return uW},get ESimplexType(){return cW},get EColliderType(){return _W},get EConstraintType(){return fW},get PhysicsGroup(){return pW}});t("physics",RZ),Ii(RX,"PhysicsSystem",[{name:"ins",newName:"instance"}]),Ii(RX.prototype,"PhysicsSystem.prototype",[{name:"deltaTime",newName:"fixedTimeStep"},{name:"maxSubStep",newName:"maxSubSteps"}]),Oi(RX.prototype,"PhysicsSystem.prototype",[{name:"useFixedTime"},{name:"useCollisionMatrix"},{name:"updateCollisionMatrix"},{name:"resetCollisionMatrix"},{name:"isCollisionGroup"},{name:"setCollisionGroup"}]),Ii(cY.prototype,"Collider.prototype",[{name:"attachedRigidbody",newName:"attachedRigidBody"},{name:"TYPE",newName:"type"}]),Ii(cY,"Collider",[{name:"EColliderType",newName:"Type"},{name:"EAxisDirection",newName:"Axis"}]),Ii(LK,"Constraint",[{name:"EConstraintType",newName:"Type"}]),Ii(RJ.prototype,"BoxCollider.prototype",[{name:"boxShape",newName:"shape"}]),Ii(IJ.prototype,"SphereCollider.prototype",[{name:"sphereShape",newName:"shape"}]),Ii(OJ.prototype,"CapsuleCollider.prototype",[{name:"capsuleShape",newName:"shape"}]),Ii(eY.prototype,"RigidBody.prototype",[{name:"rigidBody",newName:"body"}]),Ii(eY,"RigidBody",[{name:"ERigidBodyType",newName:"Type"}]),Oi(eY.prototype,"RigidBody.prototype",[{name:"fixedRotation"}]),He.RigidBodyComponent=eY,Li.setClassAlias(eY,"cc.RigidBodyComponent"),He.ColliderComponent=cY,Li.setClassAlias(cY,"cc.ColliderComponent"),He.BoxColliderComponent=RJ,Li.setClassAlias(RJ,"cc.BoxColliderComponent"),He.SphereColliderComponent=IJ,Li.setClassAlias(IJ,"cc.SphereColliderComponent"),Li.setClassAlias(OJ,"cc.CapsuleColliderComponent"),Li.setClassAlias(VJ,"cc.MeshColliderComponent"),Li.setClassAlias(FJ,"cc.CylinderColliderComponent"),He.PhysicMaterial=NW,Li.setClassAlias(NW,"cc.PhysicMaterial"),He.physics=RZ,function(t){t[t.BODY_RE_ADD=1]="BODY_RE_ADD",t[t.GHOST_RE_ADD=2]="GHOST_RE_ADD"}(CZ||(CZ={})),function(t){t[t.CF_STATIC_OBJECT=1]="CF_STATIC_OBJECT",t[t.CF_KINEMATIC_OBJECT=2]="CF_KINEMATIC_OBJECT",t[t.CF_NO_CONTACT_RESPONSE=4]="CF_NO_CONTACT_RESPONSE",t[t.CF_CUSTOM_MATERIAL_CALLBACK=8]="CF_CUSTOM_MATERIAL_CALLBACK",t[t.CF_CHARACTER_OBJECT=16]="CF_CHARACTER_OBJECT",t[t.CF_DISABLE_VISUALIZE_OBJECT=32]="CF_DISABLE_VISUALIZE_OBJECT",t[t.CF_DISABLE_SPU_COLLISION_PROCESSING=64]="CF_DISABLE_SPU_COLLISION_PROCESSING"}(xZ||(xZ={})),jn.AmmoCollisionFlags=xZ,function(t){t[t.CO_COLLISION_OBJECT=1]="CO_COLLISION_OBJECT",t[t.CO_RIGID_BODY=2]="CO_RIGID_BODY",t[t.CO_GHOST_OBJECT=4]="CO_GHOST_OBJECT",t[t.CO_SOFT_BODY=8]="CO_SOFT_BODY",t[t.CO_HF_FLUID=16]="CO_HF_FLUID",t[t.CO_USER_TYPE=32]="CO_USER_TYPE",t[t.CO_FEATHERSTONE_LINK=64]="CO_FEATHERSTONE_LINK"}(TZ||(TZ={})),jn.AmmoCollisionObjectTypes=TZ,function(t){t[t.ACTIVE_TAG=1]="ACTIVE_TAG",t[t.ISLAND_SLEEPING=2]="ISLAND_SLEEPING",t[t.WANTS_DEACTIVATION=3]="WANTS_DEACTIVATION",t[t.DISABLE_DEACTIVATION=4]="DISABLE_DEACTIVATION",t[t.DISABLE_SIMULATION=5]="DISABLE_SIMULATION"}(wZ||(wZ={})),function(t){t[t.CF_ANISOTROPIC_FRICTION_DISABLED=0]="CF_ANISOTROPIC_FRICTION_DISABLED",t[t.CF_ANISOTROPIC_FRICTION=1]="CF_ANISOTROPIC_FRICTION",t[t.CF_ANISOTROPIC_ROLLING_FRICTION=2]="CF_ANISOTROPIC_ROLLING_FRICTION"}(EZ||(EZ={})),jn.AmmoAnisotropicFrictionFlags=EZ,function(t){t[t.BT_DISABLE_WORLD_GRAVITY=1]="BT_DISABLE_WORLD_GRAVITY",t[t.BT_ENABLE_GYROPSCOPIC_FORCE=2]="BT_ENABLE_GYROPSCOPIC_FORCE"}(BZ||(BZ={})),jn.AmmoRigidBodyFlags=BZ,function(t){t[t.BOX_SHAPE_PROXYTYPE=0]="BOX_SHAPE_PROXYTYPE",t[t.TRIANGLE_SHAPE_PROXYTYPE=1]="TRIANGLE_SHAPE_PROXYTYPE",t[t.TETRAHEDRAL_SHAPE_PROXYTYPE=2]="TETRAHEDRAL_SHAPE_PROXYTYPE",t[t.CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE=3]="CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE",t[t.CONVEX_HULL_SHAPE_PROXYTYPE=4]="CONVEX_HULL_SHAPE_PROXYTYPE",t[t.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE=5]="CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE",t[t.CUSTOM_POLYHEDRAL_SHAPE_TYPE=6]="CUSTOM_POLYHEDRAL_SHAPE_TYPE",t[t.IMPLICIT_CONVEX_SHAPES_START_HERE=7]="IMPLICIT_CONVEX_SHAPES_START_HERE",t[t.SPHERE_SHAPE_PROXYTYPE=8]="SPHERE_SHAPE_PROXYTYPE",t[t.MULTI_SPHERE_SHAPE_PROXYTYPE=9]="MULTI_SPHERE_SHAPE_PROXYTYPE",t[t.CAPSULE_SHAPE_PROXYTYPE=10]="CAPSULE_SHAPE_PROXYTYPE",t[t.CONE_SHAPE_PROXYTYPE=11]="CONE_SHAPE_PROXYTYPE",t[t.CONVEX_SHAPE_PROXYTYPE=12]="CONVEX_SHAPE_PROXYTYPE",t[t.CYLINDER_SHAPE_PROXYTYPE=13]="CYLINDER_SHAPE_PROXYTYPE",t[t.UNIFORM_SCALING_SHAPE_PROXYTYPE=14]="UNIFORM_SCALING_SHAPE_PROXYTYPE",t[t.MINKOWSKI_SUM_SHAPE_PROXYTYPE=15]="MINKOWSKI_SUM_SHAPE_PROXYTYPE",t[t.MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE=16]="MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE",t[t.BOX_2D_SHAPE_PROXYTYPE=17]="BOX_2D_SHAPE_PROXYTYPE",t[t.CONVEX_2D_SHAPE_PROXYTYPE=18]="CONVEX_2D_SHAPE_PROXYTYPE",t[t.CUSTOM_CONVEX_SHAPE_TYPE=19]="CUSTOM_CONVEX_SHAPE_TYPE",t[t.CONCAVE_SHAPES_START_HERE=20]="CONCAVE_SHAPES_START_HERE",t[t.TRIANGLE_MESH_SHAPE_PROXYTYPE=21]="TRIANGLE_MESH_SHAPE_PROXYTYPE",t[t.SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE=22]="SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE",t[t.FAST_CONCAVE_MESH_PROXYTYPE=23]="FAST_CONCAVE_MESH_PROXYTYPE",t[t.TERRAIN_SHAPE_PROXYTYPE=24]="TERRAIN_SHAPE_PROXYTYPE",t[t.GIMPACT_SHAPE_PROXYTYPE=25]="GIMPACT_SHAPE_PROXYTYPE",t[t.MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE=26]="MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE",t[t.EMPTY_SHAPE_PROXYTYPE=27]="EMPTY_SHAPE_PROXYTYPE",t[t.STATIC_PLANE_PROXYTYPE=28]="STATIC_PLANE_PROXYTYPE",t[t.CUSTOM_CONCAVE_SHAPE_TYPE=29]="CUSTOM_CONCAVE_SHAPE_TYPE",t[t.CONCAVE_SHAPES_END_HERE=30]="CONCAVE_SHAPES_END_HERE",t[t.COMPOUND_SHAPE_PROXYTYPE=31]="COMPOUND_SHAPE_PROXYTYPE",t[t.SOFTBODY_SHAPE_PROXYTYPE=32]="SOFTBODY_SHAPE_PROXYTYPE",t[t.HFFLUID_SHAPE_PROXYTYPE=33]="HFFLUID_SHAPE_PROXYTYPE",t[t.HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE=34]="HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE",t[t.INVALID_SHAPE_PROXYTYPE=35]="INVALID_SHAPE_PROXYTYPE",t[t.MAX_BROADPHASE_COLLISION_TYPES=36]="MAX_BROADPHASE_COLLISION_TYPES"}(DZ||(DZ={})),jn.AmmoBroadphaseNativeTypes=DZ,function(t){t[t.DefaultFilter=1]="DefaultFilter",t[t.StaticFilter=2]="StaticFilter",t[t.KinematicFilter=4]="KinematicFilter",t[t.DebrisFilter=8]="DebrisFilter",t[t.SensorTrigger=16]="SensorTrigger",t[t.CharacterFilter=32]="CharacterFilter",t[t.AllFilter=-1]="AllFilter"}(MZ||(MZ={})),jn.AmmoCollisionFilterGroups=MZ,function(t){t[t.CD_STATIC_STATIC_REPORTED=1]="CD_STATIC_STATIC_REPORTED",t[t.CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD=2]="CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD",t[t.CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION=4]="CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION"}(PZ||(PZ={})),jn.AmmoDispatcherFlags=PZ;var IZ={type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},OZ={type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},FZ=function(){function t(){this.EMPTY_SHAPE=new jn.btEmptyShape,this.TRANSFORM=new jn.btTransform,this.TRANSFORM_1=new jn.btTransform,this.VECTOR3_0=new jn.btVector3,this.VECTOR3_1=new jn.btVector3,this.QUAT_0=new jn.btQuaternion}return Pe(t,null,[{key:"instance",get:function(){return null==t._instance&&(t._instance=new t),t._instance}}]),t}();FZ._instance=void 0;var LZ=new ii,VZ=new ii,kZ=new si,NZ=LZ,GZ=VZ,zZ=function(){var t=e.prototype;function e(){this.id=void 0,this._isEnabled=!1,this.id=e.idCounter++}return t.setMass=function(t){if(this._rigidBody.isDynamic){var e=FZ.instance.VECTOR3_0;e.setValue(1.6666666269302368,1.6666666269302368,1.6666666269302368);var i=this.impl.getCollisionShape();i.isCompound()?this._sharedBody.bodyCompoundShape.getNumChildShapes()>0&&i.calculateLocalInertia(this._rigidBody.mass,e):i.calculateLocalInertia(this._rigidBody.mass,e),this.impl.setMassProps(t,e),this._wakeUpIfSleep(),this._sharedBody.dirty|=CZ.BODY_RE_ADD}},t.setType=function(t){var e=this.impl.getCollisionFlags(),i=this._sharedBody.ghost.getCollisionFlags(),r=FZ.instance.VECTOR3_0;switch(t){case hW.DYNAMIC:e&=~xZ.CF_KINEMATIC_OBJECT,e&=~xZ.CF_STATIC_OBJECT,this.impl.setCollisionFlags(e),this.setMass(this._rigidBody.mass),this.useGravity(this._rigidBody.useGravity),this.setAllowSleep(this._rigidBody.allowSleep),i&=~xZ.CF_STATIC_OBJECT,i|=xZ.CF_KINEMATIC_OBJECT,this._sharedBody.ghost.setCollisionFlags(i);break;case hW.KINEMATIC:r.setValue(0,0,0),this.impl.setMassProps(0,r),e|=xZ.CF_KINEMATIC_OBJECT,e&=~xZ.CF_STATIC_OBJECT,this.impl.setCollisionFlags(e),this.impl.forceActivationState(wZ.DISABLE_DEACTIVATION),i|=xZ.CF_KINEMATIC_OBJECT,i&=~xZ.CF_STATIC_OBJECT,this._sharedBody.ghost.setCollisionFlags(i);break;case hW.STATIC:default:r.setValue(0,0,0),this.impl.setMassProps(0,r),e|=xZ.CF_STATIC_OBJECT,e&=~xZ.CF_KINEMATIC_OBJECT,this.impl.setCollisionFlags(e),this.impl.forceActivationState(wZ.DISABLE_DEACTIVATION),i&=~xZ.CF_KINEMATIC_OBJECT,i|=xZ.CF_STATIC_OBJECT,this._sharedBody.ghost.setCollisionFlags(i)}this._sharedBody.dirty|=CZ.BODY_RE_ADD,this._sharedBody.dirty|=CZ.GHOST_RE_ADD},t.setLinearDamping=function(){this.impl.setDamping(this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.setAngularDamping=function(){this.impl.setDamping(this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.useGravity=function(t){if(this._rigidBody.isDynamic){var e=this.impl.getFlags();t?e&=~BZ.BT_DISABLE_WORLD_GRAVITY:(this.impl.setGravity(mW(FZ.instance.VECTOR3_0,ii.ZERO)),e|=BZ.BT_DISABLE_WORLD_GRAVITY),this.impl.setFlags(e),this._wakeUpIfSleep(),this._sharedBody.dirty|=CZ.BODY_RE_ADD}},t.setLinearFactor=function(t){this.impl.setLinearFactor(mW(FZ.instance.VECTOR3_0,t)),this._wakeUpIfSleep()},t.setAngularFactor=function(t){this.impl.setAngularFactor(mW(FZ.instance.VECTOR3_0,t)),this._wakeUpIfSleep()},t.setAllowSleep=function(t){this._rigidBody.isDynamic&&(t?this.impl.forceActivationState(wZ.ACTIVE_TAG):this.impl.forceActivationState(wZ.DISABLE_DEACTIVATION),this._wakeUpIfSleep())},t.clearState=function(){this.impl.clearState()},t.clearVelocity=function(){this.setLinearVelocity(ii.ZERO),this.setAngularVelocity(ii.ZERO)},t.clearForces=function(){this.impl.clearForces()},t.initialize=function(t){this._rigidBody=t,this._sharedBody=RX.instance.physicsWorld.getSharedBody(this._rigidBody.node,this),this._sharedBody.reference=!0},t.onEnable=function(){this._isEnabled=!0,this.setMass(this._rigidBody.mass),this.setType(this._rigidBody.type),this.setAllowSleep(this._rigidBody.allowSleep),this.setLinearDamping(this._rigidBody.linearDamping),this.setAngularDamping(this._rigidBody.angularDamping),this.setLinearFactor(this._rigidBody.linearFactor),this.setAngularFactor(this._rigidBody.angularFactor),this.useGravity(this._rigidBody.useGravity),this._sharedBody.bodyEnabled=!0},t.onDisable=function(){this._isEnabled=!1,this._sharedBody.bodyEnabled=!1},t.onDestroy=function(){this._sharedBody.reference=!1,this._rigidBody=null,this._sharedBody=null},t.wakeUp=function(t){void 0===t&&(t=!0),this.impl.activate(t)},t.sleep=function(){return this.impl.wantsSleeping()},t.setSleepThreshold=function(t){this._wakeUpIfSleep(),this.impl.setSleepingThresholds(t,t)},t.getSleepThreshold=function(){return this.impl.getLinearSleepingThreshold()},t.getLinearVelocity=function(t){return yW(t,this.impl.getLinearVelocity())},t.setLinearVelocity=function(t){this._wakeUpIfSleep(),mW(this.impl.getLinearVelocity(),t)},t.getAngularVelocity=function(t){return yW(t,this.impl.getAngularVelocity())},t.setAngularVelocity=function(t){this._wakeUpIfSleep(),mW(this.impl.getAngularVelocity(),t)},t.applyLocalForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,r=ii.transformQuat(NZ,t,i),n=e?ii.transformQuat(GZ,e,i):ii.ZERO;this.impl.applyForce(mW(FZ.instance.VECTOR3_0,r),mW(FZ.instance.VECTOR3_1,n))},t.applyLocalTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),ii.transformQuat(NZ,t,this._sharedBody.node.worldRotation),this.impl.applyTorque(mW(FZ.instance.VECTOR3_0,NZ))},t.applyLocalImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,r=ii.transformQuat(NZ,t,i),n=e?ii.transformQuat(GZ,e,i):ii.ZERO;this.impl.applyImpulse(mW(FZ.instance.VECTOR3_0,r),mW(FZ.instance.VECTOR3_1,n))},t.applyForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||ii.ZERO;this.impl.applyForce(mW(FZ.instance.VECTOR3_0,t),mW(FZ.instance.VECTOR3_1,i))},t.applyTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),this.impl.applyTorque(mW(FZ.instance.VECTOR3_0,t))},t.applyImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||ii.ZERO;this.impl.applyImpulse(mW(FZ.instance.VECTOR3_0,t),mW(FZ.instance.VECTOR3_1,i))},t.getGroup=function(){return this._sharedBody.collisionFilterGroup},t.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},t.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},t.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},t.getMask=function(){return this._sharedBody.collisionFilterMask},t.setMask=function(t){this._sharedBody.collisionFilterMask=t},t.addMask=function(t){this._sharedBody.collisionFilterMask|=t},t.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},t._wakeUpIfSleep=function(){this.isAwake||this.impl.activate(!0)},Pe(e,[{key:"isAwake",get:function(){var t=this.impl.getActivationState();return t===wZ.ACTIVE_TAG||t===wZ.DISABLE_DEACTIVATION}},{key:"isSleepy",get:function(){return this.impl.getActivationState()===wZ.WANTS_DEACTIVATION}},{key:"isSleeping",get:function(){return this.impl.getActivationState()===wZ.ISLAND_SLEEPING}},{key:"isEnabled",get:function(){return this._isEnabled}},{key:"impl",get:function(){return this._sharedBody.body}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"sharedBody",get:function(){return this._sharedBody}}]),e}();zZ.idCounter=0;var UZ=function(){function t(){}return Pe(t,null,[{key:"bodyStructs",get:function(){return this.bodyAndGhosts}},{key:"ghostStructs",get:function(){return this.bodyAndGhosts}}]),t}();UZ.bodyAndGhosts={};var HZ=LZ,jZ=kZ,WZ=0,XZ=function(){function t(e,i){this.id=void 0,this.node=void 0,this.wrappedWorld=void 0,this.wrappedJoints0=[],this.wrappedJoints1=[],this.dirty=0,this._collisionFilterGroup=RX.PhysicsGroup.DEFAULT,this._collisionFilterMask=-1,this.ref=0,this.bodyIndex=-1,this.ghostIndex=-1,this._wrappedBody=null,this.id=t.idCounter++,this.wrappedWorld=i,this.node=e}t.getSharedBody=function(e,i,r){var n,s=e.uuid;if(t.sharedBodesMap.has(s))n=t.sharedBodesMap.get(s);else{n=new t(e,i);var a=pW.DEFAULT,o=RX.instance.collisionMatrix[a];n._collisionFilterGroup=a,n._collisionFilterMask=o,t.sharedBodesMap.set(e.uuid,n)}if(r){n._wrappedBody=r;var l=r.rigidBody._group,h=RX.instance.collisionMatrix[l];n._collisionFilterGroup=l,n._collisionFilterMask=h}return n};var e=t.prototype;return e._instantiateBodyStruct=function(){if(!this._bodyStruct){var t=new jn.btTransform;t.setIdentity(),mW(t.getOrigin(),this.node.worldPosition);var e=new jn.btQuaternion;gW(e,this.node.worldRotation),t.setRotation(e);var i=new jn.btDefaultMotionState(t),r=new jn.btVector3(1.6666666269302368,1.6666666269302368,1.6666666269302368),n=new jn.btCompoundShape,s=0;this._wrappedBody&&this._wrappedBody.rigidBody.enabled&&this._wrappedBody.rigidBody.isDynamic&&(s=this._wrappedBody.rigidBody.mass),0===s&&r.setValue(0,0,0);var a=new jn.btRigidBodyConstructionInfo(s,i,FZ.instance.EMPTY_SHAPE,r),o=new jn.btRigidBody(a),l=RX.instance.sleepThreshold;o.setSleepingThresholds(l,l),this._bodyStruct={id:WZ++,body:o,localInertia:r,motionState:i,startTransform:t,shape:n,rbInfo:a,worldQuat:e,wrappedShapes:[],useCompound:!1},UZ.bodyStructs["KEY"+this._bodyStruct.id]=this._bodyStruct,this.body.setUserIndex2(2),this.body.setUserIndex(this._bodyStruct.id),0===s&&this.body.setActivationState(wZ.DISABLE_DEACTIVATION),jn.CC_CONFIG.ignoreSelfBody&&this._ghostStruct&&this.ghost.setIgnoreCollisionCheck(this.body,!0)}},e._instantiateGhostStruct=function(){if(!this._ghostStruct){var t=new jn.btCollisionObject,e=new jn.btCompoundShape;t.setCollisionShape(e),t.setCollisionFlags(xZ.CF_STATIC_OBJECT|xZ.CF_NO_CONTACT_RESPONSE),this._ghostStruct={id:WZ++,ghost:t,shape:e,worldQuat:new jn.btQuaternion,wrappedShapes:[]},UZ.ghostStructs["KEY"+this._ghostStruct.id]=this._ghostStruct,this.ghost.setUserIndex2(2),this.ghost.setUserIndex(this._ghostStruct.id),this.ghost.setActivationState(wZ.DISABLE_DEACTIVATION),jn.CC_CONFIG.ignoreSelfBody&&this._bodyStruct&&this.ghost.setIgnoreCollisionCheck(this.body,!0)}},e.addShape=function(t,e){function i(t,e){t.body.setCollisionShape(e),t.dirty|=CZ.BODY_RE_ADD,t._wrappedBody&&t._wrappedBody.isEnabled&&t._wrappedBody.setMass(t._wrappedBody.rigidBody.mass)}if(e)this.ghostStruct.wrappedShapes.indexOf(t)<0&&(this.ghostStruct.wrappedShapes.push(t),t.setCompound(this.ghostCompoundShape),this.ghostEnabled=!0);else if(this.bodyStruct.wrappedShapes.indexOf(t)<0){if(this.bodyStruct.wrappedShapes.push(t),this.bodyStruct.useCompound)t.setCompound(this.bodyCompoundShape);else{var r=this.bodyStruct.wrappedShapes.length;if(1!==r||t.needCompound()){this.bodyStruct.useCompound=!0;for(var n=0;n<r;n++)this.bodyStruct.wrappedShapes[n].setCompound(this.bodyCompoundShape);i(this,this.bodyStruct.shape)}else i(this,t.impl)}this.bodyEnabled=!0}},e.removeShape=function(t,e){if(e){var i=this.ghostStruct.wrappedShapes.indexOf(t);i>=0&&(Zn(this.ghostStruct.wrappedShapes,i),t.setCompound(null),this.ghostEnabled=!1)}else{var r=this.bodyStruct.wrappedShapes.indexOf(t);r>=0&&(this.bodyStruct.useCompound?t.setCompound(null):this.body.setCollisionShape(FZ.instance.EMPTY_SHAPE),this.body.activate(!0),this.dirty|=CZ.BODY_RE_ADD,Zn(this.bodyStruct.wrappedShapes,r),this.bodyEnabled=!1)}},e.addJoint=function(t,e){e?this.wrappedJoints1.indexOf(t)<0&&this.wrappedJoints1.push(t):this.wrappedJoints0.indexOf(t)<0&&this.wrappedJoints0.push(t)},e.removeJoint=function(t,e){if(e){var i=this.wrappedJoints1.indexOf(t);i>=0&&Zn(this.wrappedJoints1,i)}else{var r=this.wrappedJoints0.indexOf(t);r>=0&&Zn(this.wrappedJoints0,r)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&this.dirty&CZ.BODY_RE_ADD&&this.updateBodyByReAdd(),this.ghostIndex>=0&&this.dirty&CZ.GHOST_RE_ADD&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=this.body.getWorldTransform();if(mW(t.getOrigin(),this.node.worldPosition),gW(this.bodyStruct.worldQuat,this.node.worldRotation),t.setRotation(this.bodyStruct.worldQuat),this.node.hasChangedFlags&Ai.SCALE&&this.syncBodyScale(),this.body.isKinematicObject()){var e=this.body.getMotionState();e&&e.setWorldTransform(t)}else this.isBodySleeping()&&this.body.activate()}},e.syncPhysicsToScene=function(){if(!this.body.isStaticOrKinematicObject()&&!this.isBodySleeping()){var t=this.bodyStruct.startTransform;this.body.getMotionState().getWorldTransform(t),this.node.worldPosition=yW(HZ,t.getOrigin()),t.getBasis().getRotation(this.bodyStruct.worldQuat),this.node.worldRotation=vW(jZ,this.bodyStruct.worldQuat);var e=this.ghost.getWorldTransform();mW(e.getOrigin(),this.node.worldPosition),gW(this.ghostStruct.worldQuat,this.node.worldRotation),e.setRotation(this.ghostStruct.worldQuat)}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=this.ghost.getWorldTransform();mW(t.getOrigin(),this.node.worldPosition),gW(this.ghostStruct.worldQuat,this.node.worldRotation),t.setRotation(this.ghostStruct.worldQuat),this.node.hasChangedFlags&Ai.SCALE&&this.syncGhostScale(),this.ghost.activate()}},e.syncInitialBody=function(){var t=this.body.getWorldTransform();mW(t.getOrigin(),this.node.worldPosition),gW(this.bodyStruct.worldQuat,this.node.worldRotation),t.setRotation(this.bodyStruct.worldQuat),this.syncBodyScale(),this.body.activate()},e.syncInitialGhost=function(){var t=this.ghost.getWorldTransform();mW(t.getOrigin(),this.node.worldPosition),gW(this.ghostStruct.worldQuat,this.node.worldRotation),t.setRotation(this.ghostStruct.worldQuat),this.syncGhostScale(),this.ghost.activate()},e.syncBodyScale=function(){for(var t=0;t<this.bodyStruct.wrappedShapes.length;t++)this.bodyStruct.wrappedShapes[t].setScale();for(var e=0;e<this.wrappedJoints0.length;e++)this.wrappedJoints0[e].updateScale0();for(var i=0;i<this.wrappedJoints1.length;i++)this.wrappedJoints1[i].updateScale1()},e.syncGhostScale=function(){for(var t=0;t<this.ghostStruct.wrappedShapes.length;t++)this.ghostStruct.wrappedShapes[t].setScale()},e.updateBodyByReAdd=function(){this.bodyIndex>=0&&(this.wrappedWorld.removeSharedBody(this),this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this))},e.updateGhostByReAdd=function(){this.ghostIndex>=0&&(this.wrappedWorld.removeGhostObject(this),this.ghostIndex=this.wrappedWorld.ghosts.length,this.wrappedWorld.addGhostObject(this))},e.destroy=function(){if(t.sharedBodesMap.delete(this.node.uuid),this.node=null,this.wrappedWorld=null,this._bodyStruct){var e=this._bodyStruct;jn.destroy(e.localInertia),jn.destroy(e.worldQuat),jn.destroy(e.startTransform),jn.destroy(e.motionState),jn.destroy(e.rbInfo),jn.destroy(e.shape),bW(e.shape,jn.btCollisionShape),jn.castObject(e.body,jn.btRigidBody).wrapped=null,bW(e.body,jn.btRigidBody),bW(e.body,jn.btCollisionObject);var i="KEY"+e.id;delete UZ.bodyStructs[i],this._bodyStruct=null}if(this._ghostStruct){var r=this._ghostStruct;jn.destroy(r.worldQuat),jn.destroy(r.shape),bW(r.shape,jn.btCollisionShape),jn.destroy(r.ghost);var n="KEY"+r.id;delete UZ.bodyStructs[n],this._ghostStruct=null}},e.isBodySleeping=function(){return this.body.getActivationState()===wZ.ISLAND_SLEEPING},Pe(t,[{key:"wrappedBody",get:function(){return this._wrappedBody}},{key:"bodyCompoundShape",get:function(){return this.bodyStruct.shape}},{key:"ghostCompoundShape",get:function(){return this.ghostStruct.shape}},{key:"body",get:function(){return this.bodyStruct.body}},{key:"ghost",get:function(){return this.ghostStruct.ghost}},{key:"collisionFilterGroup",get:function(){return this._collisionFilterGroup},set:function(t){t!==this._collisionFilterGroup&&(this._collisionFilterGroup=t,this.dirty|=CZ.BODY_RE_ADD,this.dirty|=CZ.GHOST_RE_ADD)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=CZ.BODY_RE_ADD,this.dirty|=CZ.GHOST_RE_ADD)}},{key:"bodyStruct",get:function(){return this._instantiateBodyStruct(),this._bodyStruct}},{key:"ghostStruct",get:function(){return this._instantiateGhostStruct(),this._ghostStruct}},{key:"bodyEnabled",set:function(t){t?this.bodyIndex<0&&(this.bodyIndex=this.wrappedWorld.bodies.length,this.body.clearState(),this.wrappedWorld.addSharedBody(this),this.syncInitialBody()):this.bodyIndex>=0&&(0===this.bodyStruct.wrappedShapes.length&&null==this.wrappedBody||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.isEnabled||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.rigidBody.enabledInHierarchy)&&(this.body.clearState(),this.bodyIndex=-1,this.wrappedWorld.removeSharedBody(this))}},{key:"ghostEnabled",set:function(t){t?this.ghostIndex<0&&this.ghostStruct.wrappedShapes.length>0&&(this.ghostIndex=1,this.wrappedWorld.addGhostObject(this),this.syncInitialGhost()):this.ghostIndex>=0&&0===this.ghostStruct.wrappedShapes.length&&this.ghost&&(this.ghostIndex=-1,this.wrappedWorld.removeGhostObject(this))}},{key:"reference",set:function(t){t?this.ref++:this.ref--,0===this.ref&&this.destroy()}}]),t}();XZ.idCounter=0,XZ.sharedBodesMap=new Map;var YZ=function(){function t(){this.matrix=[]}var e=t.prototype;return e.get=function(t,e){if(e>t){var i=e;e=t,t=i}return this.matrix[(t*(t+1)>>1)+e-1]},e.set=function(t,e,i){if(e>t){var r=e;e=t,t=r}this.matrix[(t*(t+1)>>1)+e-1]=i?1:0},e.reset=function(){this.matrix.length=0},e.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1},t}(),qZ=function(){function t(){this.data=void 0,this.data={keys:[]}}var e=t.prototype;return e.get=function(t,e){if(t>e){var i=e;e=t,t=i}return this.data[t+"-"+e]},e.set=function(t,e,i){if(t>e){var r=e;e=t,t=r}var n=t+"-"+e;if(null==i){var s=this.data.keys.indexOf(n);if(-1!==s)return this.data.keys.splice(s,1),delete this.data[n],i}return this.get(t,e)||this.data.keys.push(n),this.data[n]=i,this.data[n]},e.reset=function(){this.data={keys:[]}},e.getLength=function(){return this.data.keys.length},e.getKeyByIndex=function(t){return this.data.keys[t]},e.getDataByKey=function(t){return this.data[t]},t}(),JZ=function(){function t(t){this.impl=null,this.event=void 0,this.event=t}var e=t.prototype;return e.getLocalPointOnA=function(t){this.impl&&yW(t,this.impl.m_localPointA)},e.getLocalPointOnB=function(t){this.impl&&yW(t,this.impl.m_localPointB)},e.getWorldPointOnA=function(t){this.impl&&yW(t,this.impl.m_positionWorldOnA)},e.getWorldPointOnB=function(t){this.impl&&yW(t,this.impl.m_positionWorldOnB)},e.getLocalNormalOnA=function(t){if(this.impl){yW(t,this.impl.m_normalWorldOnB),this.isBodyA||ii.negate(t,t);var e=kZ,i=FZ.instance.QUAT_0;this.event.impl.getBody0().getWorldTransform().getBasis().getRotation(i),vW(e,i),si.conjugate(e,e),ii.transformQuat(t,t,e)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=kZ,i=FZ.instance.QUAT_0;this.event.impl.getBody1().getWorldTransform().getBasis().getRotation(i),vW(e,i),si.conjugate(e,e),yW(t,this.impl.m_normalWorldOnB),ii.transformQuat(t,t,e)}},e.getWorldNormalOnA=function(t){this.impl&&(yW(t,this.impl.m_normalWorldOnB),this.isBodyA||ii.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&yW(t,this.impl.m_normalWorldOnB)},Pe(t,[{key:"isBodyA",get:function(){var t=this.event.selfCollider.shape.sharedBody.body,e=this.event.impl.getBody0();return Ammo.compare(e,t)}}]),t}(),KZ=[],ZZ=LZ,QZ=VZ,$Z=function(){var t=e.prototype;function e(){this._btWorld=void 0,this._btBroadphase=void 0,this._btSolver=void 0,this._btDispatcher=void 0,this._btCollisionConfiguration=void 0,this.bodies=[],this.ghosts=[],this.constraints=[],this.triggerArrayMat=new YZ,this.collisionArrayMat=new YZ,this.contactsDic=new qZ,this.oldContactsDic=new qZ,this._btCollisionConfiguration=new jn.btDefaultCollisionConfiguration,this._btDispatcher=new jn.btCollisionDispatcher(this._btCollisionConfiguration),this._btBroadphase=new jn.btDbvtBroadphase,this._btSolver=new jn.btSequentialImpulseConstraintSolver,this._btWorld=new jn.btDiscreteDynamicsWorld(this._btDispatcher,this._btBroadphase,this._btSolver,this._btCollisionConfiguration),this._btWorld.getPairCache().setOverlapFilterCallback(new jn.ccOverlapFilterCallback);var t=FZ.instance.VECTOR3_0;t.setValue(0,-10,0),this._btWorld.setGravity(t),e.closeHitCB||(e.closeHitCB=new jn.ClosestRayResultCallback(t,t)),e.allHitsCB||(e.allHitsCB=new jn.AllHitsRayResultCallback(t,t)),e.closeHitCB.setUseCC(!0),e.allHitsCB.setUseCC(!0)}return t.setAllowSleep=function(){},t.setDefaultMaterial=function(){},t.setGravity=function(t){var e=FZ.instance.VECTOR3_0;mW(e,t),this._btWorld.setGravity(e)},t.destroy=function(){(this.constraints.length||this.bodies.length)&&Ie("You should destroy all physics component first."),jn.destroy(this._btWorld),jn.destroy(this._btSolver),jn.destroy(this._btBroadphase),jn.destroy(this._btDispatcher),jn.destroy(this._btCollisionConfiguration),this._btCollisionConfiguration=null,this._btDispatcher=null,this._btBroadphase=null,this._btSolver=null,this._btWorld=null,this.bodies=null,this.ghosts=null,this.constraints=null,this.triggerArrayMat=null,this.collisionArrayMat=null,this.contactsDic=null,this.oldContactsDic=null,KZ.length=0},t.step=function(t,e,i){if(void 0===i&&(i=0),0!==this.bodies.length||0!==this.ghosts.length){void 0===e&&(e=t),this._btWorld.stepSimulation(e,i,t);for(var r=0;r<this.bodies.length;r++)this.bodies[r].syncPhysicsToScene()}},t.syncSceneToPhysics=function(){for(var t=0;t<this.ghosts.length;t++)this.ghosts[t].updateDirty(),this.ghosts[t].syncSceneToGhost();for(var e=0;e<this.bodies.length;e++)this.bodies[e].updateDirty(),this.bodies[e].syncSceneToPhysics()},t.syncAfterEvents=function(){this.syncSceneToPhysics()},t.raycast=function(t,i,r,n){var s=e.allHitsCB,a=mW(s.m_rayFromWorld,t.o);t.computeHit(ZZ,i.maxDistance);var o=mW(s.m_rayToWorld,ZZ);s.m_collisionFilterGroup=-1,s.m_collisionFilterMask=i.mask,s.m_closestHitFraction=1,s.m_shapePart=-1,s.m_collisionObject=null,s.m_shapeParts.clear(),s.m_hitFractions.clear(),s.m_collisionObjects.clear();var l=s.m_hitPointWorld,h=s.m_hitNormalWorld;if(l.clear(),h.clear(),this._btWorld.rayTest(a,o,s),s.hasHit()){for(var u=0,c=s.m_collisionObjects.size();u<c;u++){var _=s.m_collisionObjects.at(u),f=_.getCollisionShape(),p=void 0;if(f.isCompound()){var d=s.m_shapeParts.at(u),m=_.getUserIndex();p=UZ.bodyAndGhosts["KEY"+m].wrappedShapes[d]}else p=f.wrapped;yW(ZZ,l.at(u)),yW(QZ,h.at(u));var y=ii.distance(t.o,ZZ),g=r.add();g._assign(ZZ,y,p.collider,QZ),n.push(g)}return!0}return!1},t.raycastClosest=function(t,i,r){var n=e.closeHitCB,s=mW(n.m_rayFromWorld,t.o);t.computeHit(ZZ,i.maxDistance);var a=mW(n.m_rayToWorld,ZZ);if(n.m_collisionFilterGroup=-1,n.m_collisionFilterMask=i.mask,n.m_closestHitFraction=1,n.m_collisionObject=null,this._btWorld.rayTest(s,a,n),n.hasHit()){var o,l=n.m_collisionObject,h=l.getCollisionShape();if(h.isCompound()){var u=l.getUserIndex(),c=UZ.bodyAndGhosts["KEY"+u],_=n.m_shapePart;o=c.wrappedShapes[_]}else o=h.wrapped;yW(ZZ,n.m_hitPointWorld),yW(QZ,n.m_hitNormalWorld);var f=ii.distance(t.o,ZZ);return r._assign(ZZ,f,o.collider,QZ),!0}return!1},t.getSharedBody=function(t,e){return XZ.getSharedBody(t,this,e)},t.addSharedBody=function(t){this.bodies.indexOf(t)<0&&(this.bodies.push(t),this._btWorld.addRigidBody(t.body,t.collisionFilterGroup,t.collisionFilterMask))},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(Zn(this.bodies,e),this._btWorld.removeRigidBody(t.body))},t.addGhostObject=function(t){this.ghosts.indexOf(t)<0&&(this.ghosts.push(t),this._btWorld.addCollisionObject(t.ghost,t.collisionFilterGroup,t.collisionFilterMask))},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(Zn(this.ghosts,e),this._btWorld.removeCollisionObject(t.ghost))},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),this._btWorld.addConstraint(t.impl,!t.constraint.enableCollision),t.index=e)},t.removeConstraint=function(t){var e=this.constraints.indexOf(t);e>=0&&(this.constraints.splice(e,1),this._btWorld.removeConstraint(t.impl),t.index=-1)},t.emitEvents=function(){for(var t=this._btDispatcher.getNumManifolds(),e=0;e<t;e++){var i=this._btDispatcher.getManifoldByIndexInternal(e),r=i.getBody0(),n=i.getBody1();if(!r.useCharacter&&!n.useCharacter)for(var s=i.getNumContacts(),a=0;a<s;a++){var o=i.getContactPoint(a),l=o.getShape0(),h=o.getShape1(),u=void 0,c=void 0;if(u=l.isCompound()?jn.castObject(l,jn.btCompoundShape).getChildShape(o.m_index0).wrapped:l.wrapped,c=h.isCompound()?jn.castObject(h,jn.btCompoundShape).getChildShape(o.m_index1).wrapped:h.wrapped,u&&c&&(u.collider.needTriggerEvent||c.collider.needTriggerEvent||u.collider.needCollisionEvent||c.collider.needCollisionEvent)){var _=this.contactsDic.get(u.id,c.id);null==_&&(_=this.contactsDic.set(u.id,c.id,{shape0:u,shape1:c,contacts:[],impl:i})),_.contacts.push(o)}}}for(var f=this.contactsDic.getLength();f--;){KZ.push.apply(KZ,OZ.contacts),OZ.contacts.length=0;var p=this.contactsDic.getKeyByIndex(f),d=this.contactsDic.getDataByKey(p),m=d.shape0,y=d.shape1;this.oldContactsDic.set(m.id,y.id,d);var g=m.collider,v=y.collider;if(g&&v){if(g.isTrigger||v.isTrigger)this.triggerArrayMat.get(m.id,y.id)?IZ.type="onTriggerStay":(IZ.type="onTriggerEnter",this.triggerArrayMat.set(m.id,y.id,!0)),IZ.impl=d.impl,IZ.selfCollider=g,IZ.otherCollider=v,g.emit(IZ.type,IZ),IZ.selfCollider=v,IZ.otherCollider=g,v.emit(IZ.type,IZ);else{var b=g.attachedRigidBody,S=v.attachedRigidBody;if(b&&S){if(b.isSleeping&&S.isSleeping)continue}else if(null==b&&S){if(S.isSleeping)continue}else if(null==S&&b&&b.isSleeping)continue;this.collisionArrayMat.get(m.id,y.id)?OZ.type="onCollisionStay":(OZ.type="onCollisionEnter",this.collisionArrayMat.set(m.id,y.id,!0));for(var A=0;A<d.contacts.length;A++){var C=d.contacts[A];if(KZ.length>0){var x=KZ.pop();x.impl=C,OZ.contacts.push(x)}else{var T=new JZ(OZ);T.impl=C,OZ.contacts.push(T)}}OZ.impl=d.impl,OZ.selfCollider=g,OZ.otherCollider=v,g.emit(OZ.type,OZ),OZ.selfCollider=v,OZ.otherCollider=g,v.emit(OZ.type,OZ)}null==this.oldContactsDic.get(m.id,y.id)&&this.oldContactsDic.set(m.id,y.id,d)}}for(var w=this.oldContactsDic.getLength();w--;){var E=this.oldContactsDic.getKeyByIndex(w),B=this.oldContactsDic.getDataByKey(E),D=B.shape0,M=B.shape1,P=D.collider,R=M.collider;if(P&&R){var I=P.isTrigger||R.isTrigger;null==this.contactsDic.getDataByKey(E)&&(I?this.triggerArrayMat.get(D.id,M.id)&&(IZ.type="onTriggerExit",IZ.selfCollider=P,IZ.otherCollider=R,P.emit(IZ.type,IZ),IZ.selfCollider=R,IZ.otherCollider=P,R.emit(IZ.type,IZ),this.triggerArrayMat.set(D.id,M.id,!1),this.oldContactsDic.set(D.id,M.id,null)):this.collisionArrayMat.get(D.id,M.id)&&(KZ.push.apply(KZ,OZ.contacts),OZ.contacts.length=0,OZ.type="onCollisionExit",OZ.selfCollider=P,OZ.otherCollider=R,P.emit(OZ.type,OZ),OZ.selfCollider=R,OZ.otherCollider=P,R.emit(OZ.type,OZ),this.collisionArrayMat.set(D.id,M.id,!1),this.oldContactsDic.set(D.id,M.id,null)))}}this.contactsDic.reset()},Pe(e,[{key:"impl",get:function(){return this._btWorld}}]),e}();$Z.closeHitCB=void 0,$Z.allHitsCB=void 0;var tQ=LZ,eQ=function(){var t=e.prototype;function e(t){this.id=void 0,this.type=void 0,this._index=-1,this._isEnabled=!1,this._isBinding=!1,this._isTrigger=!1,this._btCompound=null,this.transform=void 0,this.quat=void 0,this.scale=void 0,this.type=t,this.id=e.idCounter++,this.quat=new jn.btQuaternion,this.transform=new jn.btTransform,this.transform.setIdentity(),this.scale=new jn.btVector3(1,1,1)}return t.updateEventListener=function(){},t.setMaterial=function(t){!this._isTrigger&&this._isEnabled&&t&&(this._btCompound?this._btCompound.setMaterial(this._index,t.friction,t.restitution,t.rollingFriction,t.spinningFriction,2):(this._sharedBody.body.setFriction(t.friction),this._sharedBody.body.setRestitution(t.restitution),this._sharedBody.body.setRollingFriction(t.rollingFriction),this._sharedBody.body.setSpinningFriction(t.spinningFriction),this._sharedBody.body.setUserIndex2(2)))},t.setCenter=function(t){ii.copy(tQ,t),tQ.multiply(this._collider.node.worldScale),mW(this.transform.getOrigin(),tQ),this.updateCompoundTransform()},t.setAsTrigger=function(t){this._isTrigger!==t&&(this._isEnabled&&(this._sharedBody.removeShape(this,!t),this._sharedBody.addShape(this,t)),this._isTrigger=t)},t.getAABB=function(t){var e=FZ.instance.TRANSFORM;e.setIdentity(),e.setRotation(gW(FZ.instance.QUAT_0,this._collider.node.worldRotation));var i=FZ.instance.VECTOR3_0,r=FZ.instance.VECTOR3_1;this._btShape.getAabb(e,i,r),t.halfExtents.set((r.x()-i.x())/2,(r.y()-i.y())/2,(r.z()-i.z())/2),ii.add(t.center,this._collider.node.worldPosition,this._collider.center)},t.getBoundingSphere=function(t){t.radius=this._btShape.getLocalBoundingSphere(),ii.add(t.center,this._collider.node.worldPosition,this._collider.center)},t.initialize=function(t){this._collider=t,this._isBinding=!0,this._sharedBody=RX.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},t.onComponentSet=function(){},t.onLoad=function(){this.setCenter(this._collider.center),this.setAsTrigger(this._collider.isTrigger)},t.onEnable=function(){this._isEnabled=!0,this._sharedBody.addShape(this,this._isTrigger),this.setMaterial(this.collider.sharedMaterial)},t.onDisable=function(){this._isEnabled=!1,this._sharedBody.removeShape(this,this._isTrigger)},t.onDestroy=function(){this._sharedBody.reference=!1,this._btCompound=null,this._collider=null,jn.castObject(this._btShape,jn.btCollisionShape).wrapped=null,jn.destroy(this.quat),jn.destroy(this.scale),jn.destroy(this.transform),this._btShape!==FZ.instance.EMPTY_SHAPE&&(jn.destroy(this._btShape),bW(this._btShape,jn.btCollisionShape)),this._btShape=null,this.transform=null,this.quat=null,this.scale=null},t.updateByReAdd=function(){this._isEnabled&&(this._sharedBody.removeShape(this,this._isTrigger),this._sharedBody.addShape(this,this._isTrigger))},t.getGroup=function(){return this._sharedBody.collisionFilterGroup},t.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},t.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},t.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},t.getMask=function(){return this._sharedBody.collisionFilterMask},t.setMask=function(t){this._sharedBody.collisionFilterMask=t},t.addMask=function(t){this._sharedBody.collisionFilterMask|=t},t.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},t.setCompound=function(t){this._btCompound&&(this._btCompound.removeChildShape(this._btShape),this._index=-1),t&&(this._index=t.getNumChildShapes(),t.addChildShape(this.transform,this._btShape)),this._btCompound=t},t.setWrapper=function(){jn.castObject(this._btShape,jn.btCollisionShape).wrapped=this},t.setScale=function(){this.setCenter(this._collider.center)},t.updateCompoundTransform=function(){this._btCompound?this._btCompound.updateChildTransform(this.index,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=CZ.BODY_RE_ADD)},t.needCompound=function(){return this.type===DZ.TERRAIN_SHAPE_PROXYTYPE||!this._collider.center.equals(ii.ZERO)},t.debugTransform=function(t){var i;null==e._debugTransform&&(e._debugTransform=new jn.btTransform),i=this._isTrigger?this._sharedBody.ghost.getWorldTransform():this._sharedBody.body.getWorldTransform();var r=this.transform;e._debugTransform.setIdentity(),e._debugTransform.op_mul(i).op_mul(r);var n=e._debugTransform.getOrigin();t.worldPosition=new ii(n.x(),n.y(),n.z());var s=e._debugTransform.getRotation();t.worldRotation=new si(s.x(),s.y(),s.z(),s.w());var a=this.impl.getLocalScaling();t.scale=new ii(a.x(),a.y(),a.z())},Pe(e,[{key:"attachedRigidBody",get:function(){return this._sharedBody.wrappedBody?this._sharedBody.wrappedBody.rigidBody:null}},{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}},{key:"sharedBody",get:function(){return this._sharedBody}},{key:"index",get:function(){return this._index}}]),e}();eQ.idCounter=0,eQ._debugTransform=void 0;var iQ,rQ,nQ=function(t){Me(i,t);var e=i.prototype;function i(){return t.call(this,DZ.BOX_SHAPE_PROXYTYPE)||this}return e.setSize=function(t){var e=LZ;ii.multiplyScalar(e,t,.5);var i=FZ.instance.VECTOR3_0;mW(i,e),this.impl.setUnscaledHalfExtents(i),this.updateCompoundTransform()},e.onComponentSet=function(){var t=this.collider.size,e=FZ.instance.VECTOR3_0;e.setValue(t.x/2,t.y/2,t.z/2),this._btShape=new jn.btBoxShape(e),this.setScale()},e.setScale=function(){t.prototype.setScale.call(this),mW(this.scale,this._collider.node.worldScale),this._btShape.setLocalScaling(this.scale),this.updateCompoundTransform()},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),sQ=function(t){Me(i,t);var e=i.prototype;function i(){return t.call(this,DZ.SPHERE_SHAPE_PROXYTYPE)||this}return e.setRadius=function(t){this.impl.setUnscaledRadius(t),this.updateCompoundTransform()},e.onComponentSet=function(){this._btShape=new jn.btSphereShape(this.collider.radius),this.setScale()},e.setScale=function(){t.prototype.setScale.call(this);var e=LZ,i=this._collider.node.worldScale,r=Math.abs(i.x),n=Math.abs(i.y),s=Math.abs(i.z),a=Math.max(Math.max(r,n),s);e.set(a,a,a),mW(this.scale,e),this._btShape.setLocalScaling(this.scale),this.updateCompoundTransform()},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),aQ=function(t){Me(i,t);var e=i.prototype;function i(){return t.call(this,DZ.CAPSULE_SHAPE_PROXYTYPE)||this}return e.setCylinderHeight=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},e.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},e.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},e.onComponentSet=function(){this._btShape=new jn.btCapsuleShape(.5,1),this.setRadius(this.collider.radius)},e.setScale=function(){t.prototype.setScale.call(this),this.setRadius(this.collider.radius)},e.updateProperties=function(t,e,i,r){var n=r,s=i;if(1===s){var a=t*Math.abs(Kn(n.x,n.z)),o=e/2*Math.abs(n.y);this.impl.updateProp(a,o,s)}else if(0===s){var l=t*Math.abs(Kn(n.y,n.z)),h=e/2*Math.abs(n.x);this.impl.updateProp(l,h,s)}else{var u=t*Math.abs(Kn(n.x,n.y)),c=e/2*Math.abs(n.z);this.impl.updateProp(u,c,s)}this.updateCompoundTransform()},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),oQ=function(t){Me(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this,DZ.TRIANGLE_MESH_SHAPE_PROXYTYPE)||this).refBtTriangleMesh=null,e}return e.setMesh=function(t){if(this._isBinding)if(null!=this._btShape&&this._btShape!==FZ.instance.EMPTY_SHAPE)ze(9620);else{var e=t;if(e&&e.renderingSubMeshes.length>0){var i=this._getBtTriangleMesh(e);this.collider.convex?this._btShape=new jn.btConvexTriangleMeshShape(i,!0):this._btShape=new jn.btBvhTriangleMeshShape(i,!0,!0),mW(this.scale,this._collider.node.worldScale),this._btShape.setMargin(.01),this._btShape.setLocalScaling(this.scale),this.setWrapper(),this.setCompound(this._btCompound),this.updateByReAdd()}else this._btShape=FZ.instance.EMPTY_SHAPE}},e.onComponentSet=function(){this.setMesh(this.collider.mesh)},e.onDestroy=function(){this.refBtTriangleMesh&&jn.destroy(this.refBtTriangleMesh),t.prototype.onDestroy.call(this)},e.setCompound=function(e){t.prototype.setCompound.call(this,e),this.impl.setUserIndex(this._index)},e.setScale=function(){t.prototype.setScale.call(this),mW(this.scale,this._collider.node.worldScale),this._btShape.setLocalScaling(this.scale),this.updateCompoundTransform()},e._getBtTriangleMesh=function(t){var e,i=jn.CC_CACHE;if(i.btTriangleMesh.enable){if(null==i.btTriangleMesh[t._uuid]){var r=new jn.btTriangleMesh;i.btTriangleMesh[t._uuid]=r,SW(r,t)}e=i.btTriangleMesh[t._uuid]}else this.refBtTriangleMesh=e=new jn.btTriangleMesh,SW(e,t);return e},Pe(i,[{key:"collider",get:function(){return this._collider}},{key:"impl",get:function(){return this._btShape}}]),i}(eQ),lQ=function(t){Me(i,t);var e=i.prototype;function i(){return t.call(this,DZ.CYLINDER_SHAPE_PROXYTYPE)||this}return e.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},e.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},e.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},e.onComponentSet=function(){var t=FZ.instance.VECTOR3_0;t.setValue(.5,1,.5),this._btShape=new jn.btCylinderShape(t),this.setRadius(this.collider.radius)},e.setScale=function(){t.prototype.setScale.call(this),this.setRadius(this.collider.radius)},e.updateProperties=function(t,e,i,r){var n=r,s=i;if(1===s){var a=e*Math.abs(n.y),o=t*Math.abs(Kn(n.x,n.z)),l=a/2;this.impl.updateProp(o,l,s)}else if(0===s){var h=e*Math.abs(n.x),u=t*Math.abs(Kn(n.y,n.z)),c=h/2;this.impl.updateProp(u,c,s)}else{var _=e*Math.abs(n.z),f=t*Math.abs(Kn(n.x,n.y)),p=_/2;this.impl.updateProp(f,p,s)}this.updateCompoundTransform()},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),hQ=function(t){Me(i,t);var e=i.prototype;function i(){return t.call(this,DZ.CONE_SHAPE_PROXYTYPE)||this}return e.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},e.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},e.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},e.onComponentSet=function(){this._btShape=new jn.btConeShape(.5,1),this.setRadius(this.collider.radius)},e.setScale=function(){t.prototype.setScale.call(this),this.setRadius(this.collider.radius)},e.updateProperties=function(t,e,i,r){var n=r,s=i;if(1===s){var a=e*Math.abs(n.y),o=t*Math.abs(Kn(n.x,n.z));this.impl.setRadius(o),this.impl.setHeight(a)}else if(0===s){var l=e*Math.abs(n.x),h=t*Math.abs(Kn(n.y,n.z));this.impl.setRadius(h),this.impl.setHeight(l)}else{var u=e*Math.abs(n.z),c=t*Math.abs(Kn(n.x,n.y));this.impl.setRadius(c),this.impl.setHeight(u)}this.impl.setConeUpIndex(s),this.scale.setValue(1,1,1),this.impl.setLocalScaling(this.scale),this.updateCompoundTransform()},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),uQ=function(t){Me(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this,DZ.TERRAIN_SHAPE_PROXYTYPE)||this)._terrainID=void 0,e._buffPtr=void 0,e._tileSize=void 0,e._localOffset=void 0,e._terrainID="",e._buffPtr=0,e._tileSize=0,e._localOffset=new ii,e}return e.setTerrain=function(t){if(this._isBinding)if(null!=this._btShape&&this._btShape!==FZ.instance.EMPTY_SHAPE)Ue("[Physics] Ammo change the terrain asset after initialization is not support.");else{var e=t;if(e){this._terrainID=e._uuid,this._tileSize=e.tileSize;var i=e.getVertexCountI(),r=e.getVertexCountJ();this._buffPtr=jn._malloc(4*i*r);for(var n=0,s=Number.MIN_VALUE,a=Number.MAX_VALUE,o=0;o<r;o++)for(var l=0;l<i;l++){var h=e.getHeight(l,o);jn.HEAPF32[this._buffPtr+n>>2]=h,s=s<h?h:s,a=a>h?h:a,n+=4}s+=.1,a-=.1,this._localOffset.set((i-1)/2*this._tileSize,(s+a)/2,(r-1)/2*this._tileSize),this._btShape=new jn.btHeightfieldTerrainShape(i,r,this._buffPtr,1,a,s,1,"PHY_FLOAT",!1),this.scale.setValue(this._tileSize,1,this._tileSize),this._btShape.setLocalScaling(this.scale)}else this._btShape=FZ.instance.EMPTY_SHAPE}},e.onComponentSet=function(){this.setTerrain(this.collider.terrain)},e.onDestroy=function(){this._buffPtr&&jn._free(this._buffPtr),t.prototype.onDestroy.call(this)},e.setCompound=function(e){t.prototype.setCompound.call(this,e),this.impl.setUserIndex(this._index)},e.setCenter=function(t){ii.copy(LZ,t),LZ.add(this._localOffset),mW(this.transform.getOrigin(),LZ),this.updateCompoundTransform()},Pe(i,[{key:"collider",get:function(){return this._collider}},{key:"impl",get:function(){return this._btShape}}]),i}(eQ),cQ=function(t){Me(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this,DZ.TETRAHEDRAL_SHAPE_PROXYTYPE)||this).VERTICES=[],e}return e.setShapeType=function(){this._isBinding},e.setVertices=function(t){for(var e=this.VERTICES.length,i=0;i<e;i++)mW(this.VERTICES[i],t[i]);mW(this.scale,this._collider.node.worldScale),this._btShape.setLocalScaling(this.scale),this._btCompound&&this._btCompound.updateChildTransform(this.index,this.transform,!0)},e.onComponentSet=function(){this._btShape=new jn.btBU_Simplex1to4;for(var t=this.collider.shapeType,e=this.collider.vertices,i=0;i<t;i++)this.VERTICES[i]=new jn.btVector3,mW(this.VERTICES[i],e[i]),this.impl.addVertex(this.VERTICES[i]);mW(this.scale,this._collider.node.worldScale),this._btShape.setLocalScaling(this.scale)},e.onLoad=function(){t.prototype.onLoad.call(this),this.collider.updateVertices()},e.onDestroy=function(){for(var e=this.VERTICES.length,i=0;i<e;i++)jn.destroy(this.VERTICES[i]);this.VERTICES=null,t.prototype.onDestroy.call(this)},e.setScale=function(){t.prototype.setScale.call(this),mW(this.scale,this._collider.node.worldScale),this._btShape.setLocalScaling(this.scale),this._btCompound&&this._btCompound.updateChildTransform(this.index,this.transform,!0)},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),_Q=function(t){Me(i,t);var e=i.prototype;function i(){return t.call(this,DZ.STATIC_PLANE_PROXYTYPE)||this}return e.setNormal=function(t){mW(this.impl.getPlaneNormal(),t),this.updateCompoundTransform()},e.setConstant=function(t){this.impl.setPlaneConstant(t),this.updateCompoundTransform()},e.setScale=function(){t.prototype.setScale.call(this),mW(this.scale,this._collider.node.worldScale),this._btShape.setLocalScaling(this.scale),this.updateCompoundTransform()},e.onComponentSet=function(){var t=FZ.instance.VECTOR3_0;mW(t,this.collider.normal),this._btShape=new jn.btStaticPlaneShape(t,this.collider.constant),this.setScale()},Pe(i,[{key:"impl",get:function(){return this._btShape}},{key:"collider",get:function(){return this._collider}}]),i}(eQ),fQ=function(){function t(){this.dirty=0,this.index=-1,this._collided=!1}var e=t.prototype;return e.setConnectedBody=function(){},e.setEnableCollision=function(t){this._collided!==t&&(this._collided=t,this.updateByReAdd())},e.updateByReAdd=function(){if(this._rigidBody&&this.index>=0){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.wrappedWorld.addConstraint(this)}},e.initialize=function(t){this._com=t,this._rigidBody=t.attachedBody,this._collided=t.enableCollision,this.onComponentSet()},e.onComponentSet=function(){},e.updateScale0=function(){},e.updateScale1=function(){},e.onEnable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.addConstraint(this),t.addJoint(this,0);var e=this.constraint.connectedBody;e&&e.body.sharedBody.addJoint(this,1)},e.onDisable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.removeJoint(this,0);var e=this.constraint.connectedBody;e&&e.body.sharedBody.removeJoint(this,1)},e.onDestroy=function(){jn.destroy(this._impl),this._com=null,this._rigidBody=null,this._impl=null},Pe(t,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),t}(),pQ=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setPivotA=function(){var t=FZ.instance.VECTOR3_0,e=this.constraint;ii.multiply(LZ,e.node.worldScale,e.pivotA),mW(t,LZ),this.impl.setPivotA(t),e.connectedBody||this.setPivotB(e.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=FZ.instance.VECTOR3_0,r=t.connectedBody;r?(ii.multiply(LZ,r.node.worldScale,t.pivotB),mW(i,LZ)):(ii.multiply(LZ,e.worldScale,t.pivotA),ii.add(LZ,LZ,e.worldPosition),ii.add(LZ,LZ,t.pivotB),mW(i,LZ)),this.impl.setPivotB(i)},i.onComponentSet=function(){var t,e=this._rigidBody.body.impl,i=this.constraint.connectedBody;i&&(t=i.body.impl);var r=FZ.instance.VECTOR3_0;if(t){var n=FZ.instance.VECTOR3_1;this._impl=new jn.btPoint2PointConstraint(e,t,r,n)}else this._impl=new jn.btPoint2PointConstraint(e,r);this.setPivotA(this.constraint.pivotA),this.setPivotB(this.constraint.pivotB)},i.updateScale0=function(){this.setPivotA(this.constraint.pivotA)},i.updateScale1=function(){this.setPivotB(this.constraint.pivotB)},Pe(e,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),e}(fQ),dQ=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setPivotA=function(){this.updateFrames()},i.setPivotB=function(){this.updateFrames()},i.setAxis=function(){this.updateFrames()},i.onComponentSet=function(){var t=this._rigidBody.body.sharedBody,e=this.constraint.connectedBody,i=e?e.body.impl:t.wrappedWorld.impl.getFixedBody(),r=FZ.instance.TRANSFORM,n=FZ.instance.TRANSFORM_1;this._impl=new jn.btHingeConstraint(t.body,i,r,n),this.updateFrames()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=LZ,r=kZ,n=FZ.instance.TRANSFORM;ii.multiply(i,e.worldScale,t.pivotA),mW(n.getOrigin(),i);var s=FZ.instance.QUAT_0;si.rotationTo(r,ii.UNIT_Z,t.axis),n.setRotation(gW(s,r));var a=FZ.instance.TRANSFORM_1,o=this.constraint.connectedBody;o?ii.multiply(i,o.node.worldScale,t.pivotB):(ii.multiply(i,e.worldScale,t.pivotA),ii.add(i,i,e.worldPosition),ii.add(i,i,t.pivotB),si.multiply(r,r,e.worldRotation)),mW(a.getOrigin(),i),a.setRotation(gW(s,r)),this.impl.setFrames(n,a)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},Pe(e,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),e}(fQ);dW.select("ammo.js",{PhysicsWorld:$Z,RigidBody:zZ,BoxShape:nQ,SphereShape:sQ,CapsuleShape:aQ,TrimeshShape:oQ,CylinderShape:lQ,ConeShape:hQ,TerrainShape:uQ,SimplexShape:cQ,PlaneShape:_Q,PointToPointConstraint:pQ,HingeConstraint:dQ}),window.Ammo=jn,jn.CC_CONFIG={ignoreSelfBody:!0},jn.CC_CACHE={btTriangleMesh:{enable:!1}};var mQ=Ss((function(t,e){!function(t){function e(t,e){return void 0!==t?t:e}var i=1e37,r=1e-5,n=r*r,s=3.14159265359,a=.1,o=.008,l=2/180*s,h=.016,u=.2,c=8/180*s,_=.5*s,f=2.4674011002726646,p=-1,d=.75,m=.25,y=256,g=.01,v=2/180*s;var b=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.major=0,this.minor=0,this.revision=0,this.major=t,this.minor=e,this.revision=i}return t.prototype.toString=function(){return this.major+"."+this.minor+"."+this.revision},t}(),S=new b(2,3,2);function A(t,e){for(var i=new Array(t),r=0;r<t;++r)i[r]=e(r);return i}function C(t,e){void 0===e&&(e=0);for(var i=new Array(t),r=0;r<t;++r)i[r]=e;return i}var x=s/180,T=180/s,w=2*s,E=Math.abs;function B(t,e){return t<e?t:e}function D(t,e){return t>e?t:e}function M(t,e,i){return t<e?e:t>i?i:t}var P=isFinite;function R(t){return t*t}function I(t){return 1/Math.sqrt(t)}var O=Math.sqrt,F=Math.pow;var L=Math.cos,V=Math.sin,k=Math.acos,N=Math.asin,G=Math.atan2;var z=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(e[0]instanceof Float32Array){if(2!==e[0].length)throw new Error;this.data=e[0]}else{var r="number"==typeof e[0]?e[0]:0,n="number"==typeof e[1]?e[1]:0;this.data=new Float32Array([r,n])}}var e=t.prototype;return e.Clone=function(){return new t(this.x,this.y)},e.SetZero=function(){return this.x=0,this.y=0,this},e.Set=function(t,e){return this.x=t,this.y=e,this},e.Copy=function(t){return this.x=t.x,this.y=t.y,this},e.SelfAdd=function(t){return this.x+=t.x,this.y+=t.y,this},e.SelfAddXY=function(t,e){return this.x+=t,this.y+=e,this},e.SelfSub=function(t){return this.x-=t.x,this.y-=t.y,this},e.SelfSubXY=function(t,e){return this.x-=t,this.y-=e,this},e.SelfMul=function(t){return this.x*=t,this.y*=t,this},e.SelfMulAdd=function(t,e){return this.x+=t*e.x,this.y+=t*e.y,this},e.SelfMulSub=function(t,e){return this.x-=t*e.x,this.y-=t*e.y,this},e.Dot=function(t){return this.x*t.x+this.y*t.y},e.Cross=function(t){return this.x*t.y-this.y*t.x},e.Length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},e.LengthSquared=function(){var t=this.x,e=this.y;return t*t+e*e},e.Normalize=function(){var t=this.Length();if(t>=r){var e=1/t;this.x*=e,this.y*=e}return t},e.SelfNormalize=function(){var t=this.Length();if(t>=r){var e=1/t;this.x*=e,this.y*=e}return this},e.SelfRotate=function(t){var e=Math.cos(t),i=Math.sin(t),r=this.x;return this.x=e*r-i*this.y,this.y=i*r+e*this.y,this},e.SelfRotateCosSin=function(t,e){var i=this.x;return this.x=t*i-e*this.y,this.y=e*i+t*this.y,this},e.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)},e.SelfCrossVS=function(t){var e=this.x;return this.x=t*this.y,this.y=-t*e,this},e.SelfCrossSV=function(t){var e=this.x;return this.x=-t*this.y,this.y=t*e,this},e.SelfMinV=function(t){return this.x=B(this.x,t.x),this.y=B(this.y,t.y),this},e.SelfMaxV=function(t){return this.x=D(this.x,t.x),this.y=D(this.y,t.y),this},e.SelfAbs=function(){return this.x=E(this.x),this.y=E(this.y),this},e.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this},e.SelfSkew=function(){var t=this.x;return this.x=-this.y,this.y=t,this},t.MakeArray=function(e){return A(e,(function(){return new t}))},t.AbsV=function(t,e){return e.x=E(t.x),e.y=E(t.y),e},t.MinV=function(t,e,i){return i.x=B(t.x,e.x),i.y=B(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=D(t.x,e.x),i.y=D(t.y,e.y),i},t.ClampV=function(t,e,i,r){return r.x=M(t.x,e.x,i.x),r.y=M(t.y,e.y,i.y),r},t.RotateV=function(t,e,i){var r=t.x,n=t.y,s=Math.cos(e),a=Math.sin(e);return i.x=s*r-a*n,i.y=a*r+s*n,i},t.DotVV=function(t,e){return t.x*e.x+t.y*e.y},t.CrossVV=function(t,e){return t.x*e.y-t.y*e.x},t.CrossVS=function(t,e,i){var r=t.x;return i.x=e*t.y,i.y=-e*r,i},t.CrossVOne=function(t,e){var i=t.x;return e.x=t.y,e.y=-i,e},t.CrossSV=function(t,e,i){var r=e.x;return i.x=-t*e.y,i.y=t*r,i},t.CrossOneV=function(t,e){var i=t.x;return e.x=-t.y,e.y=i,e},t.AddVV=function(t,e,i){return i.x=t.x+e.x,i.y=t.y+e.y,i},t.SubVV=function(t,e,i){return i.x=t.x-e.x,i.y=t.y-e.y,i},t.MulSV=function(t,e,i){return i.x=e.x*t,i.y=e.y*t,i},t.MulVS=function(t,e,i){return i.x=t.x*e,i.y=t.y*e,i},t.AddVMulSV=function(t,e,i,r){return r.x=t.x+e*i.x,r.y=t.y+e*i.y,r},t.SubVMulSV=function(t,e,i,r){return r.x=t.x-e*i.x,r.y=t.y-e*i.y,r},t.AddVCrossSV=function(t,e,i,r){var n=i.x;return r.x=t.x-e*i.y,r.y=t.y+e*n,r},t.MidVV=function(t,e,i){return i.x=.5*(t.x+e.x),i.y=.5*(t.y+e.y),i},t.ExtVV=function(t,e,i){return i.x=.5*(e.x-t.x),i.y=.5*(e.y-t.y),i},t.IsEqualToV=function(t,e){return t.x===e.x&&t.y===e.y},t.DistanceVV=function(t,e){var i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},t.DistanceSquaredVV=function(t,e){var i=t.x-e.x,r=t.y-e.y;return i*i+r*r},t.NegV=function(t,e){return e.x=-t.x,e.y=-t.y,e},Pe(t,[{key:"x",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"y",get:function(){return this.data[1]},set:function(t){this.data[1]=t}}]),t}();z.ZERO=new z(0,0),z.UNITX=new z(1,0),z.UNITY=new z(0,1),z.s_t0=new z,z.s_t1=new z,z.s_t2=new z,z.s_t3=new z;var U=new z(0,0),H=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(e[0]instanceof Float32Array){if(3!==e[0].length)throw new Error;this.data=e[0]}else{var r="number"==typeof e[0]?e[0]:0,n="number"==typeof e[1]?e[1]:0,s="number"==typeof e[2]?e[2]:0;this.data=new Float32Array([r,n,s])}}var e=t.prototype;return e.Clone=function(){return new t(this.x,this.y,this.z)},e.SetZero=function(){return this.x=0,this.y=0,this.z=0,this},e.SetXYZ=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},e.Copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.SelfAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},e.SelfAddXYZ=function(t,e,i){return this.x+=t,this.y+=e,this.z+=i,this},e.SelfSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},e.SelfSubXYZ=function(t,e,i){return this.x-=t,this.y-=e,this.z-=i,this},e.SelfMul=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.DotV3V3=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},t.CrossV3V3=function(t,e,i){var r=t.x,n=t.y,s=t.z,a=e.x,o=e.y,l=e.z;return i.x=n*l-s*o,i.y=s*a-r*l,i.z=r*o-n*a,i},Pe(t,[{key:"x",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"y",get:function(){return this.data[1]},set:function(t){this.data[1]=t}},{key:"z",get:function(){return this.data[2]},set:function(t){this.data[2]=t}}]),t}();H.ZERO=new H(0,0,0),H.s_t0=new H;var j=function(){function t(){this.data=new Float32Array([1,0,0,1]),this.ex=new z(this.data.subarray(0,2)),this.ey=new z(this.data.subarray(2,4))}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},t.FromVV=function(e,i){return(new t).SetVV(e,i)},t.FromSSSS=function(e,i,r,n){return(new t).SetSSSS(e,i,r,n)},t.FromAngle=function(e){return(new t).SetAngle(e)},e.SetSSSS=function(t,e,i,r){return this.ex.Set(t,i),this.ey.Set(e,r),this},e.SetVV=function(t,e){return this.ex.Copy(t),this.ey.Copy(e),this},e.SetAngle=function(t){var e=Math.cos(t),i=Math.sin(t);return this.ex.Set(e,i),this.ey.Set(-i,e),this},e.Copy=function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this},e.SetIdentity=function(){return this.ex.Set(1,0),this.ey.Set(0,1),this},e.SetZero=function(){return this.ex.SetZero(),this.ey.SetZero(),this},e.GetAngle=function(){return Math.atan2(this.ex.y,this.ex.x)},e.GetInverse=function(t){var e=this.ex.x,i=this.ey.x,r=this.ex.y,n=this.ey.y,s=e*n-i*r;return 0!==s&&(s=1/s),t.ex.x=s*n,t.ey.x=-s*i,t.ex.y=-s*r,t.ey.y=s*e,t},e.Solve=function(t,e,i){var r=this.ex.x,n=this.ey.x,s=this.ex.y,a=this.ey.y,o=r*a-n*s;return 0!==o&&(o=1/o),i.x=o*(a*t-n*e),i.y=o*(r*e-s*t),i},e.SelfAbs=function(){return this.ex.SelfAbs(),this.ey.SelfAbs(),this},e.SelfInv=function(){return this.GetInverse(this),this},e.SelfAddM=function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this},e.SelfSubM=function(t){return this.ex.SelfSub(t.ex),this.ey.SelfSub(t.ey),this},t.AbsM=function(t,e){var i=t.ex,r=t.ey;return e.ex.x=E(i.x),e.ex.y=E(i.y),e.ey.x=E(r.x),e.ey.y=E(r.y),e},t.MulMV=function(t,e,i){var r=t.ex,n=t.ey,s=e.x,a=e.y;return i.x=r.x*s+n.x*a,i.y=r.y*s+n.y*a,i},t.MulTMV=function(t,e,i){var r=t.ex,n=t.ey,s=e.x,a=e.y;return i.x=r.x*s+r.y*a,i.y=n.x*s+n.y*a,i},t.AddMM=function(t,e,i){var r=t.ex,n=t.ey,s=e.ex,a=e.ey;return i.ex.x=r.x+s.x,i.ex.y=r.y+s.y,i.ey.x=n.x+a.x,i.ey.y=n.y+a.y,i},t.MulMM=function(t,e,i){var r=t.ex.x,n=t.ex.y,s=t.ey.x,a=t.ey.y,o=e.ex.x,l=e.ex.y,h=e.ey.x,u=e.ey.y;return i.ex.x=r*o+s*l,i.ex.y=n*o+a*l,i.ey.x=r*h+s*u,i.ey.y=n*h+a*u,i},t.MulTMM=function(t,e,i){var r=t.ex.x,n=t.ex.y,s=t.ey.x,a=t.ey.y,o=e.ex.x,l=e.ex.y,h=e.ey.x,u=e.ey.y;return i.ex.x=r*o+n*l,i.ex.y=s*o+a*l,i.ey.x=r*h+n*u,i.ey.y=s*h+a*u,i},t}();j.IDENTITY=new j;var W=function(){function t(){this.data=new Float32Array([1,0,0,0,1,0,0,0,1]),this.ex=new H(this.data.subarray(0,3)),this.ey=new H(this.data.subarray(3,6)),this.ez=new H(this.data.subarray(6,9))}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.SetVVV=function(t,e,i){return this.ex.Copy(t),this.ey.Copy(e),this.ez.Copy(i),this},e.Copy=function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this.ez.Copy(t.ez),this},e.SetIdentity=function(){return this.ex.SetXYZ(1,0,0),this.ey.SetXYZ(0,1,0),this.ez.SetXYZ(0,0,1),this},e.SetZero=function(){return this.ex.SetZero(),this.ey.SetZero(),this.ez.SetZero(),this},e.SelfAddM=function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this.ez.SelfAdd(t.ez),this},e.Solve33=function(t,e,i,r){var n=this.ex.x,s=this.ex.y,a=this.ex.z,o=this.ey.x,l=this.ey.y,h=this.ey.z,u=this.ez.x,c=this.ez.y,_=this.ez.z,f=n*(l*_-h*c)+s*(h*u-o*_)+a*(o*c-l*u);return 0!==f&&(f=1/f),r.x=f*(t*(l*_-h*c)+e*(h*u-o*_)+i*(o*c-l*u)),r.y=f*(n*(e*_-i*c)+s*(i*u-t*_)+a*(t*c-e*u)),r.z=f*(n*(l*i-h*e)+s*(h*t-o*i)+a*(o*e-l*t)),r},e.Solve22=function(t,e,i){var r=this.ex.x,n=this.ey.x,s=this.ex.y,a=this.ey.y,o=r*a-n*s;return 0!==o&&(o=1/o),i.x=o*(a*t-n*e),i.y=o*(r*e-s*t),i},e.GetInverse22=function(t){var e=this.ex.x,i=this.ey.x,r=this.ex.y,n=this.ey.y,s=e*n-i*r;0!==s&&(s=1/s),t.ex.x=s*n,t.ey.x=-s*i,t.ex.z=0,t.ex.y=-s*r,t.ey.y=s*e,t.ey.z=0,t.ez.x=0,t.ez.y=0,t.ez.z=0},e.GetSymInverse33=function(t){var e=H.DotV3V3(this.ex,H.CrossV3V3(this.ey,this.ez,H.s_t0));0!==e&&(e=1/e);var i=this.ex.x,r=this.ey.x,n=this.ez.x,s=this.ey.y,a=this.ez.y,o=this.ez.z;t.ex.x=e*(s*o-a*a),t.ex.y=e*(n*a-r*o),t.ex.z=e*(r*a-n*s),t.ey.x=t.ex.y,t.ey.y=e*(i*o-n*n),t.ey.z=e*(n*r-i*a),t.ez.x=t.ex.z,t.ez.y=t.ey.z,t.ez.z=e*(i*s-r*r)},t.MulM33V3=function(t,e,i){var r=e.x,n=e.y,s=e.z;return i.x=t.ex.x*r+t.ey.x*n+t.ez.x*s,i.y=t.ex.y*r+t.ey.y*n+t.ez.y*s,i.z=t.ex.z*r+t.ey.z*n+t.ez.z*s,i},t.MulM33XYZ=function(t,e,i,r,n){return n.x=t.ex.x*e+t.ey.x*i+t.ez.x*r,n.y=t.ex.y*e+t.ey.y*i+t.ez.y*r,n.z=t.ex.z*e+t.ey.z*i+t.ez.z*r,n},t.MulM33V2=function(t,e,i){var r=e.x,n=e.y;return i.x=t.ex.x*r+t.ey.x*n,i.y=t.ex.y*r+t.ey.y*n,i},t.MulM33XY=function(t,e,i,r){return r.x=t.ex.x*e+t.ey.x*i,r.y=t.ex.y*e+t.ey.y*i,r},t}();W.IDENTITY=new W;var X=function(){function t(t){void 0===t&&(t=0),this.s=0,this.c=1,t&&(this.s=Math.sin(t),this.c=Math.cos(t))}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.s=t.s,this.c=t.c,this},e.SetAngle=function(t){return this.s=Math.sin(t),this.c=Math.cos(t),this},e.SetIdentity=function(){return this.s=0,this.c=1,this},e.GetAngle=function(){return Math.atan2(this.s,this.c)},e.GetXAxis=function(t){return t.x=this.c,t.y=this.s,t},e.GetYAxis=function(t){return t.x=-this.s,t.y=this.c,t},t.MulRR=function(t,e,i){var r=t.c,n=t.s,s=e.c,a=e.s;return i.s=n*s+r*a,i.c=r*s-n*a,i},t.MulTRR=function(t,e,i){var r=t.c,n=t.s,s=e.c,a=e.s;return i.s=r*a-n*s,i.c=r*s+n*a,i},t.MulRV=function(t,e,i){var r=t.c,n=t.s,s=e.x,a=e.y;return i.x=r*s-n*a,i.y=n*s+r*a,i},t.MulTRV=function(t,e,i){var r=t.c,n=t.s,s=e.x,a=e.y;return i.x=r*s+n*a,i.y=-n*s+r*a,i},t}();X.IDENTITY=new X;var Y=function(){function t(){this.p=new z,this.q=new X}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.p.Copy(t.p),this.q.Copy(t.q),this},e.SetIdentity=function(){return this.p.SetZero(),this.q.SetIdentity(),this},e.SetPositionRotation=function(t,e){return this.p.Copy(t),this.q.Copy(e),this},e.SetPositionAngle=function(t,e){return this.p.Copy(t),this.q.SetAngle(e),this},e.SetPosition=function(t){return this.p.Copy(t),this},e.SetPositionXY=function(t,e){return this.p.Set(t,e),this},e.SetRotation=function(t){return this.q.Copy(t),this},e.SetRotationAngle=function(t){return this.q.SetAngle(t),this},e.GetPosition=function(){return this.p},e.GetRotation=function(){return this.q},e.GetRotationAngle=function(){return this.q.GetAngle()},e.GetAngle=function(){return this.q.GetAngle()},t.MulXV=function(t,e,i){var r=t.q.c,n=t.q.s,s=e.x,a=e.y;return i.x=r*s-n*a+t.p.x,i.y=n*s+r*a+t.p.y,i},t.MulTXV=function(t,e,i){var r=t.q.c,n=t.q.s,s=e.x-t.p.x,a=e.y-t.p.y;return i.x=r*s+n*a,i.y=-n*s+r*a,i},t.MulXX=function(t,e,i){return X.MulRR(t.q,e.q,i.q),z.AddVV(X.MulRV(t.q,e.p,i.p),t.p,i.p),i},t.MulTXX=function(t,e,i){return X.MulTRR(t.q,e.q,i.q),X.MulTRV(t.q,z.SubVV(e.p,t.p,i.p),i.p),i},t}();Y.IDENTITY=new Y;var q,J=function(){function t(){this.localCenter=new z,this.c0=new z,this.c=new z,this.a0=0,this.a=0,this.alpha0=0}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.localCenter.Copy(t.localCenter),this.c0.Copy(t.c0),this.c.Copy(t.c),this.a0=t.a0,this.a=t.a,this.alpha0=t.alpha0,this},e.GetTransform=function(t,e){var i=1-e;t.p.x=i*this.c0.x+e*this.c.x,t.p.y=i*this.c0.y+e*this.c.y;var r=i*this.a0+e*this.a;return t.q.SetAngle(r),t.p.SelfSub(X.MulRV(t.q,this.localCenter,z.s_t0)),t},e.Advance=function(t){var e=(t-this.alpha0)/(1-this.alpha0),i=1-e;this.c0.x=i*this.c0.x+e*this.c.x,this.c0.y=i*this.c0.y+e*this.c.y,this.a0=i*this.a0+e*this.a,this.alpha0=t},e.Normalize=function(){var t=w*Math.floor(this.a0/w);this.a0-=t,this.a-=t},t}(),K=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(e[0]instanceof Float32Array){if(4!==e[0].length)throw new Error;this.data=e[0]}else{var r="number"==typeof e[0]?e[0]:.5,n="number"==typeof e[1]?e[1]:.5,s="number"==typeof e[2]?e[2]:.5,a="number"==typeof e[3]?e[3]:1;this.data=new Float32Array([r,n,s,a])}}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},e.IsEqual=function(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a},e.IsZero=function(){return 0===this.r&&0===this.g&&0===this.b&&0===this.a},e.Set=function(t,e,i,r){void 0===r&&(r=this.a),this.SetRGBA(t,e,i,r)},e.SetByteRGB=function(t,e,i){return this.r=t/255,this.g=e/255,this.b=i/255,this},e.SetByteRGBA=function(t,e,i,r){return this.r=t/255,this.g=e/255,this.b=i/255,this.a=r/255,this},e.SetRGB=function(t,e,i){return this.r=t,this.g=e,this.b=i,this},e.SetRGBA=function(t,e,i,r){return this.r=t,this.g=e,this.b=i,this.a=r,this},e.SelfAdd=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this},e.Add=function(t,e){return e.r=this.r+t.r,e.g=this.g+t.g,e.b=this.b+t.b,e.a=this.a+t.a,e},e.SelfSub=function(t){return this.r-=t.r,this.g-=t.g,this.b-=t.b,this.a-=t.a,this},e.Sub=function(t,e){return e.r=this.r-t.r,e.g=this.g-t.g,e.b=this.b-t.b,e.a=this.a-t.a,e},e.SelfMul=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},e.Mul=function(t,e){return e.r=this.r*t,e.g=this.g*t,e.b=this.b*t,e.a=this.a*t,e},e.Mix=function(e,i){t.MixColors(this,e,i)},t.MixColors=function(t,e,i){var r=i*(e.r-t.r),n=i*(e.g-t.g),s=i*(e.b-t.b),a=i*(e.a-t.a);t.r+=r,t.g+=n,t.b+=s,t.a+=a,e.r-=r,e.g-=n,e.b-=s,e.a-=a},e.MakeStyleString=function(e){return void 0===e&&(e=this.a),t.MakeStyleString(this.r,this.g,this.b,e)},t.MakeStyleString=function(t,e,i,r){return void 0===r&&(r=1),t*=255,e*=255,i*=255,r<1?"rgba("+t+","+e+","+i+","+r+")":"rgb("+t+","+e+","+i+")"},Pe(t,[{key:"r",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"g",get:function(){return this.data[1]},set:function(t){this.data[1]=t}},{key:"b",get:function(){return this.data[2]},set:function(t){this.data[2]=t}},{key:"a",get:function(){return this.data[3]},set:function(t){this.data[3]=t}}]),t}();K.ZERO=new K(0,0,0,0),K.RED=new K(1,0,0),K.GREEN=new K(0,1,0),K.BLUE=new K(0,0,1),(q=t.b2DrawFlags||(t.b2DrawFlags={}))[q.e_none=0]="e_none",q[q.e_shapeBit=1]="e_shapeBit",q[q.e_jointBit=2]="e_jointBit",q[q.e_aabbBit=4]="e_aabbBit",q[q.e_pairBit=8]="e_pairBit",q[q.e_centerOfMassBit=16]="e_centerOfMassBit",q[q.e_particleBit=32]="e_particleBit",q[q.e_controllerBit=64]="e_controllerBit",q[q.e_all=63]="e_all";var Z=function(){function t(){this.m_drawFlags=0}var e=t.prototype;return e.SetFlags=function(t){this.m_drawFlags=t},e.GetFlags=function(){return this.m_drawFlags},e.AppendFlags=function(t){this.m_drawFlags|=t},e.ClearFlags=function(t){this.m_drawFlags&=~t},t}(),Q=function(){function t(){this.m_start=Date.now()}var e=t.prototype;return e.Reset=function(){return this.m_start=Date.now(),this},e.GetMilliseconds=function(){return Date.now()-this.m_start},t}(),$=function(){function t(){this.m_count=0,this.m_min_count=0,this.m_max_count=0}var e=t.prototype;return e.GetCount=function(){return this.m_count},e.GetMinCount=function(){return this.m_min_count},e.GetMaxCount=function(){return this.m_max_count},e.ResetCount=function(){var t=this.m_count;return this.m_count=0,t},e.ResetMinCount=function(){this.m_min_count=0},e.ResetMaxCount=function(){this.m_max_count=0},e.Increment=function(){this.m_count++,this.m_max_count<this.m_count&&(this.m_max_count=this.m_count)},e.Decrement=function(){this.m_count--,this.m_min_count>this.m_count&&(this.m_min_count=this.m_count)},t}(),tt=function(){function t(t){this.m_stack=[],this.m_count=0,this.m_stack=A(t,(function(){return null})),this.m_count=0}var e=t.prototype;return e.Reset=function(){return this.m_count=0,this},e.Push=function(t){this.m_stack[this.m_count]=t,this.m_count++},e.Pop=function(){this.m_count--;var t=this.m_stack[this.m_count];if(this.m_stack[this.m_count]=null,null===t)throw new Error;return t},e.GetCount=function(){return this.m_count},t}(),et=function(){function t(){this.m_buffer=z.MakeArray(2),this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0}var e=t.prototype;return e.Copy=function(t){return t.m_vertices===t.m_buffer?(this.m_vertices=this.m_buffer,this.m_buffer[0].Copy(t.m_buffer[0]),this.m_buffer[1].Copy(t.m_buffer[1])):this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius,this},e.Reset=function(){return this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0,this},e.SetShape=function(t,e){t.SetupDistanceProxy(this,e)},e.SetVerticesRadius=function(t,e,i){this.m_vertices=t,this.m_count=e,this.m_radius=i},e.GetSupport=function(t){for(var e=0,i=z.DotVV(this.m_vertices[0],t),r=1;r<this.m_count;++r){var n=z.DotVV(this.m_vertices[r],t);n>i&&(e=r,i=n)}return e},e.GetSupportVertex=function(t){for(var e=0,i=z.DotVV(this.m_vertices[0],t),r=1;r<this.m_count;++r){var n=z.DotVV(this.m_vertices[r],t);n>i&&(e=r,i=n)}return this.m_vertices[e]},e.GetVertexCount=function(){return this.m_count},e.GetVertex=function(t){return this.m_vertices[t]},t}(),it=function(){function t(){this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}return t.prototype.Reset=function(){return this.metric=0,this.count=0,this},t}(),rt=function(){function t(){this.proxyA=new et,this.proxyB=new et,this.transformA=new Y,this.transformB=new Y,this.useRadii=!1}return t.prototype.Reset=function(){return this.proxyA.Reset(),this.proxyB.Reset(),this.transformA.SetIdentity(),this.transformB.SetIdentity(),this.useRadii=!1,this},t}(),nt=function(){function t(){this.pointA=new z,this.pointB=new z,this.distance=0,this.iterations=0}return t.prototype.Reset=function(){return this.pointA.SetZero(),this.pointB.SetZero(),this.distance=0,this.iterations=0,this},t}();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var st=function(){function t(){this.wA=new z,this.wB=new z,this.w=new z,this.a=0,this.indexA=0,this.indexB=0}return t.prototype.Copy=function(t){return this.wA.Copy(t.wA),this.wB.Copy(t.wB),this.w.Copy(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB,this},t}(),at=function(){function t(){this.m_v1=new st,this.m_v2=new st,this.m_v3=new st,this.m_vertices=[],this.m_count=0,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3}var e=t.prototype;return e.ReadCache=function(t,e,i,n,s){this.m_count=t.count;for(var a=this.m_vertices,o=0;o<this.m_count;++o){var l=a[o];l.indexA=t.indexA[o],l.indexB=t.indexB[o];var h=e.GetVertex(l.indexA),u=n.GetVertex(l.indexB);Y.MulXV(i,h,l.wA),Y.MulXV(s,u,l.wB),z.SubVV(l.wB,l.wA,l.w),l.a=0}if(this.m_count>1){var c=t.metric,_=this.GetMetric();(_<.5*c||2*c<_||_<r)&&(this.m_count=0)}if(0===this.m_count){var f=a[0];f.indexA=0,f.indexB=0;var p=e.GetVertex(0),d=n.GetVertex(0);Y.MulXV(i,p,f.wA),Y.MulXV(s,d,f.wB),z.SubVV(f.wB,f.wA,f.w),f.a=1,this.m_count=1}},e.WriteCache=function(t){t.metric=this.GetMetric(),t.count=this.m_count;for(var e=this.m_vertices,i=0;i<this.m_count;++i)t.indexA[i]=e[i].indexA,t.indexB[i]=e[i].indexB},e.GetSearchDirection=function(t){switch(this.m_count){case 1:return z.NegV(this.m_v1.w,t);case 2:var e=z.SubVV(this.m_v2.w,this.m_v1.w,t);return z.CrossVV(e,z.NegV(this.m_v1.w,z.s_t0))>0?z.CrossOneV(e,t):z.CrossVOne(e,t);default:return t.SetZero()}},e.GetClosestPoint=function(t){switch(this.m_count){case 0:return t.SetZero();case 1:return t.Copy(this.m_v1.w);case 2:return t.Set(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);case 3:default:return t.SetZero()}},e.GetWitnessPoints=function(t,e){switch(this.m_count){case 0:break;case 1:t.Copy(this.m_v1.wA),e.Copy(this.m_v1.wB);break;case 2:t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,e.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,e.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:e.x=t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,e.y=t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y}},e.GetMetric=function(){switch(this.m_count){case 0:case 1:return 0;case 2:return z.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return z.CrossVV(z.SubVV(this.m_v2.w,this.m_v1.w,z.s_t0),z.SubVV(this.m_v3.w,this.m_v1.w,z.s_t1));default:return 0}},e.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,r=z.SubVV(i,e,t.s_e12),n=-z.DotVV(e,r);if(n<=0)return this.m_v1.a=1,void(this.m_count=1);var s=z.DotVV(i,r);if(s<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);var a=1/(s+n);this.m_v1.a=s*a,this.m_v2.a=n*a,this.m_count=2},e.Solve3=function(){var e=this.m_v1.w,i=this.m_v2.w,r=this.m_v3.w,n=z.SubVV(i,e,t.s_e12),s=z.DotVV(e,n),a=z.DotVV(i,n),o=-s,l=z.SubVV(r,e,t.s_e13),h=z.DotVV(e,l),u=z.DotVV(r,l),c=-h,_=z.SubVV(r,i,t.s_e23),f=z.DotVV(i,_),p=z.DotVV(r,_),d=-f,m=z.CrossVV(n,l),y=m*z.CrossVV(i,r),g=m*z.CrossVV(r,e),v=m*z.CrossVV(e,i);if(o<=0&&c<=0)return this.m_v1.a=1,void(this.m_count=1);if(a>0&&o>0&&v<=0){var b=1/(a+o);return this.m_v1.a=a*b,this.m_v2.a=o*b,void(this.m_count=2)}if(u>0&&c>0&&g<=0){var S=1/(u+c);return this.m_v1.a=u*S,this.m_v3.a=c*S,this.m_count=2,void this.m_v2.Copy(this.m_v3)}if(a<=0&&d<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(u<=0&&p<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(p>0&&d>0&&y<=0){var A=1/(p+d);return this.m_v2.a=p*A,this.m_v3.a=d*A,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var C=1/(y+g+v);this.m_v1.a=y*C,this.m_v2.a=g*C,this.m_v3.a=v*C,this.m_count=3},t}();at.s_e12=new z,at.s_e13=new z,at.s_e23=new z;var ot=new at,lt=[0,0,0],ht=[0,0,0],ut=new z,ct=new z,_t=new z,ft=new z,pt=new z;function dt(e,i,s){++t.b2_gjkCalls;var a=s.proxyA,o=s.proxyB,l=s.transformA,h=s.transformB,u=ot;u.ReadCache(i,a,l,o,h);for(var c=u.m_vertices,_=lt,f=ht,p=0,d=0;d<20;){p=u.m_count;for(var m=0;m<p;++m)_[m]=c[m].indexA,f[m]=c[m].indexB;switch(u.m_count){case 1:break;case 2:u.Solve2();break;case 3:u.Solve3()}if(3===u.m_count)break;var y=u.GetSearchDirection(ct);if(y.LengthSquared()<n)break;var g=c[u.m_count];g.indexA=a.GetSupport(X.MulTRV(l.q,z.NegV(y,z.s_t0),ft)),Y.MulXV(l,a.GetVertex(g.indexA),g.wA),g.indexB=o.GetSupport(X.MulTRV(h.q,y,pt)),Y.MulXV(h,o.GetVertex(g.indexB),g.wB),z.SubVV(g.wB,g.wA,g.w),++d,++t.b2_gjkIters;for(var v=!1,b=0;b<p;++b)if(g.indexA===_[b]&&g.indexB===f[b]){v=!0;break}if(v)break;++u.m_count}if(t.b2_gjkMaxIters=D(t.b2_gjkMaxIters,d),u.GetWitnessPoints(e.pointA,e.pointB),e.distance=z.DistanceVV(e.pointA,e.pointB),e.iterations=d,u.WriteCache(i),s.useRadii){var S=a.m_radius,A=o.m_radius;if(e.distance>S+A&&e.distance>r){e.distance-=S+A;var C=z.SubVV(e.pointB,e.pointA,_t);C.Normalize(),e.pointA.SelfMulAdd(S,C),e.pointB.SelfMulSub(A,C)}else{var x=z.MidVV(e.pointA,e.pointB,ut);e.pointA.Copy(x),e.pointB.Copy(x),e.distance=0}}}var mt,yt=new z,gt=new at,vt=new z,bt=new z,St=new z,At=new z,Ct=new z,xt=new z;(mt=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[mt.e_vertex=0]="e_vertex",mt[mt.e_face=1]="e_face";var Tt,wt=function(){function t(){this._key=0,this._key_invalid=!1,this._indexA=0,this._indexB=0,this._typeA=0,this._typeB=0}return Pe(t,[{key:"key",get:function(){return this._key_invalid&&(this._key_invalid=!1,this._key=this._indexA|this._indexB<<8|this._typeA<<16|this._typeB<<24),this._key},set:function(t){this._key=t,this._key_invalid=!1,this._indexA=255&this._key,this._indexB=this._key>>8&255,this._typeA=this._key>>16&255,this._typeB=this._key>>24&255}},{key:"indexA",get:function(){return this._indexA},set:function(t){this._indexA=t,this._key_invalid=!0}},{key:"indexB",get:function(){return this._indexB},set:function(t){this._indexB=t,this._key_invalid=!0}},{key:"typeA",get:function(){return this._typeA},set:function(t){this._typeA=t,this._key_invalid=!0}},{key:"typeB",get:function(){return this._typeB},set:function(t){this._typeB=t,this._key_invalid=!0}}]),t}(),Et=function(){function t(){this.cf=new wt}var e=t.prototype;return e.Copy=function(t){return this.key=t.key,this},e.Clone=function(){return(new t).Copy(this)},Pe(t,[{key:"key",get:function(){return this.cf.key},set:function(t){this.cf.key=t}}]),t}(),Bt=function(){function t(){this.localPoint=new z,this.normalImpulse=0,this.tangentImpulse=0,this.id=new Et}t.MakeArray=function(e){return A(e,(function(){return new t}))};var e=t.prototype;return e.Reset=function(){this.localPoint.SetZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.key=0},e.Copy=function(t){return this.localPoint.Copy(t.localPoint),this.normalImpulse=t.normalImpulse,this.tangentImpulse=t.tangentImpulse,this.id.Copy(t.id),this},t}();(Tt=t.b2ManifoldType||(t.b2ManifoldType={}))[Tt.e_unknown=-1]="e_unknown",Tt[Tt.e_circles=0]="e_circles",Tt[Tt.e_faceA=1]="e_faceA",Tt[Tt.e_faceB=2]="e_faceB";var Dt,Mt=function(){function e(){this.points=Bt.MakeArray(2),this.localNormal=new z,this.localPoint=new z,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}var i=e.prototype;return i.Reset=function(){for(var e=0;e<2;++e)this.points[e].Reset();this.localNormal.SetZero(),this.localPoint.SetZero(),this.type=t.b2ManifoldType.e_unknown,this.pointCount=0},i.Copy=function(t){this.pointCount=t.pointCount;for(var e=0;e<2;++e)this.points[e].Copy(t.points[e]);return this.localNormal.Copy(t.localNormal),this.localPoint.Copy(t.localPoint),this.type=t.type,this},i.Clone=function(){return(new e).Copy(this)},e}(),Pt=function(){function e(){this.normal=new z,this.points=z.MakeArray(2),this.separations=C(2)}return e.prototype.Initialize=function(i,r,s,a,o){if(0!==i.pointCount)switch(i.type){case t.b2ManifoldType.e_circles:this.normal.Set(1,0);var l=Y.MulXV(r,i.localPoint,e.Initialize_s_pointA),h=Y.MulXV(a,i.points[0].localPoint,e.Initialize_s_pointB);z.DistanceSquaredVV(l,h)>n&&z.SubVV(h,l,this.normal).SelfNormalize();var u=z.AddVMulSV(l,s,this.normal,e.Initialize_s_cA),c=z.SubVMulSV(h,o,this.normal,e.Initialize_s_cB);z.MidVV(u,c,this.points[0]),this.separations[0]=z.DotVV(z.SubVV(c,u,z.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:X.MulRV(r.q,i.localNormal,this.normal);for(var _=Y.MulXV(r,i.localPoint,e.Initialize_s_planePoint),f=0;f<i.pointCount;++f){var p=Y.MulXV(a,i.points[f].localPoint,e.Initialize_s_clipPoint),d=s-z.DotVV(z.SubVV(p,_,z.s_t0),this.normal),m=z.AddVMulSV(p,d,this.normal,e.Initialize_s_cA),y=z.SubVMulSV(p,o,this.normal,e.Initialize_s_cB);z.MidVV(m,y,this.points[f]),this.separations[f]=z.DotVV(z.SubVV(y,m,z.s_t0),this.normal)}break;case t.b2ManifoldType.e_faceB:X.MulRV(a.q,i.localNormal,this.normal);for(var g=Y.MulXV(a,i.localPoint,e.Initialize_s_planePoint),v=0;v<i.pointCount;++v){var b=Y.MulXV(r,i.points[v].localPoint,e.Initialize_s_clipPoint),S=o-z.DotVV(z.SubVV(b,g,z.s_t0),this.normal),A=z.AddVMulSV(b,S,this.normal,e.Initialize_s_cB),C=z.SubVMulSV(b,s,this.normal,e.Initialize_s_cA);z.MidVV(C,A,this.points[v]),this.separations[v]=z.DotVV(z.SubVV(C,A,z.s_t0),this.normal)}this.normal.SelfNeg()}},e}();Pt.Initialize_s_pointA=new z,Pt.Initialize_s_pointB=new z,Pt.Initialize_s_cA=new z,Pt.Initialize_s_cB=new z,Pt.Initialize_s_planePoint=new z,Pt.Initialize_s_clipPoint=new z,(Dt=t.b2PointState||(t.b2PointState={}))[Dt.b2_nullState=0]="b2_nullState",Dt[Dt.b2_addState=1]="b2_addState",Dt[Dt.b2_persistState=2]="b2_persistState",Dt[Dt.b2_removeState=3]="b2_removeState";var Rt=function(){function t(){this.v=new z,this.id=new Et}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t.prototype.Copy=function(t){return this.v.Copy(t.v),this.id.Copy(t.id),this},t}(),It=function(){function t(){this.p1=new z,this.p2=new z,this.maxFraction=1}return t.prototype.Copy=function(t){return this.p1.Copy(t.p1),this.p2.Copy(t.p2),this.maxFraction=t.maxFraction,this},t}(),Ot=function(){function t(){this.normal=new z,this.fraction=0}return t.prototype.Copy=function(t){return this.normal.Copy(t.normal),this.fraction=t.fraction,this},t}(),Ft=function(){function t(){this.lowerBound=new z,this.upperBound=new z,this.m_cache_center=new z,this.m_cache_extent=new z}var e=t.prototype;return e.Copy=function(t){return this.lowerBound.Copy(t.lowerBound),this.upperBound.Copy(t.upperBound),this},e.IsValid=function(){return!(!this.lowerBound.IsValid()||!this.upperBound.IsValid()||this.upperBound.x<this.lowerBound.x||this.upperBound.y<this.lowerBound.y)},e.GetCenter=function(){return z.MidVV(this.lowerBound,this.upperBound,this.m_cache_center)},e.GetExtents=function(){return z.ExtVV(this.lowerBound,this.upperBound,this.m_cache_extent)},e.GetPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))},e.Combine1=function(t){return this.lowerBound.x=B(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=B(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=D(this.upperBound.x,t.upperBound.x),this.upperBound.y=D(this.upperBound.y,t.upperBound.y),this},e.Combine2=function(t,e){return this.lowerBound.x=B(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=B(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=D(t.upperBound.x,e.upperBound.x),this.upperBound.y=D(t.upperBound.y,e.upperBound.y),this},t.Combine=function(t,e,i){return i.Combine2(t,e),i},e.Contains=function(t){return!(this.lowerBound.x<=t.lowerBound.x||this.lowerBound.y<=t.lowerBound.y||t.upperBound.x<=this.upperBound.x||t.upperBound.y<=this.upperBound.y)},e.RayCast=function(t,e){var n=-i,s=i,a=e.p1.x,o=e.p1.y,l=e.p2.x-e.p1.x,h=e.p2.y-e.p1.y,u=E(l),c=E(h),_=t.normal;if(u<r){if(a<this.lowerBound.x||this.upperBound.x<a)return!1}else{var f=1/l,p=(this.lowerBound.x-a)*f,d=(this.upperBound.x-a)*f,m=-1;if(p>d){var y=p;p=d,d=y,m=1}if(p>n&&(_.x=m,_.y=0,n=p),n>(s=B(s,d)))return!1}if(c<r){if(o<this.lowerBound.y||this.upperBound.y<o)return!1}else{var g=1/h,v=(this.lowerBound.y-o)*g,b=(this.upperBound.y-o)*g,S=-1;if(v>b){var A=v;v=b,b=A,S=1}if(v>n&&(_.x=0,_.y=S,n=v),n>(s=B(s,b)))return!1}return!(n<0||e.maxFraction<n||(t.fraction=n,0))},e.TestContain=function(t){return!(t.x<this.lowerBound.x||this.upperBound.x<t.x||t.y<this.lowerBound.y||this.upperBound.y<t.y)},e.TestOverlap=function(t){return!(this.upperBound.x<t.lowerBound.x||this.upperBound.y<t.lowerBound.y||t.upperBound.x<this.lowerBound.x||t.upperBound.y<this.lowerBound.y)},t}();function Lt(t,e){return!(t.upperBound.x<e.lowerBound.x||t.upperBound.y<e.lowerBound.y||e.upperBound.x<t.lowerBound.x||e.upperBound.y<t.lowerBound.y)}function Vt(e,i,r,n,s){var a=0,o=i[0],l=i[1],h=z.DotVV(r,o.v)-n,u=z.DotVV(r,l.v)-n;if(h<=0&&e[a++].Copy(o),u<=0&&e[a++].Copy(l),h*u<0){var c=h/(h-u),_=e[a].v;_.x=o.v.x+c*(l.v.x-o.v.x),_.y=o.v.y+c*(l.v.y-o.v.y);var f=e[a].id;f.cf.indexA=s,f.cf.indexB=o.id.cf.indexB,f.cf.typeA=t.b2ContactFeatureType.e_vertex,f.cf.typeB=t.b2ContactFeatureType.e_face,++a}return a}var kt=new rt,Nt=new it,Gt=new nt;function zt(t,e,i,r,n,s){var a=kt.Reset();a.proxyA.SetShape(t,e),a.proxyB.SetShape(i,r),a.transformA.Copy(n),a.transformB.Copy(s),a.useRadii=!0;var o=Nt.Reset();o.count=0;var l=Gt.Reset();return dt(l,o,a),l.distance<1e-4}function Ut(t){if(null===t)throw new Error;return t}var Ht=function(){function t(t){void 0===t&&(t=0),this.m_id=0,this.aabb=new Ft,this._userData=null,this.parent=null,this.child1=null,this.child2=null,this.height=0,this.m_id=t}var e=t.prototype;return e.Reset=function(){this._userData=null},e.IsLeaf=function(){return null===this.child1},Pe(t,[{key:"userData",get:function(){if(null===this._userData)throw new Error;return this._userData},set:function(t){if(null!==this._userData)throw new Error;this._userData=t}}]),t}(),jt=function(){function t(){this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0,this.m_stack=new tt(256)}var e=t.prototype;return e.Query=function(t,e){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var r=i.Pop();if(null!==r&&r.aabb.TestOverlap(t))if(r.IsLeaf()){if(!e(r))return}else i.Push(r.child1),i.Push(r.child2)}},e.QueryPoint=function(t,e){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var r=i.Pop();if(null!==r&&r.aabb.TestContain(t))if(r.IsLeaf()){if(!e(r))return}else i.Push(r.child1),i.Push(r.child2)}},e.RayCast=function(e,i){var r=e.p1,n=e.p2,s=z.SubVV(n,r,t.s_r);s.Normalize();var a=z.CrossOneV(s,t.s_v),o=z.AbsV(a,t.s_abs_v),l=e.maxFraction,h=t.s_segmentAABB,u=r.x+l*(n.x-r.x),c=r.y+l*(n.y-r.y);h.lowerBound.x=B(r.x,u),h.lowerBound.y=B(r.y,c),h.upperBound.x=D(r.x,u),h.upperBound.y=D(r.y,c);var _=this.m_stack.Reset();for(_.Push(this.m_root);_.GetCount()>0;){var f=_.Pop();if(null!==f&&Lt(f.aabb,h)){var p=f.aabb.GetCenter(),d=f.aabb.GetExtents();if(!(E(z.DotVV(a,z.SubVV(r,p,z.s_t0)))-z.DotVV(o,d)>0))if(f.IsLeaf()){var m=t.s_subInput;m.p1.Copy(e.p1),m.p2.Copy(e.p2),m.maxFraction=l;var y=i(m,f);if(0===y)return;y>0&&(l=y,u=r.x+l*(n.x-r.x),c=r.y+l*(n.y-r.y),h.lowerBound.x=B(r.x,u),h.lowerBound.y=B(r.y,c),h.upperBound.x=D(r.x,u),h.upperBound.y=D(r.y,c))}else _.Push(f.child1),_.Push(f.child2)}}},e.AllocateNode=function(){if(null!==this.m_freeList){var e=this.m_freeList;return this.m_freeList=e.parent,e.parent=null,e.child1=null,e.child2=null,e.height=0,e}return new Ht(t.s_node_id++)},e.FreeNode=function(t){t.parent=this.m_freeList,t.child1=null,t.child2=null,t.height=-1,t.Reset(),this.m_freeList=t},e.CreateProxy=function(t,e){var i=this.AllocateNode();return i.aabb.lowerBound.x=t.lowerBound.x-.1,i.aabb.lowerBound.y=t.lowerBound.y-.1,i.aabb.upperBound.x=t.upperBound.x+.1,i.aabb.upperBound.y=t.upperBound.y+.1,i.userData=e,i.height=0,this.InsertLeaf(i),i},e.DestroyProxy=function(t){this.RemoveLeaf(t),this.FreeNode(t)},e.MoveProxy=function(t,e,i){if(t.aabb.Contains(e))return!1;this.RemoveLeaf(t);t.aabb.lowerBound.x=e.lowerBound.x-.1,t.aabb.lowerBound.y=e.lowerBound.y-.1,t.aabb.upperBound.x=e.upperBound.x+.1,t.aabb.upperBound.y=e.upperBound.y+.1;var r=2*i.x,n=2*i.y;return r<0?t.aabb.lowerBound.x+=r:t.aabb.upperBound.x+=r,n<0?t.aabb.lowerBound.y+=n:t.aabb.upperBound.y+=n,this.InsertLeaf(t),!0},e.InsertLeaf=function(e){if(++this.m_insertionCount,null===this.m_root)return this.m_root=e,void(this.m_root.parent=null);for(var i=e.aabb,r=this.m_root;!r.IsLeaf();){var n=Ut(r.child1),s=Ut(r.child2),a=r.aabb.GetPerimeter(),o=t.s_combinedAABB;o.Combine2(r.aabb,i);var l=o.GetPerimeter(),h=2*l,u=2*(l-a),c=void 0,_=t.s_aabb,f=void 0;n.IsLeaf()?(_.Combine2(i,n.aabb),c=_.GetPerimeter()+u):(_.Combine2(i,n.aabb),f=n.aabb.GetPerimeter(),c=_.GetPerimeter()-f+u);var p=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),p=_.GetPerimeter()+u):(_.Combine2(i,s.aabb),f=s.aabb.GetPerimeter(),p=_.GetPerimeter()-f+u),h<c&&h<p)break;r=c<p?n:s}var d=r.parent,m=this.AllocateNode();m.parent=d,m.aabb.Combine2(i,r.aabb),m.height=r.height+1,null!==d?(d.child1===r?d.child1=m:d.child2=m,m.child1=r,m.child2=e,r.parent=m,e.parent=m):(m.child1=r,m.child2=e,r.parent=m,e.parent=m,this.m_root=m);for(var y=e.parent;null!==y;){var g=Ut((y=this.Balance(y)).child1),v=Ut(y.child2);y.height=1+D(g.height,v.height),y.aabb.Combine2(g.aabb,v.aabb),y=y.parent}},e.RemoveLeaf=function(t){if(t!==this.m_root){var e=Ut(t.parent),i=e&&e.parent,r=Ut(e.child1===t?e.child2:e.child1);if(null!==i){i.child1===e?i.child1=r:i.child2=r,r.parent=i,this.FreeNode(e);for(var n=i;null!==n;){var s=Ut((n=this.Balance(n)).child1),a=Ut(n.child2);n.aabb.Combine2(s.aabb,a.aabb),n.height=1+D(s.height,a.height),n=n.parent}}else this.m_root=r,r.parent=null,this.FreeNode(e)}else this.m_root=null},e.Balance=function(t){if(t.IsLeaf()||t.height<2)return t;var e=Ut(t.child1),i=Ut(t.child2),r=i.height-e.height;if(r>1){var n=Ut(i.child1),s=Ut(i.child2);return i.child1=t,i.parent=t.parent,t.parent=i,null!==i.parent?i.parent.child1===t?i.parent.child1=i:i.parent.child2=i:this.m_root=i,n.height>s.height?(i.child2=n,t.child2=s,s.parent=t,t.aabb.Combine2(e.aabb,s.aabb),i.aabb.Combine2(t.aabb,n.aabb),t.height=1+D(e.height,s.height),i.height=1+D(t.height,n.height)):(i.child2=s,t.child2=n,n.parent=t,t.aabb.Combine2(e.aabb,n.aabb),i.aabb.Combine2(t.aabb,s.aabb),t.height=1+D(e.height,n.height),i.height=1+D(t.height,s.height)),i}if(r<-1){var a=Ut(e.child1),o=Ut(e.child2);return e.child1=t,e.parent=t.parent,t.parent=e,null!==e.parent?e.parent.child1===t?e.parent.child1=e:e.parent.child2=e:this.m_root=e,a.height>o.height?(e.child2=a,t.child1=o,o.parent=t,t.aabb.Combine2(i.aabb,o.aabb),e.aabb.Combine2(t.aabb,a.aabb),t.height=1+D(i.height,o.height),e.height=1+D(t.height,a.height)):(e.child2=o,t.child1=a,a.parent=t,t.aabb.Combine2(i.aabb,a.aabb),e.aabb.Combine2(t.aabb,o.aabb),t.height=1+D(i.height,a.height),e.height=1+D(t.height,o.height)),e}return t},e.GetHeight=function(){return null===this.m_root?0:this.m_root.height},t.GetAreaNode=function(e){if(null===e)return 0;if(e.IsLeaf())return 0;var i=e.aabb.GetPerimeter();return(i+=t.GetAreaNode(e.child1))+t.GetAreaNode(e.child2)},e.GetAreaRatio=function(){if(null===this.m_root)return 0;var e=this.m_root.aabb.GetPerimeter();return t.GetAreaNode(this.m_root)/e},t.ComputeHeightNode=function(e){return null===e||e.IsLeaf()?0:1+D(t.ComputeHeightNode(e.child1),t.ComputeHeightNode(e.child2))},e.ComputeHeight=function(){return t.ComputeHeightNode(this.m_root)},e.ValidateStructure=function(t){if(null!==t&&(this.m_root,!t.IsLeaf())){var e=Ut(t.child1),i=Ut(t.child2);this.ValidateStructure(e),this.ValidateStructure(i)}},e.ValidateMetrics=function(e){if(null!==e&&!e.IsLeaf()){var i=Ut(e.child1),r=Ut(e.child2);t.s_aabb.Combine2(i.aabb,r.aabb),this.ValidateMetrics(i),this.ValidateMetrics(r)}},e.Validate=function(){},t.GetMaxBalanceNode=function(t,e){if(null===t)return e;if(t.height<=1)return e;var i=Ut(t.child1),r=Ut(t.child2);return D(e,E(r.height-i.height))},e.GetMaxBalance=function(){return t.GetMaxBalanceNode(this.m_root,0)},e.RebuildBottomUp=function(){this.Validate()},t.ShiftOriginNode=function(e,i){if(null!==e&&!(e.height<=1)){var r=e.child1,n=e.child2;t.ShiftOriginNode(r,i),t.ShiftOriginNode(n,i),e.aabb.lowerBound.SelfSub(i),e.aabb.upperBound.SelfSub(i)}},e.ShiftOrigin=function(e){t.ShiftOriginNode(this.m_root,e)},t}();function Wt(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Xt(t,e){return t<e}jt.s_r=new z,jt.s_v=new z,jt.s_abs_v=new z,jt.s_segmentAABB=new Ft,jt.s_subInput=new It,jt.s_combinedAABB=new Ft,jt.s_aabb=new Ft,jt.s_node_id=0;var Yt=function(t,e){this.proxyA=t,this.proxyB=e},qt=function(){function t(){this.m_tree=new jt,this.m_proxyCount=0,this.m_moveCount=0,this.m_moveBuffer=[],this.m_pairCount=0,this.m_pairBuffer=[]}var e=t.prototype;return e.CreateProxy=function(t,e){var i=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(i),i},e.DestroyProxy=function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)},e.MoveProxy=function(t,e,i){this.m_tree.MoveProxy(t,e,i)&&this.BufferMove(t)},e.TouchProxy=function(t){this.BufferMove(t)},e.GetProxyCount=function(){return this.m_proxyCount},e.UpdatePairs=function(t){var e=this;this.m_pairCount=0;for(var i=function(t){var i=e.m_moveBuffer[t];if(null===i)return"continue";var r=i.aabb;e.m_tree.Query(r,(function(t){if(t.m_id===i.m_id)return!0;var r,n;if(t.m_id<i.m_id?(r=t,n=i):(r=i,n=t),e.m_pairCount===e.m_pairBuffer.length)e.m_pairBuffer[e.m_pairCount]=new Yt(r,n);else{var s=e.m_pairBuffer[e.m_pairCount];s.proxyA=r,s.proxyB=n}return++e.m_pairCount,!0}))},r=0;r<this.m_moveCount;++r)i(r);this.m_moveCount=0,function(t,e,i,r){void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===r&&(r=Xt);for(var n=e,s=[],a=0;;){for(;n+1<i;i++){var o=t[n+Math.floor(Math.random()*(i-n))];s[a++]=i;for(var l=n-1;;){for(;r(t[++l],o););for(;r(o,t[--i]););if(l>=i)break;Wt(t,l,i)}}if(0===a)break;n=i,i=s[--a]}}(this.m_pairBuffer,0,this.m_pairCount,Jt);for(var n=0;n<this.m_pairCount;){var s=this.m_pairBuffer[n];for(t(s.proxyA.userData,s.proxyB.userData),++n;n<this.m_pairCount;){var a=this.m_pairBuffer[n];if(a.proxyA.m_id!==s.proxyA.m_id||a.proxyB.m_id!==s.proxyB.m_id)break;++n}}},e.Query=function(t,e){this.m_tree.Query(t,e)},e.QueryPoint=function(t,e){this.m_tree.QueryPoint(t,e)},e.RayCast=function(t,e){this.m_tree.RayCast(t,e)},e.GetTreeHeight=function(){return this.m_tree.GetHeight()},e.GetTreeBalance=function(){return this.m_tree.GetMaxBalance()},e.GetTreeQuality=function(){return this.m_tree.GetAreaRatio()},e.ShiftOrigin=function(t){this.m_tree.ShiftOrigin(t)},e.BufferMove=function(t){this.m_moveBuffer[this.m_moveCount]=t,++this.m_moveCount},e.UnBufferMove=function(t){var e=this.m_moveBuffer.indexOf(t);this.m_moveBuffer[e]=null},t}();function Jt(t,e){return t.proxyA.m_id<e.proxyA.m_id||t.proxyA.m_id===e.proxyA.m_id&&t.proxyB.m_id<e.proxyB.m_id}t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0;var Kt,Zt=new Y,Qt=new Y,$t=new z,te=new z,ee=new z,ie=new z,re=new z,ne=function(){this.proxyA=new et,this.proxyB=new et,this.sweepA=new J,this.sweepB=new J,this.tMax=0};(Kt=t.b2TOIOutputState||(t.b2TOIOutputState={}))[Kt.e_unknown=0]="e_unknown",Kt[Kt.e_failed=1]="e_failed",Kt[Kt.e_overlapped=2]="e_overlapped",Kt[Kt.e_touching=3]="e_touching",Kt[Kt.e_separated=4]="e_separated";var se,ae=function(){this.state=t.b2TOIOutputState.e_unknown,this.t=0};(se=t.b2SeparationFunctionType||(t.b2SeparationFunctionType={}))[se.e_unknown=-1]="e_unknown",se[se.e_points=0]="e_points",se[se.e_faceA=1]="e_faceA",se[se.e_faceB=2]="e_faceB";var oe=function(){function e(){this.m_sweepA=new J,this.m_sweepB=new J,this.m_type=t.b2SeparationFunctionType.e_unknown,this.m_localPoint=new z,this.m_axis=new z}var i=e.prototype;return i.Initialize=function(e,i,r,n,s,a){this.m_proxyA=i,this.m_proxyB=n;var o=e.count;this.m_sweepA.Copy(r),this.m_sweepB.Copy(s);var l=Zt,h=Qt;if(this.m_sweepA.GetTransform(l,a),this.m_sweepB.GetTransform(h,a),1===o){this.m_type=t.b2SeparationFunctionType.e_points;var u=this.m_proxyA.GetVertex(e.indexA[0]),c=this.m_proxyB.GetVertex(e.indexB[0]),_=Y.MulXV(l,u,$t),f=Y.MulXV(h,c,te);z.SubVV(f,_,this.m_axis);var p=this.m_axis.Normalize();return this.m_localPoint.SetZero(),p}if(e.indexA[0]===e.indexA[1]){this.m_type=t.b2SeparationFunctionType.e_faceB;var d=this.m_proxyB.GetVertex(e.indexB[0]),m=this.m_proxyB.GetVertex(e.indexB[1]);z.CrossVOne(z.SubVV(m,d,z.s_t0),this.m_axis).SelfNormalize();var y=X.MulRV(h.q,this.m_axis,ee);z.MidVV(d,m,this.m_localPoint);var g=Y.MulXV(h,this.m_localPoint,te),v=this.m_proxyA.GetVertex(e.indexA[0]),b=Y.MulXV(l,v,$t),S=z.DotVV(z.SubVV(b,g,z.s_t0),y);return S<0&&(this.m_axis.SelfNeg(),S=-S),S}this.m_type=t.b2SeparationFunctionType.e_faceA;var A=this.m_proxyA.GetVertex(e.indexA[0]),C=this.m_proxyA.GetVertex(e.indexA[1]);z.CrossVOne(z.SubVV(C,A,z.s_t0),this.m_axis).SelfNormalize();var x=X.MulRV(l.q,this.m_axis,ee);z.MidVV(A,C,this.m_localPoint);var T=Y.MulXV(l,this.m_localPoint,$t),w=this.m_proxyB.GetVertex(e.indexB[0]),E=Y.MulXV(h,w,te),B=z.DotVV(z.SubVV(E,T,z.s_t0),x);return B<0&&(this.m_axis.SelfNeg(),B=-B),B},i.FindMinSeparation=function(e,i,r){var n=Zt,s=Qt;switch(this.m_sweepA.GetTransform(n,r),this.m_sweepB.GetTransform(s,r),this.m_type){case t.b2SeparationFunctionType.e_points:var a=X.MulTRV(n.q,this.m_axis,ie),o=X.MulTRV(s.q,z.NegV(this.m_axis,z.s_t0),re);e[0]=this.m_proxyA.GetSupport(a),i[0]=this.m_proxyB.GetSupport(o);var l=this.m_proxyA.GetVertex(e[0]),h=this.m_proxyB.GetVertex(i[0]),u=Y.MulXV(n,l,$t),c=Y.MulXV(s,h,te);return z.DotVV(z.SubVV(c,u,z.s_t0),this.m_axis);case t.b2SeparationFunctionType.e_faceA:var _=X.MulRV(n.q,this.m_axis,ee),f=Y.MulXV(n,this.m_localPoint,$t),p=X.MulTRV(s.q,z.NegV(_,z.s_t0),re);e[0]=-1,i[0]=this.m_proxyB.GetSupport(p);var d=this.m_proxyB.GetVertex(i[0]),m=Y.MulXV(s,d,te);return z.DotVV(z.SubVV(m,f,z.s_t0),_);case t.b2SeparationFunctionType.e_faceB:var y=X.MulRV(s.q,this.m_axis,ee),g=Y.MulXV(s,this.m_localPoint,te),v=X.MulTRV(n.q,z.NegV(y,z.s_t0),ie);i[0]=-1,e[0]=this.m_proxyA.GetSupport(v);var b=this.m_proxyA.GetVertex(e[0]),S=Y.MulXV(n,b,$t);return z.DotVV(z.SubVV(S,g,z.s_t0),y);default:return e[0]=-1,i[0]=-1,0}},i.Evaluate=function(e,i,r){var n=Zt,s=Qt;switch(this.m_sweepA.GetTransform(n,r),this.m_sweepB.GetTransform(s,r),this.m_type){case t.b2SeparationFunctionType.e_points:var a=this.m_proxyA.GetVertex(e),o=this.m_proxyB.GetVertex(i),l=Y.MulXV(n,a,$t),h=Y.MulXV(s,o,te);return z.DotVV(z.SubVV(h,l,z.s_t0),this.m_axis);case t.b2SeparationFunctionType.e_faceA:var u=X.MulRV(n.q,this.m_axis,ee),c=Y.MulXV(n,this.m_localPoint,$t),_=this.m_proxyB.GetVertex(i),f=Y.MulXV(s,_,te);return z.DotVV(z.SubVV(f,c,z.s_t0),u);case t.b2SeparationFunctionType.e_faceB:var p=X.MulRV(s.q,this.m_axis,ee),d=Y.MulXV(s,this.m_localPoint,te),m=this.m_proxyA.GetVertex(e),y=Y.MulXV(n,m,$t);return z.DotVV(z.SubVV(y,d,z.s_t0),p);default:return 0}},e}(),le=new Q,he=new it,ue=new rt,ce=new nt,_e=new oe,fe=[0],pe=[0],de=new J,me=new J;function ye(e,i){var r=le.Reset();++t.b2_toiCalls,e.state=t.b2TOIOutputState.e_unknown,e.t=i.tMax;var n=i.proxyA,s=i.proxyB,a=D(8,D(n.m_count,s.m_count)),l=de.Copy(i.sweepA),h=me.Copy(i.sweepB);l.Normalize(),h.Normalize();var u=i.tMax,c=n.m_radius+s.m_radius,_=D(o,c-.024),f=.002,p=0,d=0,m=he;m.count=0;var y=ue;for(y.proxyA.Copy(i.proxyA),y.proxyB.Copy(i.proxyB),y.useRadii=!1;;){var g=Zt,v=Qt;l.GetTransform(g,p),h.GetTransform(v,p),y.transformA.Copy(g),y.transformB.Copy(v);var b=ce;if(dt(b,m,y),b.distance<=0){e.state=t.b2TOIOutputState.e_overlapped,e.t=0;break}if(b.distance<_+f){e.state=t.b2TOIOutputState.e_touching,e.t=p;break}var S=_e;S.Initialize(m,n,l,s,h,p);for(var A=!1,C=u,x=0;;){var T=fe,w=pe,B=S.FindMinSeparation(T,w,C);if(B>_+f){e.state=t.b2TOIOutputState.e_separated,e.t=u,A=!0;break}if(B>_-f){p=C;break}var M=S.Evaluate(T[0],w[0],p);if(M<_-f){e.state=t.b2TOIOutputState.e_failed,e.t=p,A=!0;break}if(M<=_+f){e.state=t.b2TOIOutputState.e_touching,e.t=p,A=!0;break}for(var P=0,R=p,I=C;;){var O;O=1&P?R+(_-M)*(I-R)/(B-M):.5*(R+I),++P,++t.b2_toiRootIters;var F=S.Evaluate(T[0],w[0],O);if(E(F-_)<f){C=O;break}if(F>_?(R=O,M=F):(I=O,B=F),50===P)break}if(t.b2_toiMaxRootIters=D(t.b2_toiMaxRootIters,P),++x===a)break}if(++d,++t.b2_toiIters,A)break;if(20===d){e.state=t.b2TOIOutputState.e_failed,e.t=p;break}}t.b2_toiMaxIters=D(t.b2_toiMaxIters,d);var L=r.GetMilliseconds();t.b2_toiMaxTime=D(t.b2_toiMaxTime,L),t.b2_toiTime+=L}var ge=new z,ve=new z;function be(e,i,r,n,s){e.pointCount=0;var a=Y.MulXV(r,i.m_p,ge),o=Y.MulXV(s,n.m_p,ve),l=z.DistanceSquaredVV(a,o),h=i.m_radius+n.m_radius;l>h*h||(e.type=t.b2ManifoldType.e_circles,e.localPoint.Copy(i.m_p),e.localNormal.SetZero(),e.pointCount=1,e.points[0].localPoint.Copy(n.m_p),e.points[0].id.key=0)}var Se=new z,Ae=new z,Ce=new z;function xe(e,n,s,a,o){e.pointCount=0;for(var l=Y.MulXV(o,a.m_p,Se),h=Y.MulTXV(s,l,Ae),u=0,c=-i,_=n.m_radius+a.m_radius,f=n.m_count,p=n.m_vertices,d=n.m_normals,m=0;m<f;++m){var y=z.DotVV(d[m],z.SubVV(h,p[m],z.s_t0));if(y>_)return;y>c&&(c=y,u=m)}var g=u,v=(g+1)%f,b=p[g],S=p[v];if(c<r)return e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(d[u]),z.MidVV(b,S,e.localPoint),e.points[0].localPoint.Copy(a.m_p),void(e.points[0].id.key=0);var A=z.DotVV(z.SubVV(h,b,z.s_t0),z.SubVV(S,b,z.s_t1)),C=z.DotVV(z.SubVV(h,S,z.s_t0),z.SubVV(b,S,z.s_t1));if(A<=0){if(z.DistanceSquaredVV(h,b)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,z.SubVV(h,b,e.localNormal).SelfNormalize(),e.localPoint.Copy(b),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}else if(C<=0){if(z.DistanceSquaredVV(h,S)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,z.SubVV(h,S,e.localNormal).SelfNormalize(),e.localPoint.Copy(S),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}else{var x=z.MidVV(b,S,Ce);if(z.DotVV(z.SubVV(h,x,z.s_t1),d[g])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(d[g]).SelfNormalize(),e.localPoint.Copy(x),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}}var Te=new z,we=new z,Ee=new z,Be=new z;function De(t,e,r,n,s){for(var a=t.m_vertices,o=t.m_normals,l=n.m_count,h=n.m_vertices,u=X.MulRV(e.q,o[r],Te),c=X.MulTRV(s.q,u,we),_=0,f=i,p=0;p<l;++p){var d=z.DotVV(h[p],c);d<f&&(f=d,_=p)}var m=Y.MulXV(e,a[r],Ee),y=Y.MulXV(s,h[_],Be);return z.DotVV(z.SubVV(y,m,z.s_t0),u)}var Re=new z,Ie=new z;function Oe(t,e,r,n,s){for(var a=e.m_count,o=e.m_normals,l=z.SubVV(Y.MulXV(s,n.m_centroid,z.s_t0),Y.MulXV(r,e.m_centroid,z.s_t1),Re),h=X.MulTRV(r.q,l,Ie),u=0,c=-i,_=0;_<a;++_){var f=z.DotVV(o[_],h);f>c&&(c=f,u=_)}var p=De(e,r,u,n,s),d=(u+a-1)%a,m=De(e,r,d,n,s),y=(u+1)%a,g=De(e,r,y,n,s),v=0,b=0,S=0;if(m>p&&m>g)S=-1,v=d,b=m;else{if(!(g>p))return t[0]=u,p;S=1,v=y,b=g}for(;(p=De(e,r,u=-1===S?(v+a-1)%a:(v+1)%a,n,s))>b;)v=u,b=p;return t[0]=v,b}var Le=new z;var Ve=Rt.MakeArray(2),ke=Rt.MakeArray(2),Ne=Rt.MakeArray(2),Ge=[0],ze=[0],Ue=new z,He=new z,je=new z,We=new z,Xe=new z,Ye=new z,qe=new z,Je=new z;function Ke(e,r,n,s,a){e.pointCount=0;var o=r.m_radius+s.m_radius,l=Ge;l[0]=0;var h=Oe(l,r,n,s,a);if(!(h>o)){var u=ze;u[0]=0;var c=Oe(u,s,a,r,n);if(!(c>o)){var _,f,p,d,m=0,y=0;c>.98*h+.001?(_=s,f=r,p=a,d=n,m=u[0],e.type=t.b2ManifoldType.e_faceB,y=1):(_=r,f=s,p=n,d=a,m=l[0],e.type=t.b2ManifoldType.e_faceA,y=0);var g=Ve;!function(e,r,n,s,a,o){for(var l=r.m_normals,h=a.m_count,u=a.m_vertices,c=a.m_normals,_=X.MulTRV(o.q,X.MulRV(n.q,l[s],z.s_t0),Le),f=0,p=i,d=0;d<h;++d){var m=z.DotVV(_,c[d]);m<p&&(p=m,f=d)}var y=f,g=(y+1)%h,v=e[0];Y.MulXV(o,u[y],v.v);var b=v.id.cf;b.indexA=s,b.indexB=y,b.typeA=t.b2ContactFeatureType.e_face,b.typeB=t.b2ContactFeatureType.e_vertex;var S=e[1];Y.MulXV(o,u[g],S.v);var A=S.id.cf;A.indexA=s,A.indexB=g,A.typeA=t.b2ContactFeatureType.e_face,A.typeB=t.b2ContactFeatureType.e_vertex}(g,_,p,m,f,d);var v=_.m_count,b=_.m_vertices,S=m,A=(m+1)%v,C=b[S],x=b[A],T=z.SubVV(x,C,Ue);T.Normalize();var w=z.CrossVOne(T,He),E=z.MidVV(C,x,je),B=X.MulRV(p.q,T,Xe),D=z.CrossVOne(B,We),M=Y.MulXV(p,C,qe),P=Y.MulXV(p,x,Je),R=z.DotVV(D,M),I=-z.DotVV(B,M)+o,O=z.DotVV(B,P)+o,F=ke,L=Ne;if(!(Vt(F,g,z.NegV(B,Ye),I,S)<2||Vt(L,F,B,O,A)<2)){e.localNormal.Copy(w),e.localPoint.Copy(E);for(var V=0,k=0;k<2;++k){var N=L[k];if(z.DotVV(D,N.v)-R<=o){var G=e.points[V];if(Y.MulTXV(d,N.v,G.localPoint),G.id.Copy(N.id),y){var U=G.id.cf;G.id.cf.indexA=U.indexB,G.id.cf.indexB=U.indexA,G.id.cf.typeA=U.typeB,G.id.cf.typeB=U.typeA}++V}}e.pointCount=V}}}}var Ze,Qe=new z,$e=new z,ti=new z,ei=new z,ii=new z,ri=new z,ni=new z,si=new Et;function ai(e,i,r,n,s){e.pointCount=0;var a=Y.MulTXV(r,Y.MulXV(s,n.m_p,z.s_t0),Qe),o=i.m_vertex1,l=i.m_vertex2,h=z.SubVV(l,o,$e),u=z.DotVV(h,z.SubVV(l,a,z.s_t0)),c=z.DotVV(h,z.SubVV(a,o,z.s_t0)),_=i.m_radius+n.m_radius,f=si;if(f.cf.indexB=0,f.cf.typeB=t.b2ContactFeatureType.e_vertex,c<=0){var p=o,d=z.SubVV(a,p,ti);if(z.DotVV(d,d)>_*_)return;if(i.m_hasVertex0){var m=i.m_vertex0,y=o,g=z.SubVV(y,m,ei);if(z.DotVV(g,z.SubVV(y,a,z.s_t0))>0)return}return f.cf.indexA=0,f.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(p),e.points[0].id.Copy(f),void e.points[0].localPoint.Copy(n.m_p)}if(u<=0){var v=l,b=z.SubVV(a,v,ti);if(z.DotVV(b,b)>_*_)return;if(i.m_hasVertex3){var S=i.m_vertex3,A=l,C=z.SubVV(S,A,ii);if(z.DotVV(C,z.SubVV(a,A,z.s_t0))>0)return}return f.cf.indexA=1,f.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(v),e.points[0].id.Copy(f),void e.points[0].localPoint.Copy(n.m_p)}var x=z.DotVV(h,h),T=ri;T.x=1/x*(u*o.x+c*l.x),T.y=1/x*(u*o.y+c*l.y);var w=z.SubVV(a,T,ti);if(!(z.DotVV(w,w)>_*_)){var E=ni.Set(-h.y,h.x);z.DotVV(E,z.SubVV(a,o,z.s_t0))<0&&E.Set(-E.x,-E.y),E.Normalize(),f.cf.indexA=0,f.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(E),e.localPoint.Copy(o),e.points[0].id.Copy(f),e.points[0].localPoint.Copy(n.m_p)}}!function(t){t[t.e_unknown=0]="e_unknown",t[t.e_edgeA=1]="e_edgeA",t[t.e_edgeB=2]="e_edgeB"}(Ze||(Ze={}));var oi,li=function(){this.type=Ze.e_unknown,this.index=0,this.separation=0},hi=function(){this.vertices=[],this.normals=[],this.count=0};!function(t){t[t.e_isolated=0]="e_isolated",t[t.e_concave=1]="e_concave",t[t.e_convex=2]="e_convex"}(oi||(oi={}));var ui=function(){function e(){this.m_polygonB=new hi,this.m_xf=new Y,this.m_centroidB=new z,this.m_v0=new z,this.m_v1=new z,this.m_v2=new z,this.m_v3=new z,this.m_normal0=new z,this.m_normal1=new z,this.m_normal2=new z,this.m_normal=new z,this.m_type1=oi.e_isolated,this.m_type2=oi.e_isolated,this.m_lowerLimit=new z,this.m_upperLimit=new z,this.m_radius=0,this.m_front=!1}var r=e.prototype;return r.Collide=function(i,r,n,s,a){Y.MulTXX(n,a,this.m_xf),Y.MulXV(this.m_xf,s.m_centroid,this.m_centroidB),this.m_v0.Copy(r.m_vertex0),this.m_v1.Copy(r.m_vertex1),this.m_v2.Copy(r.m_vertex2),this.m_v3.Copy(r.m_vertex3);var o=r.m_hasVertex0,l=r.m_hasVertex3,h=z.SubVV(this.m_v2,this.m_v1,e.s_edge1);h.Normalize(),this.m_normal1.Set(h.y,-h.x);var u=z.DotVV(this.m_normal1,z.SubVV(this.m_centroidB,this.m_v1,z.s_t0)),c=0,_=0,f=!1,p=!1;if(o){var d=z.SubVV(this.m_v1,this.m_v0,e.s_edge0);d.Normalize(),this.m_normal0.Set(d.y,-d.x),f=z.CrossVV(d,h)>=0,c=z.DotVV(this.m_normal0,z.SubVV(this.m_centroidB,this.m_v0,z.s_t0))}if(l){var m=z.SubVV(this.m_v3,this.m_v2,e.s_edge2);m.Normalize(),this.m_normal2.Set(m.y,-m.x),p=z.CrossVV(h,m)>0,_=z.DotVV(this.m_normal2,z.SubVV(this.m_centroidB,this.m_v2,z.s_t0))}o&&l?f&&p?(this.m_front=c>=0||u>=0||_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):f?(this.m_front=c>=0||u>=0&&_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):p?(this.m_front=_>=0||c>=0&&u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):(this.m_front=c>=0&&u>=0&&_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):o?f?(this.m_front=c>=0||u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):(this.m_front=c>=0&&u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):l?p?(this.m_front=u>=0||_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=u>=0&&_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=u>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1))),this.m_polygonB.count=s.m_count;for(var y=0;y<s.m_count;++y)this.m_polygonB.vertices.length<=y&&this.m_polygonB.vertices.push(new z),this.m_polygonB.normals.length<=y&&this.m_polygonB.normals.push(new z),Y.MulXV(this.m_xf,s.m_vertices[y],this.m_polygonB.vertices[y]),X.MulRV(this.m_xf.q,s.m_normals[y],this.m_polygonB.normals[y]);this.m_radius=s.m_radius+r.m_radius,i.pointCount=0;var g=this.ComputeEdgeSeparation(e.s_edgeAxis);if(g.type!==Ze.e_unknown&&!(g.separation>this.m_radius)){var v=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(v.type!==Ze.e_unknown&&v.separation>this.m_radius)){var b;b=v.type===Ze.e_unknown?g:v.separation>.98*g.separation+.001?v:g;var S=e.s_ie,A=e.s_rf;if(b.type===Ze.e_edgeA){i.type=t.b2ManifoldType.e_faceA;for(var C=0,x=z.DotVV(this.m_normal,this.m_polygonB.normals[0]),T=1;T<this.m_polygonB.count;++T){var w=z.DotVV(this.m_normal,this.m_polygonB.normals[T]);w<x&&(x=w,C=T)}var E=C,B=(E+1)%this.m_polygonB.count,D=S[0];D.v.Copy(this.m_polygonB.vertices[E]),D.id.cf.indexA=0,D.id.cf.indexB=E,D.id.cf.typeA=t.b2ContactFeatureType.e_face,D.id.cf.typeB=t.b2ContactFeatureType.e_vertex;var M=S[1];M.v.Copy(this.m_polygonB.vertices[B]),M.id.cf.indexA=0,M.id.cf.indexB=B,M.id.cf.typeA=t.b2ContactFeatureType.e_face,M.id.cf.typeB=t.b2ContactFeatureType.e_vertex,this.m_front?(A.i1=0,A.i2=1,A.v1.Copy(this.m_v1),A.v2.Copy(this.m_v2),A.normal.Copy(this.m_normal1)):(A.i1=1,A.i2=0,A.v1.Copy(this.m_v2),A.v2.Copy(this.m_v1),A.normal.Copy(this.m_normal1).SelfNeg())}else{i.type=t.b2ManifoldType.e_faceB;var P=S[0];P.v.Copy(this.m_v1),P.id.cf.indexA=0,P.id.cf.indexB=b.index,P.id.cf.typeA=t.b2ContactFeatureType.e_vertex,P.id.cf.typeB=t.b2ContactFeatureType.e_face;var R=S[1];R.v.Copy(this.m_v2),R.id.cf.indexA=0,R.id.cf.indexB=b.index,R.id.cf.typeA=t.b2ContactFeatureType.e_vertex,R.id.cf.typeB=t.b2ContactFeatureType.e_face,A.i1=b.index,A.i2=(A.i1+1)%this.m_polygonB.count,A.v1.Copy(this.m_polygonB.vertices[A.i1]),A.v2.Copy(this.m_polygonB.vertices[A.i2]),A.normal.Copy(this.m_polygonB.normals[A.i1])}A.sideNormal1.Set(A.normal.y,-A.normal.x),A.sideNormal2.Copy(A.sideNormal1).SelfNeg(),A.sideOffset1=z.DotVV(A.sideNormal1,A.v1),A.sideOffset2=z.DotVV(A.sideNormal2,A.v2);var I=e.s_clipPoints1,O=e.s_clipPoints2;if(!(Vt(I,S,A.sideNormal1,A.sideOffset1,A.i1)<2||Vt(O,I,A.sideNormal2,A.sideOffset2,A.i2)<2)){b.type===Ze.e_edgeA?(i.localNormal.Copy(A.normal),i.localPoint.Copy(A.v1)):(i.localNormal.Copy(s.m_normals[A.i1]),i.localPoint.Copy(s.m_vertices[A.i1]));for(var F=0,L=0;L<2;++L)if(z.DotVV(A.normal,z.SubVV(O[L].v,A.v1,z.s_t0))<=this.m_radius){var V=i.points[F];b.type===Ze.e_edgeA?(Y.MulTXV(this.m_xf,O[L].v,V.localPoint),V.id.Copy(O[L].id)):(V.localPoint.Copy(O[L].v),V.id.cf.typeA=O[L].id.cf.typeB,V.id.cf.typeB=O[L].id.cf.typeA,V.id.cf.indexA=O[L].id.cf.indexB,V.id.cf.indexB=O[L].id.cf.indexA),++F}i.pointCount=F}}}},r.ComputeEdgeSeparation=function(t){var e=t;e.type=Ze.e_edgeA,e.index=this.m_front?0:1,e.separation=i;for(var r=0;r<this.m_polygonB.count;++r){var n=z.DotVV(this.m_normal,z.SubVV(this.m_polygonB.vertices[r],this.m_v1,z.s_t0));n<e.separation&&(e.separation=n)}return e},r.ComputePolygonSeparation=function(t){var r=t;r.type=Ze.e_unknown,r.index=-1,r.separation=-i;for(var n=e.s_perp.Set(-this.m_normal.y,this.m_normal.x),s=0;s<this.m_polygonB.count;++s){var a=z.NegV(this.m_polygonB.normals[s],e.s_n),o=B(z.DotVV(a,z.SubVV(this.m_polygonB.vertices[s],this.m_v1,z.s_t0)),z.DotVV(a,z.SubVV(this.m_polygonB.vertices[s],this.m_v2,z.s_t0)));if(o>this.m_radius)return r.type=Ze.e_edgeB,r.index=s,r.separation=o,r;if(z.DotVV(a,n)>=0){if(z.DotVV(z.SubVV(a,this.m_upperLimit,z.s_t0),this.m_normal)<-l)continue}else if(z.DotVV(z.SubVV(a,this.m_lowerLimit,z.s_t0),this.m_normal)<-l)continue;o>r.separation&&(r.type=Ze.e_edgeB,r.index=s,r.separation=o)}return r},e}();ui.s_edge1=new z,ui.s_edge0=new z,ui.s_edge2=new z,ui.s_ie=Rt.MakeArray(2),ui.s_rf=new function(){this.i1=0,this.i2=0,this.v1=new z,this.v2=new z,this.normal=new z,this.sideNormal1=new z,this.sideOffset1=0,this.sideNormal2=new z,this.sideOffset2=0},ui.s_clipPoints1=Rt.MakeArray(2),ui.s_clipPoints2=Rt.MakeArray(2),ui.s_edgeAxis=new li,ui.s_polygonAxis=new li,ui.s_n=new z,ui.s_perp=new z;var ci=new ui;function _i(t,e,i,r,n){ci.Collide(t,e,i,r,n)}var fi,pi=function(){this.mass=0,this.center=new z(0,0),this.I=0};(fi=t.b2ShapeType||(t.b2ShapeType={}))[fi.e_unknown=-1]="e_unknown",fi[fi.e_circleShape=0]="e_circleShape",fi[fi.e_edgeShape=1]="e_edgeShape",fi[fi.e_polygonShape=2]="e_polygonShape",fi[fi.e_chainShape=3]="e_chainShape",fi[fi.e_shapeTypeCount=4]="e_shapeTypeCount";var di=function(){function e(e,i){this.m_type=t.b2ShapeType.e_unknown,this.m_radius=0,this.m_type=e,this.m_radius=i}var i=e.prototype;return i.Copy=function(t){return this.m_radius=t.m_radius,this},i.GetType=function(){return this.m_type},e}(),mi=function(e){function i(i){var r;return void 0===i&&(i=0),(r=e.call(this,t.b2ShapeType.e_circleShape,i)||this).m_p=new z,r}Me(i,e);var n=i.prototype;return n.Set=function(t,e){return void 0===e&&(e=this.m_radius),this.m_p.Copy(t),this.m_radius=e,this},n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_p.Copy(t.m_p),this},n.GetChildCount=function(){return 1},n.TestPoint=function(t,e){var r=Y.MulXV(t,this.m_p,i.TestPoint_s_center),n=z.SubVV(e,r,i.TestPoint_s_d);return z.DotVV(n,n)<=R(this.m_radius)},n.ComputeDistance=function(t,e,r){var n=Y.MulXV(t,this.m_p,i.ComputeDistance_s_center);return z.SubVV(e,n,r),r.Normalize()-this.m_radius},n.RayCast=function(t,e,n){var s=Y.MulXV(n,this.m_p,i.RayCast_s_position),a=z.SubVV(e.p1,s,i.RayCast_s_s),o=z.DotVV(a,a)-R(this.m_radius),l=z.SubVV(e.p2,e.p1,i.RayCast_s_r),h=z.DotVV(a,l),u=z.DotVV(l,l),c=h*h-u*o;if(c<0||u<r)return!1;var _=-(h+O(c));return 0<=_&&_<=e.maxFraction*u&&(_/=u,t.fraction=_,z.AddVMulSV(a,_,l,t.normal).SelfNormalize(),!0)},n.ComputeAABB=function(t,e){var r=Y.MulXV(e,this.m_p,i.ComputeAABB_s_p);t.lowerBound.Set(r.x-this.m_radius,r.y-this.m_radius),t.upperBound.Set(r.x+this.m_radius,r.y+this.m_radius)},n.ComputeMass=function(t,e){var i=R(this.m_radius);t.mass=e*s*i,t.center.Copy(this.m_p),t.I=t.mass*(.5*i+z.DotVV(this.m_p,this.m_p))},n.SetupDistanceProxy=function(t){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_p),t.m_count=1,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){var a=Y.MulXV(i,this.m_p,new z),o=-(z.DotVV(t,a)-e);if(o<-this.m_radius+r)return 0;if(o>this.m_radius)return n.Copy(a),s*this.m_radius*this.m_radius;var l=this.m_radius*this.m_radius,h=o*o,u=l*(N(o/this.m_radius)+s/2)+o*O(l-h),c=-2/3*F(l-h,1.5)/u;return n.x=a.x+t.x*c,n.y=a.y+t.y*c,u},n.Dump=function(t){t(" const shape: b2CircleShape = new b2CircleShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_p.Set(%.15f, %.15f);\n",this.m_p.x,this.m_p.y)},i}(di);mi.TestPoint_s_center=new z,mi.TestPoint_s_d=new z,mi.ComputeDistance_s_center=new z,mi.RayCast_s_position=new z,mi.RayCast_s_s=new z,mi.RayCast_s_r=new z,mi.ComputeAABB_s_p=new z;var yi=function(e){function r(){var i;return(i=e.call(this,t.b2ShapeType.e_polygonShape,h)||this).m_centroid=new z(0,0),i.m_vertices=[],i.m_normals=[],i.m_count=0,i}Me(r,e);var n=r.prototype;return n.Clone=function(){return(new r).Copy(this)},n.Copy=function(t){e.prototype.Copy.call(this,t),this.m_centroid.Copy(t.m_centroid),this.m_count=t.m_count,this.m_vertices=z.MakeArray(this.m_count),this.m_normals=z.MakeArray(this.m_count);for(var i=0;i<this.m_count;++i)this.m_vertices[i].Copy(t.m_vertices[i]),this.m_normals[i].Copy(t.m_normals[i]);return this},n.GetChildCount=function(){return 1},n.Set=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if("number"==typeof e[0][0]){var r=e[0];if(r.length%2!=0)throw new Error;return this._Set((function(t){return{x:r[2*t],y:r[2*t+1]}}),r.length/2)}var n=e[0],s=e[1]||n.length;return this._Set((function(t){return n[t]}),s)},n._Set=function(t,e){if(e<3)return this.SetAsBox(1,1);for(var i=e,n=[],s=0;s<i;++s){for(var a=t(s),o=!0,l=0;l<n.length;++l)if(z.DistanceSquaredVV(a,n[l])<16e-6){o=!1;break}o&&n.push(a)}if((i=n.length)<3)return this.SetAsBox(1,1);for(var h=0,u=n[0].x,c=1;c<i;++c){var _=n[c].x;(_>u||_===u&&n[c].y<n[h].y)&&(h=c,u=_)}for(var f=[],p=0,d=h;;){f[p]=d;for(var m=0,y=1;y<i;++y)if(m!==d){var g=z.SubVV(n[m],n[f[p]],r.Set_s_r),v=z.SubVV(n[y],n[f[p]],r.Set_s_v),b=z.CrossVV(g,v);b<0&&(m=y),0===b&&v.LengthSquared()>g.LengthSquared()&&(m=y)}else m=y;if(++p,d=m,m===h)break}this.m_count=p,this.m_vertices=z.MakeArray(this.m_count),this.m_normals=z.MakeArray(this.m_count);for(var S=0;S<p;++S)this.m_vertices[S].Copy(n[f[S]]);for(var A=0;A<p;++A){var C=this.m_vertices[A],x=this.m_vertices[(A+1)%p],T=z.SubVV(x,C,z.s_t0);z.CrossVOne(T,this.m_normals[A]).SelfNormalize()}return r.ComputeCentroid(this.m_vertices,p,this.m_centroid),this},n.SetAsBox=function(t,e,i,r){if(void 0===r&&(r=0),this.m_count=4,this.m_vertices=z.MakeArray(this.m_count),this.m_normals=z.MakeArray(this.m_count),this.m_vertices[0].Set(-t,-e),this.m_vertices[1].Set(t,-e),this.m_vertices[2].Set(t,e),this.m_vertices[3].Set(-t,e),this.m_normals[0].Set(0,-1),this.m_normals[1].Set(1,0),this.m_normals[2].Set(0,1),this.m_normals[3].Set(-1,0),this.m_centroid.SetZero(),i){this.m_centroid.Copy(i);var n=new Y;n.SetPosition(i),n.SetRotationAngle(r);for(var s=0;s<this.m_count;++s)Y.MulXV(n,this.m_vertices[s],this.m_vertices[s]),X.MulRV(n.q,this.m_normals[s],this.m_normals[s])}return this},n.TestPoint=function(t,e){for(var i=Y.MulTXV(t,e,r.TestPoint_s_pLocal),n=0;n<this.m_count;++n)if(z.DotVV(this.m_normals[n],z.SubVV(i,this.m_vertices[n],z.s_t0))>0)return!1;return!0},n.ComputeDistance=function(t,e,n){for(var s=Y.MulTXV(t,e,r.ComputeDistance_s_pLocal),a=-i,o=r.ComputeDistance_s_normalForMaxDistance.Copy(s),l=0;l<this.m_count;++l){var h=z.DotVV(this.m_normals[l],z.SubVV(s,this.m_vertices[l],z.s_t0));h>a&&(a=h,o.Copy(this.m_normals[l]))}if(a>0){for(var u=r.ComputeDistance_s_minDistance.Copy(o),c=a*a,_=0;_<this.m_count;++_){var f=z.SubVV(s,this.m_vertices[_],r.ComputeDistance_s_distance),p=f.LengthSquared();c>p&&(u.Copy(f),c=p)}return X.MulRV(t.q,u,n),n.Normalize(),Math.sqrt(c)}return X.MulRV(t.q,o,n),a},n.RayCast=function(t,e,i){for(var n=Y.MulTXV(i,e.p1,r.RayCast_s_p1),s=Y.MulTXV(i,e.p2,r.RayCast_s_p2),a=z.SubVV(s,n,r.RayCast_s_d),o=0,l=e.maxFraction,h=-1,u=0;u<this.m_count;++u){var c=z.DotVV(this.m_normals[u],z.SubVV(this.m_vertices[u],n,z.s_t0)),_=z.DotVV(this.m_normals[u],a);if(0===_){if(c<0)return!1}else _<0&&c<o*_?(o=c/_,h=u):_>0&&c<l*_&&(l=c/_);if(l<o)return!1}return h>=0&&(t.fraction=o,X.MulRV(i.q,this.m_normals[h],t.normal),!0)},n.ComputeAABB=function(t,e){for(var i=Y.MulXV(e,this.m_vertices[0],t.lowerBound),n=t.upperBound.Copy(i),s=0;s<this.m_count;++s){var a=Y.MulXV(e,this.m_vertices[s],r.ComputeAABB_s_v);z.MinV(a,i,i),z.MaxV(a,n,n)}var o=this.m_radius;i.SelfSubXY(o,o),n.SelfAddXY(o,o)},n.ComputeMass=function(t,e){for(var i=r.ComputeMass_s_center.SetZero(),n=0,s=0,a=r.ComputeMass_s_s.SetZero(),o=0;o<this.m_count;++o)a.SelfAdd(this.m_vertices[o]);a.SelfMul(1/this.m_count);for(var l=1/3,h=0;h<this.m_count;++h){var u=z.SubVV(this.m_vertices[h],a,r.ComputeMass_s_e1),c=z.SubVV(this.m_vertices[(h+1)%this.m_count],a,r.ComputeMass_s_e2),_=z.CrossVV(u,c),f=.5*_;n+=f,i.SelfAdd(z.MulSV(f*l,z.AddVV(u,c,z.s_t0),z.s_t1));var p=u.x,d=u.y,m=c.x,y=c.y;s+=.25*l*_*(p*p+m*p+m*m+d*d+y*d+y*y)}t.mass=e*n,i.SelfMul(1/n),z.AddVV(i,a,t.center),t.I=e*s,t.I+=t.mass*(z.DotVV(t.center,t.center)-z.DotVV(i,i))},n.Validate=function(){for(var t=0;t<this.m_count;++t)for(var e=t,i=(t+1)%this.m_count,n=this.m_vertices[e],s=z.SubVV(this.m_vertices[i],n,r.Validate_s_e),a=0;a<this.m_count;++a)if(a!==e&&a!==i){var o=z.SubVV(this.m_vertices[a],n,r.Validate_s_v);if(z.CrossVV(s,o)<0)return!1}return!0},n.SetupDistanceProxy=function(t){t.m_vertices=this.m_vertices,t.m_count=this.m_count,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){for(var s=X.MulTRV(i.q,t,r.ComputeSubmergedArea_s_normalL),a=e-z.DotVV(t,i.p),o=[],l=0,h=-1,u=-1,c=!1,_=0;_<this.m_count;++_){o[_]=z.DotVV(s,this.m_vertices[_])-a;var f=o[_]<-1e-5;_>0&&(f?c||(h=_-1,l++):c&&(u=_-1,l++)),c=f}switch(l){case 0:if(c){var p=r.ComputeSubmergedArea_s_md;return this.ComputeMass(p,1),Y.MulXV(i,p.center,n),p.mass}return 0;case 1:-1===h?h=this.m_count-1:u=this.m_count-1}for(var d,m=(h+1)%this.m_count,y=(u+1)%this.m_count,g=(0-o[h])/(o[m]-o[h]),v=(0-o[u])/(o[y]-o[u]),b=r.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[h].x*(1-g)+this.m_vertices[m].x*g,this.m_vertices[h].y*(1-g)+this.m_vertices[m].y*g),S=r.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[u].x*(1-v)+this.m_vertices[y].x*v,this.m_vertices[u].y*(1-v)+this.m_vertices[y].y*v),A=0,C=r.ComputeSubmergedArea_s_center.SetZero(),x=this.m_vertices[m],T=m;T!==y;){d=(T=(T+1)%this.m_count)===y?S:this.m_vertices[T];var w=.5*((x.x-b.x)*(d.y-b.y)-(x.y-b.y)*(d.x-b.x));A+=w,C.x+=w*(b.x+x.x+d.x)/3,C.y+=w*(b.y+x.y+d.y)/3,x=d}return C.SelfMul(1/A),Y.MulXV(i,C,n),A},n.Dump=function(t){t(" const shape: b2PolygonShape = new b2PolygonShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e<this.m_count;++e)t(" vs[%d] = new b2Vec2(%.15f, %.15f);\n",e,this.m_vertices[e].x,this.m_vertices[e].y);t(" shape.Set(vs, %d);\n",this.m_count)},r.ComputeCentroid=function(t,e,i){var n=i;n.SetZero();for(var s=0,a=r.ComputeCentroid_s_pRef.SetZero(),o=1/3,l=0;l<e;++l){var h=a,u=t[l],c=t[(l+1)%e],_=z.SubVV(u,h,r.ComputeCentroid_s_e1),f=z.SubVV(c,h,r.ComputeCentroid_s_e2),p=.5*z.CrossVV(_,f);s+=p,n.x+=p*o*(h.x+u.x+c.x),n.y+=p*o*(h.y+u.y+c.y)}return n.SelfMul(1/s),n},r}(di);yi.Set_s_r=new z,yi.Set_s_v=new z,yi.TestPoint_s_pLocal=new z,yi.ComputeDistance_s_pLocal=new z,yi.ComputeDistance_s_normalForMaxDistance=new z,yi.ComputeDistance_s_minDistance=new z,yi.ComputeDistance_s_distance=new z,yi.RayCast_s_p1=new z,yi.RayCast_s_p2=new z,yi.RayCast_s_d=new z,yi.ComputeAABB_s_v=new z,yi.ComputeMass_s_center=new z,yi.ComputeMass_s_s=new z,yi.ComputeMass_s_e1=new z,yi.ComputeMass_s_e2=new z,yi.Validate_s_e=new z,yi.Validate_s_v=new z,yi.ComputeSubmergedArea_s_normalL=new z,yi.ComputeSubmergedArea_s_md=new pi,yi.ComputeSubmergedArea_s_intoVec=new z,yi.ComputeSubmergedArea_s_outoVec=new z,yi.ComputeSubmergedArea_s_center=new z,yi.ComputeCentroid_s_pRef=new z,yi.ComputeCentroid_s_e1=new z,yi.ComputeCentroid_s_e2=new z;var gi=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_edgeShape,h)||this).m_vertex1=new z,i.m_vertex2=new z,i.m_vertex0=new z,i.m_vertex3=new z,i.m_hasVertex0=!1,i.m_hasVertex3=!1,i}Me(i,e);var r=i.prototype;return r.Set=function(t,e){return this.m_vertex1.Copy(t),this.m_vertex2.Copy(e),this.m_hasVertex0=!1,this.m_hasVertex3=!1,this},r.Clone=function(){return(new i).Copy(this)},r.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_vertex1.Copy(t.m_vertex1),this.m_vertex2.Copy(t.m_vertex2),this.m_vertex0.Copy(t.m_vertex0),this.m_vertex3.Copy(t.m_vertex3),this.m_hasVertex0=t.m_hasVertex0,this.m_hasVertex3=t.m_hasVertex3,this},r.GetChildCount=function(){return 1},r.TestPoint=function(){return!1},r.ComputeDistance=function(t,e,r){var n=Y.MulXV(t,this.m_vertex1,i.ComputeDistance_s_v1),s=Y.MulXV(t,this.m_vertex2,i.ComputeDistance_s_v2),a=z.SubVV(e,n,i.ComputeDistance_s_d),o=z.SubVV(s,n,i.ComputeDistance_s_s),l=z.DotVV(a,o);if(l>0){var h=z.DotVV(o,o);l>h?z.SubVV(e,s,a):a.SelfMulSub(l/h,o)}return r.Copy(a),r.Normalize()},r.RayCast=function(t,e,r){var n=Y.MulTXV(r,e.p1,i.RayCast_s_p1),s=Y.MulTXV(r,e.p2,i.RayCast_s_p2),a=z.SubVV(s,n,i.RayCast_s_d),o=this.m_vertex1,l=this.m_vertex2,h=z.SubVV(l,o,i.RayCast_s_e),u=t.normal.Set(h.y,-h.x).SelfNormalize(),c=z.DotVV(u,z.SubVV(o,n,z.s_t0)),_=z.DotVV(u,a);if(0===_)return!1;var f=c/_;if(f<0||e.maxFraction<f)return!1;var p=z.AddVMulSV(n,f,a,i.RayCast_s_q),d=z.SubVV(l,o,i.RayCast_s_r),m=z.DotVV(d,d);if(0===m)return!1;var y=z.DotVV(z.SubVV(p,o,z.s_t0),d)/m;return!(y<0||1<y||(t.fraction=f,X.MulRV(r.q,t.normal,t.normal),c>0&&t.normal.SelfNeg(),0))},r.ComputeAABB=function(t,e){var r=Y.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),n=Y.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);z.MinV(r,n,t.lowerBound),z.MaxV(r,n,t.upperBound);var s=this.m_radius;t.lowerBound.SelfSubXY(s,s),t.upperBound.SelfAddXY(s,s)},r.ComputeMass=function(t){t.mass=0,z.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0},r.SetupDistanceProxy=function(t){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertex1),t.m_vertices[1].Copy(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius},r.ComputeSubmergedArea=function(t,e,i,r){return r.SetZero(),0},r.Dump=function(t){t(" const shape: b2EdgeShape = new b2EdgeShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y),t(" shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y),t(" shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y),t(" shape.m_vertex3.Set(%.15f, %.15f);\n",this.m_vertex3.x,this.m_vertex3.y),t(" shape.m_hasVertex0 = %s;\n",this.m_hasVertex0),t(" shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)},i}(di);gi.ComputeDistance_s_v1=new z,gi.ComputeDistance_s_v2=new z,gi.ComputeDistance_s_d=new z,gi.ComputeDistance_s_s=new z,gi.RayCast_s_p1=new z,gi.RayCast_s_p2=new z,gi.RayCast_s_d=new z,gi.RayCast_s_e=new z,gi.RayCast_s_q=new z,gi.RayCast_s_r=new z,gi.ComputeAABB_s_v1=new z,gi.ComputeAABB_s_v2=new z;var vi=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_chainShape,h)||this).m_vertices=[],i.m_count=0,i.m_prevVertex=new z,i.m_nextVertex=new z,i.m_hasPrevVertex=!1,i.m_hasNextVertex=!1,i}Me(i,e);var r=i.prototype;return r.CreateLoop=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if("number"==typeof e[0][0]){var r=e[0];if(r.length%2!=0)throw new Error;return this._CreateLoop((function(t){return{x:r[2*t],y:r[2*t+1]}}),r.length/2)}var n=e[0],s=e[1]||n.length;return this._CreateLoop((function(t){return n[t]}),s)},r._CreateLoop=function(t,e){if(e<3)return this;this.m_count=e+1,this.m_vertices=z.MakeArray(this.m_count);for(var i=0;i<e;++i)this.m_vertices[i].Copy(t(i));return this.m_vertices[e].Copy(this.m_vertices[0]),this.m_prevVertex.Copy(this.m_vertices[this.m_count-2]),this.m_nextVertex.Copy(this.m_vertices[1]),this.m_hasPrevVertex=!0,this.m_hasNextVertex=!0,this},r.CreateChain=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if("number"==typeof e[0][0]){var r=e[0];if(r.length%2!=0)throw new Error;return this._CreateChain((function(t){return{x:r[2*t],y:r[2*t+1]}}),r.length/2)}var n=e[0],s=e[1]||n.length;return this._CreateChain((function(t){return n[t]}),s)},r._CreateChain=function(t,e){this.m_count=e,this.m_vertices=z.MakeArray(e);for(var i=0;i<e;++i)this.m_vertices[i].Copy(t(i));return this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,this.m_prevVertex.SetZero(),this.m_nextVertex.SetZero(),this},r.SetPrevVertex=function(t){return this.m_prevVertex.Copy(t),this.m_hasPrevVertex=!0,this},r.SetNextVertex=function(t){return this.m_nextVertex.Copy(t),this.m_hasNextVertex=!0,this},r.Clone=function(){return(new i).Copy(this)},r.Copy=function(t){return e.prototype.Copy.call(this,t),this._CreateChain((function(e){return t.m_vertices[e]}),t.m_count),this.m_prevVertex.Copy(t.m_prevVertex),this.m_nextVertex.Copy(t.m_nextVertex),this.m_hasPrevVertex=t.m_hasPrevVertex,this.m_hasNextVertex=t.m_hasNextVertex,this},r.GetChildCount=function(){return this.m_count-1},r.GetChildEdge=function(t,e){t.m_radius=this.m_radius,t.m_vertex1.Copy(this.m_vertices[e]),t.m_vertex2.Copy(this.m_vertices[e+1]),e>0?(t.m_vertex0.Copy(this.m_vertices[e-1]),t.m_hasVertex0=!0):(t.m_vertex0.Copy(this.m_prevVertex),t.m_hasVertex0=this.m_hasPrevVertex),e<this.m_count-2?(t.m_vertex3.Copy(this.m_vertices[e+2]),t.m_hasVertex3=!0):(t.m_vertex3.Copy(this.m_nextVertex),t.m_hasVertex3=this.m_hasNextVertex)},r.TestPoint=function(){return!1},r.ComputeDistance=function(t,e,r,n){var s=i.ComputeDistance_s_edgeShape;return this.GetChildEdge(s,n),s.ComputeDistance(t,e,r,0)},r.RayCast=function(t,e,r,n){var s=i.RayCast_s_edgeShape;return s.m_vertex1.Copy(this.m_vertices[n]),s.m_vertex2.Copy(this.m_vertices[(n+1)%this.m_count]),s.RayCast(t,e,r,0)},r.ComputeAABB=function(t,e,r){var n=this.m_vertices[r],s=this.m_vertices[(r+1)%this.m_count],a=Y.MulXV(e,n,i.ComputeAABB_s_v1),o=Y.MulXV(e,s,i.ComputeAABB_s_v2);z.MinV(a,o,t.lowerBound),z.MaxV(a,o,t.upperBound)},r.ComputeMass=function(t){t.mass=0,t.center.SetZero(),t.I=0},r.SetupDistanceProxy=function(t,e){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertices[e]),e+1<this.m_count?t.m_vertices[1].Copy(this.m_vertices[e+1]):t.m_vertices[1].Copy(this.m_vertices[0]),t.m_count=2,t.m_radius=this.m_radius},r.ComputeSubmergedArea=function(t,e,i,r){return r.SetZero(),0},r.Dump=function(t){t(" const shape: b2ChainShape = new b2ChainShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e<this.m_count;++e)t(" vs[%d] = new bVec2(%.15f, %.15f);\n",e,this.m_vertices[e].x,this.m_vertices[e].y);t(" shape.CreateChain(vs, %d);\n",this.m_count),t(" shape.m_prevVertex.Set(%.15f, %.15f);\n",this.m_prevVertex.x,this.m_prevVertex.y),t(" shape.m_nextVertex.Set(%.15f, %.15f);\n",this.m_nextVertex.x,this.m_nextVertex.y),t(" shape.m_hasPrevVertex = %s;\n",this.m_hasPrevVertex?"true":"false"),t(" shape.m_hasNextVertex = %s;\n",this.m_hasNextVertex?"true":"false")},i}(di);vi.ComputeDistance_s_edgeShape=new gi,vi.RayCast_s_edgeShape=new gi,vi.ComputeAABB_s_v1=new z,vi.ComputeAABB_s_v2=new z;var bi=function(){function t(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.categoryBits=t.categoryBits,this.maskBits=t.maskBits,this.groupIndex=t.groupIndex||0,this},t}();bi.DEFAULT=new bi;var Si=function(){this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.isSensor=!1,this.filter=new bi},Ai=function(){function t(t,e){this.aabb=new Ft,this.childIndex=0,this.fixture=t,this.childIndex=e,this.fixture.m_shape.ComputeAABB(this.aabb,this.fixture.m_body.GetTransform(),e),this.treeNode=this.fixture.m_body.m_world.m_contactManager.m_broadPhase.CreateProxy(this.aabb,this)}var e=t.prototype;return e.Reset=function(){this.fixture.m_body.m_world.m_contactManager.m_broadPhase.DestroyProxy(this.treeNode)},e.Touch=function(){this.fixture.m_body.m_world.m_contactManager.m_broadPhase.TouchProxy(this.treeNode)},e.Synchronize=function(e,i,r){if(e===i)this.fixture.m_shape.ComputeAABB(this.aabb,e,this.childIndex),this.fixture.m_body.m_world.m_contactManager.m_broadPhase.MoveProxy(this.treeNode,this.aabb,r);else{var n=t.Synchronize_s_aabb1,s=t.Synchronize_s_aabb2;this.fixture.m_shape.ComputeAABB(n,e,this.childIndex),this.fixture.m_shape.ComputeAABB(s,i,this.childIndex),this.aabb.Combine2(n,s),this.fixture.m_body.m_world.m_contactManager.m_broadPhase.MoveProxy(this.treeNode,this.aabb,r)}},t}();Ai.Synchronize_s_aabb1=new Ft,Ai.Synchronize_s_aabb2=new Ft;var Ci,xi=function(){function t(t,i){this.m_density=0,this.m_next=null,this.m_friction=0,this.m_restitution=0,this.m_proxies=[],this.m_filter=new bi,this.m_isSensor=!1,this.m_userData=null,this.m_body=t,this.m_shape=i.shape.Clone(),this.m_userData=e(i.userData,null),this.m_friction=e(i.friction,.2),this.m_restitution=e(i.restitution,0),this.m_filter.Copy(e(i.filter,bi.DEFAULT)),this.m_isSensor=e(i.isSensor,!1),this.m_density=e(i.density,0)}var i=t.prototype;return i.Reset=function(){},i.GetType=function(){return this.m_shape.GetType()},i.GetShape=function(){return this.m_shape},i.SetSensor=function(t){t!==this.m_isSensor&&(this.m_body.SetAwake(!0),this.m_isSensor=t)},i.IsSensor=function(){return this.m_isSensor},i.SetFilterData=function(t){this.m_filter.Copy(t),this.Refilter()},i.GetFilterData=function(){return this.m_filter},i.Refilter=function(){for(var t=this.m_body.GetContactList();t;){var e=t.contact,i=e.GetFixtureA(),r=e.GetFixtureB();i!==this&&r!==this||e.FlagForFiltering(),t=t.next}this.TouchProxies()},i.GetBody=function(){return this.m_body},i.GetNext=function(){return this.m_next},i.GetUserData=function(){return this.m_userData},i.SetUserData=function(t){this.m_userData=t},i.TestPoint=function(t){return this.m_shape.TestPoint(this.m_body.GetTransform(),t)},i.ComputeDistance=function(t,e,i){return this.m_shape.ComputeDistance(this.m_body.GetTransform(),t,e,i)},i.RayCast=function(t,e,i){return this.m_shape.RayCast(t,e,this.m_body.GetTransform(),i)},i.GetMassData=function(t){return void 0===t&&(t=new pi),this.m_shape.ComputeMass(t,this.m_density),t},i.SetDensity=function(t){this.m_density=t},i.GetDensity=function(){return this.m_density},i.GetFriction=function(){return this.m_friction},i.SetFriction=function(t){this.m_friction=t},i.GetRestitution=function(){return this.m_restitution},i.SetRestitution=function(t){this.m_restitution=t},i.GetAABB=function(t){return this.m_proxies[t].aabb},i.Dump=function(t,e){t(" const fd: b2FixtureDef = new b2FixtureDef();\n"),t(" fd.friction = %.15f;\n",this.m_friction),t(" fd.restitution = %.15f;\n",this.m_restitution),t(" fd.density = %.15f;\n",this.m_density),t(" fd.isSensor = %s;\n",this.m_isSensor?"true":"false"),t(" fd.filter.categoryBits = %d;\n",this.m_filter.categoryBits),t(" fd.filter.maskBits = %d;\n",this.m_filter.maskBits),t(" fd.filter.groupIndex = %d;\n",this.m_filter.groupIndex),this.m_shape.Dump(t),t("\n"),t(" fd.shape = shape;\n"),t("\n"),t(" bodies[%d].CreateFixture(fd);\n",e)},i.CreateProxies=function(){if(0!==this.m_proxies.length)throw new Error;for(var t=0;t<this.m_shape.GetChildCount();++t)this.m_proxies[t]=new Ai(this,t)},i.DestroyProxies=function(){for(var t,e=Fe(this.m_proxies);!(t=e()).done;)t.value.Reset();this.m_proxies.length=0},i.TouchProxies=function(){for(var t,e=Fe(this.m_proxies);!(t=e()).done;)t.value.Touch()},i.SynchronizeProxies=function(t,e,i){for(var r,n=Fe(this.m_proxies);!(r=n()).done;)r.value.Synchronize(t,e,i)},Pe(t,[{key:"m_proxyCount",get:function(){return this.m_proxies.length}}]),t}();(Ci=t.b2BodyType||(t.b2BodyType={}))[Ci.b2_unknown=-1]="b2_unknown",Ci[Ci.b2_staticBody=0]="b2_staticBody",Ci[Ci.b2_kinematicBody=1]="b2_kinematicBody",Ci[Ci.b2_dynamicBody=2]="b2_dynamicBody";var Ti,wi,Ei=function(){function i(i,r){this.m_type=t.b2BodyType.b2_staticBody,this.m_islandFlag=!1,this.m_awakeFlag=!1,this.m_autoSleepFlag=!1,this.m_bulletFlag=!1,this.m_fixedRotationFlag=!1,this.m_activeFlag=!1,this.m_toiFlag=!1,this.m_islandIndex=0,this.m_xf=new Y,this.m_xf0=new Y,this.m_sweep=new J,this.m_linearVelocity=new z,this.m_angularVelocity=0,this.m_force=new z,this.m_torque=0,this.m_prev=null,this.m_next=null,this.m_fixtureList=null,this.m_fixtureCount=0,this.m_jointList=null,this.m_contactList=null,this.m_mass=1,this.m_invMass=1,this.m_I=0,this.m_invI=0,this.m_linearDamping=0,this.m_angularDamping=0,this.m_gravityScale=1,this.m_sleepTime=0,this.m_userData=null,this.m_controllerList=null,this.m_controllerCount=0,this.m_bulletFlag=e(i.bullet,!1),this.m_fixedRotationFlag=e(i.fixedRotation,!1),this.m_autoSleepFlag=e(i.allowSleep,!0),this.m_awakeFlag=e(i.awake,!0),this.m_activeFlag=e(i.active,!0),this.m_world=r,this.m_xf.p.Copy(e(i.position,z.ZERO)),this.m_xf.q.SetAngle(e(i.angle,0)),this.m_xf0.Copy(this.m_xf),this.m_sweep.localCenter.SetZero(),this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),this.m_sweep.a0=this.m_sweep.a=this.m_xf.q.GetAngle(),this.m_sweep.alpha0=0,this.m_linearVelocity.Copy(e(i.linearVelocity,z.ZERO)),this.m_angularVelocity=e(i.angularVelocity,0),this.m_linearDamping=e(i.linearDamping,0),this.m_angularDamping=e(i.angularDamping,0),this.m_gravityScale=e(i.gravityScale,1),this.m_force.SetZero(),this.m_torque=0,this.m_sleepTime=0,this.m_type=e(i.type,t.b2BodyType.b2_staticBody),i.type===t.b2BodyType.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0),this.m_I=0,this.m_invI=0,this.m_userData=i.userData,this.m_fixtureList=null,this.m_fixtureCount=0,this.m_controllerList=null,this.m_controllerCount=0}var r=i.prototype;return r.CreateFixture=function(t,e){return void 0===e&&(e=0),t instanceof di?this.CreateFixtureShapeDensity(t,e):this.CreateFixtureDef(t)},r.CreateFixtureDef=function(t){if(this.m_world.IsLocked())throw new Error;var e=new xi(this,t);return this.m_activeFlag&&e.CreateProxies(),e.m_next=this.m_fixtureList,this.m_fixtureList=e,++this.m_fixtureCount,e.m_density>0&&this.ResetMassData(),this.m_world.m_newFixture=!0,e},r.CreateFixtureShapeDensity=function(t,e){void 0===e&&(e=0);var r=i.CreateFixtureShapeDensity_s_def;return r.shape=t,r.density=e,this.CreateFixtureDef(r)},r.DestroyFixture=function(t){if(this.m_world.IsLocked())throw new Error;for(var e=this.m_fixtureList,i=null;null!==e;){if(e===t){i?i.m_next=t.m_next:this.m_fixtureList=t.m_next;break}i=e,e=e.m_next}for(var r=this.m_contactList;r;){var n=r.contact;r=r.next;var s=n.GetFixtureA(),a=n.GetFixtureB();t!==s&&t!==a||this.m_world.m_contactManager.Destroy(n)}this.m_activeFlag&&t.DestroyProxies(),t.m_next=null,t.Reset(),--this.m_fixtureCount,this.ResetMassData()},r.SetTransformVec=function(t,e){this.SetTransformXY(t.x,t.y,e)},r.SetTransformXY=function(t,e,i){if(this.m_world.IsLocked())throw new Error;this.m_xf.q.SetAngle(i),this.m_xf.p.Set(t,e),this.m_xf0.Copy(this.m_xf),Y.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=i,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=i;for(var r=this.m_fixtureList;r;r=r.m_next)r.SynchronizeProxies(this.m_xf,this.m_xf,z.ZERO);this.m_world.m_contactManager.FindNewContacts()},r.SetTransform=function(t){this.SetTransformVec(t.p,t.GetAngle())},r.GetTransform=function(){return this.m_xf},r.GetPosition=function(){return this.m_xf.p},r.SetPosition=function(t){this.SetTransformVec(t,this.GetAngle())},r.SetPositionXY=function(t,e){this.SetTransformXY(t,e,this.GetAngle())},r.GetAngle=function(){return this.m_sweep.a},r.SetAngle=function(t){this.SetTransformVec(this.GetPosition(),t)},r.GetWorldCenter=function(){return this.m_sweep.c},r.GetLocalCenter=function(){return this.m_sweep.localCenter},r.SetLinearVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(z.DotVV(e,e)>0&&this.SetAwake(!0),this.m_linearVelocity.Copy(e))},r.GetLinearVelocity=function(){return this.m_linearVelocity},r.SetAngularVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(e*e>0&&this.SetAwake(!0),this.m_angularVelocity=e)},r.GetAngularVelocity=function(){return this.m_angularVelocity},r.GetDefinition=function(t){return t.type=this.GetType(),t.allowSleep=this.m_autoSleepFlag,t.angle=this.GetAngle(),t.angularDamping=this.m_angularDamping,t.gravityScale=this.m_gravityScale,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=this.m_fixedRotationFlag,t.bullet=this.m_bulletFlag,t.awake=this.m_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.Copy(this.GetLinearVelocity()),t.position.Copy(this.GetPosition()),t.userData=this.GetUserData(),t},r.ApplyForce=function(e,i,r){void 0===r&&(r=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(r&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x))},r.ApplyForceToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y))},r.ApplyTorque=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_torque+=e))},r.ApplyLinearImpulse=function(e,i,r){void 0===r&&(r=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(r&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x)))},r.ApplyLinearImpulseToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y))},r.ApplyAngularImpulse=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*e))},r.GetMass=function(){return this.m_mass},r.GetInertia=function(){return this.m_I+this.m_mass*z.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter)},r.GetMassData=function(t){return t.mass=this.m_mass,t.I=this.m_I+this.m_mass*z.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center.Copy(this.m_sweep.localCenter),t},r.SetMassData=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type===t.b2BodyType.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&!this.m_fixedRotationFlag&&(this.m_I=e.I-this.m_mass*z.DotVV(e.center,e.center),this.m_invI=1/this.m_I);var r=i.SetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e.center),Y.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),z.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,z.SubVV(this.m_sweep.c,r,z.s_t0),this.m_linearVelocity)}},r.ResetMassData=function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type===t.b2BodyType.b2_staticBody||this.m_type===t.b2BodyType.b2_kinematicBody)return this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);for(var e=i.ResetMassData_s_localCenter.SetZero(),r=this.m_fixtureList;r;r=r.m_next)if(0!==r.m_density){var n=r.GetMassData(i.ResetMassData_s_massData);this.m_mass+=n.mass,e.x+=n.center.x*n.mass,e.y+=n.center.y*n.mass,this.m_I+=n.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&!this.m_fixedRotationFlag?(this.m_I-=this.m_mass*z.DotVV(e,e),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var s=i.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e),Y.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),z.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,z.SubVV(this.m_sweep.c,s,z.s_t0),this.m_linearVelocity)},r.GetWorldPoint=function(t,e){return Y.MulXV(this.m_xf,t,e)},r.GetWorldVector=function(t,e){return X.MulRV(this.m_xf.q,t,e)},r.GetLocalPoint=function(t,e){return Y.MulTXV(this.m_xf,t,e)},r.GetLocalVector=function(t,e){return X.MulTRV(this.m_xf.q,t,e)},r.GetLinearVelocityFromWorldPoint=function(t,e){return z.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,z.SubVV(t,this.m_sweep.c,z.s_t0),e)},r.GetLinearVelocityFromLocalPoint=function(t,e){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t,e),e)},r.GetLinearDamping=function(){return this.m_linearDamping},r.SetLinearDamping=function(t){this.m_linearDamping=t},r.GetAngularDamping=function(){return this.m_angularDamping},r.SetAngularDamping=function(t){this.m_angularDamping=t},r.GetGravityScale=function(){return this.m_gravityScale},r.SetGravityScale=function(t){this.m_gravityScale=t},r.SetType=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type!==e){this.m_type=e,this.ResetMassData(),this.m_type===t.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var r=i;i=i.next,this.m_world.m_contactManager.Destroy(r.contact)}this.m_contactList=null;for(var n=this.m_fixtureList;n;n=n.m_next)n.TouchProxies()}},r.GetType=function(){return this.m_type},r.SetBullet=function(t){this.m_bulletFlag=t},r.IsBullet=function(){return this.m_bulletFlag},r.SetSleepingAllowed=function(t){this.m_autoSleepFlag=t,t||this.SetAwake(!0)},r.IsSleepingAllowed=function(){return this.m_autoSleepFlag},r.SetAwake=function(t){t?(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},r.IsAwake=function(){return this.m_awakeFlag},r.SetActive=function(t){if(this.m_world.IsLocked())throw new Error;if(t!==this.IsActive())if(this.m_activeFlag=t,t)for(var e=this.m_fixtureList;e;e=e.m_next)e.CreateProxies();else{for(var i=this.m_fixtureList;i;i=i.m_next)i.DestroyProxies();for(var r=this.m_contactList;r;){var n=r;r=r.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null}},r.IsActive=function(){return this.m_activeFlag},r.SetFixedRotation=function(t){this.m_fixedRotationFlag!==t&&(this.m_fixedRotationFlag=t,this.m_angularVelocity=0,this.ResetMassData())},r.IsFixedRotation=function(){return this.m_fixedRotationFlag},r.GetFixtureList=function(){return this.m_fixtureList},r.GetJointList=function(){return this.m_jointList},r.GetContactList=function(){return this.m_contactList},r.GetNext=function(){return this.m_next},r.GetUserData=function(){return this.m_userData},r.SetUserData=function(t){this.m_userData=t},r.GetWorld=function(){return this.m_world},r.Dump=function(e){var i=this.m_islandIndex;e("{\n"),e(" const bd: b2BodyDef = new b2BodyDef();\n");var r="";switch(this.m_type){case t.b2BodyType.b2_staticBody:r="b2BodyType.b2_staticBody";break;case t.b2BodyType.b2_kinematicBody:r="b2BodyType.b2_kinematicBody";break;case t.b2BodyType.b2_dynamicBody:r="b2BodyType.b2_dynamicBody"}e(" bd.type = %s;\n",r),e(" bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y),e(" bd.angle = %.15f;\n",this.m_sweep.a),e(" bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y),e(" bd.angularVelocity = %.15f;\n",this.m_angularVelocity),e(" bd.linearDamping = %.15f;\n",this.m_linearDamping),e(" bd.angularDamping = %.15f;\n",this.m_angularDamping),e(" bd.allowSleep = %s;\n",this.m_autoSleepFlag?"true":"false"),e(" bd.awake = %s;\n",this.m_awakeFlag?"true":"false"),e(" bd.fixedRotation = %s;\n",this.m_fixedRotationFlag?"true":"false"),e(" bd.bullet = %s;\n",this.m_bulletFlag?"true":"false"),e(" bd.active = %s;\n",this.m_activeFlag?"true":"false"),e(" bd.gravityScale = %.15f;\n",this.m_gravityScale),e("\n"),e(" bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex),e("\n");for(var n=this.m_fixtureList;n;n=n.m_next)e(" {\n"),n.Dump(e,i),e(" }\n");e("}\n")},r.SynchronizeFixtures=function(){var t=i.SynchronizeFixtures_s_xf1;t.q.SetAngle(this.m_sweep.a0),X.MulRV(t.q,this.m_sweep.localCenter,t.p),z.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=z.SubVV(this.m_sweep.c,this.m_sweep.c0,i.SynchronizeFixtures_s_displacement),r=this.m_fixtureList;r;r=r.m_next)r.SynchronizeProxies(t,this.m_xf,e)},r.SynchronizeTransform=function(){this.m_xf.q.SetAngle(this.m_sweep.a),X.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),z.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},r.ShouldCollide=function(e){return(this.m_type!==t.b2BodyType.b2_staticBody||e.m_type!==t.b2BodyType.b2_staticBody)&&this.ShouldCollideConnected(e)},r.ShouldCollideConnected=function(t){for(var e=this.m_jointList;e;e=e.next)if(e.other===t&&!e.joint.m_collideConnected)return!1;return!0},r.Advance=function(t){this.m_sweep.Advance(t),this.m_sweep.c.Copy(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.SetAngle(this.m_sweep.a),X.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),z.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},r.GetControllerList=function(){return this.m_controllerList},r.GetControllerCount=function(){return this.m_controllerCount},i}();Ei.CreateFixtureShapeDensity_s_def=new Si,Ei.SetMassData_s_oldCenter=new z,Ei.ResetMassData_s_localCenter=new z,Ei.ResetMassData_s_oldCenter=new z,Ei.ResetMassData_s_massData=new pi,Ei.SynchronizeFixtures_s_xf1=new Y,Ei.SynchronizeFixtures_s_displacement=new z,(wi=t.b2JointType||(t.b2JointType={}))[wi.e_unknownJoint=0]="e_unknownJoint",wi[wi.e_revoluteJoint=1]="e_revoluteJoint",wi[wi.e_prismaticJoint=2]="e_prismaticJoint",wi[wi.e_distanceJoint=3]="e_distanceJoint",wi[wi.e_pulleyJoint=4]="e_pulleyJoint",wi[wi.e_mouseJoint=5]="e_mouseJoint",wi[wi.e_gearJoint=6]="e_gearJoint",wi[wi.e_wheelJoint=7]="e_wheelJoint",wi[wi.e_weldJoint=8]="e_weldJoint",wi[wi.e_frictionJoint=9]="e_frictionJoint",wi[wi.e_ropeJoint=10]="e_ropeJoint",wi[wi.e_motorJoint=11]="e_motorJoint",wi[wi.e_areaJoint=12]="e_areaJoint",(Ti=t.b2LimitState||(t.b2LimitState={}))[Ti.e_inactiveLimit=0]="e_inactiveLimit",Ti[Ti.e_atLowerLimit=1]="e_atLowerLimit",Ti[Ti.e_atUpperLimit=2]="e_atUpperLimit",Ti[Ti.e_equalLimits=3]="e_equalLimits";var Bi=function(){function t(){this.linear=new z,this.angularA=0,this.angularB=0}var e=t.prototype;return e.SetZero=function(){return this.linear.SetZero(),this.angularA=0,this.angularB=0,this},e.Set=function(t,e,i){return this.linear.Copy(t),this.angularA=e,this.angularB=i,this},t}(),Di=function(){function t(t){this._other=null,this.prev=null,this.next=null,this.joint=t}return t.prototype.Reset=function(){this._other=null,this.prev=null,this.next=null},Pe(t,[{key:"other",get:function(){if(null===this._other)throw new Error;return this._other},set:function(t){if(null!==this._other)throw new Error;this._other=t}}]),t}(),Mi=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},Pi=function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_edgeA=new Di(this),this.m_edgeB=new Di(this),this.m_index=0,this.m_islandFlag=!1,this.m_collideConnected=!1,this.m_userData=null,this.m_type=i.type,this.m_edgeA.other=i.bodyB,this.m_edgeB.other=i.bodyA,this.m_bodyA=i.bodyA,this.m_bodyB=i.bodyB,this.m_collideConnected=e(i.collideConnected,!1),this.m_userData=e(i.userData,null)}var r=i.prototype;return r.GetType=function(){return this.m_type},r.GetBodyA=function(){return this.m_bodyA},r.GetBodyB=function(){return this.m_bodyB},r.GetNext=function(){return this.m_next},r.GetUserData=function(){return this.m_userData},r.SetUserData=function(t){this.m_userData=t},r.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()},r.GetCollideConnected=function(){return this.m_collideConnected},r.Dump=function(t){t("// Dump is not supported for this joint type.\n")},r.ShiftOrigin=function(){},i}(),Ri=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_distanceJoint)||this).localAnchorA=new z,i.localAnchorB=new z,i.length=1,i.frequencyHz=0,i.dampingRatio=0,i}return Me(i,e),i.prototype.Initialize=function(t,e,i,r){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(r,this.localAnchorB),this.length=z.DistanceVV(i,r),this.frequencyHz=0,this.dampingRatio=0},i}(Mi),Ii=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_frequencyHz=0,r.m_dampingRatio=0,r.m_bias=0,r.m_localAnchorA=new z,r.m_localAnchorB=new z,r.m_gamma=0,r.m_impulse=0,r.m_length=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new z,r.m_rA=new z,r.m_rB=new z,r.m_localCenterA=new z,r.m_localCenterB=new z,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=0,r.m_qA=new X,r.m_qB=new X,r.m_lalcA=new z,r.m_lalcB=new z,r.m_frequencyHz=e(i.frequencyHz,0),r.m_dampingRatio=e(i.dampingRatio,0),r.m_localAnchorA.Copy(i.localAnchorA),r.m_localAnchorB.Copy(i.localAnchorB),r.m_length=i.length,r}Me(i,t);var r=i.prototype;return r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_u.x,e.y=t*this.m_impulse*this.m_u.y,e},r.GetReactionTorque=function(){return 0},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.SetLength=function(t){this.m_length=t},r.Length=function(){return this.m_length},r.SetFrequency=function(t){this.m_frequencyHz=t},r.GetFrequency=function(){return this.m_frequencyHz},r.SetDampingRatio=function(t){this.m_dampingRatio=t},r.GetDampingRatio=function(){return this.m_dampingRatio},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.length = %.15f;\n",this.m_length),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},r.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,r=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,a=t.velocities[this.m_indexA].w,l=t.positions[this.m_indexB].c,h=t.positions[this.m_indexB].a,u=t.velocities[this.m_indexB].v,c=t.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(h);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),X.MulRV(_,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),X.MulRV(f,this.m_lalcB,this.m_rB),this.m_u.x=l.x+this.m_rB.x-e.x-this.m_rA.x,this.m_u.y=l.y+this.m_rB.y-e.y-this.m_rA.y;var p=this.m_u.Length();p>o?this.m_u.SelfMul(1/p):this.m_u.SetZero();var d=z.CrossVV(this.m_rA,this.m_u),m=z.CrossVV(this.m_rB,this.m_u),y=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==y?1/y:0,this.m_frequencyHz>0){var g=p-this.m_length,v=2*s*this.m_frequencyHz,b=2*this.m_mass*this.m_dampingRatio*v,S=this.m_mass*v*v,A=t.step.dt;this.m_gamma=A*(b+A*S),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=g*A*S*this.m_gamma,y+=this.m_gamma,this.m_mass=0!==y?1/y:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var C=z.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);n.SelfMulSub(this.m_invMassA,C),a-=this.m_invIA*z.CrossVV(this.m_rA,C),u.SelfMulAdd(this.m_invMassB,C),c+=this.m_invIB*z.CrossVV(this.m_rB,C)}else this.m_impulse=0;t.velocities[this.m_indexA].w=a,t.velocities[this.m_indexB].w=c},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=z.AddVCrossSV(e,r,this.m_rA,i.SolveVelocityConstraints_s_vpA),o=z.AddVCrossSV(n,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),l=z.DotVV(this.m_u,z.SubVV(o,a,z.s_t0)),h=-this.m_mass*(l+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=h;var u=z.MulSV(h,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,u),r-=this.m_invIA*z.CrossVV(this.m_rA,u),n.SelfMulAdd(this.m_invMassB,u),s+=this.m_invIB*z.CrossVV(this.m_rB,u),t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c,r=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(r),l=this.m_qB.SetAngle(s),h=X.MulRV(a,this.m_lalcA,this.m_rA),c=X.MulRV(l,this.m_lalcB,this.m_rB),_=this.m_u;_.x=n.x+c.x-e.x-h.x,_.y=n.y+c.y-e.y-h.y;var f=this.m_u.Normalize()-this.m_length;f=M(f,-.2,u);var p=-this.m_mass*f,d=z.MulSV(p,_,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,d),r-=this.m_invIA*z.CrossVV(h,d),n.SelfMulAdd(this.m_invMassB,d),s+=this.m_invIB*z.CrossVV(c,d),t.positions[this.m_indexA].a=r,t.positions[this.m_indexB].a=s,E(f)<o},i}(Pi);Ii.InitVelocityConstraints_s_P=new z,Ii.SolveVelocityConstraints_s_vpA=new z,Ii.SolveVelocityConstraints_s_vpB=new z,Ii.SolveVelocityConstraints_s_P=new z,Ii.SolvePositionConstraints_s_P=new z;var Oi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_areaJoint)||this).bodies=[],i.frequencyHz=0,i.dampingRatio=0,i}return Me(i,e),i.prototype.AddBody=function(t){this.bodies.push(t),1===this.bodies.length?this.bodyA=t:2===this.bodies.length&&(this.bodyB=t)},i}(Mi),Fi=function(t){function i(i){var r;(r=t.call(this,i)||this).m_frequencyHz=0,r.m_dampingRatio=0,r.m_impulse=0,r.m_targetArea=0,r.m_delta=new z,r.m_bodies=i.bodies,r.m_frequencyHz=e(i.frequencyHz,0),r.m_dampingRatio=e(i.dampingRatio,0),r.m_targetLengths=C(i.bodies.length),r.m_normals=z.MakeArray(i.bodies.length),r.m_joints=[],r.m_deltas=z.MakeArray(i.bodies.length);var n=new Ri;n.frequencyHz=r.m_frequencyHz,n.dampingRatio=r.m_dampingRatio,r.m_targetArea=0;for(var s=0;s<r.m_bodies.length;++s){var a=r.m_bodies[s],o=r.m_bodies[(s+1)%r.m_bodies.length],l=a.GetWorldCenter(),h=o.GetWorldCenter();r.m_targetLengths[s]=z.DistanceVV(l,h),r.m_targetArea+=z.CrossVV(l,h),n.Initialize(a,o,l,h),r.m_joints[s]=a.GetWorld().CreateJoint(n)}return r.m_targetArea*=.5,r}Me(i,t);var n=i.prototype;return n.GetAnchorA=function(t){return t},n.GetAnchorB=function(t){return t},n.GetReactionForce=function(t,e){return e},n.GetReactionTorque=function(){return 0},n.SetFrequency=function(t){this.m_frequencyHz=t;for(var e=0;e<this.m_joints.length;++e)this.m_joints[e].SetFrequency(t)},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t;for(var e=0;e<this.m_joints.length;++e)this.m_joints[e].SetDampingRatio(t)},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){t("Area joint dumping is not supported.\n")},n.InitVelocityConstraints=function(t){for(var e=0;e<this.m_bodies.length;++e){var i=this.m_bodies[(e+this.m_bodies.length-1)%this.m_bodies.length],r=this.m_bodies[(e+1)%this.m_bodies.length],n=t.positions[i.m_islandIndex].c,s=t.positions[r.m_islandIndex].c,a=this.m_deltas[e];z.SubVV(s,n,a)}if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;for(var o=0;o<this.m_bodies.length;++o){var l=this.m_bodies[o],h=t.velocities[l.m_islandIndex].v,u=this.m_deltas[o];h.x+=l.m_invMass*u.y*.5*this.m_impulse,h.y+=l.m_invMass*-u.x*.5*this.m_impulse}}else this.m_impulse=0},n.SolveVelocityConstraints=function(t){for(var e=0,i=0,r=0;r<this.m_bodies.length;++r){var n=this.m_bodies[r],s=t.velocities[n.m_islandIndex].v,a=this.m_deltas[r];e+=a.LengthSquared()/n.GetMass(),i+=z.CrossVV(s,a)}var o=-2*i/e;this.m_impulse+=o;for(var l=0;l<this.m_bodies.length;++l){var h=this.m_bodies[l],u=t.velocities[h.m_islandIndex].v,c=this.m_deltas[l];u.x+=h.m_invMass*c.y*.5*o,u.y+=h.m_invMass*-c.x*.5*o}},n.SolvePositionConstraints=function(t){for(var e=0,i=0,n=0;n<this.m_bodies.length;++n){var s=this.m_bodies[n],a=this.m_bodies[(n+1)%this.m_bodies.length],l=t.positions[s.m_islandIndex].c,h=t.positions[a.m_islandIndex].c,c=z.SubVV(h,l,this.m_delta),_=c.Length();_<r&&(_=1),this.m_normals[n].x=c.y/_,this.m_normals[n].y=-c.x/_,e+=_,i+=z.CrossVV(l,h)}i*=.5;for(var f=.5*(this.m_targetArea-i)/e,p=!0,d=0;d<this.m_bodies.length;++d){var m=this.m_bodies[d],y=t.positions[m.m_islandIndex].c,g=(d+1)%this.m_bodies.length,v=z.AddVV(this.m_normals[d],this.m_normals[g],this.m_delta);v.SelfMul(f);var b=v.LengthSquared();b>R(u)&&v.SelfMul(u/O(b)),b>R(o)&&(p=!1),y.x+=v.x,y.y+=v.y}return p},i}(Pi),Li=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_frictionJoint)||this).localAnchorA=new z,i.localAnchorB=new z,i.maxForce=0,i.maxTorque=0,i}return Me(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB)},i}(Mi),Vi=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_localAnchorA=new z,r.m_localAnchorB=new z,r.m_linearImpulse=new z,r.m_angularImpulse=0,r.m_maxForce=0,r.m_maxTorque=0,r.m_indexA=0,r.m_indexB=0,r.m_rA=new z,r.m_rB=new z,r.m_localCenterA=new z,r.m_localCenterB=new z,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_linearMass=new j,r.m_angularMass=0,r.m_qA=new X,r.m_qB=new X,r.m_lalcA=new z,r.m_lalcB=new z,r.m_K=new j,r.m_localAnchorA.Copy(i.localAnchorA),r.m_localAnchorB.Copy(i.localAnchorB),r.m_linearImpulse.SetZero(),r.m_maxForce=e(i.maxForce,0),r.m_maxTorque=e(i.maxTorque,0),r.m_linearMass.SetZero(),r}Me(i,t);var r=i.prototype;return r.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,n=t.positions[this.m_indexB].a,s=t.velocities[this.m_indexB].v,a=t.velocities[this.m_indexB].w,o=this.m_qA.SetAngle(e),l=this.m_qB.SetAngle(n);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=X.MulRV(o,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=X.MulRV(l,this.m_lalcB,this.m_rB),c=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,p=this.m_invIB,d=this.m_K;if(d.ex.x=c+_+f*h.y*h.y+p*u.y*u.y,d.ex.y=-f*h.x*h.y-p*u.x*u.y,d.ey.x=d.ex.y,d.ey.y=c+_+f*h.x*h.x+p*u.x*u.x,d.GetInverse(this.m_linearMass),this.m_angularMass=f+p,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var m=this.m_linearImpulse;i.SelfMulSub(c,m),r-=f*(z.CrossVV(this.m_rA,m)+this.m_angularImpulse),s.SelfMulAdd(_,m),a+=p*(z.CrossVV(this.m_rB,m)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=a},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=this.m_invMassA,o=this.m_invMassB,l=this.m_invIA,h=this.m_invIB,u=t.step.dt,c=s-r,_=-this.m_angularMass*c,f=this.m_angularImpulse,p=u*this.m_maxTorque;this.m_angularImpulse=M(this.m_angularImpulse+_,-p,p),r-=l*(_=this.m_angularImpulse-f),s+=h*_;var d=z.SubVV(z.AddVCrossSV(n,s,this.m_rB,z.s_t0),z.AddVCrossSV(e,r,this.m_rA,z.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),m=j.MulMV(this.m_linearMass,d,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),y=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(m);var g=u*this.m_maxForce;this.m_linearImpulse.LengthSquared()>g*g&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(g)),z.SubVV(this.m_linearImpulse,y,m),e.SelfMulSub(a,m),r-=l*z.CrossVV(this.m_rA,m),n.SelfMulAdd(o,m),s+=h*z.CrossVV(this.m_rB,m),t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(){return!0},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*this.m_linearImpulse.x,e.y=t*this.m_linearImpulse.y,e},r.GetReactionTorque=function(t){return t*this.m_angularImpulse},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.SetMaxForce=function(t){this.m_maxForce=t},r.GetMaxForce=function(){return this.m_maxForce},r.SetMaxTorque=function(t){this.m_maxTorque=t},r.GetMaxTorque=function(){return this.m_maxTorque},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);Vi.SolveVelocityConstraints_s_Cdot_v2=new z,Vi.SolveVelocityConstraints_s_impulseV=new z,Vi.SolveVelocityConstraints_s_oldImpulseV=new z;var ki=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_gearJoint)||this).ratio=1,i}return Me(i,e),i}(Mi),Ni=function(i){function r(r){var n,s,a;(n=i.call(this,r)||this).m_typeA=t.b2JointType.e_unknownJoint,n.m_typeB=t.b2JointType.e_unknownJoint,n.m_localAnchorA=new z,n.m_localAnchorB=new z,n.m_localAnchorC=new z,n.m_localAnchorD=new z,n.m_localAxisC=new z,n.m_localAxisD=new z,n.m_referenceAngleA=0,n.m_referenceAngleB=0,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_indexC=0,n.m_indexD=0,n.m_lcA=new z,n.m_lcB=new z,n.m_lcC=new z,n.m_lcD=new z,n.m_mA=0,n.m_mB=0,n.m_mC=0,n.m_mD=0,n.m_iA=0,n.m_iB=0,n.m_iC=0,n.m_iD=0,n.m_JvAC=new z,n.m_JvBD=new z,n.m_JwA=0,n.m_JwB=0,n.m_JwC=0,n.m_JwD=0,n.m_mass=0,n.m_qA=new X,n.m_qB=new X,n.m_qC=new X,n.m_qD=new X,n.m_lalcA=new z,n.m_lalcB=new z,n.m_lalcC=new z,n.m_lalcD=new z,n.m_joint1=r.joint1,n.m_joint2=r.joint2,n.m_typeA=n.m_joint1.GetType(),n.m_typeB=n.m_joint2.GetType(),n.m_bodyC=n.m_joint1.GetBodyA(),n.m_bodyA=n.m_joint1.GetBodyB();var o=n.m_bodyA.m_xf,l=n.m_bodyA.m_sweep.a,h=n.m_bodyC.m_xf,u=n.m_bodyC.m_sweep.a;if(n.m_typeA===t.b2JointType.e_revoluteJoint){var c=r.joint1;n.m_localAnchorC.Copy(c.m_localAnchorA),n.m_localAnchorA.Copy(c.m_localAnchorB),n.m_referenceAngleA=c.m_referenceAngle,n.m_localAxisC.SetZero(),s=l-u-n.m_referenceAngleA}else{var _=r.joint1;n.m_localAnchorC.Copy(_.m_localAnchorA),n.m_localAnchorA.Copy(_.m_localAnchorB),n.m_referenceAngleA=_.m_referenceAngle,n.m_localAxisC.Copy(_.m_localXAxisA);var f=n.m_localAnchorC,p=X.MulTRV(h.q,z.AddVV(X.MulRV(o.q,n.m_localAnchorA,z.s_t0),z.SubVV(o.p,h.p,z.s_t1),z.s_t0),z.s_t0);s=z.DotVV(z.SubVV(p,f,z.s_t0),n.m_localAxisC)}n.m_bodyD=n.m_joint2.GetBodyA(),n.m_bodyB=n.m_joint2.GetBodyB();var d=n.m_bodyB.m_xf,m=n.m_bodyB.m_sweep.a,y=n.m_bodyD.m_xf,g=n.m_bodyD.m_sweep.a;if(n.m_typeB===t.b2JointType.e_revoluteJoint){var v=r.joint2;n.m_localAnchorD.Copy(v.m_localAnchorA),n.m_localAnchorB.Copy(v.m_localAnchorB),n.m_referenceAngleB=v.m_referenceAngle,n.m_localAxisD.SetZero(),a=m-g-n.m_referenceAngleB}else{var b=r.joint2;n.m_localAnchorD.Copy(b.m_localAnchorA),n.m_localAnchorB.Copy(b.m_localAnchorB),n.m_referenceAngleB=b.m_referenceAngle,n.m_localAxisD.Copy(b.m_localXAxisA);var S=n.m_localAnchorD,A=X.MulTRV(y.q,z.AddVV(X.MulRV(d.q,n.m_localAnchorB,z.s_t0),z.SubVV(d.p,y.p,z.s_t1),z.s_t0),z.s_t0);a=z.DotVV(z.SubVV(A,S,z.s_t0),n.m_localAxisD)}return n.m_ratio=e(r.ratio,1),n.m_constant=s+n.m_ratio*a,n.m_impulse=0,n}Me(r,i);var n=r.prototype;return n.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var i=e.positions[this.m_indexA].a,n=e.velocities[this.m_indexA].v,s=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].a,o=e.velocities[this.m_indexB].v,l=e.velocities[this.m_indexB].w,h=e.positions[this.m_indexC].a,u=e.velocities[this.m_indexC].v,c=e.velocities[this.m_indexC].w,_=e.positions[this.m_indexD].a,f=e.velocities[this.m_indexD].v,p=e.velocities[this.m_indexD].w,d=this.m_qA.SetAngle(i),m=this.m_qB.SetAngle(a),y=this.m_qC.SetAngle(h),g=this.m_qD.SetAngle(_);if(this.m_mass=0,this.m_typeA===t.b2JointType.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var v=X.MulRV(y,this.m_localAxisC,r.InitVelocityConstraints_s_u);z.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var b=X.MulRV(y,this.m_lalcC,r.InitVelocityConstraints_s_rC);z.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var S=X.MulRV(d,this.m_lalcA,r.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(v),this.m_JwC=z.CrossVV(b,v),this.m_JwA=z.CrossVV(S,v),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB===t.b2JointType.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{var A=X.MulRV(g,this.m_localAxisD,r.InitVelocityConstraints_s_u);z.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var C=X.MulRV(g,this.m_lalcD,r.InitVelocityConstraints_s_rD);z.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var x=X.MulRV(m,this.m_lalcB,r.InitVelocityConstraints_s_rB);z.MulSV(this.m_ratio,A,this.m_JvBD),this.m_JwD=this.m_ratio*z.CrossVV(C,A),this.m_JwB=this.m_ratio*z.CrossVV(x,A),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,e.step.warmStarting?(n.SelfMulAdd(this.m_mA*this.m_impulse,this.m_JvAC),s+=this.m_iA*this.m_impulse*this.m_JwA,o.SelfMulAdd(this.m_mB*this.m_impulse,this.m_JvBD),l+=this.m_iB*this.m_impulse*this.m_JwB,u.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),c-=this.m_iC*this.m_impulse*this.m_JwC,f.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),p-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=l,e.velocities[this.m_indexC].w=c,e.velocities[this.m_indexD].w=p},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,s=t.velocities[this.m_indexC].v,a=t.velocities[this.m_indexC].w,o=t.velocities[this.m_indexD].v,l=t.velocities[this.m_indexD].w,h=z.DotVV(this.m_JvAC,z.SubVV(e,s,z.s_t0))+z.DotVV(this.m_JvBD,z.SubVV(r,o,z.s_t0));h+=this.m_JwA*i-this.m_JwC*a+(this.m_JwB*n-this.m_JwD*l);var u=-this.m_mass*h;this.m_impulse+=u,e.SelfMulAdd(this.m_mA*u,this.m_JvAC),i+=this.m_iA*u*this.m_JwA,r.SelfMulAdd(this.m_mB*u,this.m_JvBD),n+=this.m_iB*u*this.m_JwB,s.SelfMulSub(this.m_mC*u,this.m_JvAC),a-=this.m_iC*u*this.m_JwC,o.SelfMulSub(this.m_mD*u,this.m_JvBD),l-=this.m_iD*u*this.m_JwD,t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=n,t.velocities[this.m_indexC].w=a,t.velocities[this.m_indexD].w=l},n.SolvePositionConstraints=function(e){var i,n,s,a,o,l,h=e.positions[this.m_indexA].c,u=e.positions[this.m_indexA].a,c=e.positions[this.m_indexB].c,_=e.positions[this.m_indexB].a,f=e.positions[this.m_indexC].c,p=e.positions[this.m_indexC].a,d=e.positions[this.m_indexD].c,m=e.positions[this.m_indexD].a,y=this.m_qA.SetAngle(u),g=this.m_qB.SetAngle(_),v=this.m_qC.SetAngle(p),b=this.m_qD.SetAngle(m),S=this.m_JvAC,A=this.m_JvBD,C=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)S.SetZero(),s=1,o=1,C+=this.m_iA+this.m_iC,i=u-p-this.m_referenceAngleA;else{var x=X.MulRV(v,this.m_localAxisC,r.SolvePositionConstraints_s_u),T=X.MulRV(v,this.m_lalcC,r.SolvePositionConstraints_s_rC),w=X.MulRV(y,this.m_lalcA,r.SolvePositionConstraints_s_rA);S.Copy(x),o=z.CrossVV(T,x),s=z.CrossVV(w,x),C+=this.m_mC+this.m_mA+this.m_iC*o*o+this.m_iA*s*s;var E=this.m_lalcC,B=X.MulTRV(v,z.AddVV(w,z.SubVV(h,f,z.s_t0),z.s_t0),z.s_t0);i=z.DotVV(z.SubVV(B,E,z.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)A.SetZero(),a=this.m_ratio,l=this.m_ratio,C+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),n=_-m-this.m_referenceAngleB;else{var D=X.MulRV(b,this.m_localAxisD,r.SolvePositionConstraints_s_u),M=X.MulRV(b,this.m_lalcD,r.SolvePositionConstraints_s_rD),P=X.MulRV(g,this.m_lalcB,r.SolvePositionConstraints_s_rB);z.MulSV(this.m_ratio,D,A),l=this.m_ratio*z.CrossVV(M,D),a=this.m_ratio*z.CrossVV(P,D),C+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*l*l+this.m_iB*a*a;var R=this.m_lalcD,I=X.MulTRV(b,z.AddVV(P,z.SubVV(c,d,z.s_t0),z.s_t0),z.s_t0);n=z.DotVV(z.SubVV(I,R,z.s_t0),this.m_localAxisD)}var O=i+this.m_ratio*n-this.m_constant,F=0;return C>0&&(F=-O/C),h.SelfMulAdd(this.m_mA*F,S),u+=this.m_iA*F*s,c.SelfMulAdd(this.m_mB*F,A),_+=this.m_iB*F*a,f.SelfMulSub(this.m_mC*F,S),p-=this.m_iC*F*o,d.SelfMulSub(this.m_mD*F,A),m-=this.m_iD*F*l,e.positions[this.m_indexA].a=u,e.positions[this.m_indexB].a=_,e.positions[this.m_indexC].a=p,e.positions[this.m_indexD].a=m,!0},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return z.MulSV(t*this.m_impulse,this.m_JvAC,e)},n.GetReactionTorque=function(t){return t*this.m_impulse*this.m_JwA},n.GetJoint1=function(){return this.m_joint1},n.GetJoint2=function(){return this.m_joint2},n.GetRatio=function(){return this.m_ratio},n.SetRatio=function(t){this.m_ratio=t},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex,r=this.m_joint1.m_index,n=this.m_joint2.m_index;t(" const jd: b2GearJointDef = new b2GearJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.joint1 = joints[%d];\n",r),t(" jd.joint2 = joints[%d];\n",n),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},r}(Pi);Ni.InitVelocityConstraints_s_u=new z,Ni.InitVelocityConstraints_s_rA=new z,Ni.InitVelocityConstraints_s_rB=new z,Ni.InitVelocityConstraints_s_rC=new z,Ni.InitVelocityConstraints_s_rD=new z,Ni.SolvePositionConstraints_s_u=new z,Ni.SolvePositionConstraints_s_rA=new z,Ni.SolvePositionConstraints_s_rB=new z,Ni.SolvePositionConstraints_s_rC=new z,Ni.SolvePositionConstraints_s_rD=new z;var Gi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_motorJoint)||this).linearOffset=new z(0,0),i.angularOffset=0,i.maxForce=1,i.maxTorque=1,i.correctionFactor=.3,i}return Me(i,e),i.prototype.Initialize=function(t,e){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(this.bodyB.GetPosition(),this.linearOffset);var i=this.bodyA.GetAngle(),r=this.bodyB.GetAngle();this.angularOffset=r-i},i}(Mi),zi=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_linearOffset=new z,r.m_angularOffset=0,r.m_linearImpulse=new z,r.m_angularImpulse=0,r.m_maxForce=0,r.m_maxTorque=0,r.m_correctionFactor=.3,r.m_indexA=0,r.m_indexB=0,r.m_rA=new z,r.m_rB=new z,r.m_localCenterA=new z,r.m_localCenterB=new z,r.m_linearError=new z,r.m_angularError=0,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_linearMass=new j,r.m_angularMass=0,r.m_qA=new X,r.m_qB=new X,r.m_K=new j,r.m_linearOffset.Copy(e(i.linearOffset,z.ZERO)),r.m_linearImpulse.SetZero(),r.m_maxForce=e(i.maxForce,0),r.m_maxTorque=e(i.maxTorque,0),r.m_correctionFactor=e(i.correctionFactor,.3),r}Me(i,t);var r=i.prototype;return r.GetAnchorA=function(t){var e=this.m_bodyA.GetPosition();return t.x=e.x,t.y=e.y,t},r.GetAnchorB=function(t){var e=this.m_bodyB.GetPosition();return t.x=e.x,t.y=e.y,t},r.GetReactionForce=function(t,e){return z.MulSV(t,this.m_linearImpulse,e)},r.GetReactionTorque=function(t){return t*this.m_angularImpulse},r.SetLinearOffset=function(t){z.IsEqualToV(t,this.m_linearOffset)||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Copy(t))},r.GetLinearOffset=function(){return this.m_linearOffset},r.SetAngularOffset=function(t){t!==this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=t)},r.GetAngularOffset=function(){return this.m_angularOffset},r.SetMaxForce=function(t){this.m_maxForce=t},r.GetMaxForce=function(){return this.m_maxForce},r.SetMaxTorque=function(t){this.m_maxTorque=t},r.GetMaxTorque=function(){return this.m_maxTorque},r.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].c,a=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,h=this.m_qA.SetAngle(i),u=this.m_qB.SetAngle(a),c=X.MulRV(h,z.SubVV(this.m_linearOffset,this.m_localCenterA,z.s_t0),this.m_rA),_=X.MulRV(u,z.NegV(this.m_localCenterB,z.s_t0),this.m_rB),f=this.m_invMassA,p=this.m_invMassB,d=this.m_invIA,m=this.m_invIB,y=this.m_K;if(y.ex.x=f+p+d*c.y*c.y+m*_.y*_.y,y.ex.y=-d*c.x*c.y-m*_.x*_.y,y.ey.x=y.ex.y,y.ey.y=f+p+d*c.x*c.x+m*_.x*_.x,y.GetInverse(this.m_linearMass),this.m_angularMass=d+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),z.SubVV(z.AddVV(s,_,z.s_t0),z.AddVV(e,c,z.s_t1),this.m_linearError),this.m_angularError=a-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var g=this.m_linearImpulse;r.SelfMulSub(f,g),n-=d*(z.CrossVV(c,g)+this.m_angularImpulse),o.SelfMulAdd(p,g),l+=m*(z.CrossVV(_,g)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=l},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=this.m_invMassA,o=this.m_invMassB,l=this.m_invIA,h=this.m_invIB,u=t.step.dt,c=t.step.inv_dt,_=s-r+c*this.m_correctionFactor*this.m_angularError,f=-this.m_angularMass*_,p=this.m_angularImpulse,d=u*this.m_maxTorque;this.m_angularImpulse=M(this.m_angularImpulse+f,-d,d),r-=l*(f=this.m_angularImpulse-p),s+=h*f;var m=this.m_rA,y=this.m_rB,g=z.AddVV(z.SubVV(z.AddVV(n,z.CrossSV(s,y,z.s_t0),z.s_t0),z.AddVV(e,z.CrossSV(r,m,z.s_t1),z.s_t1),z.s_t2),z.MulSV(c*this.m_correctionFactor,this.m_linearError,z.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),v=j.MulMV(this.m_linearMass,g,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),b=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(v);var S=u*this.m_maxForce;this.m_linearImpulse.LengthSquared()>S*S&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(S)),z.SubVV(this.m_linearImpulse,b,v),e.SelfMulSub(a,v),r-=l*z.CrossVV(m,v),n.SelfMulAdd(o,v),s+=h*z.CrossVV(y,v),t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(){return!0},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y),t(" jd.angularOffset = %.15f;\n",this.m_angularOffset),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" jd.correctionFactor = %.15f;\n",this.m_correctionFactor),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);zi.SolveVelocityConstraints_s_Cdot_v2=new z,zi.SolveVelocityConstraints_s_impulse_v2=new z,zi.SolveVelocityConstraints_s_oldImpulse_v2=new z;var Ui=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_mouseJoint)||this).target=new z,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return Me(i,e),i}(Mi),Hi=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_localAnchorB=new z,r.m_targetA=new z,r.m_frequencyHz=0,r.m_dampingRatio=0,r.m_beta=0,r.m_impulse=new z,r.m_maxForce=0,r.m_gamma=0,r.m_indexA=0,r.m_indexB=0,r.m_rB=new z,r.m_localCenterB=new z,r.m_invMassB=0,r.m_invIB=0,r.m_mass=new j,r.m_C=new z,r.m_qB=new X,r.m_lalcB=new z,r.m_K=new j,r.m_targetA.Copy(e(i.target,z.ZERO)),Y.MulTXV(r.m_bodyB.GetTransform(),r.m_targetA,r.m_localAnchorB),r.m_maxForce=e(i.maxForce,0),r.m_impulse.SetZero(),r.m_frequencyHz=e(i.frequencyHz,0),r.m_dampingRatio=e(i.dampingRatio,0),r.m_beta=0,r.m_gamma=0,r}Me(i,t);var r=i.prototype;return r.SetTarget=function(t){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0),this.m_targetA.Copy(t)},r.GetTarget=function(){return this.m_targetA},r.SetMaxForce=function(t){this.m_maxForce=t},r.GetMaxForce=function(){return this.m_maxForce},r.SetFrequency=function(t){this.m_frequencyHz=t},r.GetFrequency=function(){return this.m_frequencyHz},r.SetDampingRatio=function(t){this.m_dampingRatio=t},r.GetDampingRatio=function(){return this.m_dampingRatio},r.InitVelocityConstraints=function(t){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexB].c,i=t.positions[this.m_indexB].a,r=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,a=this.m_qB.SetAngle(i),o=this.m_bodyB.GetMass(),l=2*s*this.m_frequencyHz,h=2*o*this.m_dampingRatio*l,u=o*l*l,c=t.step.dt;this.m_gamma=c*(h+c*u),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=c*u*this.m_gamma,z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),X.MulRV(a,this.m_lalcB,this.m_rB);var _=this.m_K;_.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,_.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,_.ey.x=_.ex.y,_.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,_.GetInverse(this.m_mass),this.m_C.x=e.x+this.m_rB.x-this.m_targetA.x,this.m_C.y=e.y+this.m_rB.y-this.m_targetA.y,this.m_C.SelfMul(this.m_beta),n*=.98,t.step.warmStarting?(this.m_impulse.SelfMul(t.step.dtRatio),r.x+=this.m_invMassB*this.m_impulse.x,r.y+=this.m_invMassB*this.m_impulse.y,n+=this.m_invIB*z.CrossVV(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),t.velocities[this.m_indexB].w=n},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,n=z.AddVCrossSV(e,r,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=j.MulMV(this.m_mass,z.AddVV(n,z.AddVV(this.m_C,z.MulSV(this.m_gamma,this.m_impulse,z.s_t0),z.s_t0),z.s_t0).SelfNeg(),i.SolveVelocityConstraints_s_impulse),a=i.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);this.m_impulse.SelfAdd(s);var o=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>o*o&&this.m_impulse.SelfMul(o/this.m_impulse.Length()),z.SubVV(this.m_impulse,a,s),e.SelfMulAdd(this.m_invMassB,s),r+=this.m_invIB*z.CrossVV(this.m_rB,s),t.velocities[this.m_indexB].w=r},r.SolvePositionConstraints=function(){return!0},r.GetAnchorA=function(t){return t.x=this.m_targetA.x,t.y=this.m_targetA.y,t},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return z.MulSV(t,this.m_impulse,e)},r.GetReactionTorque=function(){return 0},r.Dump=function(t){t("Mouse joint dumping is not supported.\n")},r.ShiftOrigin=function(t){this.m_targetA.SelfSub(t)},i}(Pi);Hi.SolveVelocityConstraints_s_Cdot=new z,Hi.SolveVelocityConstraints_s_impulse=new z,Hi.SolveVelocityConstraints_s_oldImpulse=new z;var ji=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_prismaticJoint)||this).localAnchorA=new z,i.localAnchorB=new z,i.localAxisA=new z(1,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerTranslation=0,i.upperTranslation=0,i.enableMotor=!1,i.maxMotorForce=0,i.motorSpeed=0,i}return Me(i,e),i.prototype.Initialize=function(t,e,i,r){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(r,this.localAxisA),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Mi),Wi=function(i){function r(r){var n;return(n=i.call(this,r)||this).m_localAnchorA=new z,n.m_localAnchorB=new z,n.m_localXAxisA=new z,n.m_localYAxisA=new z,n.m_referenceAngle=0,n.m_impulse=new H(0,0,0),n.m_motorImpulse=0,n.m_lowerTranslation=0,n.m_upperTranslation=0,n.m_maxMotorForce=0,n.m_motorSpeed=0,n.m_enableLimit=!1,n.m_enableMotor=!1,n.m_limitState=t.b2LimitState.e_inactiveLimit,n.m_indexA=0,n.m_indexB=0,n.m_localCenterA=new z,n.m_localCenterB=new z,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_axis=new z(0,0),n.m_perp=new z(0,0),n.m_s1=0,n.m_s2=0,n.m_a1=0,n.m_a2=0,n.m_K=new W,n.m_K3=new W,n.m_K2=new j,n.m_motorMass=0,n.m_qA=new X,n.m_qB=new X,n.m_lalcA=new z,n.m_lalcB=new z,n.m_rA=new z,n.m_rB=new z,n.m_localAnchorA.Copy(e(r.localAnchorA,z.ZERO)),n.m_localAnchorB.Copy(e(r.localAnchorB,z.ZERO)),n.m_localXAxisA.Copy(e(r.localAxisA,new z(1,0))).SelfNormalize(),z.CrossOneV(n.m_localXAxisA,n.m_localYAxisA),n.m_referenceAngle=e(r.referenceAngle,0),n.m_lowerTranslation=e(r.lowerTranslation,0),n.m_upperTranslation=e(r.upperTranslation,0),n.m_maxMotorForce=e(r.maxMotorForce,0),n.m_motorSpeed=e(r.motorSpeed,0),n.m_enableLimit=e(r.enableLimit,!1),n.m_enableMotor=e(r.enableMotor,!1),n}Me(r,i);var n=r.prototype;return n.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,n=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,a=e.velocities[this.m_indexA].w,o=e.positions[this.m_indexB].c,l=e.positions[this.m_indexB].a,h=e.velocities[this.m_indexB].v,u=e.velocities[this.m_indexB].w,c=this.m_qA.SetAngle(n),_=this.m_qB.SetAngle(l);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var f=X.MulRV(c,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p=X.MulRV(_,this.m_lalcB,this.m_rB),d=z.AddVV(z.SubVV(o,i,z.s_t0),z.SubVV(p,f,z.s_t1),r.InitVelocityConstraints_s_d),m=this.m_invMassA,y=this.m_invMassB,g=this.m_invIA,v=this.m_invIB;if(X.MulRV(c,this.m_localXAxisA,this.m_axis),this.m_a1=z.CrossVV(z.AddVV(d,f,z.s_t0),this.m_axis),this.m_a2=z.CrossVV(p,this.m_axis),this.m_motorMass=m+y+g*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),X.MulRV(c,this.m_localYAxisA,this.m_perp),this.m_s1=z.CrossVV(z.AddVV(d,f,z.s_t0),this.m_perp),this.m_s2=z.CrossVV(p,this.m_perp),this.m_K.ex.x=m+y+g*this.m_s1*this.m_s1+v*this.m_s2*this.m_s2,this.m_K.ex.y=g*this.m_s1+v*this.m_s2,this.m_K.ex.z=g*this.m_s1*this.m_a1+v*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=g+v,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=g*this.m_a1+v*this.m_a2,this.m_K.ez.x=this.m_K.ex.z,this.m_K.ez.y=this.m_K.ey.z,this.m_K.ez.z=m+y+g*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_enableLimit){var b=z.DotVV(this.m_axis,d);E(this.m_upperTranslation-this.m_lowerTranslation)<.016?this.m_limitState=t.b2LimitState.e_equalLimits:b<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):b>=this.m_upperTranslation?this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_limitState=t.b2LimitState.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0;if(this.m_enableMotor||(this.m_motorImpulse=0),e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var S=z.AddVV(z.MulSV(this.m_impulse.x,this.m_perp,z.s_t0),z.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,z.s_t1),r.InitVelocityConstraints_s_P),A=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,C=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;s.SelfMulSub(m,S),a-=g*A,h.SelfMulAdd(y,S),u+=v*C}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=a,e.velocities[this.m_indexB].w=u},n.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,n=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,a=e.velocities[this.m_indexB].w,o=this.m_invMassA,l=this.m_invMassB,h=this.m_invIA,u=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var c=z.DotVV(this.m_axis,z.SubVV(s,i,z.s_t0))+this.m_a2*a-this.m_a1*n,_=this.m_motorMass*(this.m_motorSpeed-c),f=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=M(this.m_motorImpulse+_,-p,p),_=this.m_motorImpulse-f;var d=z.MulSV(_,this.m_axis,r.SolveVelocityConstraints_s_P),m=_*this.m_a1,y=_*this.m_a2;i.SelfMulSub(o,d),n-=h*m,s.SelfMulAdd(l,d),a+=u*y}var g=z.DotVV(this.m_perp,z.SubVV(s,i,z.s_t0))+this.m_s2*a-this.m_s1*n,v=a-n;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var b=z.DotVV(this.m_axis,z.SubVV(s,i,z.s_t0))+this.m_a2*a-this.m_a1*n,S=r.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),A=this.m_K.Solve33(-g,-v,-b,r.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(A),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=D(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=B(this.m_impulse.z,0));var C=-g-(this.m_impulse.z-S.z)*this.m_K.ez.x,x=-v-(this.m_impulse.z-S.z)*this.m_K.ez.y,T=this.m_K.Solve22(C,x,r.SolveVelocityConstraints_s_f2r);T.x+=S.x,T.y+=S.y,this.m_impulse.x=T.x,this.m_impulse.y=T.y,A.x=this.m_impulse.x-S.x,A.y=this.m_impulse.y-S.y,A.z=this.m_impulse.z-S.z;var w=z.AddVV(z.MulSV(A.x,this.m_perp,z.s_t0),z.MulSV(A.z,this.m_axis,z.s_t1),r.SolveVelocityConstraints_s_P),E=A.x*this.m_s1+A.y+A.z*this.m_a1,P=A.x*this.m_s2+A.y+A.z*this.m_a2;i.SelfMulSub(o,w),n-=h*E,s.SelfMulAdd(l,w),a+=u*P}else{var R=this.m_K.Solve22(-g,-v,r.SolveVelocityConstraints_s_df2);this.m_impulse.x+=R.x,this.m_impulse.y+=R.y;var I=z.MulSV(R.x,this.m_perp,r.SolveVelocityConstraints_s_P),O=R.x*this.m_s1+R.y,F=R.x*this.m_s2+R.y;i.SelfMulSub(o,I),n-=h*O,s.SelfMulAdd(l,I),a+=u*F}e.velocities[this.m_indexA].w=n,e.velocities[this.m_indexB].w=a},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(i),h=this.m_qB.SetAngle(s),c=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,p=this.m_invIB,d=X.MulRV(a,this.m_lalcA,this.m_rA),m=X.MulRV(h,this.m_lalcB,this.m_rB),y=z.SubVV(z.AddVV(n,m,z.s_t0),z.AddVV(e,d,z.s_t1),r.SolvePositionConstraints_s_d),g=X.MulRV(a,this.m_localXAxisA,this.m_axis),v=z.CrossVV(z.AddVV(y,d,z.s_t0),g),b=z.CrossVV(m,g),S=X.MulRV(a,this.m_localYAxisA,this.m_perp),A=z.CrossVV(z.AddVV(y,d,z.s_t0),S),C=z.CrossVV(m,S),x=r.SolvePositionConstraints_s_impulse,T=z.DotVV(S,y),w=s-i-this.m_referenceAngle,B=E(T),P=E(w),R=!1,I=0;if(this.m_enableLimit){var O=z.DotVV(g,y);E(this.m_upperTranslation-this.m_lowerTranslation)<.016?(I=M(O,-.2,u),B=D(B,E(O)),R=!0):O<=this.m_lowerTranslation?(I=M(O-this.m_lowerTranslation+o,-.2,0),B=D(B,this.m_lowerTranslation-O),R=!0):O>=this.m_upperTranslation&&(I=M(O-this.m_upperTranslation-o,0,u),B=D(B,O-this.m_upperTranslation),R=!0)}if(R){var F=c+_+f*A*A+p*C*C,L=f*A+p*C,V=f*A*v+p*C*b,k=f+p;0===k&&(k=1);var N=f*v+p*b,G=c+_+f*v*v+p*b*b,U=this.m_K3;U.ex.SetXYZ(F,L,V),U.ey.SetXYZ(L,k,N),U.ez.SetXYZ(V,N,G),x=U.Solve33(-T,-w,-I,x)}else{var H=c+_+f*A*A+p*C*C,j=f*A+p*C,W=f+p;0===W&&(W=1);var Y=this.m_K2;Y.ex.Set(H,j),Y.ey.Set(j,W);var q=Y.Solve(-T,-w,r.SolvePositionConstraints_s_impulse1);x.x=q.x,x.y=q.y,x.z=0}var J=z.AddVV(z.MulSV(x.x,S,z.s_t0),z.MulSV(x.z,g,z.s_t1),r.SolvePositionConstraints_s_P),K=x.x*A+x.y+x.z*v,Z=x.x*C+x.y+x.z*b;return e.SelfMulSub(c,J),i-=f*K,n.SelfMulAdd(_,J),s+=p*Z,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,B<=o&&P<=l},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e.y=t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y),e},n.GetReactionTorque=function(t){return t*this.m_impulse.y},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetLocalAxisA=function(){return this.m_localXAxisA},n.GetReferenceAngle=function(){return this.m_referenceAngle},n.GetJointTranslation=function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,r.GetJointTranslation_s_pA),e=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,r.GetJointTranslation_s_pB),i=z.SubVV(e,t,r.GetJointTranslation_s_d),n=this.m_bodyA.GetWorldVector(this.m_localXAxisA,r.GetJointTranslation_s_axis);return z.DotVV(i,n)},n.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;z.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=X.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var r=X.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),n=z.AddVV(t.m_sweep.c,i,z.s_t0),s=z.AddVV(e.m_sweep.c,r,z.s_t1),a=z.SubVV(s,n,z.s_t2),o=t.GetWorldVector(this.m_localXAxisA,this.m_axis),l=t.m_linearVelocity,h=e.m_linearVelocity,u=t.m_angularVelocity,c=e.m_angularVelocity;return z.DotVV(a,z.CrossSV(u,o,z.s_t0))+z.DotVV(o,z.SubVV(z.AddVCrossSV(h,c,r,z.s_t0),z.AddVCrossSV(l,u,i,z.s_t1),z.s_t0))},n.IsLimitEnabled=function(){return this.m_enableLimit},n.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},n.GetLowerLimit=function(){return this.m_lowerTranslation},n.GetUpperLimit=function(){return this.m_upperTranslation},n.SetLimits=function(t,e){t===this.m_lowerTranslation&&e===this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=e,this.m_impulse.z=0)},n.IsMotorEnabled=function(){return this.m_enableMotor},n.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.GetMotorSpeed=function(){return this.m_motorSpeed},n.SetMaxMotorForce=function(t){t!==this.m_maxMotorForce&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t)},n.GetMaxMotorForce=function(){return this.m_maxMotorForce},n.GetMotorForce=function(t){return t*this.m_motorImpulse},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation),t(" jd.upperTranslation = %.15f;\n",this.m_upperTranslation),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},r}(Pi);Wi.InitVelocityConstraints_s_d=new z,Wi.InitVelocityConstraints_s_P=new z,Wi.SolveVelocityConstraints_s_P=new z,Wi.SolveVelocityConstraints_s_f2r=new z,Wi.SolveVelocityConstraints_s_f1=new H,Wi.SolveVelocityConstraints_s_df3=new H,Wi.SolveVelocityConstraints_s_df2=new z,Wi.SolvePositionConstraints_s_d=new z,Wi.SolvePositionConstraints_s_impulse=new H,Wi.SolvePositionConstraints_s_impulse1=new z,Wi.SolvePositionConstraints_s_P=new z,Wi.GetJointTranslation_s_pA=new z,Wi.GetJointTranslation_s_pB=new z,Wi.GetJointTranslation_s_d=new z,Wi.GetJointTranslation_s_axis=new z;var Xi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_pulleyJoint)||this).groundAnchorA=new z(-1,1),i.groundAnchorB=new z(1,1),i.localAnchorA=new z(-1,0),i.localAnchorB=new z(1,0),i.lengthA=0,i.lengthB=0,i.ratio=1,i.collideConnected=!0,i}return Me(i,e),i.prototype.Initialize=function(t,e,i,r,n,s,a){this.bodyA=t,this.bodyB=e,this.groundAnchorA.Copy(i),this.groundAnchorB.Copy(r),this.bodyA.GetLocalPoint(n,this.localAnchorA),this.bodyB.GetLocalPoint(s,this.localAnchorB),this.lengthA=z.DistanceVV(n,i),this.lengthB=z.DistanceVV(s,r),this.ratio=a},i}(Mi),Yi=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_groundAnchorA=new z,r.m_groundAnchorB=new z,r.m_lengthA=0,r.m_lengthB=0,r.m_localAnchorA=new z,r.m_localAnchorB=new z,r.m_constant=0,r.m_ratio=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_uA=new z,r.m_uB=new z,r.m_rA=new z,r.m_rB=new z,r.m_localCenterA=new z,r.m_localCenterB=new z,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=0,r.m_qA=new X,r.m_qB=new X,r.m_lalcA=new z,r.m_lalcB=new z,r.m_groundAnchorA.Copy(e(i.groundAnchorA,new z(-1,1))),r.m_groundAnchorB.Copy(e(i.groundAnchorB,new z(1,0))),r.m_localAnchorA.Copy(e(i.localAnchorA,new z(-1,0))),r.m_localAnchorB.Copy(e(i.localAnchorB,new z(1,0))),r.m_lengthA=e(i.lengthA,0),r.m_lengthB=e(i.lengthB,0),r.m_ratio=e(i.ratio,1),r.m_constant=e(i.lengthA,0)+r.m_ratio*e(i.lengthB,0),r.m_impulse=0,r}Me(i,t);var r=i.prototype;return r.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,r=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,l=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(r),c=this.m_qB.SetAngle(o);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),X.MulRV(u,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),X.MulRV(c,this.m_lalcB,this.m_rB),this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA),this.m_uB.Copy(a).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);var _=this.m_uA.Length(),f=this.m_uB.Length();_>.08?this.m_uA.SelfMul(1/_):this.m_uA.SetZero(),f>.08?this.m_uB.SelfMul(1/f):this.m_uB.SetZero();var p=z.CrossVV(this.m_rA,this.m_uA),d=z.CrossVV(this.m_rB,this.m_uB),m=this.m_invMassA+this.m_invIA*p*p,y=this.m_invMassB+this.m_invIB*d*d;if(this.m_mass=m+this.m_ratio*this.m_ratio*y,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var g=z.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),v=z.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);n.SelfMulAdd(this.m_invMassA,g),s+=this.m_invIA*z.CrossVV(this.m_rA,g),l.SelfMulAdd(this.m_invMassB,v),h+=this.m_invIB*z.CrossVV(this.m_rB,v)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=h},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=z.AddVCrossSV(e,r,this.m_rA,i.SolveVelocityConstraints_s_vpA),o=z.AddVCrossSV(n,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),l=-z.DotVV(this.m_uA,a)-this.m_ratio*z.DotVV(this.m_uB,o),h=-this.m_mass*l;this.m_impulse+=h;var u=z.MulSV(-h,this.m_uA,i.SolveVelocityConstraints_s_PA),c=z.MulSV(-this.m_ratio*h,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,u),r+=this.m_invIA*z.CrossVV(this.m_rA,u),n.SelfMulAdd(this.m_invMassB,c),s+=this.m_invIB*z.CrossVV(this.m_rB,c),t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,r=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(r),l=this.m_qB.SetAngle(s);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=X.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=X.MulRV(l,this.m_lalcB,this.m_rB),c=this.m_uA.Copy(e).SelfAdd(h).SelfSub(this.m_groundAnchorA),_=this.m_uB.Copy(n).SelfAdd(u).SelfSub(this.m_groundAnchorB),f=c.Length(),p=_.Length();f>.08?c.SelfMul(1/f):c.SetZero(),p>.08?_.SelfMul(1/p):_.SetZero();var d=z.CrossVV(h,c),m=z.CrossVV(u,_),y=this.m_invMassA+this.m_invIA*d*d,g=this.m_invMassB+this.m_invIB*m*m,v=y+this.m_ratio*this.m_ratio*g;v>0&&(v=1/v);var b=this.m_constant-f-this.m_ratio*p,S=E(b),A=-v*b,C=z.MulSV(-A,c,i.SolvePositionConstraints_s_PA),x=z.MulSV(-this.m_ratio*A,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,C),r+=this.m_invIA*z.CrossVV(h,C),n.SelfMulAdd(this.m_invMassB,x),s+=this.m_invIB*z.CrossVV(u,x),t.positions[this.m_indexA].a=r,t.positions[this.m_indexB].a=s,S<o},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_uB.x,e.y=t*this.m_impulse*this.m_uB.y,e},r.GetReactionTorque=function(){return 0},r.GetGroundAnchorA=function(){return this.m_groundAnchorA},r.GetGroundAnchorB=function(){return this.m_groundAnchorB},r.GetLengthA=function(){return this.m_lengthA},r.GetLengthB=function(){return this.m_lengthB},r.GetRatio=function(){return this.m_ratio},r.GetCurrentLengthA=function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,i.GetCurrentLengthA_s_p),e=this.m_groundAnchorA;return z.DistanceVV(t,e)},r.GetCurrentLengthB=function(){var t=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,i.GetCurrentLengthB_s_p),e=this.m_groundAnchorB;return z.DistanceVV(t,e)},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PulleyJointDef = new b2PulleyJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.groundAnchorA.Set(%.15f, %.15f);\n",this.m_groundAnchorA.x,this.m_groundAnchorA.y),t(" jd.groundAnchorB.Set(%.15f, %.15f);\n",this.m_groundAnchorB.x,this.m_groundAnchorB.y),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.lengthA = %.15f;\n",this.m_lengthA),t(" jd.lengthB = %.15f;\n",this.m_lengthB),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},r.ShiftOrigin=function(t){this.m_groundAnchorA.SelfSub(t),this.m_groundAnchorB.SelfSub(t)},i}(Pi);Yi.InitVelocityConstraints_s_PA=new z,Yi.InitVelocityConstraints_s_PB=new z,Yi.SolveVelocityConstraints_s_vpA=new z,Yi.SolveVelocityConstraints_s_vpB=new z,Yi.SolveVelocityConstraints_s_PA=new z,Yi.SolveVelocityConstraints_s_PB=new z,Yi.SolvePositionConstraints_s_PA=new z,Yi.SolvePositionConstraints_s_PB=new z,Yi.GetCurrentLengthA_s_p=new z,Yi.GetCurrentLengthB_s_p=new z;var qi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_revoluteJoint)||this).localAnchorA=new z(0,0),i.localAnchorB=new z(0,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerAngle=0,i.upperAngle=0,i.enableMotor=!1,i.motorSpeed=0,i.maxMotorTorque=0,i}return Me(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Mi),Ji=function(i){function r(r){var n;return(n=i.call(this,r)||this).m_localAnchorA=new z,n.m_localAnchorB=new z,n.m_impulse=new H,n.m_motorImpulse=0,n.m_enableMotor=!1,n.m_maxMotorTorque=0,n.m_motorSpeed=0,n.m_enableLimit=!1,n.m_referenceAngle=0,n.m_lowerAngle=0,n.m_upperAngle=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new z,n.m_rB=new z,n.m_localCenterA=new z,n.m_localCenterB=new z,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=new W,n.m_motorMass=0,n.m_limitState=t.b2LimitState.e_inactiveLimit,n.m_qA=new X,n.m_qB=new X,n.m_lalcA=new z,n.m_lalcB=new z,n.m_K=new j,n.m_localAnchorA.Copy(e(r.localAnchorA,z.ZERO)),n.m_localAnchorB.Copy(e(r.localAnchorB,z.ZERO)),n.m_referenceAngle=e(r.referenceAngle,0),n.m_impulse.SetZero(),n.m_motorImpulse=0,n.m_lowerAngle=e(r.lowerAngle,0),n.m_upperAngle=e(r.upperAngle,0),n.m_maxMotorTorque=e(r.maxMotorTorque,0),n.m_motorSpeed=e(r.motorSpeed,0),n.m_enableLimit=e(r.enableLimit,!1),n.m_enableMotor=e(r.enableMotor,!1),n.m_limitState=t.b2LimitState.e_inactiveLimit,n}Me(r,i);var n=r.prototype;return n.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].a,n=e.velocities[this.m_indexA].v,s=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].a,o=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(i),c=this.m_qB.SetAngle(a);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),X.MulRV(u,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),X.MulRV(c,this.m_lalcB,this.m_rB);var _=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,d=this.m_invIB,m=p+d===0;if(this.m_mass.ex.x=_+f+this.m_rA.y*this.m_rA.y*p+this.m_rB.y*this.m_rB.y*d,this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*p-this.m_rB.y*this.m_rB.x*d,this.m_mass.ez.x=-this.m_rA.y*p-this.m_rB.y*d,this.m_mass.ex.y=this.m_mass.ey.x,this.m_mass.ey.y=_+f+this.m_rA.x*this.m_rA.x*p+this.m_rB.x*this.m_rB.x*d,this.m_mass.ez.y=this.m_rA.x*p+this.m_rB.x*d,this.m_mass.ex.z=this.m_mass.ez.x,this.m_mass.ey.z=this.m_mass.ez.y,this.m_mass.ez.z=p+d,this.m_motorMass=p+d,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!m||(this.m_motorImpulse=0),this.m_enableLimit&&!m){var y=a-i-this.m_referenceAngle;E(this.m_upperAngle-this.m_lowerAngle)<2*l?this.m_limitState=t.b2LimitState.e_equalLimits:y<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):y>=this.m_upperAngle?(this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atUpperLimit):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit;if(e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var g=r.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(_,g),s-=p*(z.CrossVV(this.m_rA,g)+this.m_motorImpulse+this.m_impulse.z),o.SelfMulAdd(f,g),h+=d*(z.CrossVV(this.m_rB,g)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h},n.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,n=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,a=e.velocities[this.m_indexB].w,o=this.m_invMassA,l=this.m_invMassB,h=this.m_invIA,u=this.m_invIB,c=h+u===0;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits&&!c){var _=a-n-this.m_motorSpeed,f=-this.m_motorMass*_,p=this.m_motorImpulse,d=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=M(this.m_motorImpulse+f,-d,d),n-=h*(f=this.m_motorImpulse-p),a+=u*f}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!c){var m=z.SubVV(z.AddVCrossSV(s,a,this.m_rB,z.s_t0),z.AddVCrossSV(i,n,this.m_rA,z.s_t1),r.SolveVelocityConstraints_s_Cdot1),y=a-n,g=this.m_mass.Solve33(m.x,m.y,y,r.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(g);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+g.z<0){var v=-m.x+this.m_impulse.z*this.m_mass.ez.x,b=-m.y+this.m_impulse.z*this.m_mass.ez.y,S=this.m_mass.Solve22(v,b,r.SolveVelocityConstraints_s_reduced_v2);g.x=S.x,g.y=S.y,g.z=-this.m_impulse.z,this.m_impulse.x+=S.x,this.m_impulse.y+=S.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(g);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+g.z>0){var A=-m.x+this.m_impulse.z*this.m_mass.ez.x,C=-m.y+this.m_impulse.z*this.m_mass.ez.y,x=this.m_mass.Solve22(A,C,r.SolveVelocityConstraints_s_reduced_v2);g.x=x.x,g.y=x.y,g.z=-this.m_impulse.z,this.m_impulse.x+=x.x,this.m_impulse.y+=x.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(g);var T=r.SolveVelocityConstraints_s_P.Set(g.x,g.y);i.SelfMulSub(o,T),n-=h*(z.CrossVV(this.m_rA,T)+g.z),s.SelfMulAdd(l,T),a+=u*(z.CrossVV(this.m_rB,T)+g.z)}else{var w=z.SubVV(z.AddVCrossSV(s,a,this.m_rB,z.s_t0),z.AddVCrossSV(i,n,this.m_rA,z.s_t1),r.SolveVelocityConstraints_s_Cdot_v2),E=this.m_mass.Solve22(-w.x,-w.y,r.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=E.x,this.m_impulse.y+=E.y,i.SelfMulSub(o,E),n-=h*z.CrossVV(this.m_rA,E),s.SelfMulAdd(l,E),a+=u*z.CrossVV(this.m_rB,E)}e.velocities[this.m_indexA].w=n,e.velocities[this.m_indexB].w=a},n.SolvePositionConstraints=function(e){var i,n=e.positions[this.m_indexA].c,s=e.positions[this.m_indexA].a,a=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,u=this.m_qA.SetAngle(s),_=this.m_qB.SetAngle(h),f=0,p=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!p){var d=h-s-this.m_referenceAngle,m=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var y=M(d-this.m_lowerAngle,-.13962634015955555,c);m=-this.m_motorMass*y,f=E(y)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var g=d-this.m_lowerAngle;f=-g,g=M(g+l,-.13962634015955555,0),m=-this.m_motorMass*g}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var v=d-this.m_upperAngle;f=v,v=M(v-l,0,c),m=-this.m_motorMass*v}s-=this.m_invIA*m,h+=this.m_invIB*m}u.SetAngle(s),_.SetAngle(h),z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var b=X.MulRV(u,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var S=X.MulRV(_,this.m_lalcB,this.m_rB),A=z.SubVV(z.AddVV(a,S,z.s_t0),z.AddVV(n,b,z.s_t1),r.SolvePositionConstraints_s_C_v2);i=A.Length();var C=this.m_invMassA,x=this.m_invMassB,T=this.m_invIA,w=this.m_invIB,B=this.m_K;B.ex.x=C+x+T*b.y*b.y+w*S.y*S.y,B.ex.y=-T*b.x*b.y-w*S.x*S.y,B.ey.x=B.ex.y,B.ey.y=C+x+T*b.x*b.x+w*S.x*S.x;var D=B.Solve(A.x,A.y,r.SolvePositionConstraints_s_impulse).SelfNeg();return n.SelfMulSub(C,D),s-=T*z.CrossVV(b,D),a.SelfMulAdd(x,D),h+=w*z.CrossVV(S,D),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=h,i<=o&&f<=l},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},n.GetReactionTorque=function(t){return t*this.m_impulse.z},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetReferenceAngle=function(){return this.m_referenceAngle},n.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle},n.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity},n.IsMotorEnabled=function(){return this.m_enableMotor},n.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.GetMotorTorque=function(t){return t*this.m_motorImpulse},n.GetMotorSpeed=function(){return this.m_motorSpeed},n.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},n.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},n.IsLimitEnabled=function(){return this.m_enableLimit},n.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},n.GetLowerLimit=function(){return this.m_lowerAngle},n.GetUpperLimit=function(){return this.m_upperAngle},n.SetLimits=function(t,e){t===this.m_lowerAngle&&e===this.m_upperAngle||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=t,this.m_upperAngle=e)},n.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerAngle = %.15f;\n",this.m_lowerAngle),t(" jd.upperAngle = %.15f;\n",this.m_upperAngle),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},r}(Pi);Ji.InitVelocityConstraints_s_P=new z,Ji.SolveVelocityConstraints_s_P=new z,Ji.SolveVelocityConstraints_s_Cdot_v2=new z,Ji.SolveVelocityConstraints_s_Cdot1=new z,Ji.SolveVelocityConstraints_s_impulse_v3=new H,Ji.SolveVelocityConstraints_s_reduced_v2=new z,Ji.SolveVelocityConstraints_s_impulse_v2=new z,Ji.SolvePositionConstraints_s_C_v2=new z,Ji.SolvePositionConstraints_s_impulse=new z;var Ki=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_ropeJoint)||this).localAnchorA=new z(-1,0),i.localAnchorB=new z(1,0),i.maxLength=0,i}return Me(i,e),i}(Mi),Zi=function(i){function r(r){var n;return(n=i.call(this,r)||this).m_localAnchorA=new z,n.m_localAnchorB=new z,n.m_maxLength=0,n.m_length=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new z,n.m_rA=new z,n.m_rB=new z,n.m_localCenterA=new z,n.m_localCenterB=new z,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_state=t.b2LimitState.e_inactiveLimit,n.m_qA=new X,n.m_qB=new X,n.m_lalcA=new z,n.m_lalcB=new z,n.m_localAnchorA.Copy(e(r.localAnchorA,new z(-1,0))),n.m_localAnchorB.Copy(e(r.localAnchorB,new z(1,0))),n.m_maxLength=e(r.maxLength,0),n}Me(r,i);var n=r.prototype;return n.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,n=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,a=e.velocities[this.m_indexA].w,l=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,u=e.velocities[this.m_indexB].v,c=e.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(n),f=this.m_qB.SetAngle(h);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),X.MulRV(_,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),X.MulRV(f,this.m_lalcB,this.m_rB),this.m_u.Copy(l).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA),this.m_length=this.m_u.Length();var p=this.m_length-this.m_maxLength;if(this.m_state=p>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>o))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var d=z.CrossVV(this.m_rA,this.m_u),m=z.CrossVV(this.m_rB,this.m_u),y=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==y?1/y:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var g=z.MulSV(this.m_impulse,this.m_u,r.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,g),a-=this.m_invIA*z.CrossVV(this.m_rA,g),u.SelfMulAdd(this.m_invMassB,g),c+=this.m_invIB*z.CrossVV(this.m_rB,g)}else this.m_impulse=0;e.velocities[this.m_indexA].w=a,e.velocities[this.m_indexB].w=c},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=z.AddVCrossSV(e,i,this.m_rA,r.SolveVelocityConstraints_s_vpA),o=z.AddVCrossSV(n,s,this.m_rB,r.SolveVelocityConstraints_s_vpB),l=this.m_length-this.m_maxLength,h=z.DotVV(this.m_u,z.SubVV(o,a,z.s_t0));l<0&&(h+=t.step.inv_dt*l);var u=-this.m_mass*h,c=this.m_impulse;this.m_impulse=B(0,this.m_impulse+u),u=this.m_impulse-c;var _=z.MulSV(u,this.m_u,r.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,_),i-=this.m_invIA*z.CrossVV(this.m_rA,_),n.SelfMulAdd(this.m_invMassB,_),s+=this.m_invIB*z.CrossVV(this.m_rB,_),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(i),l=this.m_qB.SetAngle(s);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=X.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var c=X.MulRV(l,this.m_lalcB,this.m_rB),_=this.m_u.Copy(n).SelfAdd(c).SelfSub(e).SelfSub(h),f=_.Normalize(),p=f-this.m_maxLength;p=M(p,0,u);var d=-this.m_mass*p,m=z.MulSV(d,_,r.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),i-=this.m_invIA*z.CrossVV(h,m),n.SelfMulAdd(this.m_invMassB,m),s+=this.m_invIB*z.CrossVV(c,m),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,f-this.m_maxLength<o},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return z.MulSV(t*this.m_impulse,this.m_u,e)},n.GetReactionTorque=function(){return 0},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetMaxLength=function(t){this.m_maxLength=t},n.GetMaxLength=function(){return this.m_maxLength},n.GetLimitState=function(){return this.m_state},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2RopeJointDef = new b2RopeJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxLength = %.15f;\n",this.m_maxLength),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},r}(Pi);Zi.InitVelocityConstraints_s_P=new z,Zi.SolveVelocityConstraints_s_vpA=new z,Zi.SolveVelocityConstraints_s_vpB=new z,Zi.SolveVelocityConstraints_s_P=new z,Zi.SolvePositionConstraints_s_P=new z;var Qi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_weldJoint)||this).localAnchorA=new z,i.localAnchorB=new z,i.referenceAngle=0,i.frequencyHz=0,i.dampingRatio=0,i}return Me(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Mi),$i=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_frequencyHz=0,r.m_dampingRatio=0,r.m_bias=0,r.m_localAnchorA=new z,r.m_localAnchorB=new z,r.m_referenceAngle=0,r.m_gamma=0,r.m_impulse=new H(0,0,0),r.m_indexA=0,r.m_indexB=0,r.m_rA=new z,r.m_rB=new z,r.m_localCenterA=new z,r.m_localCenterB=new z,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=new W,r.m_qA=new X,r.m_qB=new X,r.m_lalcA=new z,r.m_lalcB=new z,r.m_K=new W,r.m_frequencyHz=e(i.frequencyHz,0),r.m_dampingRatio=e(i.dampingRatio,0),r.m_localAnchorA.Copy(e(i.localAnchorA,z.ZERO)),r.m_localAnchorB.Copy(e(i.localAnchorB,z.ZERO)),r.m_referenceAngle=e(i.referenceAngle,0),r.m_impulse.SetZero(),r}Me(i,t);var r=i.prototype;return r.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v,l=t.velocities[this.m_indexB].w,h=this.m_qA.SetAngle(e),u=this.m_qB.SetAngle(a);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),X.MulRV(h,this.m_lalcA,this.m_rA),z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),X.MulRV(u,this.m_lalcB,this.m_rB);var c=this.m_invMassA,_=this.m_invMassB,f=this.m_invIA,p=this.m_invIB,d=this.m_K;if(d.ex.x=c+_+this.m_rA.y*this.m_rA.y*f+this.m_rB.y*this.m_rB.y*p,d.ey.x=-this.m_rA.y*this.m_rA.x*f-this.m_rB.y*this.m_rB.x*p,d.ez.x=-this.m_rA.y*f-this.m_rB.y*p,d.ex.y=d.ey.x,d.ey.y=c+_+this.m_rA.x*this.m_rA.x*f+this.m_rB.x*this.m_rB.x*p,d.ez.y=this.m_rA.x*f+this.m_rB.x*p,d.ex.z=d.ez.x,d.ey.z=d.ez.y,d.ez.z=f+p,this.m_frequencyHz>0){d.GetInverse22(this.m_mass);var m=f+p,y=m>0?1/m:0,g=a-e-this.m_referenceAngle,v=2*s*this.m_frequencyHz,b=2*y*this.m_dampingRatio*v,S=y*v*v,A=t.step.dt;this.m_gamma=A*(b+A*S),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=g*A*S*this.m_gamma,m+=this.m_gamma,this.m_mass.ez.z=0!==m?1/m:0}else d.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var C=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(c,C),n-=f*(z.CrossVV(this.m_rA,C)+this.m_impulse.z),o.SelfMulAdd(_,C),l+=p*(z.CrossVV(this.m_rB,C)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=l},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=this.m_invMassA,o=this.m_invMassB,l=this.m_invIA,h=this.m_invIB;if(this.m_frequencyHz>0){var u=s-r,c=-this.m_mass.ez.z*(u+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=c,r-=l*c,s+=h*c;var _=z.SubVV(z.AddVCrossSV(n,s,this.m_rB,z.s_t0),z.AddVCrossSV(e,r,this.m_rA,z.s_t1),i.SolveVelocityConstraints_s_Cdot1),f=W.MulM33XY(this.m_mass,_.x,_.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=f.x,this.m_impulse.y+=f.y;var p=f;e.SelfMulSub(a,p),r-=l*z.CrossVV(this.m_rA,p),n.SelfMulAdd(o,p),s+=h*z.CrossVV(this.m_rB,p)}else{var d=z.SubVV(z.AddVCrossSV(n,s,this.m_rB,z.s_t0),z.AddVCrossSV(e,r,this.m_rA,z.s_t1),i.SolveVelocityConstraints_s_Cdot1),m=s-r,y=W.MulM33XYZ(this.m_mass,d.x,d.y,m,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(y);var g=i.SolveVelocityConstraints_s_P.Set(y.x,y.y);e.SelfMulSub(a,g),r-=l*(z.CrossVV(this.m_rA,g)+y.z),n.SelfMulAdd(o,g),s+=h*(z.CrossVV(this.m_rB,g)+y.z)}t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,r=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(r),h=this.m_qB.SetAngle(s),u=this.m_invMassA,c=this.m_invMassB,_=this.m_invIA,f=this.m_invIB;z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var p=X.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d,m,y=X.MulRV(h,this.m_lalcB,this.m_rB),g=this.m_K;if(g.ex.x=u+c+p.y*p.y*_+y.y*y.y*f,g.ey.x=-p.y*p.x*_-y.y*y.x*f,g.ez.x=-p.y*_-y.y*f,g.ex.y=g.ey.x,g.ey.y=u+c+p.x*p.x*_+y.x*y.x*f,g.ez.y=p.x*_+y.x*f,g.ex.z=g.ez.x,g.ey.z=g.ez.y,g.ez.z=_+f,this.m_frequencyHz>0){var v=z.SubVV(z.AddVV(n,y,z.s_t0),z.AddVV(e,p,z.s_t1),i.SolvePositionConstraints_s_C1);d=v.Length(),m=0;var b=g.Solve22(v.x,v.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(u,b),r-=_*z.CrossVV(p,b),n.SelfMulAdd(c,b),s+=f*z.CrossVV(y,b)}else{var S=z.SubVV(z.AddVV(n,y,z.s_t0),z.AddVV(e,p,z.s_t1),i.SolvePositionConstraints_s_C1),A=s-r-this.m_referenceAngle;d=S.Length(),m=E(A);var C=g.Solve33(S.x,S.y,A,i.SolvePositionConstraints_s_impulse).SelfNeg(),x=i.SolvePositionConstraints_s_P.Set(C.x,C.y);e.SelfMulSub(u,x),r-=_*(z.CrossVV(this.m_rA,x)+C.z),n.SelfMulAdd(c,x),s+=f*(z.CrossVV(this.m_rB,x)+C.z)}return t.positions[this.m_indexA].a=r,t.positions[this.m_indexB].a=s,d<=o&&m<=l},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},r.GetReactionTorque=function(t){return t*this.m_impulse.z},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.GetReferenceAngle=function(){return this.m_referenceAngle},r.SetFrequency=function(t){this.m_frequencyHz=t},r.GetFrequency=function(){return this.m_frequencyHz},r.SetDampingRatio=function(t){this.m_dampingRatio=t},r.GetDampingRatio=function(){return this.m_dampingRatio},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);$i.InitVelocityConstraints_s_P=new z,$i.SolveVelocityConstraints_s_Cdot1=new z,$i.SolveVelocityConstraints_s_impulse1=new z,$i.SolveVelocityConstraints_s_impulse=new H,$i.SolveVelocityConstraints_s_P=new z,$i.SolvePositionConstraints_s_C1=new z,$i.SolvePositionConstraints_s_P=new z,$i.SolvePositionConstraints_s_impulse=new H;var tr=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_wheelJoint)||this).localAnchorA=new z(0,0),i.localAnchorB=new z(0,0),i.localAxisA=new z(1,0),i.enableMotor=!1,i.maxMotorTorque=0,i.motorSpeed=0,i.frequencyHz=2,i.dampingRatio=.7,i}return Me(i,e),i.prototype.Initialize=function(t,e,i,r){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(r,this.localAxisA)},i}(Mi),er=function(t){function i(i){var r;return(r=t.call(this,i)||this).m_frequencyHz=0,r.m_dampingRatio=0,r.m_localAnchorA=new z,r.m_localAnchorB=new z,r.m_localXAxisA=new z,r.m_localYAxisA=new z,r.m_impulse=0,r.m_motorImpulse=0,r.m_springImpulse=0,r.m_maxMotorTorque=0,r.m_motorSpeed=0,r.m_enableMotor=!1,r.m_indexA=0,r.m_indexB=0,r.m_localCenterA=new z,r.m_localCenterB=new z,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_ax=new z,r.m_ay=new z,r.m_sAx=0,r.m_sBx=0,r.m_sAy=0,r.m_sBy=0,r.m_mass=0,r.m_motorMass=0,r.m_springMass=0,r.m_bias=0,r.m_gamma=0,r.m_qA=new X,r.m_qB=new X,r.m_lalcA=new z,r.m_lalcB=new z,r.m_rA=new z,r.m_rB=new z,r.m_frequencyHz=e(i.frequencyHz,2),r.m_dampingRatio=e(i.dampingRatio,.7),r.m_localAnchorA.Copy(e(i.localAnchorA,z.ZERO)),r.m_localAnchorB.Copy(e(i.localAnchorB,z.ZERO)),r.m_localXAxisA.Copy(e(i.localAxisA,z.UNITX)),z.CrossOneV(r.m_localXAxisA,r.m_localYAxisA),r.m_maxMotorTorque=e(i.maxMotorTorque,0),r.m_motorSpeed=e(i.motorSpeed,0),r.m_enableMotor=e(i.enableMotor,!1),r.m_ax.SetZero(),r.m_ay.SetZero(),r}Me(i,t);var r=i.prototype;return r.GetMotorSpeed=function(){return this.m_motorSpeed},r.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},r.SetSpringFrequencyHz=function(t){this.m_frequencyHz=t},r.GetSpringFrequencyHz=function(){return this.m_frequencyHz},r.SetSpringDampingRatio=function(t){this.m_dampingRatio=t},r.GetSpringDampingRatio=function(){return this.m_dampingRatio},r.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,r=this.m_invMassB,n=this.m_invIA,a=this.m_invIB,o=t.positions[this.m_indexA].c,l=t.positions[this.m_indexA].a,h=t.velocities[this.m_indexA].v,u=t.velocities[this.m_indexA].w,c=t.positions[this.m_indexB].c,_=t.positions[this.m_indexB].a,f=t.velocities[this.m_indexB].v,p=t.velocities[this.m_indexB].w,d=this.m_qA.SetAngle(l),m=this.m_qB.SetAngle(_);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var y=X.MulRV(d,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var g=X.MulRV(m,this.m_lalcB,this.m_rB),v=z.SubVV(z.AddVV(c,g,z.s_t0),z.AddVV(o,y,z.s_t1),i.InitVelocityConstraints_s_d);if(X.MulRV(d,this.m_localYAxisA,this.m_ay),this.m_sAy=z.CrossVV(z.AddVV(v,y,z.s_t0),this.m_ay),this.m_sBy=z.CrossVV(g,this.m_ay),this.m_mass=e+r+n*this.m_sAy*this.m_sAy+a*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){X.MulRV(d,this.m_localXAxisA,this.m_ax),this.m_sAx=z.CrossVV(z.AddVV(v,y,z.s_t0),this.m_ax),this.m_sBx=z.CrossVV(g,this.m_ax);var b=e+r+n*this.m_sAx*this.m_sAx+a*this.m_sBx*this.m_sBx;if(b>0){this.m_springMass=1/b;var S=z.DotVV(v,this.m_ax),A=2*s*this.m_frequencyHz,C=2*this.m_springMass*this.m_dampingRatio*A,x=this.m_springMass*A*A,T=t.step.dt;this.m_gamma=T*(C+T*x),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=S*T*x*this.m_gamma,this.m_springMass=b+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=n+a,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var w=z.AddVV(z.MulSV(this.m_impulse,this.m_ay,z.s_t0),z.MulSV(this.m_springImpulse,this.m_ax,z.s_t1),i.InitVelocityConstraints_s_P),E=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,B=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;h.SelfMulSub(this.m_invMassA,w),u-=this.m_invIA*E,f.SelfMulAdd(this.m_invMassB,w),p+=this.m_invIB*B}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].w=u,t.velocities[this.m_indexB].w=p},r.SolveVelocityConstraints=function(t){var e=this.m_invMassA,r=this.m_invMassB,n=this.m_invIA,s=this.m_invIB,a=t.velocities[this.m_indexA].v,o=t.velocities[this.m_indexA].w,l=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,u=z.DotVV(this.m_ax,z.SubVV(l,a,z.s_t0))+this.m_sBx*h-this.m_sAx*o,c=-this.m_springMass*(u+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=c;var _=z.MulSV(c,this.m_ax,i.SolveVelocityConstraints_s_P),f=c*this.m_sAx,p=c*this.m_sBx;a.SelfMulSub(e,_),o-=n*f,l.SelfMulAdd(r,_);var d=(h+=s*p)-o-this.m_motorSpeed,m=-this.m_motorMass*d,y=this.m_motorImpulse,g=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=M(this.m_motorImpulse+m,-g,g),o-=n*(m=this.m_motorImpulse-y),h+=s*m;var v=z.DotVV(this.m_ay,z.SubVV(l,a,z.s_t0))+this.m_sBy*h-this.m_sAy*o,b=-this.m_mass*v;this.m_impulse+=b;var S=z.MulSV(b,this.m_ay,i.SolveVelocityConstraints_s_P),A=b*this.m_sAy,C=b*this.m_sBy;a.SelfMulSub(e,S),o-=n*A,l.SelfMulAdd(r,S),h+=s*C,t.velocities[this.m_indexA].w=o,t.velocities[this.m_indexB].w=h},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,r=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(r),l=this.m_qB.SetAngle(s);z.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=X.MulRV(a,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,c=X.MulRV(l,this.m_lalcB,this.m_rB),_=z.AddVV(z.SubVV(n,e,z.s_t0),z.SubVV(c,h,z.s_t1),i.SolvePositionConstraints_s_d),f=X.MulRV(a,this.m_localYAxisA,this.m_ay),p=z.CrossVV(z.AddVV(_,h,z.s_t0),f),d=z.CrossVV(c,f),m=z.DotVV(_,this.m_ay),y=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;u=0!==y?-m/y:0;var g=z.MulSV(u,f,i.SolvePositionConstraints_s_P),v=u*p,b=u*d;return e.SelfMulSub(this.m_invMassA,g),r-=this.m_invIA*v,n.SelfMulAdd(this.m_invMassB,g),s+=this.m_invIB*b,t.positions[this.m_indexA].a=r,t.positions[this.m_indexB].a=s,E(m)<=o},r.GetDefinition=function(t){return t},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x),e.y=t*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y),e},r.GetReactionTorque=function(t){return t*this.m_motorImpulse},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.GetLocalAxisA=function(){return this.m_localXAxisA},r.GetJointTranslation=function(){return this.GetPrismaticJointTranslation()},r.GetJointLinearSpeed=function(){return this.GetPrismaticJointSpeed()},r.GetJointAngle=function(){return this.GetRevoluteJointAngle()},r.GetJointAngularSpeed=function(){return this.GetRevoluteJointSpeed()},r.GetPrismaticJointTranslation=function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA,new z),r=e.GetWorldPoint(this.m_localAnchorB,new z),n=z.SubVV(r,i,new z),s=t.GetWorldVector(this.m_localXAxisA,new z);return z.DotVV(n,s)},r.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;z.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=X.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);z.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var r=X.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),n=z.AddVV(t.m_sweep.c,i,z.s_t0),s=z.AddVV(e.m_sweep.c,r,z.s_t1),a=z.SubVV(s,n,z.s_t2),o=t.GetWorldVector(this.m_localXAxisA,new z),l=t.m_linearVelocity,h=e.m_linearVelocity,u=t.m_angularVelocity,c=e.m_angularVelocity;return z.DotVV(a,z.CrossSV(u,o,z.s_t0))+z.DotVV(o,z.SubVV(z.AddVCrossSV(h,c,r,z.s_t0),z.AddVCrossSV(l,u,i,z.s_t1),z.s_t0))},r.GetRevoluteJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a},r.GetRevoluteJointSpeed=function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},r.IsMotorEnabled=function(){return this.m_enableMotor},r.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},r.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},r.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},r.GetMotorTorque=function(t){return t*this.m_motorImpulse},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);function ir(t,e){return O(t*e)}function rr(t,e){return t>e?t:e}er.InitVelocityConstraints_s_d=new z,er.InitVelocityConstraints_s_P=new z,er.SolveVelocityConstraints_s_P=new z,er.SolvePositionConstraints_s_d=new z,er.SolvePositionConstraints_s_P=new z;var nr=function(){function t(t){this._other=null,this.prev=null,this.next=null,this.contact=t}return t.prototype.Reset=function(){this._other=null,this.prev=null,this.next=null},Pe(t,[{key:"other",get:function(){if(null===this._other)throw new Error;return this._other},set:function(t){if(null!==this._other)throw new Error;this._other=t}}]),t}(),sr=function(){function t(){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!1,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_prev=null,this.m_next=null,this.m_nodeA=new nr(this),this.m_nodeB=new nr(this),this.m_indexA=0,this.m_indexB=0,this.m_manifold=new Mt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new Mt}var e=t.prototype;return e.GetManifold=function(){return this.m_manifold},e.GetWorldManifold=function(t){var e=this.m_fixtureA.GetBody(),i=this.m_fixtureB.GetBody(),r=this.GetShapeA(),n=this.GetShapeB();t.Initialize(this.m_manifold,e.GetTransform(),r.m_radius,i.GetTransform(),n.m_radius)},e.IsTouching=function(){return this.m_touchingFlag},e.SetEnabled=function(t){this.m_enabledFlag=t},e.IsEnabled=function(){return this.m_enabledFlag},e.GetNext=function(){return this.m_next},e.GetFixtureA=function(){return this.m_fixtureA},e.GetChildIndexA=function(){return this.m_indexA},e.GetShapeA=function(){return this.m_fixtureA.GetShape()},e.GetFixtureB=function(){return this.m_fixtureB},e.GetChildIndexB=function(){return this.m_indexB},e.GetShapeB=function(){return this.m_fixtureB.GetShape()},e.FlagForFiltering=function(){this.m_filterFlag=!0},e.SetFriction=function(t){this.m_friction=t},e.GetFriction=function(){return this.m_friction},e.ResetFriction=function(){this.m_friction=ir(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)},e.SetRestitution=function(t){this.m_restitution=t},e.GetRestitution=function(){return this.m_restitution},e.ResetRestitution=function(){this.m_restitution=rr(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},e.SetTangentSpeed=function(t){this.m_tangentSpeed=t},e.GetTangentSpeed=function(){return this.m_tangentSpeed},e.Reset=function(t,e,i,r){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!0,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_fixtureA=t,this.m_fixtureB=i,this.m_indexA=e,this.m_indexB=r,this.m_manifold.pointCount=0,this.m_prev=null,this.m_next=null,this.m_nodeA.Reset(),this.m_nodeB.Reset(),this.m_toiCount=0,this.m_friction=ir(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=rr(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},e.Update=function(t){var e=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=e,this.m_enabledFlag=!0;var i=!1,r=this.m_touchingFlag,n=this.m_fixtureA.IsSensor(),s=this.m_fixtureB.IsSensor(),a=n||s,o=this.m_fixtureA.GetBody(),l=this.m_fixtureB.GetBody(),h=o.GetTransform(),u=l.GetTransform();if(a){var c=this.GetShapeA(),_=this.GetShapeB();i=zt(c,this.m_indexA,_,this.m_indexB,h,u),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,h,u),i=this.m_manifold.pointCount>0;for(var f=0;f<this.m_manifold.pointCount;++f){var p=this.m_manifold.points[f];p.normalImpulse=0,p.tangentImpulse=0;for(var d=p.id,m=0;m<this.m_oldManifold.pointCount;++m){var y=this.m_oldManifold.points[m];if(y.id.key===d.key){p.normalImpulse=y.normalImpulse,p.tangentImpulse=y.tangentImpulse;break}}}i!==r&&(o.SetAwake(!0),l.SetAwake(!0))}this.m_touchingFlag=i,!r&&i&&t&&t.BeginContact(this),r&&!i&&t&&t.EndContact(this),!a&&i&&t&&t.PreSolve(this,this.m_oldManifold)},e.ComputeTOI=function(e,i){var r=t.ComputeTOI_s_input;r.proxyA.SetShape(this.GetShapeA(),this.m_indexA),r.proxyB.SetShape(this.GetShapeB(),this.m_indexB),r.sweepA.Copy(e),r.sweepB.Copy(i),r.tMax=o;var n=t.ComputeTOI_s_output;return ye(n,r),n.t},t}();sr.ComputeTOI_s_input=new ne,sr.ComputeTOI_s_output=new ae;var ar=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){be(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(sr),or=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){Ke(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(sr),lr=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){xe(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(sr),hr=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){ai(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(sr),ur=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){_i(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(sr),cr=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,i,r){var n=e.Evaluate_s_edge;this.GetShapeA().GetChildEdge(n,this.m_indexA),ai(t,n,i,this.GetShapeB(),r)},e}(sr);cr.Evaluate_s_edge=new gi;var _r=function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,i,r){var n=e.Evaluate_s_edge;this.GetShapeA().GetChildEdge(n,this.m_indexA),_i(t,n,i,this.GetShapeB(),r)},e}(sr);_r.Evaluate_s_edge=new gi;var fr=function(){this.pool=[],this.createFcn=null,this.destroyFcn=null,this.primary=!1},pr=function(){function e(){this.m_registers=[],this.InitializeRegisters()}var i=e.prototype;return i.AddType=function(t,e,i,r){var n=[];function s(){return n.pop()||t()}function a(t){n.push(t)}this.m_registers[i][r].pool=n,this.m_registers[i][r].createFcn=s,this.m_registers[i][r].destroyFcn=a,this.m_registers[i][r].primary=!0,i!==r&&(this.m_registers[r][i].pool=n,this.m_registers[r][i].createFcn=s,this.m_registers[r][i].destroyFcn=a,this.m_registers[r][i].primary=!1)},i.InitializeRegisters=function(){for(var e=0;e<t.b2ShapeType.e_shapeTypeCount;e++){this.m_registers[e]=[];for(var i=0;i<t.b2ShapeType.e_shapeTypeCount;i++)this.m_registers[e][i]=new fr}this.AddType(ar.Create,ar.Destroy,t.b2ShapeType.e_circleShape,t.b2ShapeType.e_circleShape),this.AddType(lr.Create,lr.Destroy,t.b2ShapeType.e_polygonShape,t.b2ShapeType.e_circleShape),this.AddType(or.Create,or.Destroy,t.b2ShapeType.e_polygonShape,t.b2ShapeType.e_polygonShape),this.AddType(hr.Create,hr.Destroy,t.b2ShapeType.e_edgeShape,t.b2ShapeType.e_circleShape),this.AddType(ur.Create,ur.Destroy,t.b2ShapeType.e_edgeShape,t.b2ShapeType.e_polygonShape),this.AddType(cr.Create,cr.Destroy,t.b2ShapeType.e_chainShape,t.b2ShapeType.e_circleShape),this.AddType(_r.Create,_r.Destroy,t.b2ShapeType.e_chainShape,t.b2ShapeType.e_polygonShape)},i.Create=function(t,e,i,r){var n=t.GetType(),s=i.GetType(),a=this.m_registers[n][s];if(a.createFcn){var o=a.createFcn();return a.primary?o.Reset(t,e,i,r):o.Reset(i,r,t,e),o}return null},i.Destroy=function(t){var e=t.m_fixtureA.GetType(),i=t.m_fixtureB.GetType(),r=this.m_registers[e][i];r.destroyFcn&&r.destroyFcn(t)},e}(),dr=function(){function t(){}var e=t.prototype;return e.SayGoodbyeJoint=function(){},e.SayGoodbyeFixture=function(){},e.SayGoodbyeParticleGroup=function(){},e.SayGoodbyeParticle=function(){},t}(),mr=function(){function e(){}var i=e.prototype;return i.ShouldCollide=function(e,i){var r=e.GetBody(),n=i.GetBody();if(n.GetType()===t.b2BodyType.b2_staticBody&&r.GetType()===t.b2BodyType.b2_staticBody)return!1;if(!n.ShouldCollideConnected(r))return!1;var s=e.GetFilterData(),a=i.GetFilterData();return s.groupIndex===a.groupIndex&&0!==s.groupIndex?s.groupIndex>0:0!=(s.maskBits&a.categoryBits)&&0!=(s.categoryBits&a.maskBits)},i.ShouldCollideFixtureParticle=function(){return!0},i.ShouldCollideParticleParticle=function(){return!0},e}();mr.b2_defaultFilter=new mr;var yr=function(){this.normalImpulses=C(2),this.tangentImpulses=C(2),this.count=0},gr=function(){function t(){}var e=t.prototype;return e.BeginContact=function(){},e.EndContact=function(){},e.BeginContactFixtureParticle=function(){},e.EndContactFixtureParticle=function(){},e.BeginContactParticleParticle=function(){},e.EndContactParticleParticle=function(){},e.PreSolve=function(){},e.PostSolve=function(){},t}();gr.b2_defaultListener=new gr;var vr=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(){return!0},e.ReportParticle=function(){return!1},e.ShouldQueryParticleSystem=function(){return!0},t}(),br=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(t,e,i,r){return r},e.ReportParticle=function(){return 0},e.ShouldQueryParticleSystem=function(){return!0},t}(),Sr=function(){function e(){this.m_broadPhase=new qt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=mr.b2_defaultFilter,this.m_contactListener=gr.b2_defaultListener,this.m_contactFactory=new pr}var i=e.prototype;return i.AddPair=function(t,e){var i=t.fixture,r=e.fixture,n=t.childIndex,s=e.childIndex,a=i.GetBody(),o=r.GetBody();if(a!==o){for(var l=o.GetContactList();l;){if(l.other===a){var h=l.contact.GetFixtureA(),u=l.contact.GetFixtureB(),c=l.contact.GetChildIndexA(),_=l.contact.GetChildIndexB();if(h===i&&u===r&&c===n&&_===s)return;if(h===r&&u===i&&c===s&&_===n)return}l=l.next}if(!this.m_contactFilter||this.m_contactFilter.ShouldCollide(i,r)){var f=this.m_contactFactory.Create(i,n,r,s);null!==f&&(i=f.GetFixtureA(),r=f.GetFixtureB(),n=f.GetChildIndexA(),s=f.GetChildIndexB(),a=i.m_body,o=r.m_body,f.m_prev=null,f.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=f),this.m_contactList=f,f.m_nodeA.other=o,f.m_nodeA.prev=null,f.m_nodeA.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=f.m_nodeA),a.m_contactList=f.m_nodeA,f.m_nodeB.other=a,f.m_nodeB.prev=null,f.m_nodeB.next=o.m_contactList,null!==o.m_contactList&&(o.m_contactList.prev=f.m_nodeB),o.m_contactList=f.m_nodeB,i.IsSensor()||r.IsSensor()||(a.SetAwake(!0),o.SetAwake(!0)),++this.m_contactCount)}}},i.FindNewContacts=function(){var t=this;this.m_broadPhase.UpdatePairs((function(e,i){t.AddPair(e,i)}))},i.Destroy=function(t){var e=t.GetFixtureA(),i=t.GetFixtureB(),r=e.GetBody(),n=i.GetBody();this.m_contactListener&&t.IsTouching()&&this.m_contactListener.EndContact(t),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_contactList&&(this.m_contactList=t.m_next),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA===r.m_contactList&&(r.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB===n.m_contactList&&(n.m_contactList=t.m_nodeB.next),t.m_manifold.pointCount>0&&!e.IsSensor()&&!i.IsSensor()&&(e.GetBody().SetAwake(!0),i.GetBody().SetAwake(!0)),this.m_contactFactory.Destroy(t),--this.m_contactCount},i.Collide=function(){for(var e=this.m_contactList;e;){var i=e.GetFixtureA(),r=e.GetFixtureB(),n=e.GetChildIndexA(),s=e.GetChildIndexB(),a=i.GetBody(),o=r.GetBody();if(e.m_filterFlag){if(this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(i,r)){var l=e;e=l.m_next,this.Destroy(l);continue}e.m_filterFlag=!1}var h=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody,u=o.IsAwake()&&o.m_type!==t.b2BodyType.b2_staticBody;if(h||u){var c=i.m_proxies[n].treeNode,_=r.m_proxies[s].treeNode;if(Lt(c.aabb,_.aabb))e.Update(this.m_contactListener),e=e.m_next;else{var f=e;e=f.m_next,this.Destroy(f)}}else e=e.m_next}},e}(),Ar=function(){function t(){this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0}return t.prototype.Reset=function(){return this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0,this},t}(),Cr=function(){function t(){this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.particleIterations=0,this.warmStarting=!1}return t.prototype.Copy=function(t){return this.dt=t.dt,this.inv_dt=t.inv_dt,this.dtRatio=t.dtRatio,this.positionIterations=t.positionIterations,this.velocityIterations=t.velocityIterations,this.particleIterations=t.particleIterations,this.warmStarting=t.warmStarting,this},t}(),xr=function(){function t(){this.c=new z,this.a=0}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t}(),Tr=function(){function t(){this.v=new z,this.w=0}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t}(),wr=function(){this.step=new Cr},Er=!1,Br=function(){function t(){this.rA=new z,this.rB=new z,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t}(),Dr=function(){function t(){this.points=Br.MakeArray(2),this.normal=new z,this.tangent=new z,this.normalMass=new j,this.K=new j,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}return t.MakeArray=function(e){return A(e,(function(){return new t}))},t}(),Mr=function(){function e(){this.localPoints=z.MakeArray(2),this.localNormal=new z,this.localPoint=new z,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new z,this.localCenterB=new z,this.invIA=0,this.invIB=0,this.type=t.b2ManifoldType.e_unknown,this.radiusA=0,this.radiusB=0,this.pointCount=0}return e.MakeArray=function(t){return A(t,(function(){return new e}))},e}(),Pr=function(){this.step=new Cr,this.count=0},Rr=function(){function e(){this.normal=new z,this.point=new z,this.separation=0}return e.prototype.Initialize=function(i,r,n,s){var a=e.Initialize_s_pointA,o=e.Initialize_s_pointB,l=e.Initialize_s_planePoint,h=e.Initialize_s_clipPoint;switch(i.type){case t.b2ManifoldType.e_circles:Y.MulXV(r,i.localPoint,a),Y.MulXV(n,i.localPoints[0],o),z.SubVV(o,a,this.normal).SelfNormalize(),z.MidVV(a,o,this.point),this.separation=z.DotVV(z.SubVV(o,a,z.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:X.MulRV(r.q,i.localNormal,this.normal),Y.MulXV(r,i.localPoint,l),Y.MulXV(n,i.localPoints[s],h),this.separation=z.DotVV(z.SubVV(h,l,z.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(h);break;case t.b2ManifoldType.e_faceB:X.MulRV(n.q,i.localNormal,this.normal),Y.MulXV(n,i.localPoint,l),Y.MulXV(r,i.localPoints[s],h),this.separation=z.DotVV(z.SubVV(h,l,z.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(h),this.normal.SelfNeg()}},e}();Rr.Initialize_s_pointA=new z,Rr.Initialize_s_pointB=new z,Rr.Initialize_s_planePoint=new z,Rr.Initialize_s_clipPoint=new z;var Ir=function(){function t(){this.m_step=new Cr,this.m_positionConstraints=Mr.MakeArray(1024),this.m_velocityConstraints=Dr.MakeArray(1024),this.m_count=0}var e=t.prototype;return e.Initialize=function(t){if(this.m_step.Copy(t.step),this.m_count=t.count,this.m_positionConstraints.length<this.m_count)for(var e=D(2*this.m_positionConstraints.length,this.m_count);this.m_positionConstraints.length<e;)this.m_positionConstraints[this.m_positionConstraints.length]=new Mr;if(this.m_velocityConstraints.length<this.m_count)for(var i=D(2*this.m_velocityConstraints.length,this.m_count);this.m_velocityConstraints.length<i;)this.m_velocityConstraints[this.m_velocityConstraints.length]=new Dr;this.m_positions=t.positions,this.m_velocities=t.velocities,this.m_contacts=t.contacts;for(var r=0;r<this.m_count;++r){var n=this.m_contacts[r],s=n.m_fixtureA,a=n.m_fixtureB,o=s.GetShape(),l=a.GetShape(),h=o.m_radius,u=l.m_radius,c=s.GetBody(),_=a.GetBody(),f=n.GetManifold(),p=f.pointCount,d=this.m_velocityConstraints[r];d.friction=n.m_friction,d.restitution=n.m_restitution,d.tangentSpeed=n.m_tangentSpeed,d.indexA=c.m_islandIndex,d.indexB=_.m_islandIndex,d.invMassA=c.m_invMass,d.invMassB=_.m_invMass,d.invIA=c.m_invI,d.invIB=_.m_invI,d.contactIndex=r,d.pointCount=p,d.K.SetZero(),d.normalMass.SetZero();var m=this.m_positionConstraints[r];m.indexA=c.m_islandIndex,m.indexB=_.m_islandIndex,m.invMassA=c.m_invMass,m.invMassB=_.m_invMass,m.localCenterA.Copy(c.m_sweep.localCenter),m.localCenterB.Copy(_.m_sweep.localCenter),m.invIA=c.m_invI,m.invIB=_.m_invI,m.localNormal.Copy(f.localNormal),m.localPoint.Copy(f.localPoint),m.pointCount=p,m.radiusA=h,m.radiusB=u,m.type=f.type;for(var y=0;y<p;++y){var g=f.points[y],v=d.points[y];this.m_step.warmStarting?(v.normalImpulse=this.m_step.dtRatio*g.normalImpulse,v.tangentImpulse=this.m_step.dtRatio*g.tangentImpulse):(v.normalImpulse=0,v.tangentImpulse=0),v.rA.SetZero(),v.rB.SetZero(),v.normalMass=0,v.tangentMass=0,v.velocityBias=0,m.localPoints[y].Copy(g.localPoint)}}return this},e.InitializeVelocityConstraints=function(){for(var e=t.InitializeVelocityConstraints_s_xfA,i=t.InitializeVelocityConstraints_s_xfB,r=t.InitializeVelocityConstraints_s_worldManifold,n=0;n<this.m_count;++n){var s=this.m_velocityConstraints[n],a=this.m_positionConstraints[n],o=a.radiusA,l=a.radiusB,h=this.m_contacts[s.contactIndex].GetManifold(),u=s.indexA,c=s.indexB,_=s.invMassA,f=s.invMassB,p=s.invIA,d=s.invIB,m=a.localCenterA,y=a.localCenterB,g=this.m_positions[u].c,v=this.m_positions[u].a,b=this.m_velocities[u].v,S=this.m_velocities[u].w,A=this.m_positions[c].c,C=this.m_positions[c].a,x=this.m_velocities[c].v,T=this.m_velocities[c].w;e.q.SetAngle(v),i.q.SetAngle(C),z.SubVV(g,X.MulRV(e.q,m,z.s_t0),e.p),z.SubVV(A,X.MulRV(i.q,y,z.s_t0),i.p),r.Initialize(h,e,o,i,l),s.normal.Copy(r.normal),z.CrossVOne(s.normal,s.tangent);for(var w=s.pointCount,E=0;E<w;++E){var B=s.points[E];z.SubVV(r.points[E],g,B.rA),z.SubVV(r.points[E],A,B.rB);var D=z.CrossVV(B.rA,s.normal),M=z.CrossVV(B.rB,s.normal),P=_+f+p*D*D+d*M*M;B.normalMass=P>0?1/P:0;var R=s.tangent,I=z.CrossVV(B.rA,R),O=z.CrossVV(B.rB,R),F=_+f+p*I*I+d*O*O;B.tangentMass=F>0?1/F:0,B.velocityBias=0;var L=z.DotVV(s.normal,z.SubVV(z.AddVCrossSV(x,T,B.rB,z.s_t0),z.AddVCrossSV(b,S,B.rA,z.s_t1),z.s_t0));L<-1&&(B.velocityBias+=-s.restitution*L)}s.pointCount}},e.WarmStart=function(){for(var e=t.WarmStart_s_P,i=0;i<this.m_count;++i){for(var r=this.m_velocityConstraints[i],n=r.indexA,s=r.indexB,a=r.invMassA,o=r.invIA,l=r.invMassB,h=r.invIB,u=r.pointCount,c=this.m_velocities[n].v,_=this.m_velocities[n].w,f=this.m_velocities[s].v,p=this.m_velocities[s].w,d=r.normal,m=r.tangent,y=0;y<u;++y){var g=r.points[y];z.AddVV(z.MulSV(g.normalImpulse,d,z.s_t0),z.MulSV(g.tangentImpulse,m,z.s_t1),e),_-=o*z.CrossVV(g.rA,e),c.SelfMulSub(a,e),p+=h*z.CrossVV(g.rB,e),f.SelfMulAdd(l,e)}this.m_velocities[n].w=_,this.m_velocities[s].w=p}},e.SolveVelocityConstraints=function(){for(var e=t.SolveVelocityConstraints_s_dv,i=(t.SolveVelocityConstraints_s_dv1,t.SolveVelocityConstraints_s_dv2,t.SolveVelocityConstraints_s_P),r=(t.SolveVelocityConstraints_s_a,t.SolveVelocityConstraints_s_b,t.SolveVelocityConstraints_s_x,t.SolveVelocityConstraints_s_d,t.SolveVelocityConstraints_s_P1,t.SolveVelocityConstraints_s_P2,t.SolveVelocityConstraints_s_P1P2,0);r<this.m_count;++r){for(var n=this.m_velocityConstraints[r],s=n.indexA,a=n.indexB,o=n.invMassA,l=n.invIA,h=n.invMassB,u=n.invIB,c=n.pointCount,_=this.m_velocities[s].v,f=this.m_velocities[s].w,p=this.m_velocities[a].v,d=this.m_velocities[a].w,m=n.normal,y=n.tangent,g=n.friction,v=0;v<c;++v){var b=n.points[v];z.SubVV(z.AddVCrossSV(p,d,b.rB,z.s_t0),z.AddVCrossSV(_,f,b.rA,z.s_t1),e);var S=z.DotVV(e,y)-n.tangentSpeed,A=b.tangentMass*-S,C=g*b.normalImpulse,x=M(b.tangentImpulse+A,-C,C);A=x-b.tangentImpulse,b.tangentImpulse=x,z.MulSV(A,y,i),_.SelfMulSub(o,i),f-=l*z.CrossVV(b.rA,i),p.SelfMulAdd(h,i),d+=u*z.CrossVV(b.rB,i)}n.pointCount;for(var T=0;T<c;++T){var w=n.points[T];z.SubVV(z.AddVCrossSV(p,d,w.rB,z.s_t0),z.AddVCrossSV(_,f,w.rA,z.s_t1),e);var E=z.DotVV(e,m),B=-w.normalMass*(E-w.velocityBias),P=D(w.normalImpulse+B,0);B=P-w.normalImpulse,w.normalImpulse=P,z.MulSV(B,m,i),_.SelfMulSub(o,i),f-=l*z.CrossVV(w.rA,i),p.SelfMulAdd(h,i),d+=u*z.CrossVV(w.rB,i)}this.m_velocities[s].w=f,this.m_velocities[a].w=d}},e.StoreImpulses=function(){for(var t=0;t<this.m_count;++t)for(var e=this.m_velocityConstraints[t],i=this.m_contacts[e.contactIndex].GetManifold(),r=0;r<e.pointCount;++r)i.points[r].normalImpulse=e.points[r].normalImpulse,i.points[r].tangentImpulse=e.points[r].tangentImpulse},e.SolvePositionConstraints=function(){for(var e=t.SolvePositionConstraints_s_xfA,i=t.SolvePositionConstraints_s_xfB,r=t.SolvePositionConstraints_s_psm,n=t.SolvePositionConstraints_s_rA,s=t.SolvePositionConstraints_s_rB,a=t.SolvePositionConstraints_s_P,l=0,h=0;h<this.m_count;++h){for(var u=this.m_positionConstraints[h],c=u.indexA,_=u.indexB,f=u.localCenterA,p=u.invMassA,d=u.invIA,m=u.localCenterB,y=u.invMassB,g=u.invIB,v=u.pointCount,b=this.m_positions[c].c,S=this.m_positions[c].a,A=this.m_positions[_].c,C=this.m_positions[_].a,x=0;x<v;++x){e.q.SetAngle(S),i.q.SetAngle(C),z.SubVV(b,X.MulRV(e.q,f,z.s_t0),e.p),z.SubVV(A,X.MulRV(i.q,m,z.s_t0),i.p),r.Initialize(u,e,i,x);var T=r.normal,w=r.point,E=r.separation;z.SubVV(w,b,n),z.SubVV(w,A,s),l=B(l,E);var D=M(.2*(E+o),-.2,0),P=z.CrossVV(n,T),R=z.CrossVV(s,T),I=p+y+d*P*P+g*R*R,O=I>0?-D/I:0;z.MulSV(O,T,a),b.SelfMulSub(p,a),S-=d*z.CrossVV(n,a),A.SelfMulAdd(y,a),C+=g*z.CrossVV(s,a)}this.m_positions[c].a=S,this.m_positions[_].a=C}return l>-.024},e.SolveTOIPositionConstraints=function(e,i){for(var r=t.SolveTOIPositionConstraints_s_xfA,n=t.SolveTOIPositionConstraints_s_xfB,s=t.SolveTOIPositionConstraints_s_psm,a=t.SolveTOIPositionConstraints_s_rA,l=t.SolveTOIPositionConstraints_s_rB,h=t.SolveTOIPositionConstraints_s_P,u=0,c=0;c<this.m_count;++c){var _=this.m_positionConstraints[c],f=_.indexA,p=_.indexB,d=_.localCenterA,m=_.localCenterB,y=_.pointCount,g=0,v=0;f!==e&&f!==i||(g=_.invMassA,v=_.invIA);var b=0,S=0;p!==e&&p!==i||(b=_.invMassB,S=_.invIB);for(var A=this.m_positions[f].c,C=this.m_positions[f].a,x=this.m_positions[p].c,T=this.m_positions[p].a,w=0;w<y;++w){r.q.SetAngle(C),n.q.SetAngle(T),z.SubVV(A,X.MulRV(r.q,d,z.s_t0),r.p),z.SubVV(x,X.MulRV(n.q,m,z.s_t0),n.p),s.Initialize(_,r,n,w);var E=s.normal,D=s.point,P=s.separation;z.SubVV(D,A,a),z.SubVV(D,x,l),u=B(u,P);var R=M(.75*(P+o),-.2,0),I=z.CrossVV(a,E),O=z.CrossVV(l,E),F=g+b+v*I*I+S*O*O,L=F>0?-R/F:0;z.MulSV(L,E,h),A.SelfMulSub(g,h),C-=v*z.CrossVV(a,h),x.SelfMulAdd(b,h),T+=S*z.CrossVV(l,h)}this.m_positions[f].a=C,this.m_positions[p].a=T}return u>=-.012},t}();Ir.InitializeVelocityConstraints_s_xfA=new Y,Ir.InitializeVelocityConstraints_s_xfB=new Y,Ir.InitializeVelocityConstraints_s_worldManifold=new Pt,Ir.WarmStart_s_P=new z,Ir.SolveVelocityConstraints_s_dv=new z,Ir.SolveVelocityConstraints_s_dv1=new z,Ir.SolveVelocityConstraints_s_dv2=new z,Ir.SolveVelocityConstraints_s_P=new z,Ir.SolveVelocityConstraints_s_a=new z,Ir.SolveVelocityConstraints_s_b=new z,Ir.SolveVelocityConstraints_s_x=new z,Ir.SolveVelocityConstraints_s_d=new z,Ir.SolveVelocityConstraints_s_P1=new z,Ir.SolveVelocityConstraints_s_P2=new z,Ir.SolveVelocityConstraints_s_P1P2=new z,Ir.SolvePositionConstraints_s_xfA=new Y,Ir.SolvePositionConstraints_s_xfB=new Y,Ir.SolvePositionConstraints_s_psm=new Rr,Ir.SolvePositionConstraints_s_rA=new z,Ir.SolvePositionConstraints_s_rB=new z,Ir.SolvePositionConstraints_s_P=new z,Ir.SolveTOIPositionConstraints_s_xfA=new Y,Ir.SolveTOIPositionConstraints_s_xfB=new Y,Ir.SolveTOIPositionConstraints_s_psm=new Rr,Ir.SolveTOIPositionConstraints_s_rA=new z,Ir.SolveTOIPositionConstraints_s_rB=new z,Ir.SolveTOIPositionConstraints_s_P=new z;var Or,Fr=function(){function e(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=xr.MakeArray(1024),this.m_velocities=Tr.MakeArray(1024),this.m_bodyCount=0,this.m_jointCount=0,this.m_contactCount=0,this.m_bodyCapacity=0,this.m_contactCapacity=0,this.m_jointCapacity=0}var r=e.prototype;return r.Initialize=function(t,e,i,r){if(this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_listener=r,this.m_positions.length<t)for(var n=D(2*this.m_positions.length,t);this.m_positions.length<n;)this.m_positions[this.m_positions.length]=new xr;if(this.m_velocities.length<t)for(var s=D(2*this.m_velocities.length,t);this.m_velocities.length<s;)this.m_velocities[this.m_velocities.length]=new Tr},r.Clear=function(){this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0},r.AddBody=function(t){t.m_islandIndex=this.m_bodyCount,this.m_bodies[this.m_bodyCount++]=t},r.AddContact=function(t){this.m_contacts[this.m_contactCount++]=t},r.AddJoint=function(t){this.m_joints[this.m_jointCount++]=t},r.Solve=function(r,n,s,a){for(var o=e.s_timer.Reset(),l=n.dt,h=0;h<this.m_bodyCount;++h){var u=this.m_bodies[h];this.m_positions[h].c.Copy(u.m_sweep.c);var c=u.m_sweep.a,p=this.m_velocities[h].v.Copy(u.m_linearVelocity),d=u.m_angularVelocity;u.m_sweep.c0.Copy(u.m_sweep.c),u.m_sweep.a0=u.m_sweep.a,u.m_type===t.b2BodyType.b2_dynamicBody&&(p.x+=l*(u.m_gravityScale*s.x+u.m_invMass*u.m_force.x),p.y+=l*(u.m_gravityScale*s.y+u.m_invMass*u.m_force.y),d+=l*u.m_invI*u.m_torque,p.SelfMul(1/(1+l*u.m_linearDamping)),d*=1/(1+l*u.m_angularDamping)),this.m_positions[h].a=c,this.m_velocities[h].w=d}o.Reset();var m=e.s_solverData;m.step.Copy(n),m.positions=this.m_positions,m.velocities=this.m_velocities;var y=e.s_contactSolverDef;y.step.Copy(n),y.contacts=this.m_contacts,y.count=this.m_contactCount,y.positions=this.m_positions,y.velocities=this.m_velocities;var g=e.s_contactSolver.Initialize(y);g.InitializeVelocityConstraints(),n.warmStarting&&g.WarmStart();for(var v=0;v<this.m_jointCount;++v)this.m_joints[v].InitVelocityConstraints(m);r.solveInit=o.GetMilliseconds(),o.Reset();for(var b=0;b<n.velocityIterations;++b){for(var S=0;S<this.m_jointCount;++S)this.m_joints[S].SolveVelocityConstraints(m);g.SolveVelocityConstraints()}g.StoreImpulses(),r.solveVelocity=o.GetMilliseconds();for(var A=0;A<this.m_bodyCount;++A){var C=this.m_positions[A].c,x=this.m_positions[A].a,T=this.m_velocities[A].v,w=this.m_velocities[A].w,D=z.MulSV(l,T,e.s_translation);if(z.DotVV(D,D)>4){var M=2/D.Length();T.SelfMul(M)}var P=l*w;P*P>f&&(w*=_/E(P)),C.x+=l*T.x,C.y+=l*T.y,x+=l*w,this.m_positions[A].a=x,this.m_velocities[A].w=w}o.Reset();for(var R=!1,I=0;I<n.positionIterations;++I){for(var O=g.SolvePositionConstraints(),F=!0,L=0;L<this.m_jointCount;++L){var V=this.m_joints[L].SolvePositionConstraints(m);F=F&&V}if(O&&F){R=!0;break}}for(var k=0;k<this.m_bodyCount;++k){var N=this.m_bodies[k];N.m_sweep.c.Copy(this.m_positions[k].c),N.m_sweep.a=this.m_positions[k].a,N.m_linearVelocity.Copy(this.m_velocities[k].v),N.m_angularVelocity=this.m_velocities[k].w,N.SynchronizeTransform()}if(r.solvePosition=o.GetMilliseconds(),this.Report(g.m_velocityConstraints),a){for(var G=i,U=0;U<this.m_bodyCount;++U){var H=this.m_bodies[U];H.GetType()!==t.b2BodyType.b2_staticBody&&(!H.m_autoSleepFlag||H.m_angularVelocity*H.m_angularVelocity>.0012184696791469947||z.DotVV(H.m_linearVelocity,H.m_linearVelocity)>1e-4?(H.m_sleepTime=0,G=0):(H.m_sleepTime+=l,G=B(G,H.m_sleepTime)))}if(G>=.5&&R)for(var j=0;j<this.m_bodyCount;++j)this.m_bodies[j].SetAwake(!1)}},r.SolveTOI=function(t,i,r){for(var n=0;n<this.m_bodyCount;++n){var s=this.m_bodies[n];this.m_positions[n].c.Copy(s.m_sweep.c),this.m_positions[n].a=s.m_sweep.a,this.m_velocities[n].v.Copy(s.m_linearVelocity),this.m_velocities[n].w=s.m_angularVelocity}var a=e.s_contactSolverDef;a.contacts=this.m_contacts,a.count=this.m_contactCount,a.step.Copy(t),a.positions=this.m_positions,a.velocities=this.m_velocities;for(var o=e.s_contactSolver.Initialize(a),l=0;l<t.positionIterations&&!o.SolveTOIPositionConstraints(i,r);++l);this.m_bodies[i].m_sweep.c0.Copy(this.m_positions[i].c),this.m_bodies[i].m_sweep.a0=this.m_positions[i].a,this.m_bodies[r].m_sweep.c0.Copy(this.m_positions[r].c),this.m_bodies[r].m_sweep.a0=this.m_positions[r].a,o.InitializeVelocityConstraints();for(var h=0;h<t.velocityIterations;++h)o.SolveVelocityConstraints();for(var u=t.dt,c=0;c<this.m_bodyCount;++c){var p=this.m_positions[c].c,d=this.m_positions[c].a,m=this.m_velocities[c].v,y=this.m_velocities[c].w,g=z.MulSV(u,m,e.s_translation);if(z.DotVV(g,g)>4){var v=2/g.Length();m.SelfMul(v)}var b=u*y;b*b>f&&(y*=_/E(b)),p.SelfMulAdd(u,m),d+=u*y,this.m_positions[c].a=d,this.m_velocities[c].w=y;var S=this.m_bodies[c];S.m_sweep.c.Copy(p),S.m_sweep.a=d,S.m_linearVelocity.Copy(m),S.m_angularVelocity=y,S.SynchronizeTransform()}this.Report(o.m_velocityConstraints)},r.Report=function(t){if(null!==this.m_listener)for(var i=0;i<this.m_contactCount;++i){var r=this.m_contacts[i];if(r){var n=t[i],s=e.s_impulse;s.count=n.pointCount;for(var a=0;a<n.pointCount;++a)s.normalImpulses[a]=n.points[a].normalImpulse,s.tangentImpulses[a]=n.points[a].tangentImpulse;this.m_listener.PostSolve(r,s)}}},e}();Fr.s_timer=new Q,Fr.s_solverData=new wr,Fr.s_contactSolverDef=new Pr,Fr.s_contactSolver=new Ir,Fr.s_translation=new z,Fr.s_impulse=new yr,(Or=t.b2ParticleFlag||(t.b2ParticleFlag={}))[Or.b2_waterParticle=0]="b2_waterParticle",Or[Or.b2_zombieParticle=2]="b2_zombieParticle",Or[Or.b2_wallParticle=4]="b2_wallParticle",Or[Or.b2_springParticle=8]="b2_springParticle",Or[Or.b2_elasticParticle=16]="b2_elasticParticle",Or[Or.b2_viscousParticle=32]="b2_viscousParticle",Or[Or.b2_powderParticle=64]="b2_powderParticle",Or[Or.b2_tensileParticle=128]="b2_tensileParticle",Or[Or.b2_colorMixingParticle=256]="b2_colorMixingParticle",Or[Or.b2_destructionListenerParticle=512]="b2_destructionListenerParticle",Or[Or.b2_barrierParticle=1024]="b2_barrierParticle",Or[Or.b2_staticPressureParticle=2048]="b2_staticPressureParticle",Or[Or.b2_reactiveParticle=4096]="b2_reactiveParticle",Or[Or.b2_repulsiveParticle=8192]="b2_repulsiveParticle",Or[Or.b2_fixtureContactListenerParticle=16384]="b2_fixtureContactListenerParticle",Or[Or.b2_particleContactListenerParticle=32768]="b2_particleContactListenerParticle",Or[Or.b2_fixtureContactFilterParticle=65536]="b2_fixtureContactFilterParticle",Or[Or.b2_particleContactFilterParticle=131072]="b2_particleContactFilterParticle";var Lr=function(){this.flags=0,this.position=new z,this.velocity=new z,this.color=new K(0,0,0,0),this.lifetime=0,this.userData=null,this.group=null};function Vr(t,e,i){return M(Math.ceil(Math.sqrt(t/(.01*e))*i),1,8)}var kr,Nr=function(){function t(){this.m_index=p}var e=t.prototype;return e.GetIndex=function(){return this.m_index},e.SetIndex=function(t){this.m_index=t},t}();(kr=t.b2ParticleGroupFlag||(t.b2ParticleGroupFlag={}))[kr.b2_solidParticleGroup=1]="b2_solidParticleGroup",kr[kr.b2_rigidParticleGroup=2]="b2_rigidParticleGroup",kr[kr.b2_particleGroupCanBeEmpty=4]="b2_particleGroupCanBeEmpty",kr[kr.b2_particleGroupWillBeDestroyed=8]="b2_particleGroupWillBeDestroyed",kr[kr.b2_particleGroupNeedsUpdateDepth=16]="b2_particleGroupNeedsUpdateDepth",kr[kr.b2_particleGroupInternalMask=24]="b2_particleGroupInternalMask";var Gr=function(){this.flags=0,this.groupFlags=0,this.position=new z,this.angle=0,this.linearVelocity=new z,this.angularVelocity=0,this.color=new K,this.strength=1,this.shapeCount=0,this.stride=0,this.particleCount=0,this.lifetime=0,this.userData=null,this.group=null},zr=function(){function e(t){this.m_firstIndex=0,this.m_lastIndex=0,this.m_groupFlags=0,this.m_strength=1,this.m_prev=null,this.m_next=null,this.m_timestamp=-1,this.m_mass=0,this.m_inertia=0,this.m_center=new z,this.m_linearVelocity=new z,this.m_angularVelocity=0,this.m_transform=new Y,this.m_userData=null,this.m_system=t}var i=e.prototype;return i.GetNext=function(){return this.m_next},i.GetParticleSystem=function(){return this.m_system},i.GetParticleCount=function(){return this.m_lastIndex-this.m_firstIndex},i.GetBufferIndex=function(){return this.m_firstIndex},i.ContainsParticle=function(t){return this.m_firstIndex<=t&&t<this.m_lastIndex},i.GetAllParticleFlags=function(){if(!this.m_system.m_flagsBuffer.data)throw new Error;for(var t=0,e=this.m_firstIndex;e<this.m_lastIndex;e++)t|=this.m_system.m_flagsBuffer.data[e];return t},i.GetGroupFlags=function(){return this.m_groupFlags},i.SetGroupFlags=function(e){e|=this.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupInternalMask,this.m_system.SetGroupFlags(this,e)},i.GetMass=function(){return this.UpdateStatistics(),this.m_mass},i.GetInertia=function(){return this.UpdateStatistics(),this.m_inertia},i.GetCenter=function(){return this.UpdateStatistics(),this.m_center},i.GetLinearVelocity=function(){return this.UpdateStatistics(),this.m_linearVelocity},i.GetAngularVelocity=function(){return this.UpdateStatistics(),this.m_angularVelocity},i.GetTransform=function(){return this.m_transform},i.GetPosition=function(){return this.m_transform.p},i.GetAngle=function(){return this.m_transform.q.GetAngle()},i.GetLinearVelocityFromWorldPoint=function(t,i){var r=e.GetLinearVelocityFromWorldPoint_s_t0;return this.UpdateStatistics(),z.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,z.SubVV(t,this.m_center,r),i)},i.GetUserData=function(){return this.m_userData},i.SetUserData=function(t){this.m_userData=t},i.ApplyForce=function(t){this.m_system.ApplyForce(this.m_firstIndex,this.m_lastIndex,t)},i.ApplyLinearImpulse=function(t){this.m_system.ApplyLinearImpulse(this.m_firstIndex,this.m_lastIndex,t)},i.DestroyParticles=function(t){if(this.m_system.m_world.IsLocked())throw new Error;for(var e=this.m_firstIndex;e<this.m_lastIndex;e++)this.m_system.DestroyParticle(e,t)},i.UpdateStatistics=function(){if(!this.m_system.m_positionBuffer.data)throw new Error;if(!this.m_system.m_velocityBuffer.data)throw new Error;var t=new z,e=new z;if(this.m_timestamp!==this.m_system.m_timestamp){var i=this.m_system.GetParticleMass();this.m_mass=i*(this.m_lastIndex-this.m_firstIndex),this.m_center.SetZero(),this.m_linearVelocity.SetZero();for(var r=this.m_firstIndex;r<this.m_lastIndex;r++)this.m_center.SelfMulAdd(i,this.m_system.m_positionBuffer.data[r]),this.m_linearVelocity.SelfMulAdd(i,this.m_system.m_velocityBuffer.data[r]);if(this.m_mass>0){var n=1/this.m_mass;this.m_center.SelfMul(n),this.m_linearVelocity.SelfMul(n)}this.m_inertia=0,this.m_angularVelocity=0;for(var s=this.m_firstIndex;s<this.m_lastIndex;s++)z.SubVV(this.m_system.m_positionBuffer.data[s],this.m_center,t),z.SubVV(this.m_system.m_velocityBuffer.data[s],this.m_linearVelocity,e),this.m_inertia+=i*z.DotVV(t,t),this.m_angularVelocity+=i*z.CrossVV(t,e);this.m_inertia>0&&(this.m_angularVelocity*=1/this.m_inertia),this.m_timestamp=this.m_system.m_timestamp}},e}();zr.GetLinearVelocityFromWorldPoint_s_t0=new z;var Ur=function(){function t(t){this.m_buffer=[],this.m_front=0,this.m_back=0,this.m_buffer.fill(null,0,t)}var e=t.prototype;return e.Push=function(t){if(this.m_back>=this.m_capacity){for(var e=this.m_front;e<this.m_back;e++)this.m_buffer[e-this.m_front]=this.m_buffer[e];this.m_back-=this.m_front,this.m_front=0}this.m_buffer[this.m_back]=t,this.m_back++},e.Pop=function(){this.m_buffer[this.m_front]=null,this.m_front++},e.Empty=function(){return this.m_front===this.m_back},e.Front=function(){var t=this.m_buffer[this.m_front];if(!t)throw new Error;return t},Pe(t,[{key:"m_capacity",get:function(){return this.m_buffer.length}}]),t}(),Hr=function(){function t(t){this.m_generatorCapacity=0,this.m_generatorCount=0,this.m_countX=0,this.m_countY=0,this.m_diagram=[],this.m_generatorBuffer=A(t,(function(){return new jr})),this.m_generatorCapacity=t}var e=t.prototype;return e.AddGenerator=function(t,e,i){var r=this.m_generatorBuffer[this.m_generatorCount++];r.center.Copy(t),r.tag=e,r.necessary=i},e.Generate=function(t,e){for(var r=1/t,n=new z(+i,+i),s=new z(-i,-i),a=0,o=0;o<this.m_generatorCount;o++){var l=this.m_generatorBuffer[o];l.necessary&&(z.MinV(n,l.center,n),z.MaxV(s,l.center,s),++a)}if(0===a)return this.m_countX=0,void(this.m_countY=0);n.x-=e,n.y-=e,s.x+=e,s.y+=e,this.m_countX=1+Math.floor(r*(s.x-n.x)),this.m_countY=1+Math.floor(r*(s.y-n.y)),this.m_diagram=[];for(var h=new Ur(4*this.m_countX*this.m_countY),u=0;u<this.m_generatorCount;u++){var c=this.m_generatorBuffer[u];c.center.SelfSub(n).SelfMul(r);var _=Math.floor(c.center.x),f=Math.floor(c.center.y);_>=0&&f>=0&&_<this.m_countX&&f<this.m_countY&&h.Push(new Wr(_,f,_+f*this.m_countX,c))}for(;!h.Empty();){var p=h.Front(),d=p.m_x,m=p.m_y,y=p.m_i,g=p.m_generator;h.Pop(),this.m_diagram[y]||(this.m_diagram[y]=g,d>0&&h.Push(new Wr(d-1,m,y-1,g)),m>0&&h.Push(new Wr(d,m-1,y-this.m_countX,g)),d<this.m_countX-1&&h.Push(new Wr(d+1,m,y+1,g)),m<this.m_countY-1&&h.Push(new Wr(d,m+1,y+this.m_countX,g)))}for(var v=0;v<this.m_countY;v++)for(var b=0;b<this.m_countX-1;b++){var S=b+v*this.m_countX,A=this.m_diagram[S],C=this.m_diagram[S+1];A!==C&&(h.Push(new Wr(b,v,S,C)),h.Push(new Wr(b+1,v,S+1,A)))}for(var x=0;x<this.m_countY-1;x++)for(var T=0;T<this.m_countX;T++){var w=T+x*this.m_countX,E=this.m_diagram[w],B=this.m_diagram[w+this.m_countX];E!==B&&(h.Push(new Wr(T,x,w,B)),h.Push(new Wr(T,x+1,w+this.m_countX,E)))}for(;!h.Empty();){var D=h.Front(),M=D.m_x,P=D.m_y,R=D.m_i,I=D.m_generator;h.Pop();var O=this.m_diagram[R],F=I;if(O!==F){var L=O.center.x-M,V=O.center.y-P,k=F.center.x-M,N=F.center.y-P;L*L+V*V>k*k+N*N&&(this.m_diagram[R]=F,M>0&&h.Push(new Wr(M-1,P,R-1,F)),P>0&&h.Push(new Wr(M,P-1,R-this.m_countX,F)),M<this.m_countX-1&&h.Push(new Wr(M+1,P,R+1,F)),P<this.m_countY-1&&h.Push(new Wr(M,P+1,R+this.m_countX,F)))}}},e.GetNodes=function(t){for(var e=0;e<this.m_countY-1;e++)for(var i=0;i<this.m_countX-1;i++){var r=i+e*this.m_countX,n=this.m_diagram[r],s=this.m_diagram[r+1],a=this.m_diagram[r+this.m_countX],o=this.m_diagram[r+1+this.m_countX];s!==a&&(n!==s&&n!==a&&(n.necessary||s.necessary||a.necessary)&&t(n.tag,s.tag,a.tag),o!==s&&o!==a&&(n.necessary||s.necessary||a.necessary)&&t(s.tag,o.tag,a.tag))}},t}(),jr=function(){this.center=new z,this.tag=0,this.necessary=!1},Wr=function(t,e,i,r){this.m_x=t,this.m_y=e,this.m_i=i,this.m_generator=r};function Xr(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Yr(t,e){return t<e}function qr(t,e,i,r){void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===r&&(r=Yr);for(var n=e,s=[],a=0;;){for(;n+1<i;i++){var o=t[n+Math.floor(Math.random()*(i-n))];s[a++]=i;for(var l=n-1;;){for(;r(t[++l],o););for(;r(o,t[--i]););if(l>=i)break;Xr(t,l,i)}}if(0===a)break;n=i,i=s[--a]}return t}function Jr(t,e,i,r){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===r&&(r=Yr),qr(t,e,i,r)}function Kr(t,e,i){void 0===i&&(i=t.length);for(var r=0,n=0;n<i;++n)e(t[n])||(n!==r?Xr(t,r++,n):++r);return r}function Zr(t,e,i,r,n){for(var s=i-e;s>0;){var a=Math.floor(s/2),o=e+a;n(t[o],r)?(e=++o,s-=a+1):s=a}return e}function Qr(t,e,i,r,n){for(var s=i-e;s>0;){var a=Math.floor(s/2),o=e+a;n(r,t[o])?s=a:(e=++o,s-=a+1)}return e}function $r(t,e,i,r){for(var n=i;e!==n;)Xr(t,e++,n++),n===r?n=i:e===i&&(i=n)}var tn=function(){function t(t){this.data=[],this.count=0,this.capacity=0,this.allocator=t}var e=t.prototype;return e.Append=function(){return this.count>=this.capacity&&this.Grow(),this.count++},e.Reserve=function(t){if(!(this.capacity>=t)){for(var e=this.capacity;e<t;++e)this.data[e]=this.allocator();this.capacity=t}},e.Grow=function(){var t=this.capacity?2*this.capacity:y;this.Reserve(t)},e.Free=function(){0!==this.data.length&&(this.data=[],this.capacity=0,this.count=0)},e.Shorten=function(){},e.Data=function(){return this.data},e.GetCount=function(){return this.count},e.SetCount=function(t){this.count=t},e.GetCapacity=function(){return this.capacity},e.RemoveIf=function(t){this.count=Kr(this.data,t,this.count)},e.Unique=function(t){this.count=function(t,e,i,r){if(e===i)return i;for(var n=e;++e!==i;)r(t[n],t[e])||Xr(t,++n,e);return++n}(this.data,0,this.count,t)},t}(),en=function(t){function e(e){var i;return(i=t.call(this)||this).m_system=e,i}Me(e,t);var i=e.prototype;return i.ShouldQueryParticleSystem=function(){return!1},i.ReportFixture=function(t){if(t.IsSensor())return!0;for(var e=t.GetShape().GetChildCount(),i=0;i<e;i++)for(var r=t.GetAABB(i),n=this.m_system.GetInsideBoundsEnumerator(r),s=void 0;(s=n.GetNext())>=0;)this.ReportFixtureAndParticle(t,i,s);return!0},i.ReportParticle=function(){return!1},i.ReportFixtureAndParticle=function(){},e}(vr),rn=function(){function t(){this.indexA=0,this.indexB=0,this.weight=0,this.normal=new z,this.flags=0}var e=t.prototype;return e.SetIndices=function(t,e){this.indexA=t,this.indexB=e},e.SetWeight=function(t){this.weight=t},e.SetNormal=function(t){this.normal.Copy(t)},e.SetFlags=function(t){this.flags=t},e.GetIndexA=function(){return this.indexA},e.GetIndexB=function(){return this.indexB},e.GetWeight=function(){return this.weight},e.GetNormal=function(){return this.normal},e.GetFlags=function(){return this.flags},e.IsEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&this.weight===t.weight&&this.normal.x===t.normal.x&&this.normal.y===t.normal.y},e.IsNotEqual=function(t){return!this.IsEqual(t)},e.ApproximatelyEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&E(this.weight-t.weight)<.01&&z.DistanceSquaredVV(this.normal,t.normal)<1e-4},t}(),nn=function(){this.index=0,this.weight=0,this.normal=new z,this.mass=0},sn=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},an=function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new z(0,0),this.pb=new z(0,0),this.pc=new z(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},on=function(){function t(){this.strictContactCheck=!1,this.density=1,this.gravityScale=1,this.radius=1,this.maxCount=0,this.pressureStrength=.005,this.dampingStrength=1,this.elasticStrength=.25,this.springStrength=.25,this.viscousStrength=.25,this.surfaceTensionPressureStrength=.2,this.surfaceTensionNormalStrength=.2,this.repulsiveStrength=1,this.powderStrength=.5,this.ejectionStrength=.5,this.staticPressureStrength=.2,this.staticPressureRelaxation=.2,this.staticPressureIterations=8,this.colorMixingStrength=.5,this.destroyByAge=!0,this.lifetimeGranularity=1/60}var e=t.prototype;return e.Copy=function(t){return this.strictContactCheck=t.strictContactCheck,this.density=t.density,this.gravityScale=t.gravityScale,this.radius=t.radius,this.maxCount=t.maxCount,this.pressureStrength=t.pressureStrength,this.dampingStrength=t.dampingStrength,this.elasticStrength=t.elasticStrength,this.springStrength=t.springStrength,this.viscousStrength=t.viscousStrength,this.surfaceTensionPressureStrength=t.surfaceTensionPressureStrength,this.surfaceTensionNormalStrength=t.surfaceTensionNormalStrength,this.repulsiveStrength=t.repulsiveStrength,this.powderStrength=t.powderStrength,this.ejectionStrength=t.ejectionStrength,this.staticPressureStrength=t.staticPressureStrength,this.staticPressureRelaxation=t.staticPressureRelaxation,this.staticPressureIterations=t.staticPressureIterations,this.colorMixingStrength=t.colorMixingStrength,this.destroyByAge=t.destroyByAge,this.lifetimeGranularity=t.lifetimeGranularity,this},e.Clone=function(){return(new t).Copy(this)},t}(),ln=function(){function r(t,e){this.m_paused=!1,this.m_timestamp=0,this.m_allParticleFlags=0,this.m_needsUpdateAllParticleFlags=!1,this.m_allGroupFlags=0,this.m_needsUpdateAllGroupFlags=!1,this.m_hasForce=!1,this.m_iterationIndex=0,this.m_inverseDensity=0,this.m_particleDiameter=0,this.m_inverseDiameter=0,this.m_squaredDiameter=0,this.m_count=0,this.m_internalAllocatedCapacity=0,this.m_handleIndexBuffer=new hn,this.m_flagsBuffer=new hn,this.m_positionBuffer=new hn,this.m_velocityBuffer=new hn,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new hn,this.m_groupBuffer=[],this.m_userDataBuffer=new hn,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new hn,this.m_bodyContactCountBuffer=new hn,this.m_consecutiveContactStepsBuffer=new hn,this.m_stuckParticleBuffer=new tn((function(){return 0})),this.m_proxyBuffer=new tn((function(){return new un})),this.m_contactBuffer=new tn((function(){return new rn})),this.m_bodyContactBuffer=new tn((function(){return new nn})),this.m_pairBuffer=new tn((function(){return new sn})),this.m_triadBuffer=new tn((function(){return new an})),this.m_expirationTimeBuffer=new hn,this.m_indexByExpirationTimeBuffer=new hn,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new on,this.m_prev=null,this.m_next=null,this.UpdateBodyContacts_callback=null,this.SolveCollision_callback=null,this.SetStrictContactCheck(t.strictContactCheck),this.SetDensity(t.density),this.SetGravityScale(t.gravityScale),this.SetRadius(t.radius),this.SetMaxParticleCount(t.maxCount),this.m_def=t.Clone(),this.m_world=e,this.SetDestructionByAge(this.m_def.destroyByAge)}r.computeTag=function(t,e){return(e+r.yOffset>>>0<<r.yShift)+(r.xScale*t+r.xOffset>>>0)>>>0},r.computeRelativeTag=function(t,e,i){return t+(i<<r.yShift)+(e<<r.xShift)>>>0};var n=r.prototype;return n.Drop=function(){for(;this.m_groupList;)this.DestroyParticleGroup(this.m_groupList);this.FreeUserOverridableBuffer(this.m_handleIndexBuffer),this.FreeUserOverridableBuffer(this.m_flagsBuffer),this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer),this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer),this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer),this.FreeUserOverridableBuffer(this.m_positionBuffer),this.FreeUserOverridableBuffer(this.m_velocityBuffer),this.FreeUserOverridableBuffer(this.m_colorBuffer),this.FreeUserOverridableBuffer(this.m_userDataBuffer),this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer),this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer),this.FreeBuffer(this.m_forceBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_weightBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_staticPressureBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulationBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulation2Buffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_depthBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_groupBuffer,this.m_internalAllocatedCapacity)},n.CreateParticle=function(t){if(this.m_world.IsLocked())throw new Error;if(this.m_count>=this.m_internalAllocatedCapacity){var i=this.m_count?2*this.m_count:y;this.ReallocateInternalAllocatedBuffers(i)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return p;this.DestroyOldestParticle(0,!1),this.SolveZombie()}var r=this.m_count++;this.m_flagsBuffer.data[r]=0,this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[r]=0),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[r]=0),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[r]=0),this.m_positionBuffer.data[r]=(this.m_positionBuffer.data[r]||new z).Copy(e(t.position,z.ZERO)),this.m_velocityBuffer.data[r]=(this.m_velocityBuffer.data[r]||new z).Copy(e(t.velocity,z.ZERO)),this.m_weightBuffer[r]=0,this.m_forceBuffer[r]=(this.m_forceBuffer[r]||new z).SetZero(),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[r]=0),this.m_depthBuffer&&(this.m_depthBuffer[r]=0);var n=(new K).Copy(e(t.color,K.ZERO));!this.m_colorBuffer.data&&n.IsZero()||(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[r]=(this.m_colorBuffer.data[r]||new K).Copy(n)),(this.m_userDataBuffer.data||t.userData)&&(this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[r]=t.userData),this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[r]=null);var s=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],a=e(t.lifetime,0),o=a>0;(this.m_expirationTimeBuffer.data||o)&&(this.SetParticleLifetime(r,o?a:this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())),this.m_indexByExpirationTimeBuffer.data[r]=r),s.index=r;var l=e(t.group,null);return this.m_groupBuffer[r]=l,l&&(l.m_firstIndex<l.m_lastIndex?(this.RotateBuffer(l.m_firstIndex,l.m_lastIndex,r),l.m_lastIndex=r+1):(l.m_firstIndex=r,l.m_lastIndex=r+1)),this.SetParticleFlags(r,e(t.flags,0)),r},n.GetParticleHandleFromIndex=function(t){this.m_handleIndexBuffer.data=this.RequestBuffer(this.m_handleIndexBuffer.data);var e=this.m_handleIndexBuffer.data[t];return e||((e=new Nr).SetIndex(t),this.m_handleIndexBuffer.data[t]=e,e)},n.DestroyParticle=function(e,i){void 0===i&&(i=!1);var r=t.b2ParticleFlag.b2_zombieParticle;i&&(r|=t.b2ParticleFlag.b2_destructionListenerParticle),this.SetParticleFlags(e,this.m_flagsBuffer.data[e]|r)},n.DestroyOldestParticle=function(t,e){void 0===e&&(e=!1);var i=this.GetParticleCount(),r=this.m_indexByExpirationTimeBuffer.data[i-(t+1)],n=this.m_indexByExpirationTimeBuffer.data[t];this.DestroyParticle(this.m_expirationTimeBuffer.data[r]>0?r:n,e)},n.DestroyParticlesInShape=function(t,e,i){void 0===i&&(i=!1);var n=r.DestroyParticlesInShape_s_aabb;if(this.m_world.IsLocked())throw new Error;var s=new yn(this,t,e,i),a=n;return t.ComputeAABB(a,e,0),this.m_world.QueryAABB(s,a),s.Destroyed()},n.CreateParticleGroup=function(t){var i=r.CreateParticleGroup_s_transform;if(this.m_world.IsLocked())throw new Error;var n=i;n.SetPositionAngle(e(t.position,z.ZERO),e(t.angle,0));var s=this.m_count;if(t.shape&&this.CreateParticlesWithShapeForGroup(t.shape,t,n),t.shapes&&this.CreateParticlesWithShapesForGroup(t.shapes,e(t.shapeCount,t.shapes.length),t,n),t.positionData)for(var a=e(t.particleCount,t.positionData.length),o=0;o<a;o++){var l=t.positionData[o];this.CreateParticleForGroup(t,n,l)}var h=this.m_count,u=new zr(this);u.m_firstIndex=s,u.m_lastIndex=h,u.m_strength=e(t.strength,1),u.m_userData=t.userData,u.m_transform.Copy(n),u.m_prev=null,u.m_next=this.m_groupList,this.m_groupList&&(this.m_groupList.m_prev=u),this.m_groupList=u,++this.m_groupCount;for(var c=s;c<h;c++)this.m_groupBuffer[c]=u;this.SetGroupFlags(u,e(t.groupFlags,0));var _=new mn;return this.UpdateContacts(!0),this.UpdatePairsAndTriads(s,h,_),t.group&&(this.JoinParticleGroups(t.group,u),u=t.group),u},n.JoinParticleGroups=function(t,e){if(this.m_world.IsLocked())throw new Error;this.RotateBuffer(e.m_firstIndex,e.m_lastIndex,this.m_count),this.RotateBuffer(t.m_firstIndex,t.m_lastIndex,e.m_firstIndex);var i=new gn(e.m_firstIndex);this.UpdateContacts(!0),this.UpdatePairsAndTriads(t.m_firstIndex,e.m_lastIndex,i);for(var r=e.m_firstIndex;r<e.m_lastIndex;r++)this.m_groupBuffer[r]=t;var n=t.m_groupFlags|e.m_groupFlags;this.SetGroupFlags(t,n),t.m_lastIndex=e.m_lastIndex,e.m_firstIndex=e.m_lastIndex,this.DestroyParticleGroup(e)},n.SplitParticleGroup=function(t){this.UpdateContacts(!0);var e=A(t.GetParticleCount(),(function(){return new _n}));r.InitializeParticleLists(t,e),this.MergeParticleListsInContact(t,e);var i=r.FindLongestParticleList(t,e);this.MergeZombieParticleListNodes(t,e,i),this.CreateParticleGroupsFromParticleList(t,e,i),this.UpdatePairsAndTriadsWithParticleList(t,e)},n.GetParticleGroupList=function(){return this.m_groupList},n.GetParticleGroupCount=function(){return this.m_groupCount},n.GetParticleCount=function(){return this.m_count},n.GetMaxParticleCount=function(){return this.m_def.maxCount},n.SetMaxParticleCount=function(t){this.m_def.maxCount=t},n.GetAllParticleFlags=function(){return this.m_allParticleFlags},n.GetAllGroupFlags=function(){return this.m_allGroupFlags},n.SetPaused=function(t){this.m_paused=t},n.GetPaused=function(){return this.m_paused},n.SetDensity=function(t){this.m_def.density=t,this.m_inverseDensity=1/this.m_def.density},n.GetDensity=function(){return this.m_def.density},n.SetGravityScale=function(t){this.m_def.gravityScale=t},n.GetGravityScale=function(){return this.m_def.gravityScale},n.SetDamping=function(t){this.m_def.dampingStrength=t},n.GetDamping=function(){return this.m_def.dampingStrength},n.SetStaticPressureIterations=function(t){this.m_def.staticPressureIterations=t},n.GetStaticPressureIterations=function(){return this.m_def.staticPressureIterations},n.SetRadius=function(t){this.m_particleDiameter=2*t,this.m_squaredDiameter=this.m_particleDiameter*this.m_particleDiameter,this.m_inverseDiameter=1/this.m_particleDiameter},n.GetRadius=function(){return this.m_particleDiameter/2},n.GetPositionBuffer=function(){return this.m_positionBuffer.data},n.GetVelocityBuffer=function(){return this.m_velocityBuffer.data},n.GetColorBuffer=function(){return this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data},n.GetGroupBuffer=function(){return this.m_groupBuffer},n.GetWeightBuffer=function(){return this.m_weightBuffer},n.GetUserDataBuffer=function(){return this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data},n.GetFlagsBuffer=function(){return this.m_flagsBuffer.data},n.SetParticleFlags=function(e,i){this.m_flagsBuffer.data[e]&~i&&(this.m_needsUpdateAllParticleFlags=!0),~this.m_allParticleFlags&i&&(i&t.b2ParticleFlag.b2_tensileParticle&&(this.m_accumulation2Buffer=this.RequestBuffer(this.m_accumulation2Buffer)),i&t.b2ParticleFlag.b2_colorMixingParticle&&(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data)),this.m_allParticleFlags|=i),this.m_flagsBuffer.data[e]=i},n.GetParticleFlags=function(t){return this.m_flagsBuffer.data[t]},n.SetFlagsBuffer=function(t){this.SetUserOverridableBuffer(this.m_flagsBuffer,t)},n.SetPositionBuffer=function(t){if(t instanceof Float32Array){if(t.length%2!=0)throw new Error;for(var e=t.length/2,i=new Array(e),r=0;r<e;++r)i[r]=new z(t.subarray(2*r,2*r+2));t=i}this.SetUserOverridableBuffer(this.m_positionBuffer,t)},n.SetVelocityBuffer=function(t){if(t instanceof Float32Array){if(t.length%2!=0)throw new Error;for(var e=t.length/2,i=new Array(e),r=0;r<e;++r)i[r]=new z(t.subarray(2*r,2*r+2));t=i}this.SetUserOverridableBuffer(this.m_velocityBuffer,t)},n.SetColorBuffer=function(t){if(t instanceof Float32Array){if(t.length%4!=0)throw new Error;for(var e=t.length/4,i=new Array(e),r=0;r<e;++r)i[r]=new K(t.subarray(4*r,4*r+4));t=i}this.SetUserOverridableBuffer(this.m_colorBuffer,t)},n.SetUserDataBuffer=function(t){this.SetUserOverridableBuffer(this.m_userDataBuffer,t)},n.GetContacts=function(){return this.m_contactBuffer.data},n.GetContactCount=function(){return this.m_contactBuffer.count},n.GetBodyContacts=function(){return this.m_bodyContactBuffer.data},n.GetBodyContactCount=function(){return this.m_bodyContactBuffer.count},n.GetPairs=function(){return this.m_pairBuffer.data},n.GetPairCount=function(){return this.m_pairBuffer.count},n.GetTriads=function(){return this.m_triadBuffer.data},n.GetTriadCount=function(){return this.m_triadBuffer.count},n.SetStuckThreshold=function(t){this.m_stuckThreshold=t,t>0&&(this.m_lastBodyContactStepBuffer.data=this.RequestBuffer(this.m_lastBodyContactStepBuffer.data),this.m_bodyContactCountBuffer.data=this.RequestBuffer(this.m_bodyContactCountBuffer.data),this.m_consecutiveContactStepsBuffer.data=this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data))},n.GetStuckCandidates=function(){return this.m_stuckParticleBuffer.Data()},n.GetStuckCandidateCount=function(){return this.m_stuckParticleBuffer.GetCount()},n.ComputeCollisionEnergy=function(){for(var t=r.ComputeCollisionEnergy_s_v,e=this.m_velocityBuffer.data,i=0,n=0;n<this.m_contactBuffer.count;n++){var s=this.m_contactBuffer.data[n],a=s.indexA,o=s.indexB,l=s.normal,h=z.SubVV(e[o],e[a],t),u=z.DotVV(h,l);u<0&&(i+=u*u)}return.5*this.GetParticleMass()*i},n.SetStrictContactCheck=function(t){this.m_def.strictContactCheck=t},n.GetStrictContactCheck=function(){return this.m_def.strictContactCheck},n.SetParticleLifetime=function(t,e){var i=null===this.m_indexByExpirationTimeBuffer.data;if(this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),i)for(var r=this.GetParticleCount(),n=0;n<r;++n)this.m_indexByExpirationTimeBuffer.data[n]=n;var s=e/this.m_def.lifetimeGranularity,a=s>0?this.GetQuantizedTimeElapsed()+s:s;a!==this.m_expirationTimeBuffer.data[t]&&(this.m_expirationTimeBuffer.data[t]=a,this.m_expirationTimeBufferRequiresSorting=!0)},n.GetParticleLifetime=function(t){return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t])},n.SetDestructionByAge=function(t){t&&this.GetExpirationTimeBuffer(),this.m_def.destroyByAge=t},n.GetDestructionByAge=function(){return this.m_def.destroyByAge},n.GetExpirationTimeBuffer=function(){return this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_expirationTimeBuffer.data},n.ExpirationTimeToLifetime=function(t){return(t>0?t-this.GetQuantizedTimeElapsed():t)*this.m_def.lifetimeGranularity},n.GetIndexByExpirationTimeBuffer=function(){return this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),this.m_indexByExpirationTimeBuffer.data},n.ParticleApplyLinearImpulse=function(t,e){this.ApplyLinearImpulse(t,t+1,e)},n.ApplyLinearImpulse=function(t,e,i){for(var r=this.m_velocityBuffer.data,n=(e-t)*this.GetParticleMass(),s=(new z).Copy(i).SelfMul(1/n),a=t;a<e;a++)r[a].SelfAdd(s)},r.IsSignificantForce=function(t){return 0!==t.x||0!==t.y},n.ParticleApplyForce=function(t,e){r.IsSignificantForce(e)&&this.ForceCanBeApplied(this.m_flagsBuffer.data[t])&&(this.PrepareForceBuffer(),this.m_forceBuffer[t].SelfAdd(e))},n.ApplyForce=function(t,e,i){var n=(new z).Copy(i).SelfMul(1/(e-t));if(r.IsSignificantForce(n)){this.PrepareForceBuffer();for(var s=t;s<e;s++)this.m_forceBuffer[s].SelfAdd(n)}},n.GetNext=function(){return this.m_next},n.QueryAABB=function(t,e){if(0!==this.m_proxyBuffer.count)for(var i=this.m_proxyBuffer.count,n=Zr(this.m_proxyBuffer.data,0,i,r.computeTag(this.m_inverseDiameter*e.lowerBound.x,this.m_inverseDiameter*e.lowerBound.y),un.CompareProxyTag),s=Qr(this.m_proxyBuffer.data,n,i,r.computeTag(this.m_inverseDiameter*e.upperBound.x,this.m_inverseDiameter*e.upperBound.y),un.CompareTagProxy),a=this.m_positionBuffer.data,o=n;o<s;++o){var l=this.m_proxyBuffer.data[o].index,h=a[l];if(e.lowerBound.x<h.x&&h.x<e.upperBound.x&&e.lowerBound.y<h.y&&h.y<e.upperBound.y&&!t.ReportParticle(this,l))break}},n.QueryShapeAABB=function(t,e,i,n){void 0===n&&(n=0);var s=r.QueryShapeAABB_s_aabb;e.ComputeAABB(s,i,n),this.QueryAABB(t,s)},n.QueryPointAABB=function(t,e,i){void 0===i&&(i=o);var n=r.QueryPointAABB_s_aabb;n.lowerBound.Set(e.x-i,e.y-i),n.upperBound.Set(e.x+i,e.y+i),this.QueryAABB(t,n)},n.RayCast=function(t,e,i){var n=r.RayCast_s_aabb,s=r.RayCast_s_p,a=r.RayCast_s_v,o=r.RayCast_s_n,l=r.RayCast_s_point;if(0!==this.m_proxyBuffer.count){var h=this.m_positionBuffer.data,u=n;z.MinV(e,i,u.lowerBound),z.MaxV(e,i,u.upperBound);for(var c,_=1,f=z.SubVV(i,e,a),p=z.DotVV(f,f),d=this.GetInsideBoundsEnumerator(u);(c=d.GetNext())>=0;){var m=z.SubVV(e,h[c],s),y=z.DotVV(m,f),g=y*y-p*(z.DotVV(m,m)-this.m_squaredDiameter);if(g>=0){var v=O(g),b=(-y-v)/p;if(b>_)continue;if(b<0&&((b=(-y+v)/p)<0||b>_))continue;var S=z.AddVMulSV(m,b,f,o);if(S.Normalize(),(_=B(_,t.ReportParticle(this,c,z.AddVMulSV(e,b,f,l),S,b)))<=0)break}}}},n.ComputeAABB=function(t){var e=this.GetParticleCount();t.lowerBound.x=+i,t.lowerBound.y=+i,t.upperBound.x=-i,t.upperBound.y=-i;for(var r=this.m_positionBuffer.data,n=0;n<e;n++){var s=r[n];z.MinV(t.lowerBound,s,t.lowerBound),z.MaxV(t.upperBound,s,t.upperBound)}t.lowerBound.x-=this.m_particleDiameter,t.lowerBound.y-=this.m_particleDiameter,t.upperBound.x+=this.m_particleDiameter,t.upperBound.y+=this.m_particleDiameter},n.FreeBuffer=function(t){null!==t&&(t.length=0)},n.FreeUserOverridableBuffer=function(t){0===t.userSuppliedCapacity&&this.FreeBuffer(t.data,this.m_internalAllocatedCapacity)},n.ReallocateBuffer3=function(t,e,i){if(i<=e)throw new Error;var r=t?t.slice():[];return r.length=i,r},n.ReallocateBuffer5=function(t,e,i,r,n){if(r<=i)throw new Error;if(e&&!(r<=e))throw new Error;return n&&!t||e||(t=this.ReallocateBuffer3(t,i,r)),t},n.ReallocateBuffer4=function(t,e,i,r){return this.ReallocateBuffer5(t.data,t.userSuppliedCapacity,e,i,r)},n.RequestBuffer=function(t){return t||(0===this.m_internalAllocatedCapacity&&this.ReallocateInternalAllocatedBuffers(y),(t=[]).length=this.m_internalAllocatedCapacity),t},n.ReallocateHandleBuffers=function(t){this.m_handleIndexBuffer.data=this.ReallocateBuffer4(this.m_handleIndexBuffer,this.m_internalAllocatedCapacity,t,!0)},n.ReallocateInternalAllocatedBuffers=function(t){function e(t,e){return e&&t>e?e:t}if(t=e(t,this.m_def.maxCount),t=e(t,this.m_flagsBuffer.userSuppliedCapacity),t=e(t,this.m_positionBuffer.userSuppliedCapacity),t=e(t,this.m_velocityBuffer.userSuppliedCapacity),t=e(t,this.m_colorBuffer.userSuppliedCapacity),t=e(t,this.m_userDataBuffer.userSuppliedCapacity),this.m_internalAllocatedCapacity<t){this.ReallocateHandleBuffers(t),this.m_flagsBuffer.data=this.ReallocateBuffer4(this.m_flagsBuffer,this.m_internalAllocatedCapacity,t,!1);var i=this.m_stuckThreshold>0;this.m_lastBodyContactStepBuffer.data=this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer,this.m_internalAllocatedCapacity,t,i),this.m_bodyContactCountBuffer.data=this.ReallocateBuffer4(this.m_bodyContactCountBuffer,this.m_internalAllocatedCapacity,t,i),this.m_consecutiveContactStepsBuffer.data=this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer,this.m_internalAllocatedCapacity,t,i),this.m_positionBuffer.data=this.ReallocateBuffer4(this.m_positionBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_velocityBuffer.data=this.ReallocateBuffer4(this.m_velocityBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_forceBuffer=this.ReallocateBuffer5(this.m_forceBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_weightBuffer=this.ReallocateBuffer5(this.m_weightBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_staticPressureBuffer=this.ReallocateBuffer5(this.m_staticPressureBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_accumulationBuffer=this.ReallocateBuffer5(this.m_accumulationBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_accumulation2Buffer=this.ReallocateBuffer5(this.m_accumulation2Buffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_depthBuffer=this.ReallocateBuffer5(this.m_depthBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_colorBuffer.data=this.ReallocateBuffer4(this.m_colorBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_groupBuffer=this.ReallocateBuffer5(this.m_groupBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_userDataBuffer.data=this.ReallocateBuffer4(this.m_userDataBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_expirationTimeBuffer.data=this.ReallocateBuffer4(this.m_expirationTimeBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_indexByExpirationTimeBuffer.data=this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_internalAllocatedCapacity=t}},n.CreateParticleForGroup=function(t,i,r){var n=new Lr;n.flags=e(t.flags,0),Y.MulXV(i,r,n.position),z.AddVV(e(t.linearVelocity,z.ZERO),z.CrossSV(e(t.angularVelocity,0),z.SubVV(n.position,e(t.position,z.ZERO),z.s_t0),z.s_t0),n.velocity),n.color.Copy(e(t.color,K.ZERO)),n.lifetime=e(t.lifetime,0),n.userData=t.userData,this.CreateParticle(n)},n.CreateParticlesStrokeShapeForGroup=function(i,n,s){var a=r.CreateParticlesStrokeShapeForGroup_s_edge,o=r.CreateParticlesStrokeShapeForGroup_s_d,l=r.CreateParticlesStrokeShapeForGroup_s_p,h=e(n.stride,0);0===h&&(h=this.GetParticleStride());for(var u=0,c=i.GetChildCount(),_=0;_<c;_++){var f=null;i.GetType()===t.b2ShapeType.e_edgeShape?f=i:(f=a,i.GetChildEdge(f,_));for(var p=z.SubVV(f.m_vertex2,f.m_vertex1,o),d=p.Length();u<d;){var m=z.AddVMulSV(f.m_vertex1,u/d,p,l);this.CreateParticleForGroup(n,s,m),u+=h}u-=d}},n.CreateParticlesFillShapeForGroup=function(t,i,n){var s=r.CreateParticlesFillShapeForGroup_s_aabb,a=r.CreateParticlesFillShapeForGroup_s_p,o=e(i.stride,0);0===o&&(o=this.GetParticleStride());var l=Y.IDENTITY,h=s;t.ComputeAABB(h,l,0);for(var u=Math.floor(h.lowerBound.y/o)*o;u<h.upperBound.y;u+=o)for(var c=Math.floor(h.lowerBound.x/o)*o;c<h.upperBound.x;c+=o){var _=a.Set(c,u);t.TestPoint(l,_)&&this.CreateParticleForGroup(i,n,_)}},n.CreateParticlesWithShapeForGroup=function(e,i,r){switch(e.GetType()){case t.b2ShapeType.e_edgeShape:case t.b2ShapeType.e_chainShape:this.CreateParticlesStrokeShapeForGroup(e,i,r);break;case t.b2ShapeType.e_polygonShape:case t.b2ShapeType.e_circleShape:this.CreateParticlesFillShapeForGroup(e,i,r)}},n.CreateParticlesWithShapesForGroup=function(t,e,i,r){var n=new vn(t,e);this.CreateParticlesFillShapeForGroup(n,i,r)},n.CloneParticle=function(t,e){var i=new Lr;i.flags=this.m_flagsBuffer.data[t],i.position.Copy(this.m_positionBuffer.data[t]),i.velocity.Copy(this.m_velocityBuffer.data[t]),this.m_colorBuffer.data&&i.color.Copy(this.m_colorBuffer.data[t]),this.m_userDataBuffer.data&&(i.userData=this.m_userDataBuffer.data[t]),i.group=e;var r=this.CreateParticle(i);if(this.m_handleIndexBuffer.data){var n=this.m_handleIndexBuffer.data[t];n&&n.SetIndex(r),this.m_handleIndexBuffer.data[r]=n,this.m_handleIndexBuffer.data[t]=null}return this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[r]=this.m_lastBodyContactStepBuffer.data[t]),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[r]=this.m_bodyContactCountBuffer.data[t]),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[r]=this.m_consecutiveContactStepsBuffer.data[t]),this.m_hasForce&&this.m_forceBuffer[r].Copy(this.m_forceBuffer[t]),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[r]=this.m_staticPressureBuffer[t]),this.m_depthBuffer&&(this.m_depthBuffer[r]=this.m_depthBuffer[t]),this.m_expirationTimeBuffer.data&&(this.m_expirationTimeBuffer.data[r]=this.m_expirationTimeBuffer.data[t]),r},n.DestroyParticlesInGroup=function(t,e){void 0===e&&(e=!1);for(var i=t.m_firstIndex;i<t.m_lastIndex;i++)this.DestroyParticle(i,e)},n.DestroyParticleGroup=function(t){this.m_world.m_destructionListener&&this.m_world.m_destructionListener.SayGoodbyeParticleGroup(t),this.SetGroupFlags(t,0);for(var e=t.m_firstIndex;e<t.m_lastIndex;e++)this.m_groupBuffer[e]=null;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_groupList&&(this.m_groupList=t.m_next),--this.m_groupCount},r.ParticleCanBeConnected=function(e,i){return 0!=(e&(t.b2ParticleFlag.b2_wallParticle|t.b2ParticleFlag.b2_springParticle|t.b2ParticleFlag.b2_elasticParticle))||null!==i&&0!=(i.GetGroupFlags()&t.b2ParticleGroupFlag.b2_rigidParticleGroup)},n.UpdatePairsAndTriads=function(e,i,n){for(var s=r.UpdatePairsAndTriads_s_dab,a=r.UpdatePairsAndTriads_s_dbc,o=r.UpdatePairsAndTriads_s_dca,l=this.m_positionBuffer.data,h=0,u=e;u<i;u++)h|=this.m_flagsBuffer.data[u];if(h&r.k_pairFlags)for(var c=0;c<this.m_contactBuffer.count;c++){var _=this.m_contactBuffer.data[c],f=_.indexA,p=_.indexB,d=this.m_flagsBuffer.data[f],m=this.m_flagsBuffer.data[p],y=this.m_groupBuffer[f],g=this.m_groupBuffer[p];if(f>=e&&f<i&&p>=e&&p<i&&!((d|m)&t.b2ParticleFlag.b2_zombieParticle)&&(d|m)&r.k_pairFlags&&(n.IsNecessary(f)||n.IsNecessary(p))&&r.ParticleCanBeConnected(d,y)&&r.ParticleCanBeConnected(m,g)&&n.ShouldCreatePair(f,p)){var v=this.m_pairBuffer.data[this.m_pairBuffer.Append()];v.indexA=f,v.indexB=p,v.flags=_.flags,v.strength=B(y?y.m_strength:1,g?g.m_strength:1),v.distance=z.DistanceVV(l[f],l[p])}Jr(this.m_pairBuffer.data,0,this.m_pairBuffer.count,r.ComparePairIndices),this.m_pairBuffer.Unique(r.MatchPairIndices)}if(h&r.k_triadFlags){for(var b=new Hr(i-e),S=e;S<i;S++){var A=this.m_flagsBuffer.data[S],C=this.m_groupBuffer[S];A&t.b2ParticleFlag.b2_zombieParticle||!r.ParticleCanBeConnected(A,C)||b.AddGenerator(l[S],S,n.IsNecessary(S))}var x=this.GetParticleStride();b.Generate(x/2,2*x);var T=this;b.GetNodes((function(t,e,i){var h=T.m_flagsBuffer.data[t],u=T.m_flagsBuffer.data[e],c=T.m_flagsBuffer.data[i];if((h|u|c)&r.k_triadFlags&&n.ShouldCreateTriad(t,e,i)){var _=l[t],f=l[e],p=l[i],d=z.SubVV(_,f,s),m=z.SubVV(f,p,a),y=z.SubVV(p,_,o),g=4*T.m_squaredDiameter;if(z.DotVV(d,d)>g||z.DotVV(m,m)>g||z.DotVV(y,y)>g)return;var v=T.m_groupBuffer[t],b=T.m_groupBuffer[e],S=T.m_groupBuffer[i],A=T.m_triadBuffer.data[T.m_triadBuffer.Append()];A.indexA=t,A.indexB=e,A.indexC=i,A.flags=h|u|c,A.strength=B(B(v?v.m_strength:1,b?b.m_strength:1),S?S.m_strength:1);var C=(_.x+f.x+p.x)/3,x=(_.y+f.y+p.y)/3;A.pa.x=_.x-C,A.pa.y=_.y-x,A.pb.x=f.x-C,A.pb.y=f.y-x,A.pc.x=p.x-C,A.pc.y=p.y-x,A.ka=-z.DotVV(y,d),A.kb=-z.DotVV(d,m),A.kc=-z.DotVV(m,y),A.s=z.CrossVV(_,f)+z.CrossVV(f,p)+z.CrossVV(p,_)}})),Jr(this.m_triadBuffer.data,0,this.m_triadBuffer.count,r.CompareTriadIndices),this.m_triadBuffer.Unique(r.MatchTriadIndices)}},n.UpdatePairsAndTriadsWithReactiveParticles=function(){var e=new bn(this.m_flagsBuffer);this.UpdatePairsAndTriads(0,this.m_count,e);for(var i=0;i<this.m_count;i++)this.m_flagsBuffer.data[i]&=~t.b2ParticleFlag.b2_reactiveParticle;this.m_allParticleFlags&=~t.b2ParticleFlag.b2_reactiveParticle},r.ComparePairIndices=function(t,e){var i=t.indexA-e.indexA;return 0!==i?i<0:t.indexB<e.indexB},r.MatchPairIndices=function(t,e){return t.indexA===e.indexA&&t.indexB===e.indexB},r.CompareTriadIndices=function(t,e){var i=t.indexA-e.indexA;if(0!==i)return i<0;var r=t.indexB-e.indexB;return 0!==r?r<0:t.indexC<e.indexC},r.MatchTriadIndices=function(t,e){return t.indexA===e.indexA&&t.indexB===e.indexB&&t.indexC===e.indexC},r.InitializeParticleLists=function(t,e){for(var i=t.GetBufferIndex(),r=t.GetParticleCount(),n=0;n<r;n++){var s=e[n];s.list=s,s.next=null,s.count=1,s.index=n+i}},n.MergeParticleListsInContact=function(t,e){for(var i=t.GetBufferIndex(),n=0;n<this.m_contactBuffer.count;n++){var s=this.m_contactBuffer.data[n],a=s.indexA,o=s.indexB;if(t.ContainsParticle(a)&&t.ContainsParticle(o)){var l=e[a-i].list,h=e[o-i].list;if(l!==h){if(l.count<h.count){var u=l;l=h,h=u}r.MergeParticleLists(l,h)}}}},r.MergeParticleLists=function(t,e){for(var i=e;;){i.list=t;var r=i.next;if(!r){i.next=t.next;break}i=r}t.next=e,t.count+=e.count,e.count=0},r.FindLongestParticleList=function(t,e){for(var i=t.GetParticleCount(),r=e[0],n=0;n<i;n++){var s=e[n];r.count<s.count&&(r=s)}return r},n.MergeZombieParticleListNodes=function(e,i,n){for(var s=e.GetParticleCount(),a=0;a<s;a++){var o=i[a];o!==n&&this.m_flagsBuffer.data[o.index]&t.b2ParticleFlag.b2_zombieParticle&&r.MergeParticleListAndNode(n,o)}},r.MergeParticleListAndNode=function(t,e){e.list=t,e.next=t.next,t.next=e,t.count++,e.count=0},n.CreateParticleGroupsFromParticleList=function(e,i,r){var n=e.GetParticleCount(),s=new Gr;s.groupFlags=e.GetGroupFlags(),s.userData=e.GetUserData();for(var a=0;a<n;a++){var o=i[a];if(o.count&&o!==r)for(var l=this.CreateParticleGroup(s),h=o;h;h=h.next){var u=h.index,c=this.CloneParticle(u,l);this.m_flagsBuffer.data[u]|=t.b2ParticleFlag.b2_zombieParticle,h.index=c}}},n.UpdatePairsAndTriadsWithParticleList=function(t,e){for(var i=t.GetBufferIndex(),r=0;r<this.m_pairBuffer.count;r++){var n=this.m_pairBuffer.data[r],s=n.indexA,a=n.indexB;t.ContainsParticle(s)&&(n.indexA=e[s-i].index),t.ContainsParticle(a)&&(n.indexB=e[a-i].index)}for(var o=0;o<this.m_triadBuffer.count;o++){var l=this.m_triadBuffer.data[o],h=l.indexA,u=l.indexB,c=l.indexC;t.ContainsParticle(h)&&(l.indexA=e[h-i].index),t.ContainsParticle(u)&&(l.indexB=e[u-i].index),t.ContainsParticle(c)&&(l.indexC=e[c-i].index)}},n.ComputeDepth=function(){for(var e=[],r=0,n=0;n<this.m_contactBuffer.count;n++){var s=this.m_contactBuffer.data[n],a=s.indexA,o=s.indexB,l=this.m_groupBuffer[a],h=this.m_groupBuffer[o];l&&l===h&&l.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth&&(e[r++]=s)}for(var u=[],c=0,_=this.m_groupList;_;_=_.GetNext())if(_.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth){u[c++]=_,this.SetGroupFlags(_,_.m_groupFlags&~t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth);for(var f=_.m_firstIndex;f<_.m_lastIndex;f++)this.m_accumulationBuffer[f]=0}for(var p=0;p<r;p++){var d=e[p],m=d.indexA,y=d.indexB,g=d.weight;this.m_accumulationBuffer[m]+=g,this.m_accumulationBuffer[y]+=g}for(var v=0;v<c;v++)for(var b=u[v],S=b.m_firstIndex;S<b.m_lastIndex;S++){var A=this.m_accumulationBuffer[S];this.m_depthBuffer[S]=A<.8?0:i}for(var C=O(this.m_count)>>0,x=0;x<C;x++){for(var T=!1,w=0;w<r;w++){var E=e[w],B=E.indexA,D=E.indexB,M=1-E.weight,P=this.m_depthBuffer[B],R=this.m_depthBuffer[D],I=R+M,F=P+M;P>I&&(this.m_depthBuffer[B]=I,T=!0),R>F&&(this.m_depthBuffer[D]=F,T=!0)}if(!T)break}for(var L=0;L<c;L++)for(var V=u[L],k=V.m_firstIndex;k<V.m_lastIndex;k++)this.m_depthBuffer[k]<i?this.m_depthBuffer[k]*=this.m_particleDiameter:this.m_depthBuffer[k]=0},n.GetInsideBoundsEnumerator=function(t){var e=r.computeTag(this.m_inverseDiameter*t.lowerBound.x-1,this.m_inverseDiameter*t.lowerBound.y-1),i=r.computeTag(this.m_inverseDiameter*t.upperBound.x+1,this.m_inverseDiameter*t.upperBound.y+1),n=this.m_proxyBuffer.count,s=Zr(this.m_proxyBuffer.data,0,n,e,un.CompareProxyTag),a=Qr(this.m_proxyBuffer.data,0,n,i,un.CompareTagProxy);return new cn(this,e,i,s,a)},n.UpdateAllParticleFlags=function(){this.m_allParticleFlags=0;for(var t=0;t<this.m_count;t++)this.m_allParticleFlags|=this.m_flagsBuffer.data[t];this.m_needsUpdateAllParticleFlags=!1},n.UpdateAllGroupFlags=function(){this.m_allGroupFlags=0;for(var t=this.m_groupList;t;t=t.GetNext())this.m_allGroupFlags|=t.m_groupFlags;this.m_needsUpdateAllGroupFlags=!1},n.AddContact=function(t,e){var i=this.m_flagsBuffer.data,n=this.m_positionBuffer.data,s=z.SubVV(n[e],n[t],r.AddContact_s_d),a=z.DotVV(s,s);if(0<a&&a<this.m_squaredDiameter){var o=I(a),l=this.m_contactBuffer.data[this.m_contactBuffer.Append()];l.indexA=t,l.indexB=e,l.flags=i[t]|i[e],l.weight=1-a*o*this.m_inverseDiameter,l.normal.x=o*s.x,l.normal.y=o*s.y}},n.FindContacts_Reference=function(){var t=this.m_proxyBuffer.count;this.m_contactBuffer.count=0;for(var e=0,i=0;e<t;e++){for(var n=r.computeRelativeTag(this.m_proxyBuffer.data[e].tag,1,0),s=e+1;s<t&&!(n<this.m_proxyBuffer.data[s].tag);s++)this.AddContact(this.m_proxyBuffer.data[e].index,this.m_proxyBuffer.data[s].index,this.m_contactBuffer);for(var a=r.computeRelativeTag(this.m_proxyBuffer.data[e].tag,-1,1);i<t&&!(a<=this.m_proxyBuffer.data[i].tag);i++);for(var o=r.computeRelativeTag(this.m_proxyBuffer.data[e].tag,1,1),l=i;l<t&&!(o<this.m_proxyBuffer.data[l].tag);l++)this.AddContact(this.m_proxyBuffer.data[e].index,this.m_proxyBuffer.data[l].index,this.m_contactBuffer)}},n.FindContacts=function(t){this.FindContacts_Reference(t)},n.UpdateProxies_Reference=function(){for(var t=this.m_positionBuffer.data,e=this.m_inverseDiameter,i=0;i<this.m_proxyBuffer.count;++i){var n=this.m_proxyBuffer.data[i],s=t[n.index];n.tag=r.computeTag(e*s.x,e*s.y)}},n.UpdateProxies=function(t){this.UpdateProxies_Reference(t)},n.SortProxies=function(){qr(this.m_proxyBuffer.data,0,this.m_proxyBuffer.count,un.CompareProxyProxy)},n.FilterContacts=function(){var e=this.GetParticleContactFilter();if(null!==e){var i=this;this.m_contactBuffer.RemoveIf((function(r){return 0!=(r.flags&t.b2ParticleFlag.b2_particleContactFilterParticle)&&!e.ShouldCollideParticleParticle(i,r.indexA,r.indexB)}))}},n.NotifyContactListenerPreContact=function(t){if(null!==this.GetParticleContactListener())throw t.Initialize(this.m_contactBuffer,this.m_flagsBuffer),new Error},n.NotifyContactListenerPostContact=function(){var t=this.GetParticleContactListener();if(null!==t){for(var e=0;e<this.m_contactBuffer.count;++e){var i=this.m_contactBuffer.data[e];t.BeginContactParticleParticle(this,i)}throw new Error}},r.b2ParticleContactIsZombie=function(e){return(e.flags&t.b2ParticleFlag.b2_zombieParticle)===t.b2ParticleFlag.b2_zombieParticle},n.UpdateContacts=function(t){this.UpdateProxies(this.m_proxyBuffer),this.SortProxies(this.m_proxyBuffer);var e=new dn;this.NotifyContactListenerPreContact(e),this.FindContacts(this.m_contactBuffer),this.FilterContacts(this.m_contactBuffer),this.NotifyContactListenerPostContact(e),t&&this.m_contactBuffer.RemoveIf(r.b2ParticleContactIsZombie)},n.NotifyBodyContactListenerPreContact=function(t){if(null!==this.GetFixtureContactListener())throw t.Initialize(this.m_bodyContactBuffer,this.m_flagsBuffer),new Error},n.NotifyBodyContactListenerPostContact=function(){var t=this.GetFixtureContactListener();if(null!==t){for(var e=0;e<this.m_bodyContactBuffer.count;e++){var i=this.m_bodyContactBuffer.data[e];t.BeginContactFixtureParticle(this,i)}throw new Error}},n.UpdateBodyContacts=function(){var t=r.UpdateBodyContacts_s_aabb,e=new pn;if(this.NotifyBodyContactListenerPreContact(e),this.m_stuckThreshold>0)for(var i=this.GetParticleCount(),n=0;n<i;n++)this.m_bodyContactCountBuffer.data[n]=0,this.m_timestamp>this.m_lastBodyContactStepBuffer.data[n]+1&&(this.m_consecutiveContactStepsBuffer.data[n]=0);this.m_bodyContactBuffer.SetCount(0),this.m_stuckParticleBuffer.SetCount(0);var s=t;this.ComputeAABB(s),null===this.UpdateBodyContacts_callback&&(this.UpdateBodyContacts_callback=new Sn(this));var a=this.UpdateBodyContacts_callback;a.m_contactFilter=this.GetFixtureContactFilter(),this.m_world.QueryAABB(a,s),this.m_def.strictContactCheck&&this.RemoveSpuriousBodyContacts(),this.NotifyBodyContactListenerPostContact(e)},n.Solve=function(e){var i=r.Solve_s_subStep;if(0!==this.m_count&&(this.m_expirationTimeBuffer.data&&this.SolveLifetimes(e),this.m_allParticleFlags&t.b2ParticleFlag.b2_zombieParticle&&this.SolveZombie(),this.m_needsUpdateAllParticleFlags&&this.UpdateAllParticleFlags(),this.m_needsUpdateAllGroupFlags&&this.UpdateAllGroupFlags(),!this.m_paused))for(this.m_iterationIndex=0;this.m_iterationIndex<e.particleIterations;this.m_iterationIndex++){++this.m_timestamp;var n=i.Copy(e);n.dt/=e.particleIterations,n.inv_dt*=e.particleIterations,this.UpdateContacts(!1),this.UpdateBodyContacts(),this.ComputeWeight(),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth&&this.ComputeDepth(),this.m_allParticleFlags&t.b2ParticleFlag.b2_reactiveParticle&&this.UpdatePairsAndTriadsWithReactiveParticles(),this.m_hasForce&&this.SolveForce(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_viscousParticle&&this.SolveViscous(),this.m_allParticleFlags&t.b2ParticleFlag.b2_repulsiveParticle&&this.SolveRepulsive(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_powderParticle&&this.SolvePowder(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_tensileParticle&&this.SolveTensile(n),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SolveSolid(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_colorMixingParticle&&this.SolveColorMixing(),this.SolveGravity(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_staticPressureParticle&&this.SolveStaticPressure(n),this.SolvePressure(n),this.SolveDamping(n),this.m_allParticleFlags&r.k_extraDampingFlags&&this.SolveExtraDamping(),this.m_allParticleFlags&t.b2ParticleFlag.b2_elasticParticle&&this.SolveElastic(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_springParticle&&this.SolveSpring(n),this.LimitVelocity(n),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup&&this.SolveRigidDamping(),this.m_allParticleFlags&t.b2ParticleFlag.b2_barrierParticle&&this.SolveBarrier(n),this.SolveCollision(n),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup&&this.SolveRigid(n),this.m_allParticleFlags&t.b2ParticleFlag.b2_wallParticle&&this.SolveWall();for(var s=0;s<this.m_count;s++)this.m_positionBuffer.data[s].SelfMulAdd(n.dt,this.m_velocityBuffer.data[s])}},n.SolveCollision=function(t){var e=r.SolveCollision_s_aabb,n=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,a=e;a.lowerBound.x=+i,a.lowerBound.y=+i,a.upperBound.x=-i,a.upperBound.y=-i;for(var o=0;o<this.m_count;o++){var l=s[o],h=n[o],u=h.x+t.dt*l.x,c=h.y+t.dt*l.y;a.lowerBound.x=B(a.lowerBound.x,B(h.x,u)),a.lowerBound.y=B(a.lowerBound.y,B(h.y,c)),a.upperBound.x=D(a.upperBound.x,D(h.x,u)),a.upperBound.y=D(a.upperBound.y,D(h.y,c))}null===this.SolveCollision_callback&&(this.SolveCollision_callback=new An(this,t));var _=this.SolveCollision_callback;_.m_step=t,this.m_world.QueryAABB(_,a)},n.LimitVelocity=function(t){for(var e=this.m_velocityBuffer.data,i=this.GetCriticalVelocitySquared(t),r=0;r<this.m_count;r++){var n=e[r],s=z.DotVV(n,n);s>i&&n.SelfMul(O(i/s))}},n.SolveGravity=function(t){for(var e=r.SolveGravity_s_gravity,i=this.m_velocityBuffer.data,n=z.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s<this.m_count;s++)i[s].SelfAdd(n)},n.SolveBarrier=function(e){for(var i=r.SolveBarrier_s_aabb,n=r.SolveBarrier_s_va,s=r.SolveBarrier_s_vb,a=r.SolveBarrier_s_pba,o=r.SolveBarrier_s_vba,l=r.SolveBarrier_s_vc,h=r.SolveBarrier_s_pca,u=r.SolveBarrier_s_vca,c=r.SolveBarrier_s_qba,_=r.SolveBarrier_s_qca,f=r.SolveBarrier_s_dv,p=r.SolveBarrier_s_f,d=this.m_positionBuffer.data,m=this.m_velocityBuffer.data,y=0;y<this.m_count;y++)0!=(this.m_flagsBuffer.data[y]&r.k_barrierWallFlags)&&m[y].SetZero();for(var g=2.5*e.dt,v=this.GetParticleMass(),b=0;b<this.m_pairBuffer.count;b++){var S=this.m_pairBuffer.data[b];if(S.flags&t.b2ParticleFlag.b2_barrierParticle){var A=S.indexA,C=S.indexB,x=d[A],T=d[C],w=i;z.MinV(x,T,w.lowerBound),z.MaxV(x,T,w.upperBound);for(var E=this.m_groupBuffer[A],B=this.m_groupBuffer[C],D=this.GetLinearVelocity(E,A,x,n),M=this.GetLinearVelocity(B,C,T,s),P=z.SubVV(T,x,a),R=z.SubVV(M,D,o),I=this.GetInsideBoundsEnumerator(w),F=void 0;(F=I.GetNext())>=0;){var L=d[F],V=this.m_groupBuffer[F];if(E!==V&&B!==V){var k=this.GetLinearVelocity(V,F,L,l),N=z.SubVV(L,x,h),G=z.SubVV(k,D,u),U=z.CrossVV(R,G),H=z.CrossVV(P,G)-z.CrossVV(N,R),j=z.CrossVV(P,N),W=void 0,X=void 0,Y=c,q=_;if(0===U){if(0===H)continue;if(!((X=-j/H)>=0&&X<g))continue;if(z.AddVMulSV(P,X,R,Y),z.AddVMulSV(N,X,G,q),!((W=z.DotVV(Y,q)/z.DotVV(Y,Y))>=0&&W<=1))continue}else{var J=H*H-4*j*U;if(J<0)continue;var K=O(J),Z=(-H-K)/(2*U),Q=(-H+K)/(2*U);if(Z>Q){var $=Z;Z=Q,Q=$}if(X=Z,z.AddVMulSV(P,X,R,Y),z.AddVMulSV(N,X,G,q),W=z.DotVV(Y,q)/z.DotVV(Y,Y),!(X>=0&&X<g&&W>=0&&W<=1)){if(!((X=Q)>=0&&X<g))continue;if(z.AddVMulSV(P,X,R,Y),z.AddVMulSV(N,X,G,q),!((W=z.DotVV(Y,q)/z.DotVV(Y,Y))>=0&&W<=1))continue}}var tt=f;tt.x=D.x+W*R.x-k.x,tt.y=D.y+W*R.y-k.y;var et=z.MulSV(v,tt,p);if(V&&this.IsRigidGroup(V)){var it=V.GetMass(),rt=V.GetInertia();it>0&&V.m_linearVelocity.SelfMulAdd(1/it,et),rt>0&&(V.m_angularVelocity+=z.CrossVV(z.SubVV(L,V.GetCenter(),z.s_t0),et)/rt)}else m[F].SelfAdd(tt);this.ParticleApplyForce(F,et.SelfMul(-e.inv_dt))}}}}},n.SolveStaticPressure=function(e){this.m_staticPressureBuffer=this.RequestBuffer(this.m_staticPressureBuffer);for(var i=this.GetCriticalPressure(e),r=this.m_def.staticPressureStrength*i,n=m*i,s=this.m_def.staticPressureRelaxation,a=0;a<this.m_def.staticPressureIterations;a++){for(var o=0;o<this.m_count;o++)this.m_accumulationBuffer[o]=0;for(var l=0;l<this.m_contactBuffer.count;l++){var h=this.m_contactBuffer.data[l];if(h.flags&t.b2ParticleFlag.b2_staticPressureParticle){var u=h.indexA,c=h.indexB,_=h.weight;this.m_accumulationBuffer[u]+=_*this.m_staticPressureBuffer[c],this.m_accumulationBuffer[c]+=_*this.m_staticPressureBuffer[u]}}for(var f=0;f<this.m_count;f++){var p=this.m_weightBuffer[f];if(this.m_flagsBuffer.data[f]&t.b2ParticleFlag.b2_staticPressureParticle){var d=(this.m_accumulationBuffer[f]+r*(p-1))/(p+s);this.m_staticPressureBuffer[f]=M(d,0,n)}else this.m_staticPressureBuffer[f]=0}}},n.ComputeWeight=function(){for(var t=0;t<this.m_count;t++)this.m_weightBuffer[t]=0;for(var e=0;e<this.m_bodyContactBuffer.count;e++){var i=this.m_bodyContactBuffer.data[e],r=i.index,n=i.weight;this.m_weightBuffer[r]+=n}for(var s=0;s<this.m_contactBuffer.count;s++){var a=this.m_contactBuffer.data[s],o=a.indexA,l=a.indexB,h=a.weight;this.m_weightBuffer[o]+=h,this.m_weightBuffer[l]+=h}},n.SolvePressure=function(e){for(var i=r.SolvePressure_s_f,n=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,a=this.GetCriticalPressure(e),o=this.m_def.pressureStrength*a,l=m*a,h=0;h<this.m_count;h++){var u=o*D(0,this.m_weightBuffer[h]-1);this.m_accumulationBuffer[h]=B(u,l)}if(this.m_allParticleFlags&r.k_noPressureFlags)for(var c=0;c<this.m_count;c++)this.m_flagsBuffer.data[c]&r.k_noPressureFlags&&(this.m_accumulationBuffer[c]=0);if(this.m_allParticleFlags&t.b2ParticleFlag.b2_staticPressureParticle)for(var _=0;_<this.m_count;_++)this.m_flagsBuffer.data[_]&t.b2ParticleFlag.b2_staticPressureParticle&&(this.m_accumulationBuffer[_]+=this.m_staticPressureBuffer[_]);for(var f=e.dt/(this.m_def.density*this.m_particleDiameter),p=this.GetParticleInvMass(),d=0;d<this.m_bodyContactBuffer.count;d++){var y=this.m_bodyContactBuffer.data[d],g=y.index,v=y.body,b=y.weight,S=y.mass,A=y.normal,C=n[g],x=this.m_accumulationBuffer[g]+o*b,T=z.MulSV(f*b*S*x,A,i);s[g].SelfMulSub(p,T),v.ApplyLinearImpulse(T,C,!0)}for(var w=0;w<this.m_contactBuffer.count;w++){var E=this.m_contactBuffer.data[w],M=E.indexA,P=E.indexB,R=E.weight,I=E.normal,O=this.m_accumulationBuffer[M]+this.m_accumulationBuffer[P],F=z.MulSV(f*R*O,I,i);s[M].SelfSub(F),s[P].SelfAdd(F)}},n.SolveDamping=function(t){for(var e=r.SolveDamping_s_v,i=r.SolveDamping_s_f,n=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,a=this.m_def.dampingStrength,o=1/this.GetCriticalVelocity(t),l=this.GetParticleInvMass(),h=0;h<this.m_bodyContactBuffer.count;h++){var u=this.m_bodyContactBuffer.data[h],c=u.index,_=u.body,f=u.weight,p=u.mass,d=u.normal,m=n[c],y=z.SubVV(_.GetLinearVelocityFromWorldPoint(m,z.s_t0),s[c],e),g=z.DotVV(y,d);if(g<0){var v=D(a*f,B(-o*g,.5)),b=z.MulSV(v*p*g,d,i);s[c].SelfMulAdd(l,b),_.ApplyLinearImpulse(b.SelfNeg(),m,!0)}}for(var S=0;S<this.m_contactBuffer.count;S++){var A=this.m_contactBuffer.data[S],C=A.indexA,x=A.indexB,T=A.weight,w=A.normal,E=z.SubVV(s[x],s[C],e),M=z.DotVV(E,w);if(M<0){var P=D(a*T,B(-o*M,.5)),R=z.MulSV(P*M,w,i);s[C].SelfAdd(R),s[x].SelfSub(R)}}},n.SolveRigidDamping=function(){for(var t=r.SolveRigidDamping_s_t0,e=r.SolveRigidDamping_s_t1,i=r.SolveRigidDamping_s_p,n=r.SolveRigidDamping_s_v,s=[0],a=[0],o=[0],l=[0],h=[0],u=[0],c=this.m_positionBuffer.data,_=this.m_def.dampingStrength,f=0;f<this.m_bodyContactBuffer.count;f++){var p=this.m_bodyContactBuffer.data[f],d=p.index,m=this.m_groupBuffer[d];if(m&&this.IsRigidGroup(m)){var y=p.body,g=p.normal,v=p.weight,b=c[d],S=z.SubVV(y.GetLinearVelocityFromWorldPoint(b,t),m.GetLinearVelocityFromWorldPoint(b,e),n),A=z.DotVV(S,g);if(A<0){this.InitDampingParameterWithRigidGroupOrParticle(s,a,o,!0,m,d,b,g),this.InitDampingParameter(l,h,u,y.GetMass(),y.GetInertia()-y.GetMass()*y.GetLocalCenter().LengthSquared(),y.GetWorldCenter(),b,g);var C=_*B(v,1)*this.ComputeDampingImpulse(s[0],a[0],o[0],l[0],h[0],u[0],A);this.ApplyDamping(s[0],a[0],o[0],!0,m,d,C,g),y.ApplyLinearImpulse(z.MulSV(-C,g,z.s_t0),b,!0)}}}for(var x=0;x<this.m_contactBuffer.count;x++){var T=this.m_contactBuffer.data[x],w=T.indexA,E=T.indexB,D=T.normal,M=T.weight,P=this.m_groupBuffer[w],R=this.m_groupBuffer[E],I=this.IsRigidGroup(P),O=this.IsRigidGroup(R);if(P!==R&&(I||O)){var F=z.MidVV(c[w],c[E],i),L=z.SubVV(this.GetLinearVelocity(R,E,F,t),this.GetLinearVelocity(P,w,F,e),n),V=z.DotVV(L,D);if(V<0){this.InitDampingParameterWithRigidGroupOrParticle(s,a,o,I,P,w,F,D),this.InitDampingParameterWithRigidGroupOrParticle(l,h,u,O,R,E,F,D);var k=_*M*this.ComputeDampingImpulse(s[0],a[0],o[0],l[0],h[0],u[0],V);this.ApplyDamping(s[0],a[0],o[0],I,P,w,k,D),this.ApplyDamping(l[0],h[0],u[0],O,R,E,-k,D)}}}},n.SolveExtraDamping=function(){for(var t=r.SolveExtraDamping_s_v,e=r.SolveExtraDamping_s_f,i=this.m_velocityBuffer.data,n=this.m_positionBuffer.data,s=this.GetParticleInvMass(),a=0;a<this.m_bodyContactBuffer.count;a++){var o=this.m_bodyContactBuffer.data[a],l=o.index;if(this.m_flagsBuffer.data[l]&r.k_extraDampingFlags){var h=o.body,u=o.mass,c=o.normal,_=n[l],f=z.SubVV(h.GetLinearVelocityFromWorldPoint(_,z.s_t0),i[l],t),p=z.DotVV(f,c);if(p<0){var d=z.MulSV(.5*u*p,c,e);i[l].SelfMulAdd(s,d),h.ApplyLinearImpulse(d.SelfNeg(),_,!0)}}}},n.SolveWall=function(){for(var e=this.m_velocityBuffer.data,i=0;i<this.m_count;i++)this.m_flagsBuffer.data[i]&t.b2ParticleFlag.b2_wallParticle&&e[i].SetZero()},n.SolveRigid=function(e){for(var i=r.SolveRigid_s_position,n=r.SolveRigid_s_rotation,s=r.SolveRigid_s_transform,a=r.SolveRigid_s_velocityTransform,o=this.m_positionBuffer.data,l=this.m_velocityBuffer.data,h=this.m_groupList;h;h=h.GetNext())if(h.m_groupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup){h.UpdateStatistics();var u=n;u.SetAngle(e.dt*h.m_angularVelocity);var c=z.AddVV(h.m_center,z.SubVV(z.MulSV(e.dt,h.m_linearVelocity,z.s_t0),X.MulRV(u,h.m_center,z.s_t1),z.s_t0),i),_=s;_.SetPositionRotation(c,u),Y.MulXX(_,h.m_transform,h.m_transform);var f=a;f.p.x=e.inv_dt*_.p.x,f.p.y=e.inv_dt*_.p.y,f.q.s=e.inv_dt*_.q.s,f.q.c=e.inv_dt*(_.q.c-1);for(var p=h.m_firstIndex;p<h.m_lastIndex;p++)Y.MulXV(f,o[p],l[p])}},n.SolveElastic=function(e){for(var i=r.SolveElastic_s_pa,n=r.SolveElastic_s_pb,s=r.SolveElastic_s_pc,a=r.SolveElastic_s_r,o=r.SolveElastic_s_t0,l=this.m_positionBuffer.data,h=this.m_velocityBuffer.data,u=e.inv_dt*this.m_def.elasticStrength,c=0;c<this.m_triadBuffer.count;c++){var _=this.m_triadBuffer.data[c];if(_.flags&t.b2ParticleFlag.b2_elasticParticle){var f=_.indexA,p=_.indexB,d=_.indexC,m=_.pa,y=_.pb,g=_.pc,v=i.Copy(l[f]),b=n.Copy(l[p]),S=s.Copy(l[d]),A=h[f],C=h[p],x=h[d];v.SelfMulAdd(e.dt,A),b.SelfMulAdd(e.dt,C),S.SelfMulAdd(e.dt,x);var T=(v.x+b.x+S.x)/3,w=(v.y+b.y+S.y)/3;v.x-=T,v.y-=w,b.x-=T,b.y-=w,S.x-=T,S.y-=w;var E=a;E.s=z.CrossVV(m,v)+z.CrossVV(y,b)+z.CrossVV(g,S),E.c=z.DotVV(m,v)+z.DotVV(y,b)+z.DotVV(g,S);var B=I(E.s*E.s+E.c*E.c);isFinite(B)||(B=198177537e11),E.s*=B,E.c*=B;var D=u*_.strength;X.MulRV(E,m,o),z.SubVV(o,v,o),z.MulSV(D,o,o),A.SelfAdd(o),X.MulRV(E,y,o),z.SubVV(o,b,o),z.MulSV(D,o,o),C.SelfAdd(o),X.MulRV(E,g,o),z.SubVV(o,S,o),z.MulSV(D,o,o),x.SelfAdd(o)}}},n.SolveSpring=function(e){for(var i=r.SolveSpring_s_pa,n=r.SolveSpring_s_pb,s=r.SolveSpring_s_d,a=r.SolveSpring_s_f,o=this.m_positionBuffer.data,l=this.m_velocityBuffer.data,h=e.inv_dt*this.m_def.springStrength,u=0;u<this.m_pairBuffer.count;u++){var c=this.m_pairBuffer.data[u];if(c.flags&t.b2ParticleFlag.b2_springParticle){var _=c.indexA,f=c.indexB,p=i.Copy(o[_]),d=n.Copy(o[f]),m=l[_],y=l[f];p.SelfMulAdd(e.dt,m),d.SelfMulAdd(e.dt,y);var g=z.SubVV(d,p,s),v=c.distance,b=g.Length(),S=h*c.strength,A=z.MulSV(S*(v-b)/b,g,a);m.SelfSub(A),y.SelfAdd(A)}}},n.SolveTensile=function(e){for(var i=r.SolveTensile_s_weightedNormal,n=r.SolveTensile_s_s,s=r.SolveTensile_s_f,a=this.m_velocityBuffer.data,o=0;o<this.m_count;o++)this.m_accumulation2Buffer[o]=new z,this.m_accumulation2Buffer[o].SetZero();for(var l=0;l<this.m_contactBuffer.count;l++){var h=this.m_contactBuffer.data[l];if(h.flags&t.b2ParticleFlag.b2_tensileParticle){var u=h.indexA,c=h.indexB,_=h.weight,f=h.normal,p=z.MulSV((1-_)*_,f,i);this.m_accumulation2Buffer[u].SelfSub(p),this.m_accumulation2Buffer[c].SelfAdd(p)}}for(var d=this.GetCriticalVelocity(e),m=this.m_def.surfaceTensionPressureStrength*d,y=this.m_def.surfaceTensionNormalStrength*d,g=.5*d,v=0;v<this.m_contactBuffer.count;v++){var b=this.m_contactBuffer.data[v];if(b.flags&t.b2ParticleFlag.b2_tensileParticle){var S=b.indexA,A=b.indexB,C=b.weight,x=b.normal,T=this.m_weightBuffer[S]+this.m_weightBuffer[A],w=z.SubVV(this.m_accumulation2Buffer[A],this.m_accumulation2Buffer[S],n),E=B(m*(T-2)+y*z.DotVV(w,x),g)*C,D=z.MulSV(E,x,s);a[S].SelfSub(D),a[A].SelfAdd(D)}}},n.SolveViscous=function(){for(var e=r.SolveViscous_s_v,i=r.SolveViscous_s_f,n=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,a=this.m_def.viscousStrength,o=this.GetParticleInvMass(),l=0;l<this.m_bodyContactBuffer.count;l++){var h=this.m_bodyContactBuffer.data[l],u=h.index;if(this.m_flagsBuffer.data[u]&t.b2ParticleFlag.b2_viscousParticle){var c=h.body,_=h.weight,f=h.mass,p=n[u],d=z.SubVV(c.GetLinearVelocityFromWorldPoint(p,z.s_t0),s[u],e),m=z.MulSV(a*f*_,d,i);s[u].SelfMulAdd(o,m),c.ApplyLinearImpulse(m.SelfNeg(),p,!0)}}for(var y=0;y<this.m_contactBuffer.count;y++){var g=this.m_contactBuffer.data[y];if(g.flags&t.b2ParticleFlag.b2_viscousParticle){var v=g.indexA,b=g.indexB,S=g.weight,A=z.SubVV(s[b],s[v],e),C=z.MulSV(a*S,A,i);s[v].SelfAdd(C),s[b].SelfSub(C)}}},n.SolveRepulsive=function(e){for(var i=r.SolveRepulsive_s_f,n=this.m_velocityBuffer.data,s=this.m_def.repulsiveStrength*this.GetCriticalVelocity(e),a=0;a<this.m_contactBuffer.count;a++){var o=this.m_contactBuffer.data[a];if(o.flags&t.b2ParticleFlag.b2_repulsiveParticle){var l=o.indexA,h=o.indexB;if(this.m_groupBuffer[l]!==this.m_groupBuffer[h]){var u=o.weight,c=o.normal,_=z.MulSV(s*u,c,i);n[l].SelfSub(_),n[h].SelfAdd(_)}}}},n.SolvePowder=function(e){for(var i=r.SolvePowder_s_f,n=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,a=this.m_def.powderStrength*this.GetCriticalVelocity(e),o=.25,l=this.GetParticleInvMass(),h=0;h<this.m_bodyContactBuffer.count;h++){var u=this.m_bodyContactBuffer.data[h],c=u.index;if(this.m_flagsBuffer.data[c]&t.b2ParticleFlag.b2_powderParticle){var _=u.weight;if(_>o){var f=u.body,p=u.mass,d=n[c],m=u.normal,y=z.MulSV(a*p*(_-o),m,i);s[c].SelfMulSub(l,y),f.ApplyLinearImpulse(y,d,!0)}}}for(var g=0;g<this.m_contactBuffer.count;g++){var v=this.m_contactBuffer.data[g];if(v.flags&t.b2ParticleFlag.b2_powderParticle){var b=v.weight;if(b>o){var S=v.indexA,A=v.indexB,C=v.normal,x=z.MulSV(a*(b-o),C,i);s[S].SelfSub(x),s[A].SelfAdd(x)}}}},n.SolveSolid=function(t){var e=r.SolveSolid_s_f,i=this.m_velocityBuffer.data;this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer);for(var n=t.inv_dt*this.m_def.ejectionStrength,s=0;s<this.m_contactBuffer.count;s++){var a=this.m_contactBuffer.data[s],o=a.indexA,l=a.indexB;if(this.m_groupBuffer[o]!==this.m_groupBuffer[l]){var h=a.weight,u=a.normal,c=this.m_depthBuffer[o]+this.m_depthBuffer[l],_=z.MulSV(n*c*h,u,e);i[o].SelfSub(_),i[l].SelfAdd(_)}}},n.SolveForce=function(t){for(var e=this.m_velocityBuffer.data,i=t.dt*this.GetParticleInvMass(),r=0;r<this.m_count;r++)e[r].SelfMulAdd(i,this.m_forceBuffer[r]);this.m_hasForce=!1},n.SolveColorMixing=function(){var e=.5*this.m_def.colorMixingStrength;if(e)for(var i=0;i<this.m_contactBuffer.count;i++){var r=this.m_contactBuffer.data[i],n=r.indexA,s=r.indexB;if(this.m_flagsBuffer.data[n]&this.m_flagsBuffer.data[s]&t.b2ParticleFlag.b2_colorMixingParticle){var a=this.m_colorBuffer.data[n],o=this.m_colorBuffer.data[s];K.MixColors(a,o,e)}}},n.SolveZombie=function(){for(var e=0,i=[],r=0;r<this.m_count;r++)i[r]=p;for(var n=0,s=0;s<this.m_count;s++){var a=this.m_flagsBuffer.data[s];if(a&t.b2ParticleFlag.b2_zombieParticle){var o=this.m_world.m_destructionListener;if(a&t.b2ParticleFlag.b2_destructionListenerParticle&&o&&o.SayGoodbyeParticle(this,s),this.m_handleIndexBuffer.data){var l=this.m_handleIndexBuffer.data[s];l&&(l.SetIndex(p),this.m_handleIndexBuffer.data[s]=null)}i[s]=p}else{if(i[s]=e,s!==e){if(this.m_handleIndexBuffer.data){var h=this.m_handleIndexBuffer.data[s];h&&h.SetIndex(e),this.m_handleIndexBuffer.data[e]=h}this.m_flagsBuffer.data[e]=this.m_flagsBuffer.data[s],this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[e]=this.m_lastBodyContactStepBuffer.data[s]),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[e]=this.m_bodyContactCountBuffer.data[s]),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[e]=this.m_consecutiveContactStepsBuffer.data[s]),this.m_positionBuffer.data[e].Copy(this.m_positionBuffer.data[s]),this.m_velocityBuffer.data[e].Copy(this.m_velocityBuffer.data[s]),this.m_groupBuffer[e]=this.m_groupBuffer[s],this.m_hasForce&&this.m_forceBuffer[e].Copy(this.m_forceBuffer[s]),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[e]=this.m_staticPressureBuffer[s]),this.m_depthBuffer&&(this.m_depthBuffer[e]=this.m_depthBuffer[s]),this.m_colorBuffer.data&&this.m_colorBuffer.data[e].Copy(this.m_colorBuffer.data[s]),this.m_userDataBuffer.data&&(this.m_userDataBuffer.data[e]=this.m_userDataBuffer.data[s]),this.m_expirationTimeBuffer.data&&(this.m_expirationTimeBuffer.data[e]=this.m_expirationTimeBuffer.data[s])}e++,n|=a}}for(var u={IsProxyInvalid:function(t){return t.index<0},IsContactInvalid:function(t){return t.indexA<0||t.indexB<0},IsBodyContactInvalid:function(t){return t.index<0},IsPairInvalid:function(t){return t.indexA<0||t.indexB<0},IsTriadInvalid:function(t){return t.indexA<0||t.indexB<0||t.indexC<0}},c=0;c<this.m_proxyBuffer.count;c++){var _=this.m_proxyBuffer.data[c];_.index=i[_.index]}this.m_proxyBuffer.RemoveIf(u.IsProxyInvalid);for(var f=0;f<this.m_contactBuffer.count;f++){var d=this.m_contactBuffer.data[f];d.indexA=i[d.indexA],d.indexB=i[d.indexB]}this.m_contactBuffer.RemoveIf(u.IsContactInvalid);for(var m=0;m<this.m_bodyContactBuffer.count;m++){var y=this.m_bodyContactBuffer.data[m];y.index=i[y.index]}this.m_bodyContactBuffer.RemoveIf(u.IsBodyContactInvalid);for(var g=0;g<this.m_pairBuffer.count;g++){var v=this.m_pairBuffer.data[g];v.indexA=i[v.indexA],v.indexB=i[v.indexB]}this.m_pairBuffer.RemoveIf(u.IsPairInvalid);for(var b=0;b<this.m_triadBuffer.count;b++){var S=this.m_triadBuffer.data[b];S.indexA=i[S.indexA],S.indexB=i[S.indexB],S.indexC=i[S.indexC]}if(this.m_triadBuffer.RemoveIf(u.IsTriadInvalid),this.m_indexByExpirationTimeBuffer.data)for(var A=0,C=0;C<this.m_count;C++){var x=i[this.m_indexByExpirationTimeBuffer.data[C]];x!==p&&(this.m_indexByExpirationTimeBuffer.data[A++]=x)}for(var T=this.m_groupList;T;T=T.GetNext()){for(var w=e,E=0,M=!1,P=T.m_firstIndex;P<T.m_lastIndex;P++){var R=i[P];R>=0?(w=B(w,R),E=D(E,R+1)):M=!0}w<E?(T.m_firstIndex=w,T.m_lastIndex=E,M&&T.m_groupFlags&t.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SetGroupFlags(T,T.m_groupFlags|t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth)):(T.m_firstIndex=0,T.m_lastIndex=0,T.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty||this.SetGroupFlags(T,T.m_groupFlags|t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed))}this.m_count=e,this.m_allParticleFlags=n,this.m_needsUpdateAllParticleFlags=!1;for(var I=this.m_groupList;I;){var O=I.GetNext();I.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed&&this.DestroyParticleGroup(I),I=O}},n.SolveLifetimes=function(t){this.m_timeElapsed=this.LifetimeToExpirationTime(t.dt);var e=this.GetQuantizedTimeElapsed(),i=this.m_expirationTimeBuffer.data,r=this.m_indexByExpirationTimeBuffer.data,n=this.GetParticleCount();this.m_expirationTimeBufferRequiresSorting&&(qr(r,0,n,(function(t,e){var r=i[t],n=i[e],s=r<=0;return s===n<=0?r>n:s})),this.m_expirationTimeBufferRequiresSorting=!1);for(var s=n-1;s>=0;--s){var a=r[s],o=i[a];if(e<o||o<=0)break;this.DestroyParticle(a)}},n.RotateBuffer=function(t,e,i){if(t!==e&&e!==i){if($r(this.m_flagsBuffer.data,t,e,i),this.m_lastBodyContactStepBuffer.data&&$r(this.m_lastBodyContactStepBuffer.data,t,e,i),this.m_bodyContactCountBuffer.data&&$r(this.m_bodyContactCountBuffer.data,t,e,i),this.m_consecutiveContactStepsBuffer.data&&$r(this.m_consecutiveContactStepsBuffer.data,t,e,i),$r(this.m_positionBuffer.data,t,e,i),$r(this.m_velocityBuffer.data,t,e,i),$r(this.m_groupBuffer,t,e,i),this.m_hasForce&&$r(this.m_forceBuffer,t,e,i),this.m_staticPressureBuffer&&$r(this.m_staticPressureBuffer,t,e,i),this.m_depthBuffer&&$r(this.m_depthBuffer,t,e,i),this.m_colorBuffer.data&&$r(this.m_colorBuffer.data,t,e,i),this.m_userDataBuffer.data&&$r(this.m_userDataBuffer.data,t,e,i),this.m_handleIndexBuffer.data){$r(this.m_handleIndexBuffer.data,t,e,i);for(var r=t;r<i;++r){var n=this.m_handleIndexBuffer.data[r];n&&n.SetIndex(v(n.GetIndex()))}}if(this.m_expirationTimeBuffer.data){$r(this.m_expirationTimeBuffer.data,t,e,i);for(var s=this.GetParticleCount(),a=this.m_indexByExpirationTimeBuffer.data,o=0;o<s;++o)a[o]=v(a[o])}for(var l=0;l<this.m_proxyBuffer.count;l++){var h=this.m_proxyBuffer.data[l];h.index=v(h.index)}for(var u=0;u<this.m_contactBuffer.count;u++){var c=this.m_contactBuffer.data[u];c.indexA=v(c.indexA),c.indexB=v(c.indexB)}for(var _=0;_<this.m_bodyContactBuffer.count;_++){var f=this.m_bodyContactBuffer.data[_];f.index=v(f.index)}for(var p=0;p<this.m_pairBuffer.count;p++){var d=this.m_pairBuffer.data[p];d.indexA=v(d.indexA),d.indexB=v(d.indexB)}for(var m=0;m<this.m_triadBuffer.count;m++){var y=this.m_triadBuffer.data[m];y.indexA=v(y.indexA),y.indexB=v(y.indexB),y.indexC=v(y.indexC)}for(var g=this.m_groupList;g;g=g.GetNext())g.m_firstIndex=v(g.m_firstIndex),g.m_lastIndex=v(g.m_lastIndex-1)+1}function v(r){return r<t?r:r<e?r+i-e:r<i?r+t-e:r}},n.GetCriticalVelocity=function(t){return this.m_particleDiameter*t.inv_dt},n.GetCriticalVelocitySquared=function(t){var e=this.GetCriticalVelocity(t);return e*e},n.GetCriticalPressure=function(t){return this.m_def.density*this.GetCriticalVelocitySquared(t)},n.GetParticleStride=function(){return d*this.m_particleDiameter},n.GetParticleMass=function(){var t=this.GetParticleStride();return this.m_def.density*t*t},n.GetParticleInvMass=function(){var t=1.3333333333333333*this.m_inverseDiameter;return this.m_inverseDensity*t*t},n.GetFixtureContactFilter=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_fixtureContactFilterParticle?this.m_world.m_contactManager.m_contactFilter:null},n.GetParticleContactFilter=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_particleContactFilterParticle?this.m_world.m_contactManager.m_contactFilter:null},n.GetFixtureContactListener=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_fixtureContactListenerParticle?this.m_world.m_contactManager.m_contactListener:null},n.GetParticleContactListener=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_particleContactListenerParticle?this.m_world.m_contactManager.m_contactListener:null},n.SetUserOverridableBuffer=function(t,e){t.data=e,t.userSuppliedCapacity=e.length},n.SetGroupFlags=function(e,i){var r=e.m_groupFlags;(r^i)&t.b2ParticleGroupFlag.b2_solidParticleGroup&&(i|=t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth),r&~i&&(this.m_needsUpdateAllGroupFlags=!0),~this.m_allGroupFlags&i&&(i&t.b2ParticleGroupFlag.b2_solidParticleGroup&&(this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer)),this.m_allGroupFlags|=i),e.m_groupFlags=i},r.BodyContactCompare=function(t,e){return t.index===e.index?t.weight>e.weight:t.index<e.index},n.RemoveSpuriousBodyContacts=function(){qr(this.m_bodyContactBuffer.data,0,this.m_bodyContactBuffer.count,r.BodyContactCompare);var t=r.RemoveSpuriousBodyContacts_s_n,e=r.RemoveSpuriousBodyContacts_s_pos,i=r.RemoveSpuriousBodyContacts_s_normal,n=this,s=-1,a=0;this.m_bodyContactBuffer.count=Kr(this.m_bodyContactBuffer.data,(function(r){if(r.index!==s&&(a=0,s=r.index),a++>3)return!0;var l=t.Copy(r.normal);l.SelfMul(n.m_particleDiameter*(1-r.weight));var h=z.AddVV(n.m_positionBuffer.data[r.index],l,e);if(!r.fixture.TestPoint(h)){for(var u=r.fixture.GetShape().GetChildCount(),c=0;c<u;c++){var _=i;if(r.fixture.ComputeDistance(h,_,c)<o)return!1}return!0}return!1}),this.m_bodyContactBuffer.count)},n.DetectStuckParticle=function(t){this.m_stuckThreshold<=0||(++this.m_bodyContactCountBuffer.data[t],2===this.m_bodyContactCountBuffer.data[t]&&(++this.m_consecutiveContactStepsBuffer.data[t],this.m_consecutiveContactStepsBuffer.data[t]>this.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=t)),this.m_lastBodyContactStepBuffer.data[t]=this.m_timestamp)},n.ValidateParticleIndex=function(t){return t>=0&&t<this.GetParticleCount()&&t!==p},n.GetQuantizedTimeElapsed=function(){return Math.floor(this.m_timeElapsed/4294967296)},n.LifetimeToExpirationTime=function(t){return this.m_timeElapsed+Math.floor(t/this.m_def.lifetimeGranularity*4294967296)},n.ForceCanBeApplied=function(e){return!(e&t.b2ParticleFlag.b2_wallParticle)},n.PrepareForceBuffer=function(){if(!this.m_hasForce){for(var t=0;t<this.m_count;t++)this.m_forceBuffer[t].SetZero();this.m_hasForce=!0}},n.IsRigidGroup=function(e){return null!==e&&0!=(e.m_groupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup)},n.GetLinearVelocity=function(t,e,i,r){return t&&this.IsRigidGroup(t)?t.GetLinearVelocityFromWorldPoint(i,r):r.Copy(this.m_velocityBuffer.data[e])},n.InitDampingParameter=function(t,e,i,r,n,s,a,o){t[0]=r>0?1/r:0,e[0]=n>0?1/n:0,i[0]=z.CrossVV(z.SubVV(a,s,z.s_t0),o)},n.InitDampingParameterWithRigidGroupOrParticle=function(e,i,r,n,s,a,o,l){if(s&&n)this.InitDampingParameter(e,i,r,s.GetMass(),s.GetInertia(),s.GetCenter(),o,l);else{var h=this.m_flagsBuffer.data[a];this.InitDampingParameter(e,i,r,h&t.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,o,o,l)}},n.ComputeDampingImpulse=function(t,e,i,r,n,s,a){var o=t+e*i*i+r+n*s*s;return o>0?a/o:0},n.ApplyDamping=function(t,e,i,r,n,s,a,o){n&&r?(n.m_linearVelocity.SelfMulAdd(a*t,o),n.m_angularVelocity+=a*i*e):this.m_velocityBuffer.data[s].SelfMulAdd(a*t,o)},r}();ln.xTruncBits=12,ln.yTruncBits=12,ln.tagBits=32,ln.yOffset=1<<ln.yTruncBits-1,ln.yShift=ln.tagBits-ln.yTruncBits,ln.xShift=ln.tagBits-ln.yTruncBits-ln.xTruncBits,ln.xScale=1<<ln.xShift,ln.xOffset=ln.xScale*(1<<ln.xTruncBits-1),ln.yMask=(1<<ln.yTruncBits)-1<<ln.yShift,ln.xMask=~ln.yMask,ln.DestroyParticlesInShape_s_aabb=new Ft,ln.CreateParticleGroup_s_transform=new Y,ln.ComputeCollisionEnergy_s_v=new z,ln.QueryShapeAABB_s_aabb=new Ft,ln.QueryPointAABB_s_aabb=new Ft,ln.RayCast_s_aabb=new Ft,ln.RayCast_s_p=new z,ln.RayCast_s_v=new z,ln.RayCast_s_n=new z,ln.RayCast_s_point=new z,ln.k_pairFlags=t.b2ParticleFlag.b2_springParticle,ln.k_triadFlags=t.b2ParticleFlag.b2_elasticParticle,ln.k_noPressureFlags=t.b2ParticleFlag.b2_powderParticle|t.b2ParticleFlag.b2_tensileParticle,ln.k_extraDampingFlags=t.b2ParticleFlag.b2_staticPressureParticle,ln.k_barrierWallFlags=t.b2ParticleFlag.b2_barrierParticle|t.b2ParticleFlag.b2_wallParticle,ln.CreateParticlesStrokeShapeForGroup_s_edge=new gi,ln.CreateParticlesStrokeShapeForGroup_s_d=new z,ln.CreateParticlesStrokeShapeForGroup_s_p=new z,ln.CreateParticlesFillShapeForGroup_s_aabb=new Ft,ln.CreateParticlesFillShapeForGroup_s_p=new z,ln.UpdatePairsAndTriads_s_dab=new z,ln.UpdatePairsAndTriads_s_dbc=new z,ln.UpdatePairsAndTriads_s_dca=new z,ln.AddContact_s_d=new z,ln.UpdateBodyContacts_s_aabb=new Ft,ln.Solve_s_subStep=new Cr,ln.SolveCollision_s_aabb=new Ft,ln.SolveGravity_s_gravity=new z,ln.SolveBarrier_s_aabb=new Ft,ln.SolveBarrier_s_va=new z,ln.SolveBarrier_s_vb=new z,ln.SolveBarrier_s_pba=new z,ln.SolveBarrier_s_vba=new z,ln.SolveBarrier_s_vc=new z,ln.SolveBarrier_s_pca=new z,ln.SolveBarrier_s_vca=new z,ln.SolveBarrier_s_qba=new z,ln.SolveBarrier_s_qca=new z,ln.SolveBarrier_s_dv=new z,ln.SolveBarrier_s_f=new z,ln.SolvePressure_s_f=new z,ln.SolveDamping_s_v=new z,ln.SolveDamping_s_f=new z,ln.SolveRigidDamping_s_t0=new z,ln.SolveRigidDamping_s_t1=new z,ln.SolveRigidDamping_s_p=new z,ln.SolveRigidDamping_s_v=new z,ln.SolveExtraDamping_s_v=new z,ln.SolveExtraDamping_s_f=new z,ln.SolveRigid_s_position=new z,ln.SolveRigid_s_rotation=new X,ln.SolveRigid_s_transform=new Y,ln.SolveRigid_s_velocityTransform=new Y,ln.SolveElastic_s_pa=new z,ln.SolveElastic_s_pb=new z,ln.SolveElastic_s_pc=new z,ln.SolveElastic_s_r=new X,ln.SolveElastic_s_t0=new z,ln.SolveSpring_s_pa=new z,ln.SolveSpring_s_pb=new z,ln.SolveSpring_s_d=new z,ln.SolveSpring_s_f=new z,ln.SolveTensile_s_weightedNormal=new z,ln.SolveTensile_s_s=new z,ln.SolveTensile_s_f=new z,ln.SolveViscous_s_v=new z,ln.SolveViscous_s_f=new z,ln.SolveRepulsive_s_f=new z,ln.SolvePowder_s_f=new z,ln.SolveSolid_s_f=new z,ln.RemoveSpuriousBodyContacts_s_n=new z,ln.RemoveSpuriousBodyContacts_s_pos=new z,ln.RemoveSpuriousBodyContacts_s_normal=new z;var hn=function(){function t(){this._data=null,this.userSuppliedCapacity=0}return Pe(t,[{key:"data",get:function(){return this._data},set:function(t){this._data=t}}]),t}(),un=function(){function t(){this.index=p,this.tag=0}return t.CompareProxyProxy=function(t,e){return t.tag<e.tag},t.CompareTagProxy=function(t,e){return t<e.tag},t.CompareProxyTag=function(t,e){return t.tag<e},t}(),cn=function(){function t(t,e,i,r,n){this.m_system=t,this.m_xLower=(e&ln.xMask)>>>0,this.m_xUpper=(i&ln.xMask)>>>0,this.m_yLower=(e&ln.yMask)>>>0,this.m_yUpper=(i&ln.yMask)>>>0,this.m_first=r,this.m_last=n}return t.prototype.GetNext=function(){for(;this.m_first<this.m_last;){var t=(this.m_system.m_proxyBuffer.data[this.m_first].tag&ln.xMask)>>>0;if(t>=this.m_xLower&&t<=this.m_xUpper)return this.m_system.m_proxyBuffer.data[this.m_first++].index;this.m_first++}return p},t}(),_n=function(){this.next=null,this.count=0,this.index=0},fn=function(){function t(){}var e=t.prototype;return e.Allocate=function(t,e){return e},e.Clear=function(){},e.GetCount=function(){return 0},e.Invalidate=function(){},e.GetValidBuffer=function(){return[]},e.GetBuffer=function(){return[]},e.SetCount=function(){},t}(),pn=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return p},e}(fn),dn=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return p},e}(fn),mn=function(){function t(){}var e=t.prototype;return e.IsNecessary=function(){return!0},e.ShouldCreatePair=function(){return!0},e.ShouldCreateTriad=function(){return!0},t}(),yn=function(t){function e(e,i,r,n){var s;return(s=t.call(this)||this).m_callDestructionListener=!1,s.m_destroyed=0,s.m_system=e,s.m_shape=i,s.m_xf=r,s.m_callDestructionListener=n,s.m_destroyed=0,s}Me(e,t);var i=e.prototype;return i.ReportFixture=function(){return!1},i.ReportParticle=function(t,e){return t===this.m_system&&(this.m_shape.TestPoint(this.m_xf,this.m_system.m_positionBuffer.data[e])&&(this.m_system.DestroyParticle(e,this.m_callDestructionListener),this.m_destroyed++),!0)},i.Destroyed=function(){return this.m_destroyed},e}(vr),gn=function(t){function e(e){var i;return(i=t.call(this)||this).m_threshold=0,i.m_threshold=e,i}Me(e,t);var i=e.prototype;return i.ShouldCreatePair=function(t,e){return t<this.m_threshold&&this.m_threshold<=e||e<this.m_threshold&&this.m_threshold<=t},i.ShouldCreateTriad=function(t,e,i){return(t<this.m_threshold||e<this.m_threshold||i<this.m_threshold)&&(this.m_threshold<=t||this.m_threshold<=e||this.m_threshold<=i)},e}(mn),vn=function(e){function r(i,r){var n;return void 0===r&&(r=i.length),(n=e.call(this,t.b2ShapeType.e_unknown,0)||this).m_shapeCount=0,n.m_shapes=i,n.m_shapeCount=r,n}Me(r,e);var n=r.prototype;return n.Clone=function(){throw new Error},n.GetChildCount=function(){return 1},n.TestPoint=function(t,e){for(var i=0;i<this.m_shapeCount;i++)if(this.m_shapes[i].TestPoint(t,e))return!0;return!1},n.ComputeDistance=function(){return 0},n.RayCast=function(){return!1},n.ComputeAABB=function(t,e){var r=new Ft;t.lowerBound.x=+i,t.lowerBound.y=+i,t.upperBound.x=-i,t.upperBound.y=-i;for(var n=0;n<this.m_shapeCount;n++)for(var s=this.m_shapes[n].GetChildCount(),a=0;a<s;a++){var o=r;this.m_shapes[n].ComputeAABB(o,e,a),t.Combine1(o)}},n.ComputeMass=function(){},n.SetupDistanceProxy=function(){},n.ComputeSubmergedArea=function(){return 0},n.Dump=function(){},r}(di),bn=function(e){function i(t){var i;return(i=e.call(this)||this).m_flagsBuffer=t,i}return Me(i,e),i.prototype.IsNecessary=function(e){return 0!=(this.m_flagsBuffer.data[e]&t.b2ParticleFlag.b2_reactiveParticle)},i}(mn),Sn=function(e){function i(t,i){var r;return void 0===i&&(i=null),(r=e.call(this,t)||this).m_contactFilter=null,r.m_contactFilter=i,r}Me(i,e);var r=i.prototype;return r.ShouldCollideFixtureParticle=function(e,i,r){return!(this.m_contactFilter&&this.m_system.GetFlagsBuffer()[r]&t.b2ParticleFlag.b2_fixtureContactFilterParticle)||this.m_contactFilter.ShouldCollideFixtureParticle(e,this.m_system,r)},r.ReportFixtureAndParticle=function(e,r,n){var s=i.ReportFixtureAndParticle_s_n,a=i.ReportFixtureAndParticle_s_rp,o=this.m_system.m_positionBuffer.data[n],l=s,h=e.ComputeDistance(o,l,r);if(h<this.m_system.m_particleDiameter&&this.ShouldCollideFixtureParticle(e,this.m_system,n)){var u=e.GetBody(),c=u.GetWorldCenter(),_=u.GetMass(),f=u.GetInertia()-_*u.GetLocalCenter().LengthSquared(),p=_>0?1/_:0,d=f>0?1/f:0,m=this.m_system.m_flagsBuffer.data[n]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),y=z.SubVV(o,c,a),g=z.CrossVV(y,l),v=m+p+d*g*g,b=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];b.index=n,b.body=u,b.fixture=e,b.weight=1-h*this.m_system.m_inverseDiameter,b.normal.Copy(l.SelfNeg()),b.mass=v>0?1/v:0,this.m_system.DetectStuckParticle(n)}},i}(en);Sn.ReportFixtureAndParticle_s_n=new z,Sn.ReportFixtureAndParticle_s_rp=new z;var An=function(e){function i(t,i){var r;return(r=e.call(this,t)||this).m_step=i,r}Me(i,e);var r=i.prototype;return r.ReportFixtureAndParticle=function(e,r,n){var s=i.ReportFixtureAndParticle_s_p1,a=i.ReportFixtureAndParticle_s_output,l=i.ReportFixtureAndParticle_s_input,h=i.ReportFixtureAndParticle_s_p,u=i.ReportFixtureAndParticle_s_v,c=i.ReportFixtureAndParticle_s_f,_=e.GetBody(),f=this.m_system.m_positionBuffer.data[n],p=this.m_system.m_velocityBuffer.data[n],d=a,m=l;if(0===this.m_system.m_iterationIndex){var y=Y.MulTXV(_.m_xf0,f,s);e.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(y.SelfSub(_.GetLocalCenter()),X.MulRV(_.m_xf0.q,y,y),X.MulTRV(_.m_xf.q,y,y),y.SelfAdd(_.GetLocalCenter())),Y.MulXV(_.m_xf,y,m.p1)}else m.p1.Copy(f);if(z.AddVMulSV(f,this.m_step.dt,p,m.p2),m.maxFraction=1,e.RayCast(d,m,r)){var g=d.normal,v=h;v.x=(1-d.fraction)*m.p1.x+d.fraction*m.p2.x+o*g.x,v.y=(1-d.fraction)*m.p1.y+d.fraction*m.p2.y+o*g.y;var b=u;b.x=this.m_step.inv_dt*(v.x-f.x),b.y=this.m_step.inv_dt*(v.y-f.y),this.m_system.m_velocityBuffer.data[n].Copy(b);var S=c;S.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(p.x-b.x),S.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(p.y-b.y),this.m_system.ParticleApplyForce(n,S)}},r.ReportParticle=function(){return!1},i}(en);An.ReportFixtureAndParticle_s_p1=new z,An.ReportFixtureAndParticle_s_output=new Ot,An.ReportFixtureAndParticle_s_input=new It,An.ReportFixtureAndParticle_s_p=new z,An.ReportFixtureAndParticle_s_v=new z,An.ReportFixtureAndParticle_s_f=new z;var Cn=function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new Sr,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new z,this.m_allowSleep=!0,this.m_destructionListener=null,this.m_debugDraw=null,this.m_inv_dt0=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_profile=new Ar,this.m_island=new Fr,this.s_stack=[],this.m_controllerList=null,this.m_controllerCount=0,this.m_gravity.Copy(t)}var r=e.prototype;return r.SetDestructionListener=function(t){this.m_destructionListener=t},r.SetContactFilter=function(t){this.m_contactManager.m_contactFilter=t},r.SetContactListener=function(t){this.m_contactManager.m_contactListener=t},r.SetDebugDraw=function(t){this.m_debugDraw=t},r.CreateBody=function(t){if(void 0===t&&(t={}),this.IsLocked())throw new Error;var e=new Ei(t,this);return e.m_prev=null,e.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=e),this.m_bodyList=e,++this.m_bodyCount,e},r.DestroyBody=function(t){if(this.IsLocked())throw new Error;for(var e=t.m_jointList;e;){var i=e;e=e.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(i.joint),this.DestroyJoint(i.joint),t.m_jointList=e}t.m_jointList=null;for(var r=t.m_controllerList;r;){var n=r;r=r.nextController,n.controller.RemoveBody(t)}for(var s=t.m_contactList;s;){var a=s;s=s.next,this.m_contactManager.Destroy(a.contact)}t.m_contactList=null;for(var o=t.m_fixtureList;o;){var l=o;o=o.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(l),l.DestroyProxies(),l.Reset(),t.m_fixtureList=o,t.m_fixtureCount-=1}t.m_fixtureList=null,t.m_fixtureCount=0,t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_bodyList&&(this.m_bodyList=t.m_next),--this.m_bodyCount},e._Joint_Create=function(e){switch(e.type){case t.b2JointType.e_distanceJoint:return new Ii(e);case t.b2JointType.e_mouseJoint:return new Hi(e);case t.b2JointType.e_prismaticJoint:return new Wi(e);case t.b2JointType.e_revoluteJoint:return new Ji(e);case t.b2JointType.e_pulleyJoint:return new Yi(e);case t.b2JointType.e_gearJoint:return new Ni(e);case t.b2JointType.e_wheelJoint:return new er(e);case t.b2JointType.e_weldJoint:return new $i(e);case t.b2JointType.e_frictionJoint:return new Vi(e);case t.b2JointType.e_ropeJoint:return new Zi(e);case t.b2JointType.e_motorJoint:return new zi(e);case t.b2JointType.e_areaJoint:return new Fi(e)}throw new Error},e._Joint_Destroy=function(){},r.CreateJoint=function(t){if(this.IsLocked())throw new Error;var i=e._Joint_Create(t);i.m_prev=null,i.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=i),this.m_jointList=i,++this.m_jointCount,i.m_edgeA.prev=null,i.m_edgeA.next=i.m_bodyA.m_jointList,i.m_bodyA.m_jointList&&(i.m_bodyA.m_jointList.prev=i.m_edgeA),i.m_bodyA.m_jointList=i.m_edgeA,i.m_edgeB.prev=null,i.m_edgeB.next=i.m_bodyB.m_jointList,i.m_bodyB.m_jointList&&(i.m_bodyB.m_jointList.prev=i.m_edgeB),i.m_bodyB.m_jointList=i.m_edgeB;var r=i.m_bodyA,n=i.m_bodyB;if(!i.m_collideConnected)for(var s=n.GetContactList();s;)s.other===r&&s.contact.FlagForFiltering(),s=s.next;return i},r.DestroyJoint=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_jointList&&(this.m_jointList=t.m_next);var i=t.m_bodyA,r=t.m_bodyB,n=t.m_collideConnected;if(i.SetAwake(!0),r.SetAwake(!0),t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA===i.m_jointList&&(i.m_jointList=t.m_edgeA.next),t.m_edgeA.Reset(),t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB===r.m_jointList&&(r.m_jointList=t.m_edgeB.next),t.m_edgeB.Reset(),e._Joint_Destroy(t),--this.m_jointCount,!n)for(var s=r.GetContactList();s;)s.other===i&&s.contact.FlagForFiltering(),s=s.next},r.CreateParticleSystem=function(t){if(this.IsLocked())throw new Error;var e=new ln(t,this);return e.m_prev=null,e.m_next=this.m_particleSystemList,this.m_particleSystemList&&(this.m_particleSystemList.m_prev=e),this.m_particleSystemList=e,e},r.DestroyParticleSystem=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_particleSystemList&&(this.m_particleSystemList=t.m_next)},r.CalculateReasonableParticleIterations=function(t){if(null===this.m_particleSystemList)return 1;return Vr(this.m_gravity.Length(),function(t){for(var e=i,r=t.GetParticleSystemList();null!==r;r=r.m_next)e=B(e,r.GetRadius());return e}(this),t)},r.Step=function(t,i,r,n){void 0===n&&(n=this.CalculateReasonableParticleIterations(t));var s=e.Step_s_stepTimer.Reset();this.m_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_newFixture=!1),this.m_locked=!0;var a=e.Step_s_step;a.dt=t,a.velocityIterations=i,a.positionIterations=r,a.particleIterations=n,a.inv_dt=t>0?1/t:0,a.dtRatio=this.m_inv_dt0*t,a.warmStarting=this.m_warmStarting;var o=e.Step_s_timer.Reset();if(this.m_contactManager.Collide(),this.m_profile.collide=o.GetMilliseconds(),this.m_stepComplete&&a.dt>0){for(var l=e.Step_s_timer.Reset(),h=this.m_particleSystemList;h;h=h.m_next)h.Solve(a);this.Solve(a),this.m_profile.solve=l.GetMilliseconds()}if(this.m_continuousPhysics&&a.dt>0){var u=e.Step_s_timer.Reset();this.SolveTOI(a),this.m_profile.solveTOI=u.GetMilliseconds()}a.dt>0&&(this.m_inv_dt0=a.inv_dt),this.m_clearForces&&this.ClearForces(),this.m_locked=!1,this.m_profile.step=s.GetMilliseconds()},r.ClearForces=function(){for(var t=this.m_bodyList;t;t=t.m_next)t.m_force.SetZero(),t.m_torque=0},r.DrawParticleSystem=function(t){if(null!==this.m_debugDraw){var e=t.GetParticleCount();if(e){var i=t.GetRadius(),r=t.GetPositionBuffer();if(t.m_colorBuffer.data){var n=t.GetColorBuffer();this.m_debugDraw.DrawParticles(r,i,n,e)}else this.m_debugDraw.DrawParticles(r,i,null,e)}}},r.DrawDebugData=function(){if(null!==this.m_debugDraw){var i=this.m_debugDraw.GetFlags(),r=e.DrawDebugData_s_color.SetRGB(0,0,0);if(i&t.b2DrawFlags.e_shapeBit)for(var n=this.m_bodyList;n;n=n.m_next){var s=n.m_xf;this.m_debugDraw.PushTransform(s);for(var a=n.GetFixtureList();a;a=a.m_next)n.IsActive()?n.GetType()===t.b2BodyType.b2_staticBody?(r.SetRGB(.5,.9,.5),this.DrawShape(a,r)):n.GetType()===t.b2BodyType.b2_kinematicBody?(r.SetRGB(.5,.5,.9),this.DrawShape(a,r)):n.IsAwake()?(r.SetRGB(.9,.7,.7),this.DrawShape(a,r)):(r.SetRGB(.6,.6,.6),this.DrawShape(a,r)):(r.SetRGB(.5,.5,.3),this.DrawShape(a,r));this.m_debugDraw.PopTransform(s)}if(i&t.b2DrawFlags.e_particleBit)for(var o=this.m_particleSystemList;o;o=o.m_next)this.DrawParticleSystem(o);if(i&t.b2DrawFlags.e_jointBit)for(var l=this.m_jointList;l;l=l.m_next)this.DrawJoint(l);if(i&t.b2DrawFlags.e_aabbBit){r.SetRGB(.9,.3,.9);for(var h=e.DrawDebugData_s_vs,u=this.m_bodyList;u;u=u.m_next)if(u.IsActive())for(var c=u.GetFixtureList();c;c=c.m_next)for(var _=0;_<c.m_proxyCount;++_){var f=c.m_proxies[_].treeNode.aabb;h[0].Set(f.lowerBound.x,f.lowerBound.y),h[1].Set(f.upperBound.x,f.lowerBound.y),h[2].Set(f.upperBound.x,f.upperBound.y),h[3].Set(f.lowerBound.x,f.upperBound.y),this.m_debugDraw.DrawPolygon(h,4,r)}}if(i&t.b2DrawFlags.e_centerOfMassBit)for(var p=this.m_bodyList;p;p=p.m_next){var d=e.DrawDebugData_s_xf;d.q.Copy(p.m_xf.q),d.p.Copy(p.GetWorldCenter()),this.m_debugDraw.DrawTransform(d)}if(i&t.b2DrawFlags.e_controllerBit)for(var m=this.m_controllerList;m;m=m.m_next)m.Draw(this.m_debugDraw)}},r.QueryAABB=function(){(arguments.length<=0?void 0:arguments[0])instanceof vr?this._QueryAABB(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]):this._QueryAABB(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])},r._QueryAABB=function(t,e,i){if(this.m_contactManager.m_broadPhase.Query(e,(function(e){var r=e.userData.fixture;return t?t.ReportFixture(r):!i||i(r)})),t instanceof vr)for(var r=this.m_particleSystemList;r;r=r.m_next)t.ShouldQueryParticleSystem(r)&&r.QueryAABB(t,e)},r.QueryAllAABB=function(t,e){return void 0===e&&(e=[]),this.QueryAABB(t,(function(t){return e.push(t),!0})),e},r.QueryPointAABB=function(){(arguments.length<=0?void 0:arguments[0])instanceof vr?this._QueryPointAABB(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]):this._QueryPointAABB(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])},r._QueryPointAABB=function(t,e,i){if(this.m_contactManager.m_broadPhase.QueryPoint(e,(function(e){var r=e.userData.fixture;return t?t.ReportFixture(r):!i||i(r)})),t instanceof vr)for(var r=this.m_particleSystemList;r;r=r.m_next)t.ShouldQueryParticleSystem(r)&&r.QueryPointAABB(t,e)},r.QueryAllPointAABB=function(t,e){return void 0===e&&(e=[]),this.QueryPointAABB(t,(function(t){return e.push(t),!0})),e},r.QueryFixtureShape=function(){(arguments.length<=0?void 0:arguments[0])instanceof vr?this._QueryFixtureShape(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3]):this._QueryFixtureShape(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},r._QueryFixtureShape=function(t,i,r,n,s){var a=e.QueryFixtureShape_s_aabb;if(i.ComputeAABB(a,n,r),this.m_contactManager.m_broadPhase.Query(a,(function(e){var a=e.userData,o=a.fixture;if(zt(i,r,o.GetShape(),a.childIndex,n,o.GetBody().GetTransform())){if(t)return t.ReportFixture(o);if(s)return s(o)}return!0})),t instanceof vr)for(var o=this.m_particleSystemList;o;o=o.m_next)t.ShouldQueryParticleSystem(o)&&o.QueryAABB(t,a)},r.QueryAllFixtureShape=function(t,e,i,r){return void 0===r&&(r=[]),this.QueryFixtureShape(t,e,i,(function(t){return r.push(t),!0})),r},r.QueryFixturePoint=function(){(arguments.length<=0?void 0:arguments[0])instanceof vr?this._QueryFixturePoint(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]):this._QueryFixturePoint(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])},r._QueryFixturePoint=function(t,e,i){if(this.m_contactManager.m_broadPhase.QueryPoint(e,(function(r){var n=r.userData.fixture;if(n.TestPoint(e)){if(t)return t.ReportFixture(n);if(i)return i(n)}return!0})),t)for(var r=this.m_particleSystemList;r;r=r.m_next)t.ShouldQueryParticleSystem(r)&&r.QueryPointAABB(t,e)},r.QueryAllFixturePoint=function(t,e){return void 0===e&&(e=[]),this.QueryFixturePoint(t,(function(t){return e.push(t),!0})),e},r.RayCast=function(){(arguments.length<=0?void 0:arguments[0])instanceof br?this._RayCast(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2]):this._RayCast(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},r._RayCast=function(t,i,r,n){var s=e.RayCast_s_input;if(s.maxFraction=1,s.p1.Copy(i),s.p2.Copy(r),this.m_contactManager.m_broadPhase.RayCast(s,(function(s,a){var o=a.userData,l=o.fixture,h=o.childIndex,u=e.RayCast_s_output;if(l.RayCast(u,s,h)){var c=u.fraction,_=e.RayCast_s_point;if(_.Set((1-c)*i.x+c*r.x,(1-c)*i.y+c*r.y),t)return t.ReportFixture(l,_,u.normal,c);if(n)return n(l,_,u.normal,c)}return s.maxFraction})),t)for(var a=this.m_particleSystemList;a;a=a.m_next)t.ShouldQueryParticleSystem(a)&&a.RayCast(t,i,r)},r.RayCastOne=function(t,e){var i=null,r=1;return this.RayCast(t,e,(function(t,e,n,s){return s<r&&(r=s,i=t),r})),i},r.RayCastAll=function(t,e,i){return void 0===i&&(i=[]),this.RayCast(t,e,(function(t){return i.push(t),1})),i},r.GetBodyList=function(){return this.m_bodyList},r.GetJointList=function(){return this.m_jointList},r.GetParticleSystemList=function(){return this.m_particleSystemList},r.GetContactList=function(){return this.m_contactManager.m_contactList},r.SetAllowSleeping=function(t){if(t!==this.m_allowSleep&&(this.m_allowSleep=t,!this.m_allowSleep))for(var e=this.m_bodyList;e;e=e.m_next)e.SetAwake(!0)},r.GetAllowSleeping=function(){return this.m_allowSleep},r.SetWarmStarting=function(t){this.m_warmStarting=t},r.GetWarmStarting=function(){return this.m_warmStarting},r.SetContinuousPhysics=function(t){this.m_continuousPhysics=t},r.GetContinuousPhysics=function(){return this.m_continuousPhysics},r.SetSubStepping=function(t){this.m_subStepping=t},r.GetSubStepping=function(){return this.m_subStepping},r.GetProxyCount=function(){return this.m_contactManager.m_broadPhase.GetProxyCount()},r.GetBodyCount=function(){return this.m_bodyCount},r.GetJointCount=function(){return this.m_jointCount},r.GetContactCount=function(){return this.m_contactManager.m_contactCount},r.GetTreeHeight=function(){return this.m_contactManager.m_broadPhase.GetTreeHeight()},r.GetTreeBalance=function(){return this.m_contactManager.m_broadPhase.GetTreeBalance()},r.GetTreeQuality=function(){return this.m_contactManager.m_broadPhase.GetTreeQuality()},r.SetGravity=function(t,e){if(void 0===e&&(e=!0),!z.IsEqualToV(this.m_gravity,t)&&(this.m_gravity.Copy(t),e))for(var i=this.m_bodyList;i;i=i.m_next)i.SetAwake(!0)},r.GetGravity=function(){return this.m_gravity},r.IsLocked=function(){return this.m_locked},r.SetAutoClearForces=function(t){this.m_clearForces=t},r.GetAutoClearForces=function(){return this.m_clearForces},r.ShiftOrigin=function(t){if(this.IsLocked())throw new Error;for(var e=this.m_bodyList;e;e=e.m_next)e.m_xf.p.SelfSub(t),e.m_sweep.c0.SelfSub(t),e.m_sweep.c.SelfSub(t);for(var i=this.m_jointList;i;i=i.m_next)i.ShiftOrigin(t);this.m_contactManager.m_broadPhase.ShiftOrigin(t)},r.GetContactManager=function(){return this.m_contactManager},r.GetProfile=function(){return this.m_profile},r.Dump=function(e){if(!this.m_locked){e("const g: b2Vec2 = new b2Vec2(%.15f, %.15f);\n",this.m_gravity.x,this.m_gravity.y),e("this.m_world.SetGravity(g);\n"),e("const bodies: b2Body[] = [];\n"),e("const joints: b2Joint[] = [];\n");for(var i=0,r=this.m_bodyList;r;r=r.m_next)r.m_islandIndex=i,r.Dump(e),++i;i=0;for(var n=this.m_jointList;n;n=n.m_next)n.m_index=i,++i;for(var s=this.m_jointList;s;s=s.m_next)s.m_type!==t.b2JointType.e_gearJoint&&(e("{\n"),s.Dump(e),e("}\n"));for(var a=this.m_jointList;a;a=a.m_next)a.m_type===t.b2JointType.e_gearJoint&&(e("{\n"),a.Dump(e),e("}\n"))}},r.DrawJoint=function(i){if(null!==this.m_debugDraw){var r=i.GetBodyA(),n=i.GetBodyB(),s=r.m_xf,a=n.m_xf,o=s.p,l=a.p,h=i.GetAnchorA(e.DrawJoint_s_p1),u=i.GetAnchorB(e.DrawJoint_s_p2),c=e.DrawJoint_s_color.SetRGB(.5,.8,.8);switch(i.m_type){case t.b2JointType.e_distanceJoint:this.m_debugDraw.DrawSegment(h,u,c);break;case t.b2JointType.e_pulleyJoint:var _=i,f=_.GetGroundAnchorA(),p=_.GetGroundAnchorB();this.m_debugDraw.DrawSegment(f,h,c),this.m_debugDraw.DrawSegment(p,u,c),this.m_debugDraw.DrawSegment(f,p,c);break;case t.b2JointType.e_mouseJoint:var d=e.DrawJoint_s_c;d.Set(0,1,0),this.m_debugDraw.DrawPoint(h,4,d),this.m_debugDraw.DrawPoint(u,4,d),d.Set(.8,.8,.8),this.m_debugDraw.DrawSegment(h,u,d);break;default:this.m_debugDraw.DrawSegment(o,h,c),this.m_debugDraw.DrawSegment(h,u,c),this.m_debugDraw.DrawSegment(l,u,c)}}},r.DrawShape=function(i,r){if(null!==this.m_debugDraw){var n=i.GetShape();switch(n.m_type){case t.b2ShapeType.e_circleShape:var s=n,a=s.m_p,o=s.m_radius,l=z.UNITX;this.m_debugDraw.DrawSolidCircle(a,o,l,r);break;case t.b2ShapeType.e_edgeShape:var h=n,u=h.m_vertex1,c=h.m_vertex2;this.m_debugDraw.DrawSegment(u,c,r);break;case t.b2ShapeType.e_chainShape:var _=n,f=_.m_count,p=_.m_vertices,d=e.DrawShape_s_ghostColor.SetRGBA(.75*r.r,.75*r.g,.75*r.b,r.a),m=p[0];if(this.m_debugDraw.DrawPoint(m,4,r),_.m_hasPrevVertex){var y=_.m_prevVertex;this.m_debugDraw.DrawSegment(y,m,d),this.m_debugDraw.DrawCircle(y,.1,d)}for(var g=1;g<f;++g){var v=p[g];this.m_debugDraw.DrawSegment(m,v,r),this.m_debugDraw.DrawPoint(v,4,r),m=v}if(_.m_hasNextVertex){var b=_.m_nextVertex;this.m_debugDraw.DrawSegment(b,m,d),this.m_debugDraw.DrawCircle(b,.1,d)}break;case t.b2ShapeType.e_polygonShape:var S=n,A=S.m_count,C=S.m_vertices;this.m_debugDraw.DrawSolidPolygon(C,A,r)}}},r.Solve=function(e){for(var i=this.m_bodyList;i;i=i.m_next)i.m_xf0.Copy(i.m_xf);for(var r=this.m_controllerList;r;r=r.m_next)r.Step(e);this.m_profile.solveInit=0,this.m_profile.solveVelocity=0,this.m_profile.solvePosition=0;var n=this.m_island;n.Initialize(this.m_bodyCount,this.m_contactManager.m_contactCount,this.m_jointCount,this.m_contactManager.m_contactListener);for(var s=this.m_bodyList;s;s=s.m_next)s.m_islandFlag=!1;for(var a=this.m_contactManager.m_contactList;a;a=a.m_next)a.m_islandFlag=!1;for(var o=this.m_jointList;o;o=o.m_next)o.m_islandFlag=!1;for(var l=this.s_stack,h=this.m_bodyList;h;h=h.m_next)if(!h.m_islandFlag&&h.IsAwake()&&h.IsActive()&&h.GetType()!==t.b2BodyType.b2_staticBody){n.Clear();var u=0;for(l[u++]=h,h.m_islandFlag=!0;u>0;){var c=l[--u];if(!c)throw new Error;if(n.AddBody(c),c.m_awakeFlag=!0,c.GetType()!==t.b2BodyType.b2_staticBody){for(var _=c.m_contactList;_;_=_.next){var f=_.contact;if(!f.m_islandFlag&&f.IsEnabled()&&f.IsTouching()){var p=f.m_fixtureA.m_isSensor,d=f.m_fixtureB.m_isSensor;if(!p&&!d){n.AddContact(f),f.m_islandFlag=!0;var m=_.other;m.m_islandFlag||(l[u++]=m,m.m_islandFlag=!0)}}}for(var y=c.m_jointList;y;y=y.next)if(!y.joint.m_islandFlag){var g=y.other;g.IsActive()&&(n.AddJoint(y.joint),y.joint.m_islandFlag=!0,g.m_islandFlag||(l[u++]=g,g.m_islandFlag=!0))}}}var v=new Ar;n.Solve(v,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=v.solveInit,this.m_profile.solveVelocity+=v.solveVelocity,this.m_profile.solvePosition+=v.solvePosition;for(var b=0;b<n.m_bodyCount;++b){var S=n.m_bodies[b];S.GetType()===t.b2BodyType.b2_staticBody&&(S.m_islandFlag=!1)}}for(var A=0;A<l.length&&l[A];++A)l[A]=null;for(var C=new Q,x=this.m_bodyList;x;x=x.m_next)x.m_islandFlag&&x.GetType()!==t.b2BodyType.b2_staticBody&&x.SynchronizeFixtures();this.m_contactManager.FindNewContacts(),this.m_profile.broadphase=C.GetMilliseconds()},r.SolveTOI=function(i){var r=this.m_island;if(r.Initialize(64,32,0,this.m_contactManager.m_contactListener),this.m_stepComplete){for(var n=this.m_bodyList;n;n=n.m_next)n.m_islandFlag=!1,n.m_sweep.alpha0=0;for(var s=this.m_contactManager.m_contactList;s;s=s.m_next)s.m_toiFlag=!1,s.m_islandFlag=!1,s.m_toiCount=0,s.m_toi=1}for(;;){for(var a=null,o=1,l=this.m_contactManager.m_contactList;l;l=l.m_next)if(l.IsEnabled()&&!(l.m_toiCount>8)){var h=1;if(l.m_toiFlag)h=l.m_toi;else{var u=l.GetFixtureA(),c=l.GetFixtureB();if(u.IsSensor()||c.IsSensor())continue;var _=u.GetBody(),f=c.GetBody(),p=_.m_type,d=f.m_type,m=_.IsAwake()&&p!==t.b2BodyType.b2_staticBody,y=f.IsAwake()&&d!==t.b2BodyType.b2_staticBody;if(!m&&!y)continue;var g=_.IsBullet()||p!==t.b2BodyType.b2_dynamicBody,v=f.IsBullet()||d!==t.b2BodyType.b2_dynamicBody;if(!g&&!v)continue;var b=_.m_sweep.alpha0;_.m_sweep.alpha0<f.m_sweep.alpha0?(b=f.m_sweep.alpha0,_.m_sweep.Advance(b)):f.m_sweep.alpha0<_.m_sweep.alpha0&&(b=_.m_sweep.alpha0,f.m_sweep.Advance(b));var S=l.GetChildIndexA(),A=l.GetChildIndexB(),C=e.SolveTOI_s_toi_input;C.proxyA.SetShape(u.GetShape(),S),C.proxyB.SetShape(c.GetShape(),A),C.sweepA.Copy(_.m_sweep),C.sweepB.Copy(f.m_sweep),C.tMax=1;var x=e.SolveTOI_s_toi_output;ye(x,C);var T=x.t;h=x.state===t.b2TOIOutputState.e_touching?B(b+(1-b)*T,1):1,l.m_toi=h,l.m_toiFlag=!0}h<o&&(a=l,o=h)}if(null===a||.9999<o){this.m_stepComplete=!0;break}var w=a.GetFixtureA(),E=a.GetFixtureB(),D=w.GetBody(),M=E.GetBody(),P=e.SolveTOI_s_backup1.Copy(D.m_sweep),R=e.SolveTOI_s_backup2.Copy(M.m_sweep);if(D.Advance(o),M.Advance(o),a.Update(this.m_contactManager.m_contactListener),a.m_toiFlag=!1,++a.m_toiCount,a.IsEnabled()&&a.IsTouching()){D.SetAwake(!0),M.SetAwake(!0),r.Clear(),r.AddBody(D),r.AddBody(M),r.AddContact(a),D.m_islandFlag=!0,M.m_islandFlag=!0,a.m_islandFlag=!0;for(var I=0;I<2;++I){var O=0===I?D:M;if(O.m_type===t.b2BodyType.b2_dynamicBody)for(var F=O.m_contactList;F&&r.m_bodyCount!==r.m_bodyCapacity&&r.m_contactCount!==r.m_contactCapacity;F=F.next){var L=F.contact;if(!L.m_islandFlag){var V=F.other;if(V.m_type!==t.b2BodyType.b2_dynamicBody||O.IsBullet()||V.IsBullet()){var k=L.m_fixtureA.m_isSensor,N=L.m_fixtureB.m_isSensor;if(!k&&!N){var G=e.SolveTOI_s_backup.Copy(V.m_sweep);V.m_islandFlag||V.Advance(o),L.Update(this.m_contactManager.m_contactListener),L.IsEnabled()&&L.IsTouching()?(L.m_islandFlag=!0,r.AddContact(L),V.m_islandFlag||(V.m_islandFlag=!0,V.m_type!==t.b2BodyType.b2_staticBody&&V.SetAwake(!0),r.AddBody(V))):(V.m_sweep.Copy(G),V.SynchronizeTransform())}}}}}var z=e.SolveTOI_s_subStep;z.dt=(1-o)*i.dt,z.inv_dt=1/z.dt,z.dtRatio=1,z.positionIterations=20,z.velocityIterations=i.velocityIterations,z.particleIterations=i.particleIterations,z.warmStarting=!1,r.SolveTOI(z,D.m_islandIndex,M.m_islandIndex);for(var U=0;U<r.m_bodyCount;++U){var H=r.m_bodies[U];if(H.m_islandFlag=!1,H.m_type===t.b2BodyType.b2_dynamicBody){H.SynchronizeFixtures();for(var j=H.m_contactList;j;j=j.next)j.contact.m_toiFlag=!1,j.contact.m_islandFlag=!1}}if(this.m_contactManager.FindNewContacts(),this.m_subStepping){this.m_stepComplete=!1;break}}else a.SetEnabled(!1),D.m_sweep.Copy(P),M.m_sweep.Copy(R),D.SynchronizeTransform(),M.SynchronizeTransform()}},r.AddController=function(t){return t.m_next=this.m_controllerList,t.m_prev=null,this.m_controllerList&&(this.m_controllerList.m_prev=t),this.m_controllerList=t,++this.m_controllerCount,t},r.RemoveController=function(t){return t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),this.m_controllerList===t&&(this.m_controllerList=t.m_next),--this.m_controllerCount,t.m_prev=null,t.m_next=null,t},e}();Cn.Step_s_step=new Cr,Cn.Step_s_stepTimer=new Q,Cn.Step_s_timer=new Q,Cn.DrawDebugData_s_color=new K(0,0,0),Cn.DrawDebugData_s_vs=z.MakeArray(4),Cn.DrawDebugData_s_xf=new Y,Cn.QueryFixtureShape_s_aabb=new Ft,Cn.RayCast_s_input=new It,Cn.RayCast_s_output=new Ot,Cn.RayCast_s_point=new z,Cn.DrawJoint_s_p1=new z,Cn.DrawJoint_s_p2=new z,Cn.DrawJoint_s_color=new K(.5,.8,.8),Cn.DrawJoint_s_c=new K,Cn.DrawShape_s_ghostColor=new K,Cn.SolveTOI_s_subStep=new Cr,Cn.SolveTOI_s_backup=new J,Cn.SolveTOI_s_backup1=new J,Cn.SolveTOI_s_backup2=new J,Cn.SolveTOI_s_toi_input=new ne,Cn.SolveTOI_s_toi_output=new ae;var xn=function(t,e){this.prevBody=null,this.nextBody=null,this.prevController=null,this.nextController=null,this.controller=t,this.body=e},Tn=function(){function t(){this.m_bodyList=null,this.m_bodyCount=0,this.m_prev=null,this.m_next=null}var e=t.prototype;return e.GetNext=function(){return this.m_next},e.GetPrev=function(){return this.m_prev},e.GetBodyList=function(){return this.m_bodyList},e.AddBody=function(t){var e=new xn(this,t);e.nextBody=this.m_bodyList,e.prevBody=null,this.m_bodyList&&(this.m_bodyList.prevBody=e),this.m_bodyList=e,++this.m_bodyCount,e.nextController=t.m_controllerList,e.prevController=null,t.m_controllerList&&(t.m_controllerList.prevController=e),t.m_controllerList=e,++t.m_controllerCount},e.RemoveBody=function(t){if(this.m_bodyCount<=0)throw new Error;for(var e=this.m_bodyList;e&&e.body!==t;)e=e.nextBody;if(null===e)throw new Error;e.prevBody&&(e.prevBody.nextBody=e.nextBody),e.nextBody&&(e.nextBody.prevBody=e.prevBody),this.m_bodyList===e&&(this.m_bodyList=e.nextBody),--this.m_bodyCount,e.nextController&&(e.nextController.prevController=e.prevController),e.prevController&&(e.prevController.nextController=e.nextController),t.m_controllerList===e&&(t.m_controllerList=e.nextController),--t.m_controllerCount},e.Clear=function(){for(;this.m_bodyList;)this.RemoveBody(this.m_bodyList.body);this.m_bodyCount=0},t}(),wn=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).normal=new z(0,1),e.offset=0,e.density=0,e.velocity=new z(0,0),e.linearDrag=0,e.angularDrag=0,e.useDensity=!1,e.useWorldGravity=!0,e.gravity=new z(0,0),e}Me(e,t);var i=e.prototype;return i.Step=function(){if(this.m_bodyList){this.useWorldGravity&&this.gravity.Copy(this.m_bodyList.body.GetWorld().GetGravity());for(var t=this.m_bodyList;t;t=t.nextBody){var e=t.body;if(e.IsAwake()){for(var i=new z,n=new z,s=0,a=0,o=e.GetFixtureList();o;o=o.m_next){var l=new z,h=o.GetShape().ComputeSubmergedArea(this.normal,this.offset,e.GetTransform(),l);s+=h,i.x+=h*l.x,i.y+=h*l.y;var u;a+=h*(u=this.useDensity?o.GetDensity():1),n.x+=h*l.x*u,n.y+=h*l.y*u}if(i.x/=s,i.y/=s,n.x/=a,n.y/=a,!(s<r)){var c=this.gravity.Clone().SelfNeg();c.SelfMul(this.density*s),e.ApplyForce(c,n);var _=e.GetLinearVelocityFromWorldPoint(i,new z);_.SelfSub(this.velocity),_.SelfMul(-this.linearDrag*s),e.ApplyForce(_,i),e.ApplyTorque(-e.GetInertia()/e.GetMass()*s*e.GetAngularVelocity()*this.angularDrag)}}}}},i.Draw=function(t){var e=100,i=new z,r=new z;i.x=this.normal.x*this.offset+this.normal.y*e,i.y=this.normal.y*this.offset-this.normal.x*e,r.x=this.normal.x*this.offset-this.normal.y*e,r.y=this.normal.y*this.offset+this.normal.x*e;var n=new K(0,0,.8);t.DrawSegment(i,r,n)},e}(Tn),En=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).A=new z(0,0),e}Me(e,t);var i=e.prototype;return i.Step=function(t){for(var i=z.MulSV(t.dt,this.A,e.Step_s_dtA),r=this.m_bodyList;r;r=r.nextBody){var n=r.body;n.IsAwake()&&n.SetLinearVelocity(z.AddVV(n.GetLinearVelocity(),i,z.s_t0))}},i.Draw=function(){},e}(Tn);En.Step_s_dtA=new z;var Bn=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).F=new z(0,0),e}Me(e,t);var i=e.prototype;return i.Step=function(){for(var t=this.m_bodyList;t;t=t.nextBody){var e=t.body;e.IsAwake()&&e.ApplyForce(this.F,e.GetWorldCenter())}},i.Draw=function(){},e}(Tn),Dn=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).G=1,e.invSqr=!0,e}Me(e,t);var i=e.prototype;return i.Step=function(){if(this.invSqr)for(var t=this.m_bodyList;t;t=t.nextBody)for(var i=t.body,n=i.GetWorldCenter(),s=i.GetMass(),a=this.m_bodyList;a&&a!==t;a=a.nextBody){var o=a.body,l=o.GetWorldCenter(),h=o.GetMass(),u=l.x-n.x,c=l.y-n.y,_=u*u+c*c;if(!(_<r)){var f=e.Step_s_f.Set(u,c);f.SelfMul(this.G/_/O(_)*s*h),i.IsAwake()&&i.ApplyForce(f,n),o.IsAwake()&&o.ApplyForce(f.SelfMul(-1),l)}}else for(var p=this.m_bodyList;p;p=p.nextBody)for(var d=p.body,m=d.GetWorldCenter(),y=d.GetMass(),g=this.m_bodyList;g&&g!==p;g=g.nextBody){var v=g.body,b=v.GetWorldCenter(),S=v.GetMass(),A=b.x-m.x,C=b.y-m.y,x=A*A+C*C;if(!(x<r)){var T=e.Step_s_f.Set(A,C);T.SelfMul(this.G/x*y*S),d.IsAwake()&&d.ApplyForce(T,m),v.IsAwake()&&v.ApplyForce(T.SelfMul(-1),b)}}},i.Draw=function(){},e}(Tn);Dn.Step_s_f=new z;var Mn=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).T=new j,e.maxTimestep=0,e}Me(e,t);var i=e.prototype;return i.Step=function(t){var i=t.dt;if(!(i<=r)){i>this.maxTimestep&&this.maxTimestep>0&&(i=this.maxTimestep);for(var n=this.m_bodyList;n;n=n.nextBody){var s=n.body;if(s.IsAwake()){var a=s.GetWorldVector(j.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),z.s_t0),z.s_t1),e.Step_s_damping);s.SetLinearVelocity(z.AddVV(s.GetLinearVelocity(),z.MulSV(i,a,z.s_t0),z.s_t1))}}}},i.Draw=function(){},i.SetAxisAligned=function(t,e){this.T.ex.x=-t,this.T.ex.y=0,this.T.ey.x=0,this.T.ey.y=-e,this.maxTimestep=t>0||e>0?1/D(t,e):0},e}(Tn);Mn.Step_s_damping=new z;var Pn=function(){function t(){this.m_count=0,this.m_ps=[],this.m_p0s=[],this.m_vs=[],this.m_ims=[],this.m_Ls=[],this.m_as=[],this.m_gravity=new z,this.m_damping=0,this.m_k2=1,this.m_k3=.1}var e=t.prototype;return e.GetVertexCount=function(){return this.m_count},e.GetVertices=function(){return this.m_ps},e.Initialize=function(t){this.m_count=t.count,this.m_ps=z.MakeArray(this.m_count),this.m_p0s=z.MakeArray(this.m_count),this.m_vs=z.MakeArray(this.m_count),this.m_ims=C(this.m_count);for(var e=0;e<this.m_count;++e){this.m_ps[e].Copy(t.vertices[e]),this.m_p0s[e].Copy(t.vertices[e]),this.m_vs[e].SetZero();var i=t.masses[e];this.m_ims[e]=i>0?1/i:0}var r=this.m_count-1,n=this.m_count-2;this.m_Ls=C(r),this.m_as=C(n);for(var s=0;s<r;++s){var a=this.m_ps[s],o=this.m_ps[s+1];this.m_Ls[s]=z.DistanceVV(a,o)}for(var l=0;l<n;++l){var h=this.m_ps[l],u=this.m_ps[l+1],c=this.m_ps[l+2],_=z.SubVV(u,h,z.s_t0),f=z.SubVV(c,u,z.s_t1),p=z.CrossVV(_,f),d=z.DotVV(_,f);this.m_as[l]=G(p,d)}this.m_gravity.Copy(t.gravity),this.m_damping=t.damping,this.m_k2=t.k2,this.m_k3=t.k3},e.Step=function(t,e){if(0!==t){for(var i=Math.exp(-t*this.m_damping),r=0;r<this.m_count;++r)this.m_p0s[r].Copy(this.m_ps[r]),this.m_ims[r]>0&&this.m_vs[r].SelfMulAdd(t,this.m_gravity),this.m_vs[r].SelfMul(i),this.m_ps[r].SelfMulAdd(t,this.m_vs[r]);for(var n=0;n<e;++n)this.SolveC2(),this.SolveC3(),this.SolveC2();for(var s=1/t,a=0;a<this.m_count;++a)z.MulSV(s,z.SubVV(this.m_ps[a],this.m_p0s[a],z.s_t0),this.m_vs[a])}},e.SolveC2=function(){for(var e=this.m_count-1,i=0;i<e;++i){var r=this.m_ps[i],n=this.m_ps[i+1],s=z.SubVV(n,r,t.s_d),a=s.Normalize(),o=this.m_ims[i],l=this.m_ims[i+1];if(o+l!==0){var h=o/(o+l),u=l/(o+l);r.SelfMulSub(this.m_k2*h*(this.m_Ls[i]-a),s),n.SelfMulAdd(this.m_k2*u*(this.m_Ls[i]-a),s)}}},e.SetAngle=function(t){for(var e=this.m_count-2,i=0;i<e;++i)this.m_as[i]=t},e.SolveC3=function(){for(var e=this.m_count-2,i=0;i<e;++i){var r=this.m_ps[i],n=this.m_ps[i+1],a=this.m_ps[i+2],o=this.m_ims[i],l=this.m_ims[i+1],h=this.m_ims[i+2],u=z.SubVV(n,r,t.s_d1),c=z.SubVV(a,n,t.s_d2),_=u.LengthSquared(),f=c.LengthSquared();if(_*f!=0){var p=z.CrossVV(u,c),d=z.DotVV(u,c),m=G(p,d),y=z.MulSV(-1/_,u.SelfSkew(),t.s_Jd1),g=z.MulSV(1/f,c.SelfSkew(),t.s_Jd2),v=z.NegV(y,t.s_J1),b=z.SubVV(y,g,t.s_J2),S=g,A=o*z.DotVV(v,v)+l*z.DotVV(b,b)+h*z.DotVV(S,S);if(0!==A){A=1/A;for(var C=m-this.m_as[i];C>s;)C=(m-=2*s)-this.m_as[i];for(;C<-s;)C=(m+=2*s)-this.m_as[i];var x=-this.m_k3*A*C;r.SelfMulAdd(o*x,v),n.SelfMulAdd(l*x,b),a.SelfMulAdd(h*x,S)}}}},e.Draw=function(t){for(var e=new K(.4,.5,.7),i=0;i<this.m_count-1;++i)t.DrawSegment(this.m_ps[i],this.m_ps[i+1],e)},t}();Pn.s_d=new z,Pn.s_d1=new z,Pn.s_d2=new z,Pn.s_Jd1=new z,Pn.s_Jd2=new z,Pn.s_J1=new z,Pn.s_J2=new z,t.b2AABB=Ft,t.b2Abs=E,t.b2Acos=k,t.b2Alloc=function(){return null},t.b2AreaJoint=Fi,t.b2AreaJointDef=Oi,t.b2Asin=N,t.b2Assert=function(t){if(!t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];throw Qn(Error,i)}},t.b2Atan2=G,t.b2BlockAllocator=function(){},t.b2Body=Ei,t.b2BodyDef=function(){this.type=t.b2BodyType.b2_staticBody,this.position=new z(0,0),this.angle=0,this.linearVelocity=new z(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.active=!0,this.userData=null,this.gravityScale=1},t.b2BroadPhase=qt,t.b2BuoyancyController=wn,t.b2CalculateParticleIterations=Vr,t.b2ChainAndCircleContact=cr,t.b2ChainAndPolygonContact=_r,t.b2ChainShape=vi,t.b2CircleContact=ar,t.b2CircleShape=mi,t.b2Clamp=M,t.b2ClipSegmentToLine=Vt,t.b2ClipVertex=Rt,t.b2CollideCircles=be,t.b2CollideEdgeAndCircle=ai,t.b2CollideEdgeAndPolygon=_i,t.b2CollidePolygonAndCircle=xe,t.b2CollidePolygons=Ke,t.b2Color=K,t.b2ConstantAccelController=En,t.b2ConstantForceController=Bn,t.b2Contact=sr,t.b2ContactEdge=nr,t.b2ContactFactory=pr,t.b2ContactFeature=wt,t.b2ContactFilter=mr,t.b2ContactID=Et,t.b2ContactImpulse=yr,t.b2ContactListener=gr,t.b2ContactManager=Sr,t.b2ContactPositionConstraint=Mr,t.b2ContactRegister=fr,t.b2ContactSolver=Ir,t.b2ContactSolverDef=Pr,t.b2ContactVelocityConstraint=Dr,t.b2Controller=Tn,t.b2ControllerEdge=xn,t.b2Cos=L,t.b2Counter=$,t.b2DegToRad=function(t){return t*x},t.b2DestructionListener=dr,t.b2Distance=dt,t.b2DistanceInput=rt,t.b2DistanceJoint=Ii,t.b2DistanceJointDef=Ri,t.b2DistanceOutput=nt,t.b2DistanceProxy=et,t.b2Draw=Z,t.b2DynamicTree=jt,t.b2EdgeAndCircleContact=hr,t.b2EdgeAndPolygonContact=ur,t.b2EdgeShape=gi,t.b2Filter=bi,t.b2Fixture=xi,t.b2FixtureDef=Si,t.b2FixtureParticleQueryCallback=en,t.b2FixtureProxy=Ai,t.b2Free=function(){},t.b2FrictionJoint=Vi,t.b2FrictionJointDef=Li,t.b2GearJoint=Ni,t.b2GearJointDef=ki,t.b2GetPointStates=function(e,i,r,n){var s;for(s=0;s<r.pointCount;++s){var a=r.points[s].id.key;e[s]=t.b2PointState.b2_removeState;for(var o=0,l=n.pointCount;o<l;++o)if(n.points[o].id.key===a){e[s]=t.b2PointState.b2_persistState;break}}for(;s<2;++s)e[s]=t.b2PointState.b2_nullState;for(s=0;s<n.pointCount;++s){var h=n.points[s].id.key;i[s]=t.b2PointState.b2_addState;for(var u=0,c=r.pointCount;u<c;++u)if(r.points[u].id.key===h){i[s]=t.b2PointState.b2_persistState;break}}for(;s<2;++s)i[s]=t.b2PointState.b2_nullState},t.b2GravityController=Dn,t.b2GrowableBuffer=tn,t.b2GrowableStack=tt,t.b2InvSqrt=I,t.b2IsPowerOfTwo=function(t){return t>0&&0==(t&t-1)},t.b2IsValid=P,t.b2Island=Fr,t.b2Jacobian=Bi,t.b2Joint=Pi,t.b2JointDef=Mi,t.b2JointEdge=Di,t.b2Log=function(){},t.b2MakeArray=A,t.b2MakeNullArray=function(t){for(var e=new Array(t),i=0;i<t;++i)e[i]=null;return e},t.b2MakeNumberArray=C,t.b2Manifold=Mt,t.b2ManifoldPoint=Bt,t.b2MassData=pi,t.b2Mat22=j,t.b2Mat33=W,t.b2Max=D,t.b2Maybe=e,t.b2Min=B,t.b2MixFriction=ir,t.b2MixRestitution=rr,t.b2MotorJoint=zi,t.b2MotorJointDef=Gi,t.b2MouseJoint=Hi,t.b2MouseJointDef=Ui,t.b2NextPowerOfTwo=function(t){return t|=t>>1&2147483647,t|=t>>2&1073741823,t|=t>>4&268435455,1+((t|=t>>8&16777215)|t>>16&65535)},t.b2Pair=Yt,t.b2PairLessThan=Jt,t.b2ParseInt=function(t){return parseInt(t,10)},t.b2ParseUInt=function(t){return Math.abs(parseInt(t,10))},t.b2ParticleBodyContact=nn,t.b2ParticleContact=rn,t.b2ParticleDef=Lr,t.b2ParticleGroup=zr,t.b2ParticleGroupDef=Gr,t.b2ParticleHandle=Nr,t.b2ParticlePair=sn,t.b2ParticlePairSet=dn,t.b2ParticleSystem=ln,t.b2ParticleSystemDef=on,t.b2ParticleSystem_CompositeShape=vn,t.b2ParticleSystem_ConnectionFilter=mn,t.b2ParticleSystem_DestroyParticlesInShapeCallback=yn,t.b2ParticleSystem_FixedSetAllocator=fn,t.b2ParticleSystem_FixtureParticle=function(t,e){this.second=p,this.first=t,this.second=e},t.b2ParticleSystem_FixtureParticleSet=pn,t.b2ParticleSystem_InsideBoundsEnumerator=cn,t.b2ParticleSystem_JoinParticleGroupsFilter=gn,t.b2ParticleSystem_ParticleListNode=_n,t.b2ParticleSystem_ParticlePair=function(t,e){this.first=p,this.second=p,this.first=t,this.second=e},t.b2ParticleSystem_Proxy=un,t.b2ParticleSystem_ReactiveFilter=bn,t.b2ParticleSystem_SolveCollisionCallback=An,t.b2ParticleSystem_UpdateBodyContactsCallback=Sn,t.b2ParticleSystem_UserOverridableBuffer=hn,t.b2ParticleTriad=an,t.b2PolygonAndCircleContact=lr,t.b2PolygonContact=or,t.b2PolygonShape=yi,t.b2Position=xr,t.b2PositionSolverManifold=Rr,t.b2Pow=F,t.b2PrismaticJoint=Wi,t.b2PrismaticJointDef=ji,t.b2Profile=Ar,t.b2PulleyJoint=Yi,t.b2PulleyJointDef=Xi,t.b2QueryCallback=vr,t.b2RadToDeg=function(t){return t*T},t.b2Random=function(){return 2*Math.random()-1},t.b2RandomRange=function(t,e){return(e-t)*Math.random()+t},t.b2RayCastCallback=br,t.b2RayCastInput=It,t.b2RayCastOutput=Ot,t.b2RevoluteJoint=Ji,t.b2RevoluteJointDef=qi,t.b2Rope=Pn,t.b2RopeDef=function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new z(0,0),this.damping=.1,this.k2=.9,this.k3=.1},t.b2RopeJoint=Zi,t.b2RopeJointDef=Ki,t.b2Rot=X,t.b2SeparationFunction=oe,t.b2Shape=di,t.b2ShapeCast=function(t,e){t.iterations=0,t.lambda=1,t.normal.SetZero(),t.point.SetZero();var i=e.proxyA,r=e.proxyB,n=D(i.m_radius,h)+D(r.m_radius,h),s=e.transformA,a=e.transformB,o=e.translationB,l=yt.Set(0,0),u=0,c=gt;c.m_count=0;for(var _=c.m_vertices,f=i.GetSupport(X.MulTRV(s.q,z.NegV(o,z.s_t1),z.s_t0)),p=Y.MulXV(s,i.GetVertex(f),vt),d=r.GetSupport(X.MulTRV(a.q,o,z.s_t0)),m=Y.MulXV(a,r.GetVertex(d),bt),y=z.SubVV(p,m,St),g=D(h,n-h),v=0;v<20&&E(y.Length()-g)>.004;){t.iterations+=1,f=i.GetSupport(X.MulTRV(s.q,z.NegV(y,z.s_t1),z.s_t0)),p=Y.MulXV(s,i.GetVertex(f),vt),d=r.GetSupport(X.MulTRV(a.q,y,z.s_t0)),m=Y.MulXV(a,r.GetVertex(d),bt);var b=z.SubVV(p,m,At);y.Normalize();var S=z.DotVV(y,b),A=z.DotVV(y,o);if(S-g>u*A){if(A<=0)return!1;if((u=(S-g)/A)>1)return!1;l.Copy(y).SelfNeg(),c.m_count=0}var C=_[c.m_count];switch(C.indexA=d,C.wA.Copy(m).SelfMulAdd(u,o),C.indexB=f,C.wB.Copy(p),C.w.Copy(C.wB).SelfSub(C.wA),C.a=1,c.m_count+=1,c.m_count){case 1:break;case 2:c.Solve2();break;case 3:c.Solve3()}if(3===c.m_count)return!1;c.GetClosestPoint(y),++v}var x=Ct,T=xt;return c.GetWitnessPoints(x,T),y.LengthSquared()>0&&(l.Copy(y).SelfNeg(),l.Normalize()),t.normal.Copy(l),t.lambda=u,t.iterations=v,!0},t.b2ShapeCastInput=function(){this.proxyA=new et,this.proxyB=new et,this.transformA=new Y,this.transformB=new Y,this.translationB=new z},t.b2ShapeCastOutput=function(){this.point=new z,this.normal=new z,this.lambda=0,this.iterations=0},t.b2Simplex=at,t.b2SimplexCache=it,t.b2SimplexVertex=st,t.b2Sin=V,t.b2SolverData=wr,t.b2Sq=R,t.b2Sqrt=O,t.b2StackAllocator=function(){},t.b2Swap=function(t,e){var i=t[0];t[0]=e[0],e[0]=i},t.b2Sweep=J,t.b2TOIInput=ne,t.b2TOIOutput=ae,t.b2TensorDampingController=Mn,t.b2TestOverlapAABB=Lt,t.b2TestOverlapShape=zt,t.b2TimeOfImpact=ye,t.b2TimeStep=Cr,t.b2Timer=Q,t.b2Transform=Y,t.b2TreeNode=Ht,t.b2Vec2=z,t.b2Vec2_zero=U,t.b2Vec3=H,t.b2Velocity=Tr,t.b2VelocityConstraintPoint=Br,t.b2Version=b,t.b2WeldJoint=$i,t.b2WeldJointDef=Qi,t.b2WheelJoint=er,t.b2WheelJointDef=tr,t.b2World=Cn,t.b2WorldManifold=Pt,t.b2_180_over_pi=T,t.b2_aabbExtension=a,t.b2_aabbMultiplier=2,t.b2_angularSleepTolerance=v,t.b2_angularSlop=l,t.b2_barrierCollisionTime=2.5,t.b2_baumgarte=.2,t.b2_branch="master",t.b2_commit="fbf51801d80fc389d43dc46524520e89043b6faf",t.b2_epsilon=r,t.b2_epsilon_sq=n,t.b2_gjk_reset=function(){t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0},t.b2_invalidParticleIndex=p,t.b2_linearSleepTolerance=g,t.b2_linearSlop=o,t.b2_maxAngularCorrection=c,t.b2_maxFloat=i,t.b2_maxLinearCorrection=u,t.b2_maxManifoldPoints=2,t.b2_maxParticleForce=.5,t.b2_maxParticleIndex=2147483647,t.b2_maxParticlePressure=m,t.b2_maxPolygonVertices=8,t.b2_maxRotation=_,t.b2_maxRotationSquared=f,t.b2_maxSubSteps=8,t.b2_maxTOIContacts=32,t.b2_maxTranslation=2,t.b2_maxTranslationSquared=4,t.b2_maxTriadDistance=2,t.b2_maxTriadDistanceSquared=4,t.b2_minParticleSystemBufferCapacity=y,t.b2_minParticleWeight=1,t.b2_minPulleyLength=2,t.b2_particleStride=d,t.b2_pi=s,t.b2_pi_over_180=x,t.b2_polygonRadius=h,t.b2_timeToSleep=.5,t.b2_toiBaumgarte=.75,t.b2_toi_reset=function(){t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0},t.b2_two_pi=w,t.b2_velocityThreshold=1,t.b2_version=S,t.g_blockSolve=Er,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));As(mQ);var yQ={};for(var gQ in mQ)-1===gQ.indexOf("b2_")&&(yQ[gQ.replace("b2","")]=mQ[gQ]);var vQ,bQ,SQ,AQ,CQ=yQ;!function(t){t[t.Static=0]="Static",t[t.Kinematic=1]="Kinematic",t[t.Dynamic=2]="Dynamic",t[t.Animated=3]="Animated"}(vQ||(vQ=t("ERigidBody2DType",{}))),yi(vQ),function(t){t[t.None=0]="None",t[t.BOX=1]="BOX",t[t.CIRCLE=2]="CIRCLE",t[t.POLYGON=3]="POLYGON"}(bQ||(bQ=t("ECollider2DType",{}))),yi(bQ),function(t){t[t.None=0]="None",t[t.DISTANCE=1]="DISTANCE",t[t.SPRING=2]="SPRING",t[t.WHEEL=3]="WHEEL",t[t.MOUSE=4]="MOUSE",t[t.FIXED=5]="FIXED",t[t.SLIDER=6]="SLIDER",t[t.RELATIVE=7]="RELATIVE",t[t.HINGE=8]="HINGE"}(SQ||(SQ=t("EJoint2DType",{}))),yi(SQ),function(t){t[t.Closest=0]="Closest",t[t.Any=1]="Any",t[t.AllClosest=2]="AllClosest",t[t.All=3]="All"}(AQ||(AQ=t("ERaycast2DType",{})));var xQ,TQ=t("Contact2DType",{None:"none-contact",BEGIN_CONTACT:"begin-contact",END_CONTACT:"end-contact",PRE_SOLVE:"pre-solve",POST_SOLVE:"post-solve"});!function(t){t[t.None=0]="None",t[t.Shape=1]="Shape",t[t.Joint=2]="Joint",t[t.Aabb=4]="Aabb",t[t.Pair=8]="Pair",t[t.CenterOfMass=16]="CenterOfMass",t[t.Particle=32]="Particle",t[t.Controller=64]="Controller",t[t.All=63]="All"}(xQ||(xQ=t("EPhysics2DDrawFlags",{})));var wQ=t("PHYSICS_2D_PTM_RATIO",32),EQ=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._contactFixtures=[],e._BeginContact=null,e._EndContact=null,e._PreSolve=null,e._PostSolve=null,e}Me(e,t);var i=e.prototype;return i.setBeginContact=function(t){this._BeginContact=t},i.setEndContact=function(t){this._EndContact=t},i.setPreSolve=function(t){this._PreSolve=t},i.setPostSolve=function(t){this._PostSolve=t},i.BeginContact=function(t){if(this._BeginContact){var e=t.GetFixtureA(),i=t.GetFixtureB(),r=this._contactFixtures;t._shouldReport=!1,-1===r.indexOf(e)&&-1===r.indexOf(i)||(t._shouldReport=!0,this._BeginContact(t))}},i.EndContact=function(t){this._EndContact&&t._shouldReport&&(t._shouldReport=!1,this._EndContact(t))},i.PreSolve=function(t,e){this._PreSolve&&t._shouldReport&&this._PreSolve(t,e)},i.PostSolve=function(t,e){this._PostSolve&&t._shouldReport&&this._PostSolve(t,e)},i.registerContactFixture=function(t){this._contactFixtures.push(t)},i.unregisterContactFixture=function(t){$n(this._contactFixtures,t)},e}(CQ.ContactListener),BQ=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._point=new CQ.Vec2,e._isPoint=!1,e._fixtures=[],e}Me(e,t);var i=e.prototype;return i.init=function(t){t?(this._isPoint=!0,this._point.x=t.x,this._point.y=t.y):this._isPoint=!1,this._fixtures.length=0},i.ReportFixture=function(t){return this._isPoint?t.TestPoint(this._point)&&this._fixtures.push(t):this._fixtures.push(t),!0},i.getFixture=function(){return this._fixtures[0]},i.getFixtures=function(){return this._fixtures},e}(CQ.QueryCallback);function DQ(t,e){var i=e.length;return e[t<0?i- -t%i:t%i]}function MQ(t,e,i){for(var r=[];e<t;)e+=i.length;for(;t<=e;++t)r.push(DQ(t,i));return r}function PQ(t){NQ(t);for(var e,i,r,n,s,a,o=[],l=new dr,h=new dr,u=0,c=0,_=0;_<t.length;++_)if(IQ(_,t)){i=r=1e8;for(var f=0;f<t.length;++f)FQ(DQ(_-1,t),DQ(_,t),DQ(f,t))&&VQ(DQ(_-1,t),DQ(_,t),DQ(f-1,t))&&(n=zQ(DQ(_-1,t),DQ(_,t),DQ(f,t),DQ(f-1,t)),OQ(DQ(_+1,t),DQ(_,t),n)&&(e=kQ(DQ(_,t),n))<i&&(i=e,l=n,u=f)),FQ(DQ(_+1,t),DQ(_,t),DQ(f+1,t))&&VQ(DQ(_+1,t),DQ(_,t),DQ(f,t))&&(n=zQ(DQ(_+1,t),DQ(_,t),DQ(f,t),DQ(f+1,t)),FQ(DQ(_-1,t),DQ(_,t),n)&&(e=kQ(DQ(_,t),n))<r&&(r=e,c=f,h=n));if(u==(c+1)%t.length){var p=l.add(h).multiplyScalar(.5);(s=MQ(_,c,t)).push(p),(a=MQ(u,_,t)).push(p)}else{for(var d=0,m=u;c<u;)c+=t.length;for(var y=u;y<=c;++y)if(RQ(_,y,t)){var g=1/(kQ(DQ(_,t),DQ(y,t))+1);IQ(y,t)?VQ(DQ(y-1,t),DQ(y,t),DQ(_,t))&&LQ(DQ(y+1,t),DQ(y,t),DQ(_,t))?g+=3:g+=2:g+=1,g>d&&(m=y,d=g)}s=MQ(_,m,t),a=MQ(m,_,t)}return(o=o.concat(PQ(s))).concat(PQ(a))}o.push(t);for(var v=o.length-1;v>=0;v--)0==o[v].length&&o.splice(v,0);return o}function RQ(t,e,i){if(IQ(t,i)){if(LQ(DQ(t,i),DQ(t-1,i),DQ(e,i))&&VQ(DQ(t,i),DQ(t+1,i),DQ(e,i)))return!1}else if(VQ(DQ(t,i),DQ(t+1,i),DQ(e,i))||LQ(DQ(t,i),DQ(t-1,i),DQ(e,i)))return!1;if(IQ(e,i)){if(LQ(DQ(e,i),DQ(e-1,i),DQ(t,i))&&VQ(DQ(e,i),DQ(e+1,i),DQ(t,i)))return!1}else if(VQ(DQ(e,i),DQ(e+1,i),DQ(t,i))||LQ(DQ(e,i),DQ(e-1,i),DQ(t,i)))return!1;for(var r=0;r<i.length;++r)if((r+1)%i.length!=t&&r!=t&&(r+1)%i.length!=e&&r!=e){var n=new dr;if(UQ(DQ(t,i),DQ(e,i),DQ(r,i),DQ(r+1,i),n))return!1}return!0}function IQ(t,e){return OQ(t,e)}function OQ(t,e,i){if(void 0===i){var r=t,n=e;t=DQ(r-1,n),e=DQ(r,n),i=DQ(r+1,n)}return HQ(t,e,i)<0}function FQ(t,e,i){return HQ(t,e,i)>0}function LQ(t,e,i){return HQ(t,e,i)>=0}function VQ(t,e,i){return HQ(t,e,i)<=0}function kQ(t,e){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r}function NQ(t){GQ(t)||t.reverse()}function GQ(t){return t.length<3||function(t){var e,i=0;for(e=0;e<t.length;e++){var r=(e+1)%t.length;i+=t[e].x*t[r].y,i-=t[e].y*t[r].x}return i/2}(t)>0}function zQ(t,e,i,r){var n,s=new dr,a=e.y-t.y,o=t.x-e.x,l=a*t.x+o*t.y,h=r.y-i.y,u=i.x-r.x,c=h*i.x+u*i.y,_=a*u-h*o;return n=_,0,Math.abs(n-0)<=1e-6||(s.x=(u*l-o*c)/_,s.y=(a*c-h*l)/_),s}function UQ(t,e,i,r,n){if(t==i||t==r||e==i||e==r)return!1;var s=t.x,a=t.y,o=e.x,l=e.y,h=i.x,u=i.y,c=r.x,_=r.y;if(Math.max(s,o)<Math.min(h,c)||Math.max(h,c)<Math.min(s,o))return!1;if(Math.max(a,l)<Math.min(u,_)||Math.max(u,_)<Math.min(a,l))return!1;var f=(c-h)*(a-u)-(_-u)*(s-h),p=(o-s)*(a-u)-(l-a)*(s-h),d=(_-u)*(o-s)-(c-h)*(l-a);return!(Math.abs(d)<1e-6)&&(p/=d,(f/=d)>0&&f<1&&p>0&&p<1&&(n.x=s+f*(o-s),n.y=a+f*(l-a),!0))}function HQ(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}var jQ=Object.freeze({__proto__:null,ConvexPartition:PQ,ForceCounterClockWise:NQ,IsCounterClockWise:GQ}),WQ=function(){return 0},XQ={impl:null,rigidBody:null,isAwake:!1,isSleeping:!1,initialize:WQ,setType:WQ,setLinearDamping:WQ,setAngularDamping:WQ,setGravityScale:WQ,setFixedRotation:WQ,setAllowSleep:WQ,isActive:WQ,setActive:WQ,wakeUp:WQ,sleep:WQ,getMass:WQ,getInertia:WQ,getLinearVelocity:WQ,setLinearVelocity:WQ,getLinearVelocityFromWorldPoint:WQ,getAngularVelocity:WQ,setAngularVelocity:WQ,getLocalVector:WQ,getWorldVector:WQ,getLocalPoint:WQ,getWorldPoint:WQ,getLocalCenter:WQ,getWorldCenter:WQ,applyForce:WQ,applyForceToCenter:WQ,applyTorque:WQ,applyLinearImpulse:WQ,applyLinearImpulseToCenter:WQ,applyAngularImpulse:WQ,onEnable:WQ,onDisable:WQ,onDestroy:WQ},YQ={INITED:!1};var qQ={INITED:!1},JQ={impl:null,initialize:WQ,setDampingRatio:WQ,setFrequency:WQ,setMaxForce:WQ,setTarget:WQ,setDistance:WQ,setAngularOffset:WQ,setCorrectionFactor:WQ,setLinearOffset:WQ,setMaxLength:WQ,setMaxTorque:WQ,setLowerLimit:WQ,setUpperLimit:WQ,setMaxMotorForce:WQ,setMaxMotorTorque:WQ,setMotorSpeed:WQ,enableLimit:WQ,enableMotor:WQ,setLowerAngle:WQ,setUpperAngle:WQ};var KQ,ZQ,QQ,$Q,t$,e$,i$,r$,n$,s$,a$,o$,l$,h$,u$,c$,_$,f$,p$,d$,m$=null,y$=t("PhysicsSystem2D",function(t){function e(){var e;(e=t.call(this)||this).velocityIterations=10,e.positionIterations=10,e.physicsWorld=void 0,e.collisionMatrix=new zW,e._enable=!0,e._allowSleep=!0,e._maxSubSteps=1,e._fixedTimeStep=1/60,e._autoSimulation=!0,e._accumulator=0,e._steping=!1,e._gravity=new dr(0,-10*wQ),e._delayEvents=[];var i=Wr.config?Wr.config.physics:null;if(i&&(dr.copy(e._gravity,i.gravity),e._gravity.multiplyScalar(wQ),e._allowSleep=i.allowSleep,e._fixedTimeStep=i.fixedTimeStep,e._maxSubSteps=i.maxSubSteps,e._autoSimulation=i.autoSimulation,i.collisionMatrix))for(var r in i.collisionMatrix){var n=parseInt(r),s=1<<parseInt(r);e.collisionMatrix[""+s]=i.collisionMatrix[n]}return e.physicsWorld=new iQ.PhysicsWorld,e.gravity=e._gravity,e.allowSleep=e._allowSleep,e}Me(e,t);var i=e.prototype;return i.postUpdate=function(t){if(this._enable&&this._autoSimulation){wr.emit(Er.EVENT_BEFORE_PHYSICS),this._steping=!0;var e=this._fixedTimeStep,i=this.velocityIterations,r=this.positionIterations;this._accumulator+=t;for(var n=0;n++<this._maxSubSteps&&this._accumulator>e;)this.physicsWorld.step(e,i,r),this._accumulator-=e;for(var s=this._delayEvents,a=0,o=s.length;a<o;a++){var l=s[a];l.func.call(l.target)}s.length=0,this.physicsWorld.syncPhysicsToScene(),this.debugDrawFlags&&this.physicsWorld.drawDebug(),this._steping=!1,wr.emit(Er.EVENT_AFTER_PHYSICS)}},i._callAfterStep=function(t,e){this._steping?this._delayEvents.push({target:t,func:e}):e.call(t)},i.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},i.step=function(t){this.physicsWorld.step(t,this.velocityIterations,this.positionIterations)},i.raycast=function(t,e,i,r){return void 0===i&&(i=AQ.Closest),void 0===r&&(r=4294967295),this.physicsWorld.raycast(t,e,i,r)},i.testPoint=function(t){return this.physicsWorld.testPoint(t)},i.testAABB=function(t){return this.physicsWorld.testAABB(t)},Pe(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this.physicsWorld.setAllowSleep(t)}},{key:"gravity",get:function(){return this._gravity},set:function(t){this._gravity.set(t),this.physicsWorld.setGravity(new dr(t.x/wQ,t.y/wQ))}},{key:"maxSubSteps",get:function(){return this._maxSubSteps},set:function(t){this._maxSubSteps=t}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=t}},{key:"autoSimulation",get:function(){return this._autoSimulation},set:function(t){this._autoSimulation=t}},{key:"debugDrawFlags",get:function(){return this.physicsWorld.debugDrawFlags},set:function(t){this.physicsWorld.debugDrawFlags=t}},{key:"stepping",get:function(){return this._steping}}],[{key:"PHYSICS_NONE",get:function(){return!rQ}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===rQ}},{key:"PHYSICS_BOX2D",get:function(){return"box2d"===rQ}},{key:"instance",get:function(){return m$||(m$=new e),m$}}]),e}(Yn(Xn)));y$.ID="PHYSICS_2D",wr.once(Er.EVENT_INIT,(function(){y$.PHYSICS_NONE||Rn||wr.registerSystem(y$.ID,y$.instance,0)})),function(t){t[t.Circles=0]="Circles",t[t.FaceA=1]="FaceA",t[t.FaceB=2]="FaceB"}(KQ||(KQ=t("Physics2DManifoldType",{})));var g$,v$,b$,S$,A$,C$,x$,T$,w$,E$,B$,D$,M$,P$,R$,I$,O$,F$,L$,V$,k$,N$,G$,z$,U$,H$,j$,W$,X$,Y$,q$,J$,K$,Z$,Q$,$$,t0,e0,i0,r0,n0,s0,a0,o0,l0,h0,u0,c0,_0,f0,p0,d0,m0,y0,g0,v0,b0,S0,A0,C0,x0,T0,w0,E0,B0,D0,M0,P0,R0,I0,O0,F0,L0,V0,k0,N0,G0,z0,U0,H0,j0,W0,X0,Y0,q0,J0,K0,Z0,Q0,$0,t1,e1,i1,r1,n1,s1,a1,o1,l1,h1,u1=ts,c1=bi,_1=Bi,f1=t("RigidBody2D",(ZQ=ri("cc.RigidBody2D"),QQ=_1(),$Q=c1(pW),t$=c1(vQ),ZQ(e$=QQ((d$=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"enabledContactListener",r$,hi(e)),li(e,"bullet",n$,hi(e)),li(e,"awakeOnLoad",s$,hi(e)),e._body=null,li(e,"_group",a$,hi(e)),li(e,"_type",o$,hi(e)),li(e,"_allowSleep",l$,hi(e)),li(e,"_gravityScale",h$,hi(e)),li(e,"_linearDamping",u$,hi(e)),li(e,"_angularDamping",c$,hi(e)),li(e,"_linearVelocity",_$,hi(e)),li(e,"_angularVelocity",f$,hi(e)),li(e,"_fixedRotation",p$,hi(e)),e}Me(e,t);var i=e.prototype;return i.isAwake=function(){return!!this._body&&this._body.isAwake},i.wakeUp=function(){this._body&&this._body.wakeUp()},i.sleep=function(){this._body&&this._body.sleep()},i.getMass=function(){return this._body?this._body.getMass():0},i.applyForce=function(t,e,i){this._body&&this._body.applyForce(t,e,i)},i.applyForceToCenter=function(t,e){this._body&&this._body.applyForceToCenter(t,e)},i.applyTorque=function(t,e){this._body&&this._body.applyTorque(t,e)},i.applyLinearImpulse=function(t,e,i){this._body&&this._body.applyLinearImpulse(t,e,i)},i.applyLinearImpulseToCenter=function(t,e){this._body&&this._body.applyLinearImpulseToCenter(t,e)},i.applyAngularImpulse=function(t,e){this._body&&this._body.applyAngularImpulse(t,e)},i.getLinearVelocityFromWorldPoint=function(t,e){return this._body?this._body.getLinearVelocityFromWorldPoint(t,e):e},i.getLocalVector=function(t,e){return this._body?this._body.getLocalVector(t,e):e},i.getWorldVector=function(t,e){return this._body?this._body.getWorldVector(t,e):e},i.getLocalPoint=function(t,e){return this._body?this._body.getLocalPoint(t,e):e},i.getWorldPoint=function(t,e){return this._body?this._body.getWorldPoint(t,e):e},i.getLocalCenter=function(t){return this._body?this._body.getLocalCenter(t):t},i.getWorldCenter=function(t){return this._body?this._body.getWorldCenter(t):t},i.getInertia=function(){return this._body&&this._body.getInertia(),0},i.onLoad=function(){this._body=He._global.CC_PHYSICS_2D_BUILTIN?XQ:new iQ.RigidBody,this._body.initialize(this)},i.onEnable=function(){this._body&&this._body.onEnable()},i.onDisable=function(){this._body&&this._body.onDisable()},i.onDestroy=function(){this._body&&this._body.onDestroy()},Pe(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t}},{key:"type",get:function(){return this._type},set:function(t){this._type=t,this._body&&(t===vQ.Animated?this._body.setType(vQ.Kinematic):this._body.setType(t))}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this._body&&this._body.setAllowSleep(t)}},{key:"gravityScale",get:function(){return this._gravityScale},set:function(t){this._gravityScale=t,this._body&&this._body.setGravityScale(t)}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._body&&this._body.setLinearDamping(t)}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._body&&this._body.setAngularDamping(t)}},{key:"linearVelocity",get:function(){return this._body&&this._body.getLinearVelocity(this._linearVelocity),this._linearVelocity},set:function(t){this._linearVelocity=t,this._body&&this._body.setLinearVelocity(t)}},{key:"angularVelocity",get:function(){return this._body&&(this._angularVelocity=this._body.getAngularVelocity()),this._angularVelocity},set:function(t){this._angularVelocity=t,this._body&&this._body.setAngularVelocity(t)}},{key:"fixedRotation",get:function(){return this._fixedRotation},set:function(t){this._fixedRotation=t,this._body&&this._body.setFixedRotation(t)}},{key:"impl",get:function(){return this._body}}]),e}(zi),oi((i$=d$).prototype,"group",[$Q],Object.getOwnPropertyDescriptor(i$.prototype,"group"),i$.prototype),r$=oi(i$.prototype,"enabledContactListener",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),n$=oi(i$.prototype,"bullet",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(i$.prototype,"type",[t$],Object.getOwnPropertyDescriptor(i$.prototype,"type"),i$.prototype),oi(i$.prototype,"allowSleep",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"allowSleep"),i$.prototype),oi(i$.prototype,"gravityScale",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"gravityScale"),i$.prototype),oi(i$.prototype,"linearDamping",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"linearDamping"),i$.prototype),oi(i$.prototype,"angularDamping",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"angularDamping"),i$.prototype),oi(i$.prototype,"linearVelocity",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"linearVelocity"),i$.prototype),oi(i$.prototype,"angularVelocity",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"angularVelocity"),i$.prototype),oi(i$.prototype,"fixedRotation",[u1],Object.getOwnPropertyDescriptor(i$.prototype,"fixedRotation"),i$.prototype),s$=oi(i$.prototype,"awakeOnLoad",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),a$=oi(i$.prototype,"_group",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pW.DEFAULT}}),o$=oi(i$.prototype,"_type",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return vQ.Dynamic}}),l$=oi(i$.prototype,"_allowSleep",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),h$=oi(i$.prototype,"_gravityScale",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),u$=oi(i$.prototype,"_linearDamping",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),c$=oi(i$.prototype,"_angularDamping",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),_$=oi(i$.prototype,"_linearVelocity",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr}}),f$=oi(i$.prototype,"_angularVelocity",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),p$=oi(i$.prototype,"_fixedRotation",[u1],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),e$=i$))||e$)||e$)),p1=t("Collider2D",(g$=ri("cc.Collider2D"),v$=bi(pW),g$((M$=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"editing",A$,hi(e)),li(e,"tag",C$,hi(e)),e.TYPE=bQ.None,e._shape=null,e._body=null,li(e,"_group",x$,hi(e)),li(e,"_density",T$,hi(e)),li(e,"_sensor",w$,hi(e)),li(e,"_friction",E$,hi(e)),li(e,"_restitution",B$,hi(e)),li(e,"_offset",D$,hi(e)),e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._shape=function(t){return YQ.INITED||(YQ.INITED=!0,YQ[bQ.BOX]=function(){return new iQ.BoxShape},YQ[bQ.CIRCLE]=function(){return new iQ.CircleShape},YQ[bQ.POLYGON]=function(){return new iQ.PolygonShape}),YQ[t]()}(this.TYPE),this._shape.initialize(this),this._shape.onLoad&&this._shape.onLoad(),this._body=this.getComponent(f1)},i.onEnable=function(){this._shape&&this._shape.onEnable()},i.onDisable=function(){this._shape&&this._shape.onDisable&&this._shape.onDisable()},i.onDestroy=function(){this._shape&&this._shape.onDestroy&&this._shape.onDestroy()},i.apply=function(){this._shape&&this._shape.apply&&this._shape.apply()},Pe(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t,this._shape&&this._shape.onGroupChanged&&this._shape.onGroupChanged()}},{key:"density",get:function(){return this._density},set:function(t){this._density=t}},{key:"sensor",get:function(){return this._sensor},set:function(t){this._sensor=t}},{key:"friction",get:function(){return this._friction},set:function(t){this._friction=t}},{key:"restitution",get:function(){return this._restitution},set:function(t){this._restitution=t}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset=t}},{key:"body",get:function(){return this._body}},{key:"impl",get:function(){return this._shape}},{key:"worldAABB",get:function(){return this._shape?this._shape.worldAABB:new gr}}]),e}(Yn(zi)),A$=oi((S$=M$).prototype,"editing",[vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),C$=oi(S$.prototype,"tag",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(S$.prototype,"group",[v$],Object.getOwnPropertyDescriptor(S$.prototype,"group"),S$.prototype),oi(S$.prototype,"density",[ts],Object.getOwnPropertyDescriptor(S$.prototype,"density"),S$.prototype),oi(S$.prototype,"sensor",[ts],Object.getOwnPropertyDescriptor(S$.prototype,"sensor"),S$.prototype),oi(S$.prototype,"friction",[ts],Object.getOwnPropertyDescriptor(S$.prototype,"friction"),S$.prototype),oi(S$.prototype,"restitution",[ts],Object.getOwnPropertyDescriptor(S$.prototype,"restitution"),S$.prototype),oi(S$.prototype,"offset",[ts],Object.getOwnPropertyDescriptor(S$.prototype,"offset"),S$.prototype),x$=oi(S$.prototype,"_group",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pW.DEFAULT}}),T$=oi(S$.prototype,"_density",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),w$=oi(S$.prototype,"_sensor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),E$=oi(S$.prototype,"_friction",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.2}}),B$=oi(S$.prototype,"_restitution",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),D$=oi(S$.prototype,"_offset",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr}}),b$=S$))||b$)),d1=(t("BoxCollider2D",ri("cc.BoxCollider2D")(P$=Bi()((O$=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_size",I$,hi(e)),e.TYPE=bQ.BOX,e}return Me(e,t),Pe(e,[{key:"size",get:function(){return this._size},set:function(t){this._size=t}},{key:"worldPoints",get:function(){return this._shape?this._shape.worldPoints:[]}}]),e}(p1),I$=oi((R$=O$).prototype,"_size",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new vr(1,1)}}),oi(R$.prototype,"size",[ts],Object.getOwnPropertyDescriptor(R$.prototype,"size"),R$.prototype),P$=R$))||P$)||P$),t("CircleCollider2D",ri("cc.CircleCollider2D")(F$=Bi()((k$=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_radius",V$,hi(e)),e.TYPE=bQ.CIRCLE,e}return Me(e,t),Pe(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius=t<0?0:t}},{key:"worldPosition",get:function(){return this._shape?this._shape.worldPosition:new dr}},{key:"worldRadius",get:function(){return this._shape?this._shape.worldRadius:0}}]),e}(p1),V$=oi((L$=k$).prototype,"_radius",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),oi(L$.prototype,"radius",[ts],Object.getOwnPropertyDescriptor(L$.prototype,"radius"),L$.prototype),F$=L$))||F$)||F$),t("PolygonCollider2D",(N$=ri("cc.PolygonCollider2D"),G$=Bi(),z$=ts({serializable:!1}),U$=ts({type:dr}),N$(H$=G$((Y$=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"threshold",W$,hi(e)),li(e,"_points",X$,hi(e)),e.TYPE=bQ.POLYGON,e}return Me(e,t),Pe(e,[{key:"points",get:function(){return this._points},set:function(t){this._points=t}},{key:"worldPoints",get:function(){return this._shape?this._shape.worldPoints:[]}}]),e}(p1),W$=oi((j$=Y$).prototype,"threshold",[z$],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),X$=oi(j$.prototype,"_points",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[new dr(-1,-1),new dr(1,-1),new dr(1,1),new dr(-1,1)]}}),oi(j$.prototype,"points",[U$],Object.getOwnPropertyDescriptor(j$.prototype,"points"),j$.prototype),H$=j$))||H$)||H$)),t("Joint2D",(q$=ri("cc.Joint2D"),J$=bi(f1),q$((i0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"anchor",Q$,hi(e)),li(e,"connectedAnchor",$$,hi(e)),li(e,"collideConnected",t0,hi(e)),li(e,"connectedBody",e0,hi(e)),e._body=null,e._joint=null,e.TYPE=SQ.None,e}Me(e,t);var i=e.prototype;return i.onLoad=function(){this._joint=function(t){return function(){if(!qQ.INITED){qQ.INITED=!0;var t=He._global.CC_PHYSICS_2D_BUILTIN;qQ[SQ.SPRING]=function(){return t?JQ:new iQ.SpringJoint},qQ[SQ.DISTANCE]=function(){return t?JQ:new iQ.DistanceJoint},qQ[SQ.FIXED]=function(){return t?JQ:new iQ.FixedJoint},qQ[SQ.MOUSE]=function(){return t?JQ:new iQ.MouseJoint},qQ[SQ.RELATIVE]=function(){return t?JQ:new iQ.RelativeJoint},qQ[SQ.SLIDER]=function(){return t?JQ:new iQ.SliderJoint},qQ[SQ.WHEEL]=function(){return t?JQ:new iQ.WheelJoint},qQ[SQ.HINGE]=function(){return t?JQ:new iQ.HingeJoint}}}(),qQ[t]()}(this.TYPE),this._joint.initialize(this),this._body=this.getComponent(f1)},i.onEnable=function(){this._joint&&this._joint.onEnable&&this._joint.onEnable()},i.onDisable=function(){this._joint&&this._joint.onDisable&&this._joint.onDisable()},i.start=function(){this._joint&&this._joint.start&&this._joint.start()},i.onDestroy=function(){this._joint&&this._joint.onDestroy&&this._joint.onDestroy()},Pe(e,[{key:"body",get:function(){return this._body}},{key:"impl",get:function(){return this._joint}}]),e}(zi),Q$=oi((Z$=i0).prototype,"anchor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr}}),$$=oi(Z$.prototype,"connectedAnchor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr}}),t0=oi(Z$.prototype,"collideConnected",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),e0=oi(Z$.prototype,"connectedBody",[J$],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),K$=Z$))||K$))),m1=(t("DistanceJoint2D",ri("cc.DistanceJoint2D")(r0=Bi()((o0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.DISTANCE,li(e,"_maxLength",s0,hi(e)),li(e,"_autoCalcDistance",a0,hi(e)),e}return Me(e,t),Pe(e,[{key:"maxLength",get:function(){return this._autoCalcDistance&&this.connectedBody?ii.distance(this.node.worldPosition,this.connectedBody.node.worldPosition):this._maxLength},set:function(t){this._maxLength=t,this._joint&&this._joint.setMaxLength(t)}},{key:"autoCalcDistance",get:function(){return this._autoCalcDistance},set:function(t){this._autoCalcDistance=t}}]),e}(d1),oi((n0=o0).prototype,"maxLength",[ts],Object.getOwnPropertyDescriptor(n0.prototype,"maxLength"),n0.prototype),oi(n0.prototype,"autoCalcDistance",[ts],Object.getOwnPropertyDescriptor(n0.prototype,"autoCalcDistance"),n0.prototype),s0=oi(n0.prototype,"_maxLength",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),a0=oi(n0.prototype,"_autoCalcDistance",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),r0=n0))||r0)||r0),t("SpringJoint2D",ri("cc.SpringJoint2D")(l0=Bi()((p0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.SPRING,li(e,"_frequency",u0,hi(e)),li(e,"_dampingRatio",c0,hi(e)),li(e,"_distance",_0,hi(e)),li(e,"_autoCalcDistance",f0,hi(e)),e}return Me(e,t),Pe(e,[{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}},{key:"distance",get:function(){return this._autoCalcDistance&&this.connectedBody?ii.distance(this.node.worldPosition,this.connectedBody.node.worldPosition):this._distance},set:function(t){this._distance=t,this._joint&&this._joint.setDistance(t)}},{key:"autoCalcDistance",get:function(){return this._autoCalcDistance},set:function(t){this._autoCalcDistance=t}}]),e}(d1),oi((h0=p0).prototype,"frequency",[ts],Object.getOwnPropertyDescriptor(h0.prototype,"frequency"),h0.prototype),oi(h0.prototype,"dampingRatio",[ts],Object.getOwnPropertyDescriptor(h0.prototype,"dampingRatio"),h0.prototype),oi(h0.prototype,"distance",[ts],Object.getOwnPropertyDescriptor(h0.prototype,"distance"),h0.prototype),oi(h0.prototype,"autoCalcDistance",[ts],Object.getOwnPropertyDescriptor(h0.prototype,"autoCalcDistance"),h0.prototype),u0=oi(h0.prototype,"_frequency",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),c0=oi(h0.prototype,"_dampingRatio",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),_0=oi(h0.prototype,"_distance",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),f0=oi(h0.prototype,"_autoCalcDistance",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),l0=h0))||l0)||l0),t("MouseJoint2D",ri("cc.MouseJoint2D")(d0=Bi()((b0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.MOUSE,li(e,"_maxForce",y0,hi(e)),li(e,"_dampingRatio",g0,hi(e)),li(e,"_frequency",v0,hi(e)),e._target=new dr,e}return Me(e,t),e.prototype.update=function(t){this._joint.update(t)},Pe(e,[{key:"target",get:function(){return this._target},set:function(t){this._target=t,this._joint&&this._joint.setTarget(t)}},{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}},{key:"maxForce",get:function(){return this._maxForce},set:function(t){this._maxForce=t,this._joint&&this._joint.setMaxForce(t)}}]),e}(d1),oi((m0=b0).prototype,"frequency",[ts],Object.getOwnPropertyDescriptor(m0.prototype,"frequency"),m0.prototype),oi(m0.prototype,"dampingRatio",[ts],Object.getOwnPropertyDescriptor(m0.prototype,"dampingRatio"),m0.prototype),oi(m0.prototype,"maxForce",[ts],Object.getOwnPropertyDescriptor(m0.prototype,"maxForce"),m0.prototype),y0=oi(m0.prototype,"_maxForce",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),g0=oi(m0.prototype,"_dampingRatio",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),v0=oi(m0.prototype,"_frequency",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),d0=m0))||d0)||d0),new ii),y1=new ii,g1=(t("RelativeJoint2D",ri("cc.RelativeJoint2D")(S0=Bi()((D0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.RELATIVE,li(e,"_maxForce",C0,hi(e)),li(e,"_maxTorque",x0,hi(e)),li(e,"_correctionFactor",T0,hi(e)),li(e,"_angularOffset",w0,hi(e)),li(e,"_linearOffset",E0,hi(e)),li(e,"_autoCalcOffset",B0,hi(e)),e}return Me(e,t),Pe(e,[{key:"maxForce",get:function(){return this._maxForce},set:function(t){this._maxForce=t,this._joint&&this._joint.setMaxForce(t)}},{key:"maxTorque",get:function(){return this._maxTorque},set:function(t){this._maxTorque=t,this._joint&&this._joint.setMaxTorque(t)}},{key:"correctionFactor",get:function(){return this._correctionFactor},set:function(t){this._correctionFactor=t,this._joint&&this._joint.setCorrectionFactor(t)}},{key:"linearOffset",get:function(){return this._autoCalcOffset&&this.connectedBody?dr.subtract(this._linearOffset,this.connectedBody.node.worldPosition,this.node.worldPosition):this._linearOffset},set:function(t){this._linearOffset.set(t),this._joint&&this._joint.setLinearOffset(t)}},{key:"angularOffset",get:function(){return this._autoCalcOffset&&this.connectedBody&&(si.toEuler(m1,this.node.worldRotation),si.toEuler(y1,this.connectedBody.node.worldRotation),this._angularOffset=y1.z-m1.z),this._angularOffset},set:function(t){this._angularOffset=t,this._joint&&this._joint.setAngularOffset(t)}},{key:"autoCalcOffset",get:function(){return this._autoCalcOffset},set:function(t){this._autoCalcOffset=t}}]),e}(d1),oi((A0=D0).prototype,"maxForce",[ts],Object.getOwnPropertyDescriptor(A0.prototype,"maxForce"),A0.prototype),oi(A0.prototype,"maxTorque",[ts],Object.getOwnPropertyDescriptor(A0.prototype,"maxTorque"),A0.prototype),oi(A0.prototype,"correctionFactor",[ts],Object.getOwnPropertyDescriptor(A0.prototype,"correctionFactor"),A0.prototype),oi(A0.prototype,"linearOffset",[ts],Object.getOwnPropertyDescriptor(A0.prototype,"linearOffset"),A0.prototype),oi(A0.prototype,"angularOffset",[ts],Object.getOwnPropertyDescriptor(A0.prototype,"angularOffset"),A0.prototype),oi(A0.prototype,"autoCalcOffset",[ts],Object.getOwnPropertyDescriptor(A0.prototype,"autoCalcOffset"),A0.prototype),C0=oi(A0.prototype,"_maxForce",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),x0=oi(A0.prototype,"_maxTorque",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),T0=oi(A0.prototype,"_correctionFactor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),w0=oi(A0.prototype,"_angularOffset",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),E0=oi(A0.prototype,"_linearOffset",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new dr}}),B0=oi(A0.prototype,"_autoCalcOffset",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),S0=A0))||S0)||S0),new dr),v1=(t("SliderJoint2D",ri("cc.SliderJoint2D")(M0=Bi()((G0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.SLIDER,li(e,"_angle",R0,hi(e)),li(e,"_autoCalcAngle",I0,hi(e)),li(e,"_enableMotor",O0,hi(e)),li(e,"_maxMotorForce",F0,hi(e)),li(e,"_motorSpeed",L0,hi(e)),li(e,"_enableLimit",V0,hi(e)),li(e,"_lowerLimit",k0,hi(e)),li(e,"_upperLimit",N0,hi(e)),e}return Me(e,t),Pe(e,[{key:"angle",get:function(){return this._autoCalcAngle&&this.connectedBody&&(dr.subtract(g1,this.connectedBody.node.worldPosition,this.node.worldPosition),this._angle=Mn(Math.atan2(g1.y,g1.x))),this._angle},set:function(t){this._angle=t}},{key:"autoCalcAngle",get:function(){return this._autoCalcAngle},set:function(t){this._autoCalcAngle=t}},{key:"enableMotor",get:function(){return this._enableMotor},set:function(t){this._enableMotor=t}},{key:"maxMotorForce",get:function(){return this._maxMotorForce},set:function(t){this._maxMotorForce=t,this._joint&&this._joint.setMaxMotorForce(t)}},{key:"motorSpeed",get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.setMotorSpeed(t)}},{key:"enableLimit",get:function(){return this._enableLimit},set:function(t){this._enableLimit=t}},{key:"lowerLimit",get:function(){return this._lowerLimit},set:function(t){this._lowerLimit=t,this._joint&&this._joint.setLowerLimit(t)}},{key:"upperLimit",get:function(){return this._upperLimit},set:function(t){this._upperLimit=t,this._joint&&this._joint.setUpperLimit(t)}}]),e}(d1),oi((P0=G0).prototype,"angle",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"angle"),P0.prototype),oi(P0.prototype,"autoCalcAngle",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"autoCalcAngle"),P0.prototype),oi(P0.prototype,"enableMotor",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"enableMotor"),P0.prototype),oi(P0.prototype,"maxMotorForce",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"maxMotorForce"),P0.prototype),oi(P0.prototype,"motorSpeed",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"motorSpeed"),P0.prototype),oi(P0.prototype,"enableLimit",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"enableLimit"),P0.prototype),oi(P0.prototype,"lowerLimit",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"lowerLimit"),P0.prototype),oi(P0.prototype,"upperLimit",[ts],Object.getOwnPropertyDescriptor(P0.prototype,"upperLimit"),P0.prototype),R0=oi(P0.prototype,"_angle",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),I0=oi(P0.prototype,"_autoCalcAngle",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),O0=oi(P0.prototype,"_enableMotor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),F0=oi(P0.prototype,"_maxMotorForce",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),L0=oi(P0.prototype,"_motorSpeed",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),V0=oi(P0.prototype,"_enableLimit",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),k0=oi(P0.prototype,"_lowerLimit",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),N0=oi(P0.prototype,"_upperLimit",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),M0=P0))||M0)||M0),t("FixedJoint2D",ri("cc.FixedJoint2D")(z0=Bi()((W0=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.FIXED,li(e,"_frequency",H0,hi(e)),li(e,"_dampingRatio",j0,hi(e)),e}return Me(e,t),Pe(e,[{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}}]),e}(d1),oi((U0=W0).prototype,"frequency",[ts],Object.getOwnPropertyDescriptor(U0.prototype,"frequency"),U0.prototype),oi(U0.prototype,"dampingRatio",[ts],Object.getOwnPropertyDescriptor(U0.prototype,"dampingRatio"),U0.prototype),H0=oi(U0.prototype,"_frequency",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),j0=oi(U0.prototype,"_dampingRatio",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),z0=U0))||z0)||z0),t("WheelJoint2D",ri("cc.WheelJoint2D")(X0=Bi()((t1=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.WHEEL,li(e,"_angle",q0,hi(e)),li(e,"_enableMotor",J0,hi(e)),li(e,"_maxMotorTorque",K0,hi(e)),li(e,"_motorSpeed",Z0,hi(e)),li(e,"_frequency",Q0,hi(e)),li(e,"_dampingRatio",$0,hi(e)),e}return Me(e,t),Pe(e,[{key:"angle",get:function(){return this._angle},set:function(t){this._angle=t}},{key:"enableMotor",get:function(){return this._enableMotor},set:function(t){this._enableMotor=t,this._joint&&this._joint.enableMotor(t)}},{key:"maxMotorTorque",get:function(){return this._maxMotorTorque},set:function(t){this._maxMotorTorque=t,this._joint&&this._joint.setMaxMotorTorque(t)}},{key:"motorSpeed",get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.setMotorSpeed(t)}},{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}}]),e}(d1),oi((Y0=t1).prototype,"angle",[ts],Object.getOwnPropertyDescriptor(Y0.prototype,"angle"),Y0.prototype),oi(Y0.prototype,"enableMotor",[ts],Object.getOwnPropertyDescriptor(Y0.prototype,"enableMotor"),Y0.prototype),oi(Y0.prototype,"maxMotorTorque",[ts],Object.getOwnPropertyDescriptor(Y0.prototype,"maxMotorTorque"),Y0.prototype),oi(Y0.prototype,"motorSpeed",[ts],Object.getOwnPropertyDescriptor(Y0.prototype,"motorSpeed"),Y0.prototype),oi(Y0.prototype,"frequency",[ts],Object.getOwnPropertyDescriptor(Y0.prototype,"frequency"),Y0.prototype),oi(Y0.prototype,"dampingRatio",[ts],Object.getOwnPropertyDescriptor(Y0.prototype,"dampingRatio"),Y0.prototype),q0=oi(Y0.prototype,"_angle",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 90}}),J0=oi(Y0.prototype,"_enableMotor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),K0=oi(Y0.prototype,"_maxMotorTorque",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),Z0=oi(Y0.prototype,"_motorSpeed",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Q0=oi(Y0.prototype,"_frequency",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),$0=oi(Y0.prototype,"_dampingRatio",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.7}}),X0=Y0))||X0)||X0),t("HingeJoint2D",ri("cc.HingeJoint2D")(e1=Bi()((h1=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).TYPE=SQ.HINGE,li(e,"_enableLimit",r1,hi(e)),li(e,"_lowerAngle",n1,hi(e)),li(e,"_upperAngle",s1,hi(e)),li(e,"_enableMotor",a1,hi(e)),li(e,"_maxMotorTorque",o1,hi(e)),li(e,"_motorSpeed",l1,hi(e)),e}return Me(e,t),Pe(e,[{key:"enableLimit",get:function(){return this._enableLimit},set:function(t){this._enableLimit=t}},{key:"lowerAngle",get:function(){return this._lowerAngle},set:function(t){this._lowerAngle=t,this._joint&&this._joint.setLowerAngle(t)}},{key:"upperAngle",get:function(){return this._upperAngle},set:function(t){this._upperAngle=t,this._joint&&this._joint.setUpperAngle(t)}},{key:"enableMotor",get:function(){return this._enableMotor},set:function(t){this._enableMotor=t,this._joint&&this._joint.enableMotor(t)}},{key:"maxMotorTorque",get:function(){return this._maxMotorTorque},set:function(t){this._maxMotorTorque=t,this._joint&&this._joint.setMaxMotorTorque(t)}},{key:"motorSpeed",get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.setMotorSpeed(t)}}]),e}(d1),oi((i1=h1).prototype,"enableLimit",[ts],Object.getOwnPropertyDescriptor(i1.prototype,"enableLimit"),i1.prototype),oi(i1.prototype,"lowerAngle",[ts],Object.getOwnPropertyDescriptor(i1.prototype,"lowerAngle"),i1.prototype),oi(i1.prototype,"upperAngle",[ts],Object.getOwnPropertyDescriptor(i1.prototype,"upperAngle"),i1.prototype),oi(i1.prototype,"enableMotor",[ts],Object.getOwnPropertyDescriptor(i1.prototype,"enableMotor"),i1.prototype),oi(i1.prototype,"maxMotorTorque",[ts],Object.getOwnPropertyDescriptor(i1.prototype,"maxMotorTorque"),i1.prototype),oi(i1.prototype,"motorSpeed",[ts],Object.getOwnPropertyDescriptor(i1.prototype,"motorSpeed"),i1.prototype),r1=oi(i1.prototype,"_enableLimit",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),n1=oi(i1.prototype,"_lowerAngle",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),s1=oi(i1.prototype,"_upperAngle",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),a1=oi(i1.prototype,"_enableMotor",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),o1=oi(i1.prototype,"_maxMotorTorque",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),l1=oi(i1.prototype,"_motorSpeed",[ts],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),e1=i1))||e1)||e1),t("Physics2DUtils",{PolygonSeparator:jQ}),function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._type=AQ.Closest,e._fixtures=[],e._points=[],e._normals=[],e._fractions=[],e._mask=4294967295,e}Me(e,t);var i=e.prototype;return i.init=function(t,e){this._type=t,this._mask=e,this._fixtures.length=0,this._points.length=0,this._normals.length=0,this._fractions.length=0},i.ReportFixture=function(t,e,i,r){return 0==(t.GetFilterData().categoryBits&this._mask)?0:this._type===AQ.Closest?(this._fixtures[0]=t,this._points[0]=e,this._normals[0]=i,this._fractions[0]=r,r):(this._fixtures.push(t),this._points.push(new dr(e.x,e.y)),this._normals.push(new dr(i.x,i.y)),this._fractions.push(r),this._type===AQ.Any?0:this._type>=AQ.All?1:r)},i.getFixtures=function(){return this._fixtures},i.getPoints=function(){return this._points},i.getNormals=function(){return this._normals},i.getFractions=function(){return this._fractions},e}(CQ.RayCastCallback)),b1=[],S1=[new dr,new dr],A1=new CQ.WorldManifold,C1={points:[],separations:[],normal:new dr},x1=function(){this.localPoint=new dr,this.normalImpulse=0,this.tangentImpulse=0},T1=[new x1,new x1],w1={type:0,localPoint:new dr,localNormal:new dr,points:[]},E1={normalImpulses:[],tangentImpulses:[]},B1=function(){function t(){this.colliderA=null,this.colliderB=null,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=null}t.get=function(e){var i=b1.pop();return i||(i=new t),i.init(e),i},t.put=function(t){var e=t.m_userData;e&&(b1.push(e),e.reset())};var e=t.prototype;return e._setImpulse=function(t){this._impulse=t},e.init=function(t){this.colliderA=t.m_fixtureA.m_userData.collider,this.colliderB=t.m_fixtureB.m_userData.collider,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=t,t.m_userData=this},e.reset=function(){this.setTangentSpeed(0),this.resetFriction(),this.resetRestitution(),this.colliderA=null,this.colliderB=null,this.disabled=!1,this._impulse=null,this._b2contact.m_userData=null,this._b2contact=null},e.getWorldManifold=function(){var t=C1.points,e=C1.separations,i=C1.normal;this._b2contact.GetWorldManifold(A1);var r=A1.points,n=A1.separations,s=this._b2contact.GetManifold().pointCount;t.length=e.length=s;for(var a=0;a<s;a++){var o=S1[a];o.x=r[a].x*wQ,o.y=r[a].y*wQ,t[a]=o,e[a]=n[a]*wQ}return i.x=A1.normal.x,i.y=A1.normal.y,this._inverted&&(i.x*=-1,i.y*=-1),C1},e.getManifold=function(){for(var t=w1.points,e=w1.localNormal,i=w1.localPoint,r=this._b2contact.GetManifold(),n=r.points,s=t.length=r.pointCount,a=0;a<s;a++){var o=T1[a],l=n[a];o.localPoint.x=l.localPoint.x*wQ,o.localPoint.y=l.localPoint.y*wQ,o.normalImpulse=l.normalImpulse*wQ,o.tangentImpulse=l.tangentImpulse,t[a]=o}return i.x=r.localPoint.x*wQ,i.y=r.localPoint.y*wQ,e.x=r.localNormal.x,e.y=r.localNormal.y,w1.type=r.type,this._inverted&&(e.x*=-1,e.y*=-1),w1},e.getImpulse=function(){var t=this._impulse;if(!t)return null;for(var e=E1.normalImpulses,i=E1.tangentImpulses,r=t.count,n=0;n<r;n++)e[n]=t.normalImpulses[n]*wQ,i[n]=t.tangentImpulses[n];return i.length=e.length=r,E1},e.emit=function(t){var e=this.colliderA,i=this.colliderB,r=e.body,n=i.body;r.enabledContactListener&&(null==e||e.emit(t,e,i,this)),n.enabledContactListener&&(null==i||i.emit(t,i,e,this)),(r.enabledContactListener||n.enabledContactListener)&&y$.instance.emit(t,e,i),(this.disabled||this.disabledOnce)&&(this.setEnabled(!1),this.disabledOnce=!1)},e.setEnabled=function(t){this._b2contact.SetEnabled(t)},e.isTouching=function(){return this._b2contact.IsTouching()},e.setTangentSpeed=function(t){this._b2contact.SetTangentSpeed(t)},e.getTangentSpeed=function(){return this._b2contact.GetTangentSpeed()},e.setFriction=function(t){this._b2contact.SetFriction(t)},e.getFriction=function(){return this._b2contact.GetFriction()},e.resetFriction=function(){return this._b2contact.ResetFriction()},e.setRestitution=function(t){this._b2contact.SetRestitution(t)},e.getRestitution=function(){return this._b2contact.GetRestitution()},e.resetRestitution=function(){return this._b2contact.ResetRestitution()},t}(),D1=new CQ.Vec2,M1=new Ui,P1=Ui.GREEN,R1=Ui.RED,I1=function(t){function e(e){var i;return(i=t.call(this)||this)._drawer=null,i._xf=new CQ.Transform,i._dxf=new CQ.Transform,i._drawer=e,i}Me(e,t);var i=e.prototype;return i._DrawPolygon=function(t,e){for(var i=this._drawer,r=0;r<e;r++){CQ.Transform.MulXV(this._xf,t[r],D1);var n=D1.x*wQ,s=D1.y*wQ;0===r?i.moveTo(n,s):i.lineTo(n,s)}i.close()},i.DrawPolygon=function(t,e,i){this._applyStrokeColor(i),this._DrawPolygon(t,e),this._drawer.stroke()},i.DrawSolidPolygon=function(t,e,i){this._applyFillColor(i),this._DrawPolygon(t,e),this._drawer.fill(),this._drawer.stroke()},i._DrawCircle=function(t,e){var i=this._xf.p;this._drawer.circle((t.x+i.x)*wQ,(t.y+i.y)*wQ,e*wQ)},i.DrawCircle=function(t,e,i){this._applyStrokeColor(i),this._DrawCircle(t,e),this._drawer.stroke()},i.DrawSolidCircle=function(t,e,i,r){this._applyFillColor(r),this._DrawCircle(t,e),this._drawer.fill()},i.DrawSegment=function(t,e,i){var r=this._drawer;if(t.x===e.x&&t.y===e.y)return this._applyFillColor(i),this._DrawCircle(t,2/wQ),void r.fill();this._applyStrokeColor(i),CQ.Transform.MulXV(this._xf,t,D1),r.moveTo(D1.x*wQ,D1.y*wQ),CQ.Transform.MulXV(this._xf,e,D1),r.lineTo(D1.x*wQ,D1.y*wQ),r.stroke()},i.DrawTransform=function(t){var e=this._drawer;e.strokeColor=R1,D1.x=D1.y=0,CQ.Transform.MulXV(t,D1,D1),e.moveTo(D1.x*wQ,D1.y*wQ),D1.x=1,D1.y=0,CQ.Transform.MulXV(t,D1,D1),e.lineTo(D1.x*wQ,D1.y*wQ),e.stroke(),e.strokeColor=P1,D1.x=D1.y=0,CQ.Transform.MulXV(t,D1,D1),e.moveTo(D1.x*wQ,D1.y*wQ),D1.x=0,D1.y=1,CQ.Transform.MulXV(t,D1,D1),e.lineTo(D1.x*wQ,D1.y*wQ),e.stroke()},i.DrawPoint=function(){},i.DrawParticles=function(){},i._applyStrokeColor=function(t){this._drawer.strokeColor=M1.set(255*t.r,255*t.g,255*t.b,150)},i._applyFillColor=function(t){this._drawer.fillColor=M1.set(255*t.r,255*t.g,255*t.b,150)},i.PushTransform=function(t){this._xf=t},i.PopTransform=function(){this._xf=this._dxf},e}(CQ.Draw),O1=new ii,F1=new dr,L1=new dr,V1=new CQ.BodyDef,k1=new CQ.AABB,N1=[],G1=function(){function t(){this._world=void 0,this._bodies=[],this._animatedBodies=[],this._contactListener=void 0,this._aabbQueryCallback=void 0,this._raycastQueryCallback=void 0,this._debugGraphics=null,this._b2DebugDrawer=null,this._debugDrawFlags=0,this._world=new CQ.World(new CQ.Vec2(0,-10));var t=new EQ;t.setBeginContact(this._onBeginContact),t.setEndContact(this._onEndContact),t.setPreSolve(this._onPreSolve),t.setPostSolve(this._onPostSolve),this._world.SetContactListener(t),this._contactListener=t,this._aabbQueryCallback=new BQ,this._raycastQueryCallback=new v1}var e=t.prototype;return e._checkDebugDrawValid=function(){if(!this._debugGraphics||!this._debugGraphics.isValid){var t=pi("Canvas");if(!t){var e=wr.getScene();if(!e)return;(t=new ur("Canvas")).addComponent(vy),t.parent=e}var i=new ur("PHYSICS_2D_DEBUG_DRAW");i.hideFlags|=Lr.Flags.DontSave,i.parent=t,i.worldPosition=ii.ZERO,this._debugGraphics=i.addComponent(Hd),this._debugGraphics.lineWidth=2;var r=new I1(this._debugGraphics);this._b2DebugDrawer=r,this._world.SetDebugDraw(r)}var n=this._debugGraphics.node.parent;this._debugGraphics.node.setSiblingIndex(n.children.length-1),this._b2DebugDrawer&&this._b2DebugDrawer.SetFlags(this.debugDrawFlags)},e.setGravity=function(t){this._world.SetGravity(t)},e.setAllowSleep=function(){this._world.SetAllowSleeping(!0)},e.step=function(t,e,i){void 0===e&&(e=10),void 0===i&&(i=10);for(var r=this._animatedBodies,n=0,s=r.length;n<s;n++)r[n].animate(t);this._world.Step(t,e,i)},e.raycast=function(t,e,i,r){if(t.equals(e))return[];i=i||AQ.Closest,F1.x=t.x/wQ,F1.y=t.y/wQ,L1.x=e.x/wQ,L1.y=e.y/wQ;var n=this._raycastQueryCallback;n.init(i,r),this._world.RayCast(n,F1,L1);var s=n.getFixtures();if(s.length>0){for(var a=n.getPoints(),o=n.getNormals(),l=n.getFractions(),h=[],u=0,c=s.length;u<c;u++){var _=s[u],f=_.m_userData,p=f.collider;if(i===AQ.AllClosest){for(var d=void 0,m=0;m<h.length;m++)h[m].collider===p&&(d=h[m]);if(d){l[u]<d.fraction&&(d.fixtureIndex=f.getFixtureIndex(_),d.point.x=a[u].x*wQ,d.point.y=a[u].y*wQ,d.normal.x=o[u].x,d.normal.y=o[u].y,d.fraction=l[u]);continue}}h.push({collider:p,fixtureIndex:f.getFixtureIndex(_),point:new dr(a[u].x*wQ,a[u].y*wQ),normal:new dr(o[u].x,o[u].y),fraction:l[u]})}return h}return[]},e.syncPhysicsToScene=function(){for(var t=this._bodies,e=0,i=t.length;e<i;e++){var r=t[e],n=r.rigidBody;if(n.type!==vQ.Animated){var s=n.node,a=r.impl,o=a.GetPosition();O1.x=o.x*wQ,O1.y=o.y*wQ,O1.z=0,s.worldPosition=O1;var l=Mn(a.GetAngle());s.setWorldRotationFromEuler(0,0,l)}else r.resetVelocity()}},e.syncSceneToPhysics=function(){for(var t=this._bodies,e=0;e<t.length;e++)t[e].syncRotationToPhysics(),t[e].syncPositionToPhysics()},e.addBody=function(t){if(!this._bodies.includes(t)){var e=V1,i=t.rigidBody;e.allowSleep=i.allowSleep,e.gravityScale=i.gravityScale,e.linearDamping=i.linearDamping,e.angularDamping=i.angularDamping,e.fixedRotation=i.fixedRotation,e.bullet=i.bullet;var r=i.node,n=r.worldPosition;e.position.Set(n.x/wQ,n.y/wQ),si.toEuler(O1,r.worldRotation),e.angle=qi(O1.z),e.awake=i.awakeOnLoad,i.type===vQ.Animated?(e.type=vQ.Kinematic,this._animatedBodies.push(t),t._animatedPos.set(e.position.x,e.position.y),t._animatedAngle=e.angle):e.type=i.type;var s=i,a=s._linearVelocity;e.linearVelocity.Set(a.x,a.y),e.angularVelocity=qi(s._angularVelocity);var o=this._world.CreateBody(e);o.m_userData=t,t._imp=o,this._bodies.push(t)}},e.removeBody=function(t){this._bodies.includes(t)&&(t.impl&&(t.impl.m_userData=null,this._world.DestroyBody(t.impl),t._imp=null),Bn.remove(this._bodies,t),t.rigidBody.type===vQ.Animated&&Bn.remove(this._animatedBodies,t))},e.registerContactFixture=function(t){this._contactListener.registerContactFixture(t)},e.unregisterContactFixture=function(t){this._contactListener.unregisterContactFixture(t)},e.testPoint=function(t){var e=F1.x=t.x/wQ,i=F1.y=t.y/wQ,r=.2/wQ;k1.lowerBound.x=e-r,k1.lowerBound.y=i-r,k1.upperBound.x=e+r,k1.upperBound.y=i+r;var n=this._aabbQueryCallback;n.init(F1),this._world.QueryAABB(n,k1);var s=n.getFixtures();N1.length=0;for(var a=0;a<s.length;a++){var o=s[a].m_userData.collider;N1.includes(o)||N1.push(o)}return N1},e.testAABB=function(t){k1.lowerBound.x=t.xMin/wQ,k1.lowerBound.y=t.yMin/wQ,k1.upperBound.x=t.xMax/wQ,k1.upperBound.y=t.yMax/wQ;var e=this._aabbQueryCallback;e.init(),this._world.QueryAABB(e,k1);var i=e.getFixtures();N1.length=0;for(var r=0;r<i.length;r++){var n=i[r].m_userData.collider;N1.includes(n)||N1.push(n)}return N1},e.drawDebug=function(){this._checkDebugDrawValid(),this._debugGraphics&&(this._debugGraphics.clear(),this._world.DrawDebugData())},e._onBeginContact=function(t){B1.get(t).emit(TQ.BEGIN_CONTACT)},e._onEndContact=function(t){var e=t.m_userData;e&&(e.emit(TQ.END_CONTACT),B1.put(t))},e._onPreSolve=function(t){var e=t.m_userData;e&&e.emit(TQ.PRE_SOLVE)},e._onPostSolve=function(t,e){var i=t.m_userData;i&&(i._setImpulse(e),i.emit(TQ.POST_SOLVE),i._setImpulse(null))},Pe(t,[{key:"impl",get:function(){return this._world}},{key:"debugDrawFlags",get:function(){return this._debugDrawFlags},set:function(t){t||this._debugGraphics&&(this._debugGraphics.node.parent=null),this._debugDrawFlags=t}}]),t}(),z1=(new ii,new CQ.Vec2),U1=function(){function t(){this._animatedPos=new dr,this._animatedAngle=0,this._body=null,this._inited=!1}var e=t.prototype;return e.initialize=function(t){this._rigidBody=t,y$.instance._callAfterStep(this,this._init)},e.onDestroy=function(){y$.instance._callAfterStep(this,this._destroy)},e.onEnable=function(){this.setActive(!0)},e.onDisable=function(){this.setActive(!1)},e._registerNodeEvents=function(){this.rigidBody.node.on(ur.EventType.TRANSFORM_CHANGED,this._onNodeTransformChanged,this)},e._unregisterNodeEvents=function(){this.rigidBody.node.off(ur.EventType.TRANSFORM_CHANGED,this._onNodeTransformChanged,this)},e._onNodeTransformChanged=function(t){if(!y$.instance.stepping)if(t&ur.TransformBit.SCALE)for(var e=this.rigidBody.getComponents(p1),i=0;i<e.length;i++)e[i].apply();else t&ur.TransformBit.POSITION&&this.syncPositionToPhysics(!0),t&ur.TransformBit.ROTATION&&this.syncRotationToPhysics(!0)},e._init=function(){this._inited||(this._registerNodeEvents(),y$.instance.physicsWorld.addBody(this),this._inited=!0)},e._destroy=function(){this._inited&&(y$.instance.physicsWorld.removeBody(this),this._unregisterNodeEvents(),this._inited=!1)},e.animate=function(t){var e=this._body;if(e){var i=e.GetPosition();e.SetAwake(!0);var r=1/t;z1.x=(this._animatedPos.x-i.x)*r,z1.y=(this._animatedPos.y-i.y)*r,e.SetLinearVelocity(z1);var n=e.GetAngle();e.SetAngularVelocity((this._animatedAngle-n)*r)}},e.syncPositionToPhysics=function(t){void 0===t&&(t=!1);var e=this._body;if(e){var i,r=this._rigidBody.node.worldPosition,n=this._rigidBody.type;(i=n===vQ.Animated?e.GetLinearVelocity():e.GetPosition()).x=r.x/wQ,i.y=r.y/wQ,n===vQ.Animated&&t?this._animatedPos.set(i.x,i.y):e.SetTransformVec(i,e.GetAngle())}},e.syncRotationToPhysics=function(t){void 0===t&&(t=!1);var e=this._body;if(e){var i=qi(this._rigidBody.node.eulerAngles.z);this._rigidBody.type===vQ.Animated&&t?this._animatedAngle=i:e.SetTransformVec(e.GetPosition(),i)}},e.resetVelocity=function(){var t=this._body;if(t){var e=t.m_linearVelocity;e.Set(0,0),t.SetLinearVelocity(e),t.SetAngularVelocity(0)}},e.setType=function(t){this._body.SetType(t)},e.setLinearDamping=function(t){this._body.SetLinearDamping(t)},e.setAngularDamping=function(t){this._body.SetAngularDamping(t)},e.setGravityScale=function(t){this._body.SetGravityScale(t)},e.setFixedRotation=function(t){this._body.SetFixedRotation(t)},e.setAllowSleep=function(t){this._body.SetSleepingAllowed(t)},e.isActive=function(){return this._body.IsActive()},e.setActive=function(t){this._body.SetActive(t)},e.wakeUp=function(){this._body.SetAwake(!0)},e.sleep=function(){this._body.SetAwake(!1)},e.getMass=function(){return this._body.GetMass()},e.setLinearVelocity=function(t){this._body.SetLinearVelocity(t)},e.getLinearVelocity=function(t){var e=this._body.GetLinearVelocity();return t.x=e.x,t.y=e.y,t},e.getLinearVelocityFromWorldPoint=function(t,e){return z1.Set(t.x/wQ,t.y/wQ),this._body.GetLinearVelocityFromWorldPoint(z1,e),e.x*=wQ,e.y*=wQ,e},e.setAngularVelocity=function(t){this._body.SetAngularVelocity(t)},e.getAngularVelocity=function(){return Mn(this._body.GetAngularVelocity())},e.getLocalVector=function(t,e){return e=e||new dr,z1.Set(t.x/wQ,t.y/wQ),this._body.GetLocalVector(z1,e),e.x*=wQ,e.y*=wQ,e},e.getWorldVector=function(t,e){return z1.Set(t.x/wQ,t.y/wQ),this._body.GetWorldVector(z1,e),e.x*=wQ,e.y*=wQ,e},e.getLocalPoint=function(t,e){return e=e||new dr,z1.Set(t.x/wQ,t.y/wQ),this._body.GetLocalPoint(z1,e),e.x*=wQ,e.y*=wQ,e},e.getWorldPoint=function(t,e){return e=e||new dr,z1.Set(t.x/wQ,t.y/wQ),this._body.GetWorldPoint(z1,e),e.x*=wQ,e.y*=wQ,e},e.getLocalCenter=function(t){t=t||new dr;var e=this._body.GetLocalCenter();return t.x=e.x*wQ,t.y=e.y*wQ,t},e.getWorldCenter=function(t){t=t||new dr;var e=this._body.GetWorldCenter();return t.x=e.x*wQ,t.y=e.y*wQ,t},e.getInertia=function(){return this._body.GetInertia()},e.applyForce=function(t,e,i){this._body&&(z1.Set(e.x/wQ,e.y/wQ),this._body.ApplyForce(t,z1,i))},e.applyForceToCenter=function(t,e){this._body&&this._body.ApplyForceToCenter(t,e)},e.applyTorque=function(t,e){this._body&&this._body.ApplyTorque(t,e)},e.applyLinearImpulse=function(t,e,i){this._body&&(z1.Set(e.x/wQ,e.y/wQ),this._body.ApplyLinearImpulse(t,z1,i))},e.applyLinearImpulseToCenter=function(t,e){this._body&&this._body.ApplyLinearImpulse(t,this._body.GetPosition(),e)},e.applyAngularImpulse=function(t,e){this._body&&this._body.ApplyAngularImpulse(t,e)},Pe(t,[{key:"impl",get:function(){return this._body}},{key:"_imp",set:function(t){this._body=t}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"isAwake",get:function(){return this._body.IsAwake()}},{key:"isSleeping",get:function(){return!this._body.IsAwake()}}]),t}(),H1=new CQ.Filter;function j1(t){var e=t.collider;return H1.categoryBits=e.group===pW.DEFAULT?e.body.group:e.group,H1.maskBits=y$.instance.collisionMatrix[H1.categoryBits],H1}var W1,X1=function(){function t(){this._shapes=[],this._fixtures=[],this._collider=null,this._body=null,this._inited=!1,this._rect=new gr}var e=t.prototype;return e.initialize=function(t){this._collider=t},e.onLoad=function(){},e.onEnable=function(){y$.instance._callAfterStep(this,this._init)},e.onDisable=function(){y$.instance._callAfterStep(this,this._destroy)},e.start=function(){},e.onGroupChanged=function(){var t=j1(this);this._fixtures.forEach((function(e){e.SetFilterData(t)}))},e.apply=function(){this._destroy(),this._init()},e.getFixtureIndex=function(t){return this._fixtures.indexOf(t)},e._createShapes=function(){return[]},e._init=function(){var t;if(!this._inited){var e=this.collider,i=e.getComponent(f1);if(i){var r=null===(t=i.impl)||void 0===t?void 0:t.impl;if(r){for(var n=i.node.worldScale,s=0===n.x&&0===n.y?[]:this._createShapes(n.x,n.y),a=j1(this),o=0;o<s.length;o++){var l=s[o],h={density:e.density,isSensor:e.sensor,friction:e.friction,restitution:e.restitution,shape:l,filter:a},u=r.CreateFixture(h);u.m_userData=this,i.enabledContactListener&&y$.instance.physicsWorld.registerContactFixture(u),this._shapes.push(l),this._fixtures.push(u)}this._body=r,this._inited=!0}}}},e._destroy=function(){if(this._inited){for(var t=this._fixtures,e=this._body,i=t.length-1;i>=0;i--){var r=t[i];r.m_userData=null,y$.instance.physicsWorld.unregisterContactFixture(r),e&&e.DestroyFixture(r)}this._body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},Pe(t,[{key:"impl",get:function(){return this._shapes}},{key:"collider",get:function(){return this._collider}},{key:"worldAABB",get:function(){for(var t=1e7,e=t,i=t,r=-t,n=-t,s=this._fixtures,a=0;a<s.length;a++)for(var o=s[a],l=o.GetShape().GetChildCount(),h=0;h<l;h++){var u=o.GetAABB(h);u.lowerBound.x<e&&(e=u.lowerBound.x),u.lowerBound.y<i&&(i=u.lowerBound.y),u.upperBound.x>r&&(r=u.upperBound.x),u.upperBound.y>n&&(n=u.upperBound.y)}e*=wQ,i*=wQ,r*=wQ,n*=wQ;var c=this._rect;return c.x=e,c.y=i,c.width=r-e,c.height=n-i,c}}]),t}(),Y1=new gr,q1=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._worldPoints=[new dr,new dr,new dr,new dr],e}return Me(e,t),e.prototype._createShapes=function(t,e){t=Math.abs(t),e=Math.abs(e);var i=this.collider,r=i.size.width/2/wQ*t,n=i.size.height/2/wQ*e,s=i.offset.x/wQ*t,a=i.offset.y/wQ*e,o=new CQ.PolygonShape;return o.SetAsBox(r,n,new CQ.Vec2(s,a),0),[o]},Pe(e,[{key:"worldPoints",get:function(){var t=Y1,e=this.collider,i=e.size,r=e.offset;t.x=r.x-i.width/2,t.y=r.y-i.height/2,t.width=i.width,t.height=i.height;var n=this._worldPoints,s=n[0],a=n[1],o=n[2],l=n[3];return t.transformMat4ToPoints(e.node.worldMatrix,s,a,o,l),n}}]),e}(X1),J1=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._worldPosition=new dr,e}return Me(e,t),e.prototype._createShapes=function(t,e){t=Math.abs(t),e=Math.abs(e);var i=this.collider,r=i.offset.x/wQ*t,n=i.offset.y/wQ*e,s=new CQ.CircleShape;return s.m_radius=i.radius/wQ*t,s.m_p.Set(r,n),[s]},Pe(e,[{key:"worldRadius",get:function(){return this._shapes[0].m_radius*wQ}},{key:"worldPosition",get:function(){var t=this._shapes[0].m_p;return this._worldPosition.set(t.x*wQ,t.y*wQ)}}]),e}(X1),K1=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._worldPoints=[],e}return Me(e,t),e.prototype._createShapes=function(t,e){var i=[],r=this.collider,n=r.points;n.length>0&&n[0].equals(n[n.length-1])&&(n.length-=1);for(var s=PQ(n),a=r.offset,o=0;o<s.length;o++){for(var l=s[o],h=null,u=[],c=null,_=0,f=l.length;_<f;_++){h||(h=new CQ.PolygonShape);var p=l[_],d=(p.x+a.x)/wQ*t,m=(p.y+a.y)/wQ*e,y=new CQ.Vec2(d,m);u.push(y),c||(c=y),u.length===CQ.maxPolygonVertices&&(h.Set(u,u.length),i.push(h),h=null,_<f-1&&(u=[c,u[u.length-1]]))}h&&(h.Set(u,u.length),i.push(h))}return i},Pe(e,[{key:"worldPoints",get:function(){for(var t=this.collider,e=t.points,i=this._worldPoints,r=t.node.worldMatrix,n=0;n<e.length;n++)i[n]||(i[n]=new dr),dr.transformMat4(i[n],e[n],r);return i.length=e.length,this._worldPoints}}]),e}(X1),Z1=function(){function t(){this._b2joint=null,this._jointComp=null,this._body=null,this._inited=!1}var e=t.prototype;return e.initialize=function(t){this._jointComp=t},e.onEnable=function(){y$.instance._callAfterStep(this,this._init)},e.onDisable=function(){y$.instance._callAfterStep(this,this._destroy)},e.start=function(){y$.instance._callAfterStep(this,this._init)},e._init=function(){if(!this._inited){var t=this._jointComp;if(t.isValid){this._body=t.getComponent(f1);var e=this._createJointDef();if(e){var i=t.connectedBody;i&&i.enabledInHierarchy&&(e.bodyA=this._body.impl.impl,e.bodyB=i.impl.impl,e.collideConnected=t.collideConnected,this._b2joint=y$.instance.physicsWorld.impl.CreateJoint(e),this._inited=!0)}}}},e._destroy=function(){this._inited&&(y$.instance.physicsWorld.impl.DestroyJoint(this._b2joint),this._b2joint=null,this._inited=!1)},e._createJointDef=function(){return null},e.isValid=function(){return this._b2joint&&this._body&&this._body.impl&&this._jointComp&&this._jointComp.connectedBody&&this._jointComp.connectedBody.impl},Pe(t,[{key:"impl",get:function(){return this._b2joint}},{key:"comp",get:function(){return this._jointComp}},{key:"body",get:function(){return this._body}}]),t}(),Q1=new CQ.Vec2;function $1(t,e,i,r){var n=(r.x-i.x)*(t.y-i.y)-(r.y-i.y)*(t.x-i.x),s=(e.x-t.x)*(t.y-i.y)-(e.y-t.y)*(t.x-i.x),a=(r.y-i.y)*(e.x-t.x)-(r.x-i.x)*(e.y-t.y);if(0!==a){var o=n/a,l=s/a;if(o>=0&&o<=1&&l>=0&&l<=1)return!0}return!1}W1={PhysicsWorld:G1,RigidBody:U1,BoxShape:q1,CircleShape:J1,PolygonShape:K1,MouseJoint:function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._touchPoint=new dr,e._isTouched=!1,e}Me(e,t);var i=e.prototype;return i.setTarget=function(t){this._b2joint&&(Q1.x=t.x/wQ,Q1.y=t.y/wQ,this._b2joint.SetTarget(Q1))},i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},i.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},i.setMaxForce=function(t){this._b2joint&&this._b2joint.SetMaxForce(t)},i._createJointDef=function(){var t=new CQ.MouseJointDef,e=this._jointComp;return t.target.Set(this._touchPoint.x/wQ,this._touchPoint.y/wQ),t.maxForce=e.maxForce,t.dampingRatio=e.dampingRatio,t.frequencyHz=e.frequency,t},i.initialize=function(e){t.prototype.initialize.call(this,e);var i=pi("Canvas");i&&(i.on(Dr.TOUCH_START,this.onTouchBegan,this),i.on(Dr.TOUCH_MOVE,this.onTouchMove,this),i.on(Dr.TOUCH_END,this.onTouchEnd,this),i.on(Dr.TOUCH_CANCEL,this.onTouchEnd,this))},i.onEnable=function(){},i.start=function(){},i.onTouchBegan=function(t){this._isTouched=!0;var e=this._touchPoint.set(t.getUILocation()),i=y$.instance.physicsWorld.testPoint(e);if(!(i.length<=0)){var r=i[0].body;r.wakeUp();var n=this._jointComp;n.connectedBody=r,this._init(),this.setMaxForce(n.maxForce*r.getMass()),this.setTarget(e)}},i.onTouchMove=function(t){this._touchPoint=t.getUILocation()},i.onTouchEnd=function(){this._destroy(),this._isTouched=!1},i.update=function(){this._isTouched&&this.isValid()&&this.setTarget(this._touchPoint)},e}(Z1),DistanceJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setMaxLength=function(t){this._b2joint&&this._b2joint.SetMaxLength(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.RopeJointDef;return e.localAnchorA.Set(t.anchor.x/wQ,t.anchor.y/wQ),e.localAnchorB.Set(t.connectedAnchor.x/wQ,t.connectedAnchor.y/wQ),e.maxLength=t.maxLength/wQ,e},e}(Z1),SpringJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},i.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},i.setDistance=function(t){this._b2joint&&this._b2joint.SetLength(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.DistanceJointDef;return e.localAnchorA.Set(t.anchor.x/wQ,t.anchor.y/wQ),e.localAnchorB.Set(t.connectedAnchor.x/wQ,t.connectedAnchor.y/wQ),e.length=t.distance/wQ,e.dampingRatio=t.dampingRatio,e.frequencyHz=t.frequency,e},e}(Z1),RelativeJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setMaxForce=function(t){this._b2joint&&this._b2joint.SetMaxForce(t)},i.setAngularOffset=function(t){this._b2joint&&this._b2joint.SetAngularOffset(qi(t))},i.setLinearOffset=function(t){this._b2joint&&this._b2joint.SetLinearOffset(new CQ.Vec2(t.x/wQ,t.y/wQ))},i.setCorrectionFactor=function(t){this._b2joint&&(this._b2joint.m_correctionFactor=t)},i.setMaxTorque=function(t){this._b2joint&&this._b2joint.SetMaxTorque(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.MotorJointDef;return e.linearOffset.Set(t.linearOffset.x/wQ,t.linearOffset.y/wQ),e.angularOffset=qi(t.angularOffset),e.maxForce=t.maxForce,e.maxTorque=t.maxTorque,e.correctionFactor=t.correctionFactor,e},e}(Z1),SliderJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.enableLimit=function(t){this._b2joint&&this._b2joint.EnableLimit(t)},i.setLowerLimit=function(){this.updateLimits()},i.setUpperLimit=function(){this.updateLimits()},i.updateLimits=function(){if(this._b2joint){var t=this._jointComp;this._b2joint.SetLimits(t.lowerLimit/wQ,t.upperLimit/wQ)}},i.enableMotor=function(t){this._b2joint&&this._b2joint.EnableMotor(t)},i.setMaxMotorForce=function(t){this._b2joint&&this._b2joint.SetMaxMotorForce(t)},i.setMotorSpeed=function(t){this._b2joint&&this._b2joint.SetMotorSpeed(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.PrismaticJointDef;e.localAnchorA.Set(t.anchor.x/wQ,t.anchor.y/wQ),e.localAnchorB.Set(t.connectedAnchor.x/wQ,t.connectedAnchor.y/wQ);var i=qi(t.angle);return e.localAxisA.Set(Math.cos(i),Math.sin(i)),e.referenceAngle=0,e.enableLimit=t.enableLimit,e.lowerTranslation=t.lowerLimit/wQ,e.upperTranslation=t.upperLimit/wQ,e.enableMotor=t.enableMotor,e.maxMotorForce=t.maxMotorForce,e.motorSpeed=t.motorSpeed,e},e}(Z1),FixedJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.WeldJointDef;return e.localAnchorA.Set(t.anchor.x/wQ,t.anchor.y/wQ),e.localAnchorB.Set(t.connectedAnchor.x/wQ,t.connectedAnchor.y/wQ),e.referenceAngle=0,e.frequencyHz=t.frequency,e.dampingRatio=t.dampingRatio,e},e}(Z1),WheelJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetSpringDampingRatio(t)},i.setFrequency=function(t){this._b2joint&&this._b2joint.SetSpringFrequencyHz(t)},i.enableMotor=function(t){this._b2joint&&this._b2joint.EnableMotor(t)},i.setMaxMotorTorque=function(t){this._b2joint&&this._b2joint.SetMaxMotorTorque(t)},i.setMotorSpeed=function(t){this._b2joint&&this._b2joint.SetMotorSpeed(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.WheelJointDef;e.localAnchorA.Set(t.anchor.x/wQ,t.anchor.y/wQ),e.localAnchorB.Set(t.connectedAnchor.x/wQ,t.connectedAnchor.y/wQ);var i=qi(t.angle);return e.localAxisA.Set(Math.cos(i),Math.sin(i)),e.maxMotorTorque=t.maxMotorTorque,e.motorSpeed=qi(t.motorSpeed),e.enableMotor=t.enableMotor,e.dampingRatio=t.dampingRatio,e.frequencyHz=t.frequency,e},e}(Z1),HingeJoint:function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.enableLimit=function(t){this._b2joint&&this._b2joint.EnableLimit(t)},i.setLowerAngle=function(){this.updateLimits()},i.setUpperAngle=function(){this.updateLimits()},i.updateLimits=function(){if(this._b2joint){var t=this._jointComp;this._b2joint.SetLimits(qi(t.lowerAngle),qi(t.upperAngle))}},i.enableMotor=function(t){this._b2joint&&this._b2joint.EnableMotor(t)},i.setMaxMotorTorque=function(t){this._b2joint&&this._b2joint.SetMaxMotorTorque(t)},i.setMotorSpeed=function(t){this._b2joint&&this._b2joint.SetMotorSpeed(t)},i._createJointDef=function(){var t=this._jointComp,e=new CQ.RevoluteJointDef;return e.localAnchorA.Set(t.anchor.x/wQ,t.anchor.y/wQ),e.localAnchorB.Set(t.connectedAnchor.x/wQ,t.connectedAnchor.y/wQ),e.enableMotor=t.enableMotor,e.maxMotorTorque=t.maxMotorTorque,e.motorSpeed=qi(t.motorSpeed),e.enableLimit=t.enableLimit,e.lowerAngle=t.lowerAngle,e.upperAngle=t.upperAngle,e},e}(Z1)},rQ="box2d",He._global.CC_PHYSICS_2D_BUILTIN=!1,He._global.CC_PHYSICS_2D_BOX2D=!0,iQ=W1;var t2=new dr,e2=new dr,i2=new dr,r2=new dr;function n2(t,e,i){for(var r=i.length,n=0;n<r;++n)if($1(t,e,i[n],i[(n+1)%r]))return!0;return!1}function s2(t,e){for(var i=!1,r=t.x,n=t.y,s=e.length,a=0,o=s-1;a<s;o=a++){var l=e[a].x,h=e[a].y,u=e[o].x,c=e[o].y;h>n!=c>n&&r<(u-l)*(n-h)/(c-h)+l&&(i=!i)}return i}function a2(t,e,i,r){var n,s=i.x-e.x,a=i.y-e.y,o=s*s+a*a,l=((t.x-e.x)*s+(t.y-e.y)*a)/o;return n=r?o?l<0?e:l>1?i:t2.set(e.x+l*s,e.y+l*a):e:t2.set(e.x+l*s,e.y+l*a),s=t.x-n.x,a=t.y-n.y,Math.sqrt(s*s+a*a)}var o2,l2,h2,u2,c2,_2,f2,p2,d2,m2=t("Intersection2D",(function(){}));m2.lineLine=$1,m2.lineRect=function(t,e,i){var r=t2.set(i.x,i.y),n=e2.set(i.x,i.yMax),s=i2.set(i.xMax,i.yMax),a=r2.set(i.xMax,i.y);return!!($1(t,e,r,n)||$1(t,e,n,s)||$1(t,e,s,a)||$1(t,e,a,r))},m2.linePolygon=n2,m2.rectRect=function(t,e){var i=t.x,r=t.y,n=t.x+t.width,s=t.y+t.height,a=e.x,o=e.y,l=e.x+e.width,h=e.y+e.height;return i<=l&&n>=a&&r<=h&&s>=o},m2.rectPolygon=function(t,e){var i=t2.set(t.x,t.y),r=e2.set(t.x,t.yMax),n=i2.set(t.xMax,t.yMax),s=r2.set(t.xMax,t.y);if(n2(i,r,e))return!0;if(n2(r,n,e))return!0;if(n2(n,s,e))return!0;if(n2(s,i,e))return!0;for(var a=0,o=e.length;a<o;++a)if(t.contains(e[a]))return!0;return!!(s2(i,e)||s2(r,e)||s2(n,e)||s2(s,e))},m2.rectCircle=function(t,e,i){var r=e.x,n=e.y,s=t.x,a=t.y,o=t.width,l=t.height,h=r,u=n;r<s?h=s:r>s+o&&(h=s+o),n<a?u=a:n>a+l&&(u=a+l);var c=r-h,_=n-u;return Math.sqrt(c*c+_*_)<=i},m2.polygonPolygon=function(t,e){var i,r;for(i=0,r=t.length;i<r;++i)if(n2(t[i],t[(i+1)%r],e))return!0;for(i=0,r=e.length;i<r;++i)if(s2(e[i],t))return!0;for(i=0,r=t.length;i<r;++i)if(s2(t[i],e))return!0;return!1},m2.circleCircle=function(t,e,i,r){return dr.distance(t,i)<e+r},m2.polygonCircle=function(t,e,i){var r=e;if(s2(r,t))return!0;for(var n=0,s=t.length;n<s;n++)if(a2(r,0===n?t[t.length-1]:t[n-1],t[n],!0)<i)return!0;return!1},m2.pointInPolygon=s2,m2.pointLineDistance=a2,function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CYLINDER=2]="CYLINDER",t[t.CONE=3]="CONE",t[t.CAPSULE=4]="CAPSULE",t[t.TORUS=5]="TORUS",t[t.PLANE=6]="PLANE",t[t.QUAD=7]="QUAD"}(d2||(d2={})),Pr(d2);var y2=t("Primitive",(o2=ri("cc.Primitive"),l2=bi(d2),o2((p2=f2=function(t){function e(e){var i;return void 0===e&&(e=d2.BOX),i=t.call(this)||this,li(i,"type",c2,hi(i)),li(i,"info",_2,hi(i)),i.type=e,i}return Me(e,t),e.prototype.onLoaded=function(){Ya(bZ[d2[this.type].toLowerCase()](this.info),this)},e}(Na),f2.PrimitiveType=d2,c2=oi((u2=p2).prototype,"type",[l2],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return d2.BOX}}),_2=oi(u2.prototype,"info",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),h2=u2))||h2));He.Primitive=y2,He.primitives=bZ;var g2,v2=function(){function t(t,e,i){this._id=void 0,this._opts=void 0,this._accumStart=void 0,this._total=0,this._value=0,this._averageValue=0,this._accumValue=0,this._accumSamples=0,this._id=t,this._opts=e,this._accumStart=i}var e=t.prototype;return e.sample=function(t){this._average(this._value,t)},e.human=function(){var t=this._opts,e=t.average,i=t.isInteger,r=e?this._averageValue:this._value;return i?Math.round(r):Math.round(100*r)/100},e.alarm=function(){return this._opts.below&&this._value<this._opts.below||this._opts.over&&this._value>this._opts.over},e._average=function(t,e){if(void 0===e&&(e=0),this._opts.average){this._accumValue+=t,++this._accumSamples;var i=e;i-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=i,this._accumSamples=0)}},Pe(t,[{key:"value",get:function(){return this._value},set:function(t){this._value=t}}]),t}(),b2=ri("cc.PerfCounter")(g2=function(t){function e(e,i,r){var n;return(n=t.call(this,e,i,r)||this)._time=void 0,n._time=r,n}Me(e,t);var i=e.prototype;return i.start=function(t){void 0===t&&(t=0),this._time=t},i.end=function(t){void 0===t&&(t=0),this._value=t-this._time,this._average(this._value)},i.tick=function(){this.end(),this.start()},i.frame=function(t){var e=t,i=e-this._time;this._total++,i>(this._opts.average||1e3)&&(this._value=1e3*this._total/i,this._total=0,this._time=e,this._average(this._value))},e}(v2))||g2,S2="0123456789. ",A2={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},C2={fps:{desc:"Framerate (FPS)",below:30,average:500,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:500},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:500,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:500},render:{desc:"Renderer (ms)",min:0,max:50,average:500,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},x2=t("Profiler",function(){function t(){this._stats=null,this.id="__Profiler__",this._showFPS=!1,this._rootNode=null,this._device=null,this._canvas=null,this._ctx=null,this._texture=null,this._region=new tt,this._canvasArr=[],this._regionArr=[this._region],this.digitsData=null,this.offsetData=null,this.pass=null,this._canvasDone=!1,this._statsDone=!1,this._inited=!1,this._lineHeight=256/(Object.keys(C2).length+1),this._wordHeight=0,this._eachNumWidth=0,this._totalLines=0,this.lastTime=0,this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._canvasArr.push(this._canvas)}var e=t.prototype;return e.isShowingStats=function(){return this._showFPS},e.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),He.game.off(He.Game.EVENT_RESTART,this.generateNode,this),He.director.off(He.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),He.director.off(He.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),He.director.off(He.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),He.director.off(He.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),He.director.off(He.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),He.director.off(He.Director.EVENT_AFTER_DRAW,this.afterDraw,this),this._showFPS=!1)},e.showStats=function(){this._showFPS||(this._device||(this._device=He.director.root.device),this.generateCanvas(),this.generateStats(),He.game.once(He.Game.EVENT_ENGINE_INITED,this.generateNode,this),He.game.on(He.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),He.director.on(He.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),He.director.on(He.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),He.director.on(He.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),He.director.on(He.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),He.director.on(He.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),He.director.on(He.Director.EVENT_AFTER_DRAW,this.afterDraw,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0)},e.generateCanvas=function(){if(!this._canvasDone){this._ctx&&this._canvas&&(this._canvas.width=256,this._canvas.height=256,this._canvas.style.width=""+this._canvas.width,this._canvas.style.height=""+this._canvas.height,this._ctx.font="23px Arial",this._ctx.textBaseline="top",this._ctx.fillStyle="#fff",this._texture=this._device.createTexture(new ht(v.TEX2D,b.SAMPLED|b.TRANSFER_DST,_.RGBA8,256,256)),this._region.texExtent.width=256,this._region.texExtent.height=256)}},e.generateStats=function(){if(!this._statsDone&&this._ctx&&this._canvas){this._stats=null;var t=performance.now();this._ctx.textAlign="left";var e=0;for(var i in C2){var r=C2[i];this._ctx.fillText(r.desc,0,e*this._lineHeight),r.counter=new b2(i,r,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var n=0;n<S2.length;++n){var s=this._ctx.measureText(S2[n]).width;this._eachNumWidth=Math.max(this._eachNumWidth,s)}for(var a=0;a<S2.length;++a)this._ctx.fillText(S2[a],a*this._eachNumWidth,this._totalLines*this._lineHeight);this._eachNumWidth/=this._canvas.width,this._stats=C2,this._canvasArr[0]=this._canvas,this._device.copyTexImagesToTexture(this._canvasArr,this._texture,this._regionArr)}},e.generateNode=function(){if(!this._rootNode||!this._rootNode.isValid){this._rootNode=new ur("PROFILER_NODE"),He.game.addPersistRootNode(this._rootNode);var t=new ur("Profiler_Camera");t.setPosition(0,0,1.5),t.parent=this._rootNode;var e=t.addComponent("cc.Camera");e.projection=Hr.ProjectionType.ORTHO,e.orthoHeight=1,e.near=1,e.far=2,e.visibility=Qr.BitMask.PROFILER,e.clearFlags=j.NONE,e.priority=4294967295;var i=new ur("Profiler_Root");i.parent=this._rootNode;for(var r=.4,n=r/this._totalLines,s=r/this._wordHeight,a=n/23,o=this._eachNumWidth*this._canvas.width*a,l=[0,r,0,s,r,0,s,0,0,0,0,0],h=[0,2,1,0,3,2],u=[0,0,-1,0,1,0,-1,0,1,this._wordHeight,-1,0,0,this._wordHeight,-1,0],c=0,_=0;_<this._totalLines;_++)for(var f=0;f<8;f++){l.push(s+f*o,r-_*n,0),l.push(s+(f+1)*o,r-_*n,0),l.push(s+(f+1)*o,r-(_+1)*n,0),l.push(s+f*o,r-(_+1)*n,0),c=4*(8*_+f+1),h.push(0+c,2+c,1+c,0+c,3+c,2+c);var p=8*_+f,d=Math.floor(p/4),m=p-4*d;u.push(0,this._wordHeight,d,m),u.push(this._eachNumWidth,this._wordHeight,d,m),u.push(this._eachNumWidth,1,d,m),u.push(0,1,d,m)}var y=i.addComponent(zo);y.mesh=Ya({positions:l,indices:h,colors:u});var g=new cr;g.initialize({effectName:"profiler"});var v=this.pass=g.passes[0],b=v.getBinding("mainTexture"),S=v.getBinding("digits"),A=v.getBinding("offset");v.bindTexture(b,this._texture),this.digitsData=v.blocks[S],this.offsetData=v.blocks[A],this.offsetData[3]=-1,y.material=g,y.node.layer=Qr.Enum.PROFILER,this._inited=!0}},e.beforeUpdate=function(){if(this._stats){var t=performance.now();this._stats.frame.counter.end(t),this._stats.frame.counter.start(t),this._stats.logic.counter.start(t)}},e.afterUpdate=function(){if(this._stats){var t=performance.now();He.director.isPaused()?this._stats.frame.counter.start(t):this._stats.logic.counter.end(t)}},e.beforePhysics=function(){if(this._stats){var t=performance.now();this._stats.physics.counter.start(t)}},e.afterPhysics=function(){if(this._stats){var t=performance.now();this._stats.physics.counter.end(t)}},e.beforeDraw=function(){if(this._stats){var t=this._device.surfaceTransform,e=this._device.capabilities.clipSpaceSignY;if(t!==this.offsetData[3]){var i=es[t],r=-.9*e;this.offsetData[0]=-.9*i[0]+r*i[2],this.offsetData[1]=-.9*i[1]+r*i[3],this.offsetData[2]=this._eachNumWidth,this.offsetData[3]=t}this.pass._rootBufferDirty=!0;var n=performance.now();this._stats.render.counter.start(n)}},e.afterDraw=function(){if(this._stats&&this._inited){var t=performance.now();if(this._stats.fps.counter.frame(t),this._stats.render.counter.end(t),!(t-this.lastTime<500)){this.lastTime=t;var e=this._device;this._stats.draws.counter.value=e.numDrawCalls,this._stats.instances.counter.value=e.numInstances,this._stats.bufferMemory.counter.value=e.memoryStatus.bufferSize/1048576,this._stats.textureMemory.counter.value=e.memoryStatus.textureSize/1048576,this._stats.tricount.counter.value=e.numTris;var i=0,r=this.digitsData;for(var n in this._stats){var s=this._stats[n];s.counter.sample(t);for(var a=s.counter.human().toString(),o=7;o>=0;o--){var l=8*i+o,h=a[a.length-(8-o)],u=A2[h];void 0===u&&(u=11),r[l]=u}i++}}}},t}()),T2=t("profiler",new x2);He.profiler=T2;var w2,E2,B2,D2,M2=yi({GRAVITY:0,RADIUS:1}),P2=yi({FREE:0,RELATIVE:1,GROUPED:2}),R2=new dr(0,0),I2=new dr,O2=new dr,F2=new dr,L2=new dr,V2=_d(ud),k2=function(){this.pos=new dr(0,0),this.startPos=new dr(0,0),this.color=new Ui(0,0,0,255),this.deltaColor={r:0,g:0,b:0,a:255},this.size=0,this.deltaSize=0,this.rotation=0,this.deltaRotation=0,this.timeToLive=0,this.drawPos=new dr(0,0),this.aspectRatio=1,this.dir=new dr(0,0),this.radialAccel=0,this.tangentialAccel=0,this.angle=0,this.degreesPerSecond=0,this.radius=0,this.deltaRadius=0},N2=new(function(t){function e(){return t.apply(this,arguments)||this}return Me(e,t),e.prototype.get=function(){return this._get()||new k2},e}(Tr))((function(t){t.pos.set(R2),t.startPos.set(R2),t.color._val=4278190080,t.deltaColor.r=t.deltaColor.g=t.deltaColor.b=0,t.deltaColor.a=255,t.size=0,t.deltaSize=0,t.rotation=0,t.deltaRotation=0,t.timeToLive=0,t.drawPos.set(R2),t.aspectRatio=1,t.dir.set(R2),t.radialAccel=0,t.tangentialAccel=0,t.angle=0,t.degreesPerSecond=0,t.radius=0,t.deltaRadius=0}),1024),G2=function(){function t(t){this.particles=[],this.active=!1,this.uvFilled=0,this.finished=!1,this.readyToPlay=!0,this.elapsed=0,this.emitCounter=0,this._worldRotation=0,this.sys=t,this.particles=[],this.active=!1,this.readyToPlay=!0,this.finished=!1,this.elapsed=0,this.emitCounter=0,this.uvFilled=0,this._worldRotation=0}var e=t.prototype;return e.stop=function(){this.active=!1,this.readyToPlay=!1,this.elapsed=this.sys.duration,this.emitCounter=0},e.reset=function(){this.active=!0,this.readyToPlay=!0,this.elapsed=0,this.emitCounter=0,this.finished=!1;for(var t=this.particles,e=0;e<t.length;++e)N2.put(t[e]);t.length=0},e.emitParticle=function(t){var e=this.sys,i=N2.get();this.particles.push(i),i.timeToLive=e.life+e.lifeVar*(Math.random()-.5)*2;var r=i.timeToLive=Math.max(0,i.timeToLive);i.pos.x=e.sourcePos.x+e.posVar.x*(Math.random()-.5)*2,i.pos.y=e.sourcePos.y+e.posVar.y*(Math.random()-.5)*2;var n,s,a,o,l=e.startColor,h=e.startColorVar,u=e.endColor,c=e.endColorVar;i.color.r=n=nn(l.r+h.r*(Math.random()-.5)*2,0,255),i.color.g=s=nn(l.g+h.g*(Math.random()-.5)*2,0,255),i.color.b=a=nn(l.b+h.b*(Math.random()-.5)*2,0,255),i.color.a=o=nn(l.a+h.a*(Math.random()-.5)*2,0,255),i.deltaColor.r=(nn(u.r+c.r*(Math.random()-.5)*2,0,255)-n)/r,i.deltaColor.g=(nn(u.g+c.g*(Math.random()-.5)*2,0,255)-s)/r,i.deltaColor.b=(nn(u.b+c.b*(Math.random()-.5)*2,0,255)-a)/r,i.deltaColor.a=(nn(u.a+c.a*(Math.random()-.5)*2,0,255)-o)/r;var _=e.startSize+e.startSizeVar*(Math.random()-.5)*2;if(_=Math.max(0,_),i.size=_,-1===e.endSize)i.deltaSize=0;else{var f=e.endSize+e.endSizeVar*(Math.random()-.5)*2;f=Math.max(0,f),i.deltaSize=(f-_)/r}var p=e.startSpin+e.startSpinVar*(Math.random()-.5)*2,d=e.endSpin+e.endSpinVar*(Math.random()-.5)*2;i.rotation=p,i.deltaRotation=(d-p)/r,i.startPos.x=t.x,i.startPos.y=t.y,i.aspectRatio=e.aspectRatio||1;var m=is(e.angle+this._worldRotation+e.angleVar*(Math.random()-.5)*2);if(e.emitterMode===M2.GRAVITY){var y=e.speed+e.speedVar*(Math.random()-.5)*2;i.dir.x=Math.cos(m),i.dir.y=Math.sin(m),i.dir.multiplyScalar(y),i.radialAccel=e.radialAccel+e.radialAccelVar*(Math.random()-.5)*2,i.tangentialAccel=e.tangentialAccel+e.tangentialAccelVar*(Math.random()-.5)*2,e.rotationIsDir&&(i.rotation=-rs(Math.atan2(i.dir.y,i.dir.x)))}else{var g=e.startRadius+e.startRadiusVar*(Math.random()-.5)*2,v=e.endRadius+e.endRadiusVar*(Math.random()-.5)*2;i.radius=g,i.deltaRadius=-1===e.endRadius?0:(v-g)/r,i.angle=m,i.degreesPerSecond=is(e.rotatePerS+e.rotatePerSVar*(Math.random()-.5)*2)}},e.updateUVs=function(t){var e=this.renderData;if(e&&this.sys._renderSpriteFrame){for(var i=e.vData,r=this.sys._renderSpriteFrame.uv,n=t?0:this.uvFilled,s=this.particles.length,a=n;a<s;a++){var o=a*V2*4;i[o+3]=r[0],i[o+4]=r[1],i[o+12]=r[2],i[o+13]=r[3],i[o+21]=r[4],i[o+22]=r[5],i[o+30]=r[6],i[o+31]=r[7]}this.uvFilled=s}},e.updateParticleBuffer=function(t,e,i,r){var n=i.vData,s=e.x,a=e.y,o=t.size,l=o,h=t.aspectRatio;h>1?l=o/h:o=l*h;var u=o/2,c=l/2;if(t.rotation){var _=-u,f=-c,p=u,d=c,m=-is(t.rotation),y=Math.cos(m),g=Math.sin(m);n[r]=_*y-f*g+s,n[r+1]=_*g+f*y+a,n[r+2]=0,n[r+9]=p*y-f*g+s,n[r+10]=p*g+f*y+a,n[r+11]=0,n[r+18]=_*y-d*g+s,n[r+19]=_*g+d*y+a,n[r+20]=0,n[r+27]=p*y-d*g+s,n[r+28]=p*g+d*y+a,n[r+29]=0}else n[r]=s-u,n[r+1]=a-c,n[r+2]=0,n[r+9]=s+u,n[r+10]=a-c,n[r+11]=0,n[r+18]=s-u,n[r+19]=a+c,n[r+20]=0,n[r+27]=s+u,n[r+28]=a+c,n[r+29]=0;Ui.toArray(n,t.color,r+5),Ui.toArray(n,t.color,r+14),Ui.toArray(n,t.color,r+23),Ui.toArray(n,t.color,r+32)},e.step=function(t){var e=this.sys.assembler,i=this.sys,r=i.node,n=this.particles;if(t=t>e.maxParticleDeltaTime?e.maxParticleDeltaTime:t,r.updateWorldTransform(),i.positionType===P2.FREE){this._worldRotation=function(t){for(var e=0,i=t;i;)e+=i.eulerAngles.z,i=i.parent;return e}(r);var s=r.worldMatrix;I2.x=s.m12,I2.y=s.m13}else i.positionType===P2.RELATIVE?(this._worldRotation=r.eulerAngles.z,I2.x=r.position.x,I2.y=r.position.y):this._worldRotation=0;if(this.active&&i.emissionRate){var a=1/i.emissionRate;for(n.length<i.totalParticles&&(this.emitCounter+=t);n.length<i.totalParticles&&this.emitCounter>a;)this.emitParticle(I2),this.emitCounter-=a;this.elapsed+=t,-1!==i.duration&&i.duration<this.elapsed&&i.stopSystem()}var o=this.renderData,l=n.length;o.reset(),this.requestData(4*l,6*l),l>this.uvFilled&&this.updateUVs();for(var h=0;h<n.length;){O2.x=O2.y=F2.x=F2.y=L2.x=L2.y=0;var u=n[h];if(u.timeToLive-=t,u.timeToLive>0){if(i.emitterMode===M2.GRAVITY){var c=L2,_=O2,f=F2;(u.pos.x||u.pos.y)&&(_.set(u.pos),_.normalize()),f.set(_),_.multiplyScalar(u.radialAccel);var p=f.x;f.x=-f.y,f.y=p,f.multiplyScalar(u.tangentialAccel),c.set(_),c.add(f),c.add(i.gravity),c.multiplyScalar(t),u.dir.add(c),c.set(u.dir),c.multiplyScalar(t),u.pos.add(c)}else u.angle+=u.degreesPerSecond*t,u.radius+=u.deltaRadius*t,u.pos.x=-Math.cos(u.angle)*u.radius,u.pos.y=-Math.sin(u.angle)*u.radius;u.color.r+=u.deltaColor.r*t,u.color.g+=u.deltaColor.g*t,u.color.b+=u.deltaColor.b*t,u.color.a+=u.deltaColor.a*t,u.size+=u.deltaSize*t,u.size<0&&(u.size=0),u.rotation+=u.deltaRotation*t;var d=O2;d.set(u.pos),i.positionType!==P2.GROUPED&&d.add(u.startPos);var m=V2*h*4;this.updateParticleBuffer(u,d,o,m),++h}else{var y=n[h];h!==n.length-1&&(n[h]=n[n.length-1]),N2.put(y),n.length--,o.indicesCount-=6,o.vertexCount-=4}}0!==n.length||this.active||this.readyToPlay||(this.finished=!0,i._finishedSimulation())},e.requestData=function(t,e){var i=this.renderData.indicesCount;this.renderData.request(t,e);for(var r=this.renderData.indicesCount/6,n=this.renderData.iData,s=i;s<r;s++){var a=4*s;n[i++]=a,n[i++]=a+1,n[i++]=a+2,n[i++]=a+1,n[i++]=a+3,n[i++]=a+2}},t}(),z2=t("ParticleAsset",ri("cc.ParticleAsset")((D2=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"spriteFrame",B2,hi(e)),e}return Me(e,t),e}(ai),B2=oi((E2=D2).prototype,"spriteFrame",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),w2=E2))||w2);He.ParticleAsset=z2;
- /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
- var U2={};(function(){function t(t){throw t}var e=void 0,i=!0,r=this;function n(t,i){var n,s=t.split("."),a=r;!(s[0]in a)&&a.execScript&&a.execScript("var "+s[0]);for(;s.length&&(n=s.shift());)s.length||i===e?a=a[n]?a[n]:a[n]={}:a[n]=i}var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;function a(t){if("string"==typeof t){var e,i,r=t.split("");for(e=0,i=r.length;e<i;e++)r[e]=(255&r[e].charCodeAt(0))>>>0;t=r}for(var n,s=1,a=0,o=t.length,l=0;0<o;){o-=n=1024<o?1024:o;do{a+=s+=t[l++]}while(--n);s%=65521,a%=65521}return(a<<16|s)>>>0}function o(e,i){this.index="number"==typeof i?i:0,this.i=0,this.buffer=e instanceof(s?Uint8Array:Array)?e:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}o.prototype.f=function(){var t,e=this.buffer,i=e.length,r=new(s?Uint8Array:Array)(i<<1);if(s)r.set(e);else for(t=0;t<i;++t)r[t]=e[t];return this.buffer=r},o.prototype.d=function(t,e,i){var r,n=this.buffer,s=this.index,a=this.i,o=n[s];if(i&&1<e&&(t=8<e?(f[255&t]<<24|f[t>>>8&255]<<16|f[t>>>16&255]<<8|f[t>>>24&255])>>32-e:f[t]>>8-e),8>e+a)o=o<<e|t,a+=e;else for(r=0;r<e;++r)o=o<<1|t>>e-r-1&1,8==++a&&(a=0,n[s++]=f[o],o=0,s===n.length&&(n=this.f()));n[s]=o,this.buffer=n,this.i=a,this.index=s},o.prototype.finish=function(){var t,e=this.buffer,i=this.index;return 0<this.i&&(e[i]<<=8-this.i,e[i]=f[e[i]],i++),s?t=e.subarray(0,i):(e.length=i,t=e),t};var l,h=new(s?Uint8Array:Array)(256);for(l=0;256>l;++l){for(var u=_=l,c=7,_=_>>>1;_;_>>>=1)u<<=1,u|=1&_,--c;h[l]=(u<<c&255)>>>0}var f=h;function p(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function d(t){var e,i,r,n,a,o,l,h,u,c=t.length,_=0,f=Number.POSITIVE_INFINITY;for(h=0;h<c;++h)t[h]>_&&(_=t[h]),t[h]<f&&(f=t[h]);for(e=1<<_,i=new(s?Uint32Array:Array)(e),r=1,n=0,a=2;r<=_;){for(h=0;h<c;++h)if(t[h]===r){for(o=0,l=n,u=0;u<r;++u)o=o<<1|1&l,l>>=1;for(u=o;u<e;u+=a)i[u]=r<<16|h;++n}++r,n<<=1,a<<=1}return[i,_,f]}function m(t,e){this.h=g,this.w=0,this.input=t,this.b=0,e&&(e.lazy&&(this.w=e.lazy),"number"==typeof e.compressionType&&(this.h=e.compressionType),e.outputBuffer&&(this.a=s&&e.outputBuffer instanceof Array?new Uint8Array(e.outputBuffer):e.outputBuffer),"number"==typeof e.outputIndex&&(this.b=e.outputIndex)),this.a||(this.a=new(s?Uint8Array:Array)(32768))}p.prototype.getParent=function(t){return 2*((t-2)/4|0)},p.prototype.push=function(t,e){var i,r,n,s=this.buffer;for(i=this.length,s[this.length++]=e,s[this.length++]=t;0<i&&(r=this.getParent(i),s[i]>s[r]);)n=s[i],s[i]=s[r],s[r]=n,n=s[i+1],s[i+1]=s[r+1],s[r+1]=n,i=r;return this.length},p.prototype.pop=function(){var t,e,i,r,n,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],n=0;!((r=2*n+2)>=this.length)&&(r+2<this.length&&s[r+2]>s[r]&&(r+=2),s[r]>s[n]);)i=s[n],s[n]=s[r],s[r]=i,i=s[n+1],s[n+1]=s[r+1],s[r+1]=i,n=r;return{index:t,value:e,length:this.length}};var y,g=2,v={NONE:0,r:1,j:g,N:3},b=[];for(y=0;288>y;y++)switch(i){case 143>=y:b.push([y+48,8]);break;case 255>=y:b.push([y-144+400,9]);break;case 279>=y:b.push([y-256+0,7]);break;case 287>=y:b.push([y-280+192,8]);break;default:t("invalid literal: "+y)}function S(t,e){this.length=t,this.G=e}function A(){var e=C;switch(i){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}m.prototype.n=function(){var r,n,a,l,h=this.input;switch(this.h){case 0:for(a=0,l=h.length;a<l;){var u,c,_,f=n=s?h.subarray(a,a+65535):h.slice(a,a+65535),p=(a+=n.length)===l,d=e,m=e,y=this.a,v=this.b;if(s){for(y=new Uint8Array(this.a.buffer);y.length<=v+f.length+5;)y=new Uint8Array(y.length<<1);y.set(this.a)}if(u=p?1:0,y[v++]=0|u,_=65536+~(c=f.length)&65535,y[v++]=255&c,y[v++]=c>>>8&255,y[v++]=255&_,y[v++]=_>>>8&255,s)y.set(f,v),v+=f.length,y=y.subarray(0,v);else{for(d=0,m=f.length;d<m;++d)y[v++]=f[d];y.length=v}this.b=v,this.a=y}break;case 1:var S=new o(new Uint8Array(this.a.buffer),this.b);S.d(1,1,i),S.d(1,2,i);var A,C,x,T=E(this,h);for(A=0,C=T.length;A<C;A++)if(x=T[A],o.prototype.d.apply(S,b[x]),256<x)S.d(T[++A],T[++A],i),S.d(T[++A],5),S.d(T[++A],T[++A],i);else if(256===x)break;this.a=S.finish(),this.b=this.a.length;break;case g:var w,M,P,R,I,O,F,L,V,k,N,G,z,U,H,j=new o(new Uint8Array(this.a),this.b),W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X=Array(19);for(w=g,j.d(1,1,i),j.d(w,2,i),M=E(this,h),F=D(O=B(this.L,15)),V=D(L=B(this.K,7)),P=286;257<P&&0===O[P-1];P--);for(R=30;1<R&&0===L[R-1];R--);var Y,q,J,K,Z,Q,$=P,tt=R,et=new(s?Uint32Array:Array)($+tt),it=new(s?Uint32Array:Array)(316),rt=new(s?Uint8Array:Array)(19);for(Y=q=0;Y<$;Y++)et[q++]=O[Y];for(Y=0;Y<tt;Y++)et[q++]=L[Y];if(!s)for(Y=0,K=rt.length;Y<K;++Y)rt[Y]=0;for(Y=Z=0,K=et.length;Y<K;Y+=q){for(q=1;Y+q<K&&et[Y+q]===et[Y];++q);if(J=q,0===et[Y])if(3>J)for(;0<J--;)it[Z++]=0,rt[0]++;else for(;0<J;)(Q=138>J?J:138)>J-3&&Q<J&&(Q=J-3),10>=Q?(it[Z++]=17,it[Z++]=Q-3,rt[17]++):(it[Z++]=18,it[Z++]=Q-11,rt[18]++),J-=Q;else if(it[Z++]=et[Y],rt[et[Y]]++,3>--J)for(;0<J--;)it[Z++]=et[Y],rt[et[Y]]++;else for(;0<J;)(Q=6>J?J:6)>J-3&&Q<J&&(Q=J-3),it[Z++]=16,it[Z++]=Q-3,rt[16]++,J-=Q}for(r=s?it.subarray(0,Z):it.slice(0,Z),k=B(rt,7),U=0;19>U;U++)X[U]=k[W[U]];for(I=19;4<I&&0===X[I-1];I--);for(N=D(k),j.d(P-257,5,i),j.d(R-1,5,i),j.d(I-4,4,i),U=0;U<I;U++)j.d(X[U],3,i);for(U=0,H=r.length;U<H;U++)if(G=r[U],j.d(N[G],k[G],i),16<=G){switch(U++,G){case 16:z=2;break;case 17:z=3;break;case 18:z=7;break;default:t("invalid code: "+G)}j.d(r[U],z,i)}var nt,st,at,ot,lt,ht,ut,ct,_t=[F,O],ft=[V,L];for(lt=_t[0],ht=_t[1],ut=ft[0],ct=ft[1],nt=0,st=M.length;nt<st;++nt)if(at=M[nt],j.d(lt[at],ht[at],i),256<at)j.d(M[++nt],M[++nt],i),ot=M[++nt],j.d(ut[ot],ct[ot],i),j.d(M[++nt],M[++nt],i);else if(256===at)break;this.a=j.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var C,x,T=[];for(C=3;258>=C;C++)x=A(),T[C]=x[2]<<24|x[1]<<16|x[0];var w=s?new Uint32Array(T):T;function E(r,n){function a(e,r){var n,s,a,o,l=e.G,h=[],u=0;switch(n=w[e.length],h[u++]=65535&n,h[u++]=n>>16&255,h[u++]=n>>24,i){case 1===l:s=[0,l-1,0];break;case 2===l:s=[1,l-2,0];break;case 3===l:s=[2,l-3,0];break;case 4===l:s=[3,l-4,0];break;case 6>=l:s=[4,l-5,1];break;case 8>=l:s=[5,l-7,1];break;case 12>=l:s=[6,l-9,2];break;case 16>=l:s=[7,l-13,2];break;case 24>=l:s=[8,l-17,3];break;case 32>=l:s=[9,l-25,3];break;case 48>=l:s=[10,l-33,4];break;case 64>=l:s=[11,l-49,4];break;case 96>=l:s=[12,l-65,5];break;case 128>=l:s=[13,l-97,5];break;case 192>=l:s=[14,l-129,6];break;case 256>=l:s=[15,l-193,6];break;case 384>=l:s=[16,l-257,7];break;case 512>=l:s=[17,l-385,7];break;case 768>=l:s=[18,l-513,8];break;case 1024>=l:s=[19,l-769,8];break;case 1536>=l:s=[20,l-1025,9];break;case 2048>=l:s=[21,l-1537,9];break;case 3072>=l:s=[22,l-2049,10];break;case 4096>=l:s=[23,l-3073,10];break;case 6144>=l:s=[24,l-4097,11];break;case 8192>=l:s=[25,l-6145,11];break;case 12288>=l:s=[26,l-8193,12];break;case 16384>=l:s=[27,l-12289,12];break;case 24576>=l:s=[28,l-16385,13];break;case 32768>=l:s=[29,l-24577,13];break;default:t("invalid distance")}for(n=s,h[u++]=n[0],h[u++]=n[1],h[u++]=n[2],a=0,o=h.length;a<o;++a)y[g++]=h[a];b[h[0]]++,A[h[3]]++,v=e.length+r-1,p=null}var o,l,h,u,c,_,f,p,d,m={},y=s?new Uint16Array(2*n.length):[],g=0,v=0,b=new(s?Uint32Array:Array)(286),A=new(s?Uint32Array:Array)(30),C=r.w;if(!s){for(h=0;285>=h;)b[h++]=0;for(h=0;29>=h;)A[h++]=0}for(b[256]=1,o=0,l=n.length;o<l;++o){for(h=c=0,u=3;h<u&&o+h!==l;++h)c=c<<8|n[o+h];if(m[c]===e&&(m[c]=[]),_=m[c],!(0<v--)){for(;0<_.length&&32768<o-_[0];)_.shift();if(o+3>=l){for(p&&a(p,-1),h=0,u=l-o;h<u;++h)d=n[o+h],y[g++]=d,++b[d];break}if(0<_.length){var x=e,T=e,E=0,B=e,D=e,M=e,P=n.length,R=(D=0,_.length);t:for(;D<R;D++){if(x=_[R-D-1],B=3,3<E){for(M=E;3<M;M--)if(n[x+M-1]!==n[o+M-1])continue t;B=E}for(;258>B&&o+B<P&&n[x+B]===n[o+B];)++B;if(B>E&&(T=x,E=B),258===B)break}f=new S(E,o-T),p?p.length<f.length?(d=n[o-1],y[g++]=d,++b[d],a(f,0)):a(p,-1):f.length<C?p=f:a(f,0)}else p?a(p,-1):(d=n[o],y[g++]=d,++b[d])}_.push(o)}return y[g++]=256,b[256]++,r.L=b,r.K=A,s?y.subarray(0,g):y}function B(t,e){function i(t){var e=C[t][x[t]];e===g?(i(t+1),i(t+1)):--S[e],++x[t]}var r,n,a,o,l,h=t.length,u=new p(572),c=new(s?Uint8Array:Array)(h);if(!s)for(o=0;o<h;o++)c[o]=0;for(o=0;o<h;++o)0<t[o]&&u.push(o,t[o]);if(r=Array(u.length/2),n=new(s?Uint32Array:Array)(u.length/2),1===r.length)return c[u.pop().index]=1,c;for(o=0,l=u.length/2;o<l;++o)r[o]=u.pop(),n[o]=r[o].value;var _,f,d,m,y,g=n.length,v=new(s?Uint16Array:Array)(e),b=new(s?Uint8Array:Array)(e),S=new(s?Uint8Array:Array)(g),A=Array(e),C=Array(e),x=Array(e),T=(1<<e)-g,w=1<<e-1;for(v[e-1]=g,f=0;f<e;++f)T<w?b[f]=0:(b[f]=1,T-=w),T<<=1,v[e-2-f]=(v[e-1-f]/2|0)+g;for(v[0]=b[0],A[0]=Array(v[0]),C[0]=Array(v[0]),f=1;f<e;++f)v[f]>2*v[f-1]+b[f]&&(v[f]=2*v[f-1]+b[f]),A[f]=Array(v[f]),C[f]=Array(v[f]);for(_=0;_<g;++_)S[_]=e;for(d=0;d<v[e-1];++d)A[e-1][d]=n[d],C[e-1][d]=d;for(_=0;_<e;++_)x[_]=0;for(1===b[e-1]&&(--S[0],++x[e-1]),f=e-2;0<=f;--f){for(m=_=0,y=x[f+1],d=0;d<v[f];d++)(m=A[f+1][y]+A[f+1][y+1])>n[_]?(A[f][d]=m,C[f][d]=g,y+=2):(A[f][d]=n[_],C[f][d]=_,++_);x[f]=0,1===b[f]&&i(f)}for(a=S,o=0,l=r.length;o<l;++o)c[r[o].index]=a[o];return c}function D(e){var i,r,n,a,o=new(s?Uint16Array:Array)(e.length),l=[],h=[],u=0;for(i=0,r=e.length;i<r;i++)l[e[i]]=1+(0|l[e[i]]);for(i=1,r=16;i<=r;i++)h[i]=u,(u+=0|l[i])>1<<i&&t("overcommitted"),u<<=1;for(65536>u&&t("undercommitted"),i=0,r=e.length;i<r;i++)for(u=h[e[i]],h[e[i]]+=1,n=o[i]=0,a=e[i];n<a;n++)o[i]=o[i]<<1|1&u,u>>>=1;return o}function M(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=P.j;var i,r={};for(i in!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType),e)r[i]=e[i];r.outputBuffer=this.a,this.z=new m(this.input,r)}var P=v;function R(e,i){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(e):e,this.s=!1,this.m=O,this.B=!1,!i&&(i={})||(i.index&&(this.c=i.index),i.bufferSize&&(this.l=i.bufferSize),i.bufferType&&(this.m=i.bufferType),i.resize&&(this.B=i.resize)),this.m){case I:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.l+258);break;case O:this.b=0,this.a=new(s?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}M.prototype.n=function(){var e,i,r,n,o,l,h,u=0;switch(h=this.a,e=ut){case ut:i=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(r=i<<4|e,h[u++]=r,e){case ut:switch(this.h){case P.NONE:o=0;break;case P.r:o=1;break;case P.j:o=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return n=o<<6|0,h[u++]=n|31-(256*r+n)%31,l=a(this.input),this.z.b=u,u=(h=this.z.n()).length,s&&((h=new Uint8Array(h.buffer)).length<=u+4&&(this.a=new Uint8Array(h.length+4),this.a.set(h),h=this.a),h=h.subarray(0,u+4)),h[u++]=l>>24&255,h[u++]=l>>16&255,h[u++]=l>>8&255,h[u++]=255&l,h},n("Zlib.Deflate",M),n("Zlib.Deflate.compress",(function(t,e){return new M(t,e).n()})),n("Zlib.Deflate.CompressionType",P),n("Zlib.Deflate.CompressionType.NONE",P.NONE),n("Zlib.Deflate.CompressionType.FIXED",P.r),n("Zlib.Deflate.CompressionType.DYNAMIC",P.j);var I=0,O=1,F={D:I,C:O};R.prototype.p=function(){for(;!this.s;){var r=tt(this,3);switch(1&r&&(this.s=i),r>>>=1){case 0:var n=this.input,a=this.c,o=this.a,l=this.b,h=e,u=e,c=e,_=o.length,f=e;switch(this.e=this.g=0,(h=n[a++])===e&&t(Error("invalid uncompressed block header: LEN (first byte)")),u=h,(h=n[a++])===e&&t(Error("invalid uncompressed block header: LEN (second byte)")),u|=h<<8,(h=n[a++])===e&&t(Error("invalid uncompressed block header: NLEN (first byte)")),c=h,(h=n[a++])===e&&t(Error("invalid uncompressed block header: NLEN (second byte)")),u===~(c|=h<<8)&&t(Error("invalid uncompressed block header: length verify")),a+u>n.length&&t(Error("input buffer is broken")),this.m){case I:for(;l+u>o.length;){if(u-=f=_-l,s)o.set(n.subarray(a,a+f),l),l+=f,a+=f;else for(;f--;)o[l++]=n[a++];this.b=l,o=this.f(),l=this.b}break;case O:for(;l+u>o.length;)o=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)o.set(n.subarray(a,a+u),l),l+=u,a+=u;else for(;u--;)o[l++]=n[a++];this.c=a,this.b=l,this.a=o;break;case 1:this.o(Z,$);break;case 2:it(this);break;default:t(Error("unknown BTYPE: "+r))}}return this.t()};var L,V,k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=s?new Uint16Array(k):k,G=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],z=s?new Uint16Array(G):G,U=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],H=s?new Uint8Array(U):U,j=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],W=s?new Uint16Array(j):j,X=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Y=s?new Uint8Array(X):X,q=new(s?Uint8Array:Array)(288);for(L=0,V=q.length;L<V;++L)q[L]=143>=L?8:255>=L?9:279>=L?7:8;var J,K,Z=d(q),Q=new(s?Uint8Array:Array)(30);for(J=0,K=Q.length;J<K;++J)Q[J]=5;var $=d(Q);function tt(i,r){for(var n,s=i.g,a=i.e,o=i.input,l=i.c;a<r;)(n=o[l++])===e&&t(Error("input buffer is broken")),s|=n<<a,a+=8;return n=s&(1<<r)-1,i.g=s>>>r,i.e=a-r,i.c=l,n}function et(i,r){for(var n,s,a,o=i.g,l=i.e,h=i.input,u=i.c,c=r[0],_=r[1];l<_;)(n=h[u++])===e&&t(Error("input buffer is broken")),o|=n<<l,l+=8;return a=(s=c[o&(1<<_)-1])>>>16,i.g=o>>a,i.e=l-a,i.c=u,65535&s}function it(t){function e(t,e,i){var r,n,s,a;for(a=0;a<t;)switch(r=et(this,e)){case 16:for(s=3+tt(this,2);s--;)i[a++]=n;break;case 17:for(s=3+tt(this,3);s--;)i[a++]=0;n=0;break;case 18:for(s=11+tt(this,7);s--;)i[a++]=0;n=0;break;default:n=i[a++]=r}return i}var i,r,n,a,o=tt(t,5)+257,l=tt(t,5)+1,h=tt(t,4)+4,u=new(s?Uint8Array:Array)(N.length);for(a=0;a<h;++a)u[N[a]]=tt(t,3);i=d(u),r=new(s?Uint8Array:Array)(o),n=new(s?Uint8Array:Array)(l),t.o(d(e.call(t,o,i,r)),d(e.call(t,l,i,n)))}function rt(e,i){var r,n;switch(this.input=e,this.c=0,!i&&(i={})||(i.index&&(this.c=i.index),i.verify&&(this.M=i.verify)),r=e[this.c++],n=e[this.c++],15&r){case ut:this.method=ut;break;default:t(Error("unsupported compression method"))}0!=((r<<8)+n)%31&&t(Error("invalid fcheck flag:"+((r<<8)+n)%31)),32&n&&t(Error("fdict flag is not supported")),this.A=new R(e,{index:this.c,bufferSize:i.bufferSize,bufferType:i.bufferType,resize:i.resize})}R.prototype.o=function(t,e){var i=this.a,r=this.b;this.u=t;for(var n,s,a,o,l=i.length-258;256!==(n=et(this,t));)if(256>n)r>=l&&(this.b=r,i=this.f(),r=this.b),i[r++]=n;else for(o=z[s=n-257],0<H[s]&&(o+=tt(this,H[s])),n=et(this,e),a=W[n],0<Y[n]&&(a+=tt(this,Y[n])),r>=l&&(this.b=r,i=this.f(),r=this.b);o--;)i[r]=i[r++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=r},R.prototype.I=function(t,e){var i=this.a,r=this.b;this.u=t;for(var n,s,a,o,l=i.length;256!==(n=et(this,t));)if(256>n)r>=l&&(l=(i=this.f()).length),i[r++]=n;else for(o=z[s=n-257],0<H[s]&&(o+=tt(this,H[s])),n=et(this,e),a=W[n],0<Y[n]&&(a+=tt(this,Y[n])),r+o>l&&(l=(i=this.f()).length);o--;)i[r]=i[r++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=r},R.prototype.f=function(){var t,e,i=new(s?Uint8Array:Array)(this.b-32768),r=this.b-32768,n=this.a;if(s)i.set(n.subarray(32768,i.length));else for(t=0,e=i.length;t<e;++t)i[t]=n[t+32768];if(this.k.push(i),this.q+=i.length,s)n.set(n.subarray(r,r+32768));else for(t=0;32768>t;++t)n[t]=n[r+t];return this.b=32768,n},R.prototype.J=function(t){var e,i,r,n=this.input.length/this.c+1|0,a=this.input,o=this.a;return t&&("number"==typeof t.v&&(n=t.v),"number"==typeof t.F&&(n+=t.F)),i=2>n?(r=(a.length-this.c)/this.u[2]/2*258|0)<o.length?o.length+r:o.length<<1:o.length*n,s?(e=new Uint8Array(i)).set(o):e=o,this.a=e},R.prototype.t=function(){var t,e,i,r,n,a=0,o=this.a,l=this.k,h=new(s?Uint8Array:Array)(this.q+(this.b-32768));if(0===l.length)return s?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(e=0,i=l.length;e<i;++e)for(r=0,n=(t=l[e]).length;r<n;++r)h[a++]=t[r];for(e=32768,i=this.b;e<i;++e)h[a++]=o[e];return this.k=[],this.buffer=h},R.prototype.H=function(){var t,e=this.b;return s?this.B?(t=new Uint8Array(e)).set(this.a.subarray(0,e)):t=this.a.subarray(0,e):(this.a.length>e&&(this.a.length=e),t=this.a),this.buffer=t},rt.prototype.p=function(){var e,i=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&(i[this.c++]<<24|i[this.c++]<<16|i[this.c++]<<8|i[this.c++])>>>0!==a(e)&&t(Error("invalid adler-32 checksum")),e},n("Zlib.Inflate",rt),n("Zlib.Inflate.BufferType",F),F.ADAPTIVE=F.C,F.BLOCK=F.D,n("Zlib.Inflate.prototype.decompress",rt.prototype.p);var nt,st,at=new(s?Uint8Array:Array)(288);for(nt=0,st=at.length;nt<st;++nt)at[nt]=143>=nt?8:255>=nt?9:279>=nt?7:8;d(at);var ot,lt,ht=new(s?Uint8Array:Array)(30);for(ot=0,lt=ht.length;ot<lt;++ot)ht[ot]=5;d(ht);var ut=8}).call(U2);var H2=U2.Zlib;H2.Deflate=H2.Deflate,H2.Deflate.compress=H2.Deflate.compress,H2.Inflate=H2.Inflate,H2.Inflate.BufferType=H2.Inflate.BufferType,H2.Inflate.prototype.decompress=H2.Inflate.prototype.decompress;for(var j2=function(){function t(t){var e,i=this;this.pos=8,this.palette=[],this.imgData=[],this.text={},this.width=0,this.height=0,this.bits=0,this.colorType=0,this.compressionMethod=0,this.filterMethod=0,this.interlaceMethod=0,this.colors=0,this.hasAlphaChannel=!1,this.pixelBitlength=0,this.data=t,this.transparency={indexed:[],rgb:0,grayscale:0};for(var r=0,n=0,s=0;;){s=this.readUInt32();var a=function(){var t=[];for(r=0;r<4;++r)t.push(String.fromCharCode(i.data[i.pos++]));return t}.call(this).join("");switch(a){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(s);break;case"fcTL":e&&this.animation.frames.push(e),this.pos+=4,e={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()};var o=this.readUInt16(),l=this.readUInt16()||100;e.delay=1e3*o/l,e.disposeOp=this.data[this.pos++],e.blendOp=this.data[this.pos++],e.data=[];break;case"IDAT":case"fdAT":for("fdAT"===a&&(this.pos+=4,s-=4),t=(null!=e?e.data:void 0)||this.imgData,r=0;s>=0?r<s:r>s;s>=0?++r:--r)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:this.transparency.indexed=this.read(s);var h=255-this.transparency.indexed.length;if(h>0)for(n=0;h>=0?n<h:n>h;h>=0?++n:--n)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(s)[0];break;case 2:this.transparency.rgb=this.read(s)}break;case"tEXt":var u=this.read(s),c=u.indexOf(0),_=String.fromCharCode.apply(String,u.slice(0,c));this.text[_]=String.fromCharCode.apply(String,u.slice(c+1));break;case"IEND":e&&this.animation.frames.push(e),this.colors=function(){switch(i.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this);var f=this.colorType;this.hasAlphaChannel=4===f||6===f;var p=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*p,this.colorSpace=function(){switch(i.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData instanceof Uint8Array||(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=s}if(this.pos+=4,this.pos>this.data.length)throw new Error(ns(6017))}}var e=t.prototype;return e.read=function(t){var e=0,i=[];for(e=0;t>=0?e<t:e>t;t>=0?++e:--e)i.push(this.data[this.pos++]);return i},e.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},e.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},e.decodePixels=function(t){if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);t=new H2.Inflate(t,{index:0,verify:!1}).decompress();for(var e=this.pixelBitlength/8,i=e*this.width,r=new Uint8Array(i*this.height),n=t.length,s=0,a=0,o=0,l=0,h=0,u=0,c=0,_=0,f=0,p=0,d=0,m=0,y=0,g=0,v=0,b=0,S=0,A=0,C=0;a<n;){switch(t[a++]){case 0:for(u=c=0;c<i;u=c+=1)r[o++]=t[a++];break;case 1:for(u=_=0;_<i;u=_+=1)l=t[a++],m=u<e?0:r[o-e],r[o++]=(l+m)%256;break;case 2:for(u=f=0;f<i;u=f+=1)l=t[a++],h=(u-u%e)/e,A=s&&r[(s-1)*i+h*e+u%e],r[o++]=(A+l)%256;break;case 3:for(u=p=0;p<i;u=p+=1)l=t[a++],h=(u-u%e)/e,m=u<e?0:r[o-e],A=s&&r[(s-1)*i+h*e+u%e],r[o++]=(l+Math.floor((m+A)/2))%256;break;case 4:for(u=d=0;d<i;u=d+=1)l=t[a++],h=(u-u%e)/e,m=u<e?0:r[o-e],0===s?A=C=0:(A=r[(s-1)*i+h*e+u%e],C=h&&r[(s-1)*i+(h-1)*e+u%e]),y=m+A-C,g=Math.abs(y-m),b=Math.abs(y-A),S=Math.abs(y-C),v=g<=b&&g<=S?m:b<=S?A:C,r[o++]=(l+v)%256;break;default:throw new Error(ns(6018,t[a-1]))}s++}return r},e.copyToImageData=function(t,e){var i,r=this.hasAlphaChannel,n=this.colors;this.palette.length&&(i=null!=this._decodedPalette?this._decodedPalette:this._decodedPalette=this.decodePalette(),n=4,r=!0);var s=t.data||t,a=s.length,o=i||e,l=0,h=0,u=0,c=0;if(1===n)for(;l<a;)u=i?4*e[l/4]:h,c=o[u++],s[l++]=c,s[l++]=c,s[l++]=c,s[l++]=r?o[u++]:255,h=u;else for(;l<a;)u=i?4*e[l/4]:h,s[l++]=o[u++],s[l++]=o[u++],s[l++]=o[u++],s[l++]=r?o[u++]:255,h=u},e.decodePalette=function(){for(var t=this.palette,e=this.transparency.indexed||[],i=new Uint8Array((e.length||0)+t.length),r=0,n=0,s=0,a=0,o=0,l=t.length;o<l;a=o+=3)i[r++]=t[a],i[r++]=t[a+1],i[r++]=t[a+2],s=e[n++],i[r++]=null!=s?s:255;return i},e.render=function(t){t.width=this.width,t.height=this.height;var e=t.getContext("2d"),i=e.createImageData(this.width,this.height);return this.copyToImageData(i,this.decodePixels(null)),e.putImageData(i,0,0)},t}(),W2=function(){function t(){this._littleEndian=!1,this._tiffData=[],this._fileDirectories=[]}var e=t.prototype;return e.getUint8=function(t){return this._tiffData[t]},e.getUint16=function(t){return this._littleEndian?this._tiffData[t+1]<<8|this._tiffData[t]:this._tiffData[t]<<8|this._tiffData[t+1]},e.getUint32=function(t){var e=this._tiffData;return this._littleEndian?e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]:e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]},e.checkLittleEndian=function(){var t=this.getUint16(0);if(18761===t)this._littleEndian=!0;else{if(19789!==t)throw console.log(t),TypeError(ns(6019));this._littleEndian=!1}return this._littleEndian},e.hasTowel=function(){if(42!==this.getUint16(2))throw RangeError(ns(6020));return!0},e.getFieldTypeName=function(t){return t in Y2?Y2[t]:null},e.getFieldTagName=function(t){return t in X2?X2[t]:(an(6021,t),"Tag"+t)},e.getFieldTypeLength=function(t){return-1!==["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(t)?1:-1!==["SHORT","SSHORT"].indexOf(t)?2:-1!==["LONG","SLONG","FLOAT"].indexOf(t)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(t)?8:0},e.getFieldValues=function(t,e,i,r){var n=[],s=this.getFieldTypeLength(e);if(s*i<=4)!1===this._littleEndian?n.push(r>>>8*(4-s)):n.push(r);else for(var a=0;a<i;a++){var o=s*a;s>=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(n.push(this.getUint32(r+o)),n.push(this.getUint32(r+o+4))):an(8e3):n.push(this.getBytes(s,r+o))}return"ASCII"===e&&n.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),n},e.getBytes=function(t,e){if(t<=0)an(8001);else{if(t<=1)return this.getUint8(e);if(t<=2)return this.getUint16(e);if(t<=3)return this.getUint32(e)>>>8;if(t<=4)return this.getUint32(e);an(8002)}return 0},e.getBits=function(t,e,i){i=i||0;var r=e+Math.floor(i/8),n=i+t,s=32-t,a=0,o=0;return n<=0?an(6023):n<=8?(a=24+i,o=this.getUint8(r)):n<=16?(a=16+i,o=this.getUint16(r)):n<=32?(a=i,o=this.getUint32(r)):an(6022),{bits:o<<a>>>s,byteOffset:r+Math.floor(n/8),bitOffset:n%8}},e.parseFileDirectory=function(t){var e=this.getUint16(t),i=[],r=0,n=0;for(r=t+2,n=0;n<e;r+=12,n++){var s=this.getUint16(r),a=this.getUint16(r+2),o=this.getUint32(r+4),l=this.getUint32(r+8),h=this.getFieldTagName(s),u=this.getFieldTypeName(a),c=this.getFieldValues(h,u,o,l);i[h]={type:u,values:c}}this._fileDirectories.push(i);var _=this.getUint32(r);0!==_&&this.parseFileDirectory(_)},e.clampColorSample=function(t,e){var i=Math.pow(2,8-e);return Math.floor(t*i+(i-1))},e.parseTIFF=function(t,e){var i=this;if(e=e||document.createElement("canvas"),this._tiffData=t,this._canvas=e,this.checkLittleEndian(),this.hasTowel()){var r=this.getUint32(4);this._fileDirectories.length=0,this.parseFileDirectory(r);var n=this._fileDirectories[0],s=n.ImageWidth.values[0],a=n.ImageLength.values[0];this._canvas.width=s,this._canvas.height=a;var o=[],l=n.Compression?n.Compression.values[0]:1,h=n.SamplesPerPixel.values[0],u=[],c=0,_=!1;n.BitsPerSample.values.forEach((function(t,e){u[e]={bitsPerSample:t,hasBytesPerSample:!1,bytesPerSample:void 0},t%8==0&&(u[e].hasBytesPerSample=!0,u[e].bytesPerSample=t/8),c+=t}),this);var f=0;c%8==0&&(_=!0,f=c/8);var p,d=n.StripOffsets.values,m=d.length;if(n.StripByteCounts)p=n.StripByteCounts.values;else{if(an(8003),1!==m)throw Error(ns(6024));p=[Math.ceil(s*a*c/8)]}for(var y=1,g=1,v=0;v<m;v++){var b=d[v];o[v]=[];for(var S=p[v],A=0,C=0,x=1,T=!0,w=[],E=0,B=0,D=0;A<S;A+=x)switch(l){case 1:w=[];for(var M=0;M<h;M++){var P=u[M];if(!P.hasBytesPerSample){var R=this.getBits(P.bitsPerSample,b+A,C);throw w.push(R.bits),A=R.byteOffset-b,C=R.bitOffset,RangeError(ns(6025))}var I=P.bytesPerSample*M;w.push(this.getBytes(P.bytesPerSample,b+A+I))}if(o[v].push(w),!_)throw x=0,RangeError(ns(6026));x=f;break;case 2:case 3:case 4:case 5:case 6:case 7:break;case 32773:if(T){T=!1;var O=this.getUint8(b+A);O>=0&&O<=127?y=O+1:O>=-127&&O<=-1?g=1-O:T=!0}else{for(var F=this.getUint8(b+A),L=0;L<g;L++){var V=u[B];if(!V.hasBytesPerSample)throw RangeError(ns(6025));D=D<<8*E|F,++E===V.bytesPerSample&&(w.push(D),D=E=0,B++),B===h&&(o[v].push(w),w=[],B=0)}0==--y&&(T=!0)}x=1}}if(e.getContext){var k=this._canvas.getContext("2d");k.fillStyle="rgba(255, 255, 255, 0)";var N=n.RowsPerStrip?n.RowsPerStrip.values[0]:a,G=o.length,z=a%N,U=0===z?N:z,H=N,j=0,W=n.PhotometricInterpretation.values[0],X=[],Y=0;n.ExtraSamples&&(Y=(X=n.ExtraSamples.values).length);var q=[],J=0;n.ColorMap&&(q=n.ColorMap.values,J=Math.pow(2,u[0].bitsPerSample));for(var K=0;K<G;K++){K+1===G&&(H=U);for(var Z=o[K].length,Q=j*K,$=0,tt=0;$<H&&tt<Z;$++)for(var et=0;et<s;et++,tt++){var it=o[K][tt],rt=0,nt=0,st=0,at=1;if(Y>0)for(var ot=0;ot<Y;ot++)if(1===X[ot]||2===X[ot]){at=it[3+ot]/256;break}!function(){switch(W){case 0:var t=0;u[0].hasBytesPerSample&&(t=Math.pow(16,2*u[0].bytesPerSample)),it.forEach((function(e,i,r){r[i]=t-e}));case 1:rt=nt=st=i.clampColorSample(it[0],u[0].bitsPerSample);break;case 2:rt=i.clampColorSample(it[0],u[0].bitsPerSample),nt=i.clampColorSample(it[1],u[1].bitsPerSample),st=i.clampColorSample(it[2],u[2].bitsPerSample);break;case 3:if(void 0===q)throw Error(ns(6027));var e=it[0];rt=i.clampColorSample(q[e],16),nt=i.clampColorSample(q[J+e],16),st=i.clampColorSample(q[2*J+e],16);break;default:throw RangeError(ns(6028,W))}}(),k.fillStyle="rgba("+rt+", "+nt+", "+st+", "+at+")",k.fillRect(et,Q+$,1,1)}j=H}}return this._canvas}},t}(),X2={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop"},Y2={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"},q2=new Array(123),J2=0;J2<123;++J2)q2[J2]=64;for(var K2=0;K2<64;++K2)q2["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(K2)]=K2;var Z2={name:"Jacob__Codec__Base64",decode:function(t){var e,i,r,n,s,a,o=[],l=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<t.length;)e=q2[t.charCodeAt(l++)]<<2|(n=q2[t.charCodeAt(l++)])>>4,i=(15&n)<<4|(s=q2[t.charCodeAt(l++)])>>2,r=(3&s)<<6|(a=q2[t.charCodeAt(l++)]),o.push(String.fromCharCode(e)),64!==s&&o.push(String.fromCharCode(i)),64!==a&&o.push(String.fromCharCode(r));return o.join("")},decodeAsArray:function(t,e){var i,r,n,s=this.decode(t),a=[];for(i=0,n=s.length/e;i<n;i++)for(a[i]=0,r=e-1;r>=0;--r)a[i]+=s.charCodeAt(i*e+r)<<8*r;return a}},Q2=function(t){this.data=t,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(Q2.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};Q2.gunzip=function(t){return t.constructor===Array||t.constructor,new Q2(t).gunzip()[0][0]},Q2.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},Q2.LITERALS=288,Q2.NAMEMAX=256,Q2.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],Q2.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Q2.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],Q2.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Q2.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Q2.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Q2.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},Q2.prototype.readByte=function(){return this.bits+=8,this.bytepos<this.data.length?this.data.charCodeAt(this.bytepos++):-1},Q2.prototype.byteAlign=function(){this.bb=1},Q2.prototype.readBit=function(){var t;return this.bits++,t=1&this.bb,this.bb>>=1,0===this.bb&&(this.bb=this.readByte(),t=1&this.bb,this.bb=this.bb>>1|128),t},Q2.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=Q2.bitReverse[e]>>8-t),e},Q2.prototype.flushBuffer=function(){this.bIdx=0},Q2.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},Q2.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},Q2.prototype.Rec=function(){var t,e=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(t=this.IsPat())>=0)e.b0=t;else if(e.b0=32768,this.Rec())return-1;if((t=this.IsPat())>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=this.Places[this.treepos],e.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},Q2.prototype.CreateTree=function(t,e,i){var r;for(this.Places=t,this.treepos=0,this.flens=i,this.fmax=e,r=0;r<17;r++)this.fpos[r]=0;return this.len=0,this.Rec()?-1:0},Q2.prototype.DecodeValue=function(t){for(var e,i,r=0,n=t[r];;)if(this.readBit()){if(!(32768&n.b1))return n.b1;for(n=n.jump,e=t.length,i=0;i<e;i++)if(t[i]===n){r=i;break}}else{if(!(32768&n.b0))return n.b0;n=t[++r]}return-1},Q2.prototype.DeflateLoop=function(){var t,e,i;do{var r,n;if(t=this.readBit(),0===(e=this.readBits(2)))for(this.byteAlign(),r=this.readByte(),r|=this.readByte()<<8,n=this.readByte(),65535&(r^~(n|=this.readByte()<<8))&&document.write("BlockLen checksum mismatch\n");r--;)s=this.readByte(),this.addBuffer(s);else if(1===e)for(;;)if((a=Q2.bitReverse[this.readBits(7)]>>1)>23?(a=a<<1|this.readBit())>199?a=(a-=128)<<1|this.readBit():(a-=48)>143&&(a+=136):a+=256,a<256)this.addBuffer(a);else{if(256===a)break;for(a-=257,p=this.readBits(Q2.cplext[a])+Q2.cplens[a],a=Q2.bitReverse[this.readBits(5)]>>3,Q2.cpdext[a]>8?(d=this.readBits(8),d|=this.readBits(Q2.cpdext[a]-8)<<8):d=this.readBits(Q2.cpdext[a]),d+=Q2.cpdist[a],a=0;a<p;a++){var s=this.buf32k[this.bIdx-d&32767];this.addBuffer(s)}}else if(2===e){var a,o,l,h,u,c=new Array(320);for(l=257+this.readBits(5),h=1+this.readBits(5),u=4+this.readBits(4),a=0;a<19;a++)c[a]=0;for(a=0;a<u;a++)c[Q2.border[a]]=this.readBits(3);for(p=this.distanceTree.length,i=0;i<p;i++)this.distanceTree[i]=new Q2.HufNode;if(this.CreateTree(this.distanceTree,19,c,0))return this.flushBuffer(),1;for(o=l+h,i=0;i<o;)if((a=this.DecodeValue(this.distanceTree))<16)c[i++]=a;else if(16===a){var _;if(i+(a=3+this.readBits(2))>o)return this.flushBuffer(),1;for(_=i?c[i-1]:0;a--;)c[i++]=_}else{if(i+(a=17===a?3+this.readBits(3):11+this.readBits(7))>o)return this.flushBuffer(),1;for(;a--;)c[i++]=0}for(p=this.literalTree.length,i=0;i<p;i++)this.literalTree[i]=new Q2.HufNode;if(this.CreateTree(this.literalTree,l,c,0))return this.flushBuffer(),1;for(p=this.literalTree.length,i=0;i<p;i++)this.distanceTree[i]=new Q2.HufNode;var f=new Array;for(i=l;i<c.length;i++)f[i-l]=c[i];if(this.CreateTree(this.distanceTree,h,f,0))return this.flushBuffer(),1;for(;;)if((a=this.DecodeValue(this.literalTree))>=256){var p,d;if(0==(a-=256))break;for(a--,p=this.readBits(Q2.cplext[a])+Q2.cplens[a],a=this.DecodeValue(this.distanceTree),Q2.cpdext[a]>8?(d=this.readBits(8),d|=this.readBits(Q2.cpdext[a]-8)<<8):d=this.readBits(Q2.cpdext[a]),d+=Q2.cpdist[a];p--;)s=this.buf32k[this.bIdx-d&32767],this.addBuffer(s)}else this.addBuffer(a)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},Q2.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e<this.unzipped.length;e++)if(this.unzipped[e][1]===t)return this.unzipped[e][0]},Q2.prototype.nextFile=function(){this.outputArr=[],this.modeZIP=!1;var t=[];if(t[0]=this.readByte(),t[1]=this.readByte(),120===t[0]&&218===t[1]&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),"geonext.gxt"],this.files++),31===t[0]&&139===t[1]&&(this.skipdir(),this.unzipped[this.files]=[this.outputArr.join(""),"file"],this.files++),80===t[0]&&75===t[1]&&(this.modeZIP=!0,t[2]=this.readByte(),t[3]=this.readByte(),3===t[2]&&4===t[3])){t[0]=this.readByte(),t[1]=this.readByte(),this.gpflags=this.readByte(),this.gpflags|=this.readByte()<<8;var e=this.readByte();e|=this.readByte()<<8,this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte();var i=this.readByte();i|=this.readByte()<<8;var r=this.readByte();for(r|=this.readByte()<<8,s=0,this.nameBuf=[];i--;){var n=this.readByte();"/"===n|":"===n?s=0:s<Q2.NAMEMAX-1&&(this.nameBuf[s++]=String.fromCharCode(n))}this.fileout||(this.fileout=this.nameBuf);for(var s=0;s<r;)n=this.readByte(),s++;8===e&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),this.nameBuf.join("")],this.files++),this.skipdir()}},Q2.prototype.skipdir=function(){var t,e,i=[];if(8&this.gpflags&&(i[0]=this.readByte(),i[1]=this.readByte(),i[2]=this.readByte(),i[3]=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte()),this.modeZIP&&this.nextFile(),i[0]=this.readByte(),8!==i[0])return 0;if(this.gpflags=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),4&this.gpflags)for(i[0]=this.readByte(),i[2]=this.readByte(),this.len=i[0]+256*i[1],t=0;t<this.len;t++)this.readByte();if(8&this.gpflags)for(t=0,this.nameBuf=[];e=this.readByte();)"7"!==e&&":"!==e||(t=0),t<Q2.NAMEMAX-1&&(this.nameBuf[t++]=e);if(16&this.gpflags)for(;e=this.readByte(););2&this.gpflags&&(this.readByte(),this.readByte()),this.DeflateLoop(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.modeZIP&&this.nextFile()};var $2,t3,e3,i3,r3,n3,s3,a3,o3,l3,h3,u3,c3,_3,f3,p3,d3,m3,y3,g3,v3,b3,S3,A3,C3,x3,T3,w3,E3,B3,D3,M3,P3,R3,I3,O3,F3,L3,V3,k3,N3,G3,z3,U3,H3,j3,W3,X3,Y3,q3,J3,K3,Z3,Q3,$3,t5,e5,i5,r5,n5,s5,a5,o5,l5,h5,u5,c5,_5,f5,p5,d5,m5,y5,g5,v5,b5,S5,A5,C5,x5,T5,w5,E5,B5,D5,M5,P5,R5,I5,O5,F5,L5,V5,k5,N5,G5,z5={name:"Jacob__Codec"};function U5(t){var e=t.parent,i=t.getComponent(r4);return e&&i?U5(e):t.getComponentsInChildren(r4)}z5.Base64=Z2,z5.GZip=Q2,z5.unzip=function(){return z5.GZip.gunzip.apply(z5.GZip,arguments)},z5.unzipBase64=function(){var t=z5.Base64.decode.apply(z5.Base64,arguments);try{return z5.GZip.gunzip.call(z5.GZip,t)}catch(e){return t.slice(7)}},z5.unzipBase64AsArray=function(t,e){e=e||1;var i,r,n,s=this.unzipBase64(t),a=[];for(i=0,n=s.length/e;i<n;i++)for(a[i]=0,r=e-1;r>=0;--r)a[i]+=s.charCodeAt(i*e+r)<<8*r;return a},z5.unzipAsArray=function(t,e){e=e||1;var i,r,n,s=this.unzip(t),a=[];for(i=0,n=s.length/e;i<n;i++)for(a[i]=0,r=e-1;r>=0;--r)a[i]+=s.charCodeAt(i*e+r)<<8*r;return a},function(t){t[t.JPG=0]="JPG",t[t.PNG=1]="PNG",t[t.TIFF=2]="TIFF",t[t.WEBP=3]="WEBP",t[t.PVR=4]="PVR",t[t.ETC=5]="ETC",t[t.S3TC=6]="S3TC",t[t.ATITC=7]="ATITC",t[t.TGA=8]="TGA",t[t.RAWDATA=9]="RAWDATA",t[t.UNKNOWN=10]="UNKNOWN"}(G5||(G5={}));var H5,j5,W5,X5,Y5,q5,J5,K5,Z5,Q5,$5,t4,e4,i4,r4=t("ParticleSystem2D",($2=ri("cc.ParticleSystem2D"),t3=Bi(),e3=Di(),i3=bi(z2),r3=Di(),n3=bi(xc),s3=Di(),a3=Di(),o3=Di(),l3=Di(),h3=Di(),u3=Di(),c3=Di(),_3=Di(),f3=Di(),p3=Di(),d3=Di(),m3=Di(),y3=Di(),g3=Di(),v3=Di(),b3=Di(),S3=Di(),A3=Di(),C3=Di(),x3=Di(),T3=Di(),w3=bi(P2),E3=Di(),B3=bi(M2),D3=Di(),M3=Di(),P3=Di(),R3=Di(),I3=Di(),O3=Di(),F3=Di(),L3=Di(),V3=Di(),k3=Di(),N3=Di(),G3=Di(),z3=Di(),U3=Di(),H3=Di(),j3=Di(),W3=Di(),X3=Di(),$2(Y3=t3(Y3=ss(Y3=Si((N5=k5=function(t){function e(){var e;return e=t.call(this)||this,li(e,"duration",J3,hi(e)),li(e,"emissionRate",K3,hi(e)),li(e,"life",Z3,hi(e)),li(e,"lifeVar",Q3,hi(e)),li(e,"angle",$3,hi(e)),li(e,"angleVar",t5,hi(e)),li(e,"startSize",e5,hi(e)),li(e,"startSizeVar",i5,hi(e)),li(e,"endSize",r5,hi(e)),li(e,"endSizeVar",n5,hi(e)),li(e,"startSpin",s5,hi(e)),li(e,"startSpinVar",a5,hi(e)),li(e,"endSpin",o5,hi(e)),li(e,"endSpinVar",l5,hi(e)),li(e,"sourcePos",h5,hi(e)),li(e,"posVar",u5,hi(e)),li(e,"emitterMode",c5,hi(e)),li(e,"gravity",_5,hi(e)),li(e,"speed",f5,hi(e)),li(e,"speedVar",p5,hi(e)),li(e,"tangentialAccel",d5,hi(e)),li(e,"tangentialAccelVar",m5,hi(e)),li(e,"radialAccel",y5,hi(e)),li(e,"radialAccelVar",g5,hi(e)),li(e,"rotationIsDir",v5,hi(e)),li(e,"startRadius",b5,hi(e)),li(e,"startRadiusVar",S5,hi(e)),li(e,"endRadius",A5,hi(e)),li(e,"endRadiusVar",C5,hi(e)),li(e,"rotatePerS",x5,hi(e)),li(e,"rotatePerSVar",T5,hi(e)),e.aspectRatio=1,li(e,"playOnLoad",w5,hi(e)),li(e,"autoRemoveOnFinish",E5,hi(e)),li(e,"preview",B5,hi(e)),li(e,"_custom",D5,hi(e)),li(e,"_file",M5,hi(e)),li(e,"_spriteFrame",P5,hi(e)),li(e,"_totalParticles",R5,hi(e)),li(e,"_startColor",I5,hi(e)),li(e,"_startColorVar",O5,hi(e)),li(e,"_endColor",F5,hi(e)),li(e,"_endColorVar",L5,hi(e)),li(e,"_positionType",V5,hi(e)),e._stopped=!0,e._deferredloaded=!1,e.initProperties(),e}Me(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMaterial()},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.autoRemoveOnFinish&&(this.autoRemoveOnFinish=!1),this._simulator.uvFilled=0},i.initProperties=function(){this._previewTimer=null,this._focused=!1,this.aspectRatio=1,this._simulator=new G2(this)},i.onFocusInEditor=function(){this._focused=!0;for(var t=U5(this.node),e=0;e<t.length;++e)t[e]._startPreview()},i.onLostFocusInEditor=function(){this._focused=!1;for(var t=U5(this.node),e=0;e<t.length;++e)t[e]._stopPreview()},i._startPreview=function(){this.preview&&this.resetSystem()},i._stopPreview=function(){this.preview&&(this.resetSystem(),this.stopSystem()),this._previewTimer&&clearInterval(this._previewTimer)},i.__preload=function(){t.prototype.__preload.call(this),this._custom&&this.spriteFrame&&!this._renderSpriteFrame?this._applySpriteFrame():this._file&&(this._custom?!this._getTexture()&&this._applyFile():this._applyFile()),this.playOnLoad&&this.resetSystem()},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._assembler&&this._assembler.createData&&(this._simulator.renderData=this._assembler.createData(this))},i.lateUpdate=function(t){this._simulator.finished||this._simulator.step(t)},i.addParticle=function(){},i.stopSystem=function(){this._stopped=!0,this._simulator.stop()},i.resetSystem=function(){this._stopped=!1,this._simulator.reset(),this._renderFlag=this._canRender()},i.isFull=function(){return this.particleCount>=this.totalParticles},i._applyFile=function(){var t=this,e=this._file;if(e){var i=function(i){!i&&e?t.isValid&&(t._plistFile=e.nativeUrl,t._custom||(t._spriteFrame!==e.spriteFrame&&(t.spriteFrame=e.spriteFrame),t._initWithDictionary(e._nativeAsset)),t._spriteFrame?!t._renderSpriteFrame&&t._spriteFrame&&t._applySpriteFrame():e.spriteFrame?t.spriteFrame=e.spriteFrame:t._custom&&t._initTextureWithDictionary(e._nativeAsset),t._deferredloaded=!1):Re(6029)};e._nativeAsset?i(null):(this._deferredloaded=!0,qr.postLoadNative(e,i))}},i._initTextureWithDictionary=function(t){var e,i=this;if(t.spriteFrameUuid){var r=t.spriteFrameUuid;qr.loadAny(r,(function(e,r){e?(t.spriteFrameUuid=void 0,i._initTextureWithDictionary(t),Ie(e)):i.spriteFrame=r}))}else{var n=as(this._plistFile,t.textureFileName||"");if(t.textureFileName)qr.loadRemote(n,(function(e,r){e?(t.textureFileName=void 0,i._initTextureWithDictionary(t),Ie(e)):i.spriteFrame=xc.createWithImage(r)}));else if(t.textureImageData){var s=t.textureImageData;if(!(s&&s.length>0))return!1;var a=qr.assets.get(n);if(!a){var o=z5.unzipBase64AsArray(s,1);if(!o)return ze(6030,this._file.name),!1;var l=(e=o).length>8&&137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]&&13===e[4]&&10===e[5]&&26===e[6]&&10===e[7]?G5.PNG:e.length>2&&(73===e[0]&&73===e[1]||77===e[0]&&77===e[1]||255===e[0]&&216===e[1])?G5.TIFF:G5.UNKNOWN;if(l!==G5.TIFF&&l!==G5.PNG)return ze(6031,this._file.name),!1;var h=document.createElement("canvas");l===G5.PNG?new j2(o).render(h):(this._tiffReader||(this._tiffReader=new W2),this._tiffReader.parseTIFF(o,h)),a=new Ye(h),qr.assets.add(n,a)}a||ze(6032,this._file.name),this.spriteFrame=xc.createWithImage(a)}}return!0},i._initWithDictionary=function(t){this.totalParticles=parseInt(t.maxParticles||0),this.life=parseFloat(t.particleLifespan||0),this.lifeVar=parseFloat(t.particleLifespanVariance||0);var e=t.emissionRate;this.emissionRate=e||Math.min(this.totalParticles/this.life,Number.MAX_VALUE),this.duration=parseFloat(t.duration||0),this._srcBlendFactor=parseInt(t.blendFuncSource||E.SRC_ALPHA),this._dstBlendFactor=parseInt(t.blendFuncDestination||E.ONE_MINUS_SRC_ALPHA);var i=this._startColor;i.r=255*parseFloat(t.startColorRed||0),i.g=255*parseFloat(t.startColorGreen||0),i.b=255*parseFloat(t.startColorBlue||0),i.a=255*parseFloat(t.startColorAlpha||0);var r=this._startColorVar;r.r=255*parseFloat(t.startColorVarianceRed||0),r.g=255*parseFloat(t.startColorVarianceGreen||0),r.b=255*parseFloat(t.startColorVarianceBlue||0),r.a=255*parseFloat(t.startColorVarianceAlpha||0);var n=this._endColor;n.r=255*parseFloat(t.finishColorRed||0),n.g=255*parseFloat(t.finishColorGreen||0),n.b=255*parseFloat(t.finishColorBlue||0),n.a=255*parseFloat(t.finishColorAlpha||0);var s=this._endColorVar;if(s.r=255*parseFloat(t.finishColorVarianceRed||0),s.g=255*parseFloat(t.finishColorVarianceGreen||0),s.b=255*parseFloat(t.finishColorVarianceBlue||0),s.a=255*parseFloat(t.finishColorVarianceAlpha||0),this.startSize=parseFloat(t.startParticleSize||0),this.startSizeVar=parseFloat(t.startParticleSizeVariance||0),this.endSize=parseFloat(t.finishParticleSize||0),this.endSizeVar=parseFloat(t.finishParticleSizeVariance||0),this.positionType=parseFloat(void 0!==t.positionType?t.positionType:P2.FREE),this.sourcePos.set(0,0),this.posVar.set(parseFloat(t.sourcePositionVariancex||0),parseFloat(t.sourcePositionVariancey||0)),this.angle=parseFloat(t.angle||0),this.angleVar=parseFloat(t.angleVariance||0),this.startSpin=parseFloat(t.rotationStart||0),this.startSpinVar=parseFloat(t.rotationStartVariance||0),this.endSpin=parseFloat(t.rotationEnd||0),this.endSpinVar=parseFloat(t.rotationEndVariance||0),this.emitterMode=parseInt(t.emitterType||M2.GRAVITY),this.emitterMode===M2.GRAVITY){this.gravity.set(parseFloat(t.gravityx||0),parseFloat(t.gravityy||0)),this.speed=parseFloat(t.speed||0),this.speedVar=parseFloat(t.speedVariance||0),this.radialAccel=parseFloat(t.radialAcceleration||0),this.radialAccelVar=parseFloat(t.radialAccelVariance||0),this.tangentialAccel=parseFloat(t.tangentialAcceleration||0),this.tangentialAccelVar=parseFloat(t.tangentialAccelVariance||0);var a=t.rotationIsDir||"";null!==a?(a=a.toString().toLowerCase(),this.rotationIsDir="true"===a||"1"===a):this.rotationIsDir=!1}else{if(this.emitterMode!==M2.RADIUS)return ze(6009),!1;this.startRadius=parseFloat(t.maxRadius||0),this.startRadiusVar=parseFloat(t.maxRadiusVariance||0),this.endRadius=parseFloat(t.minRadius||0),this.endRadiusVar=parseFloat(t.minRadiusVariance||0),this.rotatePerS=parseFloat(t.rotatePerSecond||0),this.rotatePerSVar=parseFloat(t.rotatePerSecondVariance||0)}return this._initTextureWithDictionary(t),!0},i._onTextureLoaded=function(){this._simulator.updateUVs(!0),this._syncAspect(),this._updateMaterial(),this._stopped=!1,this._renderFlag=this._canRender()},i._syncAspect=function(){if(this._renderSpriteFrame){var t=this._renderSpriteFrame.rect;this.aspectRatio=t.width/t.height}},i._applySpriteFrame=function(){this._renderSpriteFrame=this._renderSpriteFrame||this._spriteFrame,this._renderSpriteFrame?this._renderSpriteFrame.textureLoaded()?this._onTextureLoaded():this._renderSpriteFrame.once("load",this._onTextureLoaded,this):this.resetSystem()},i._getTexture=function(){return this._renderSpriteFrame&&this._renderSpriteFrame.texture},i._updateMaterial=function(){var t=this.getMaterialInstance(0);t&&t.recompileShaders({USE_LOCAL:this._positionType!==P2.FREE})},i._finishedSimulation=function(){this.resetSystem(),this.stopSystem(),this._renderFlag=this._canRender(),this.autoRemoveOnFinish&&this._stopped&&this.node.destroy()},i._canRender=function(){return t.prototype._canRender.call(this)&&!this._stopped&&!this._deferredloaded&&null!==this._renderSpriteFrame},i._render=function(t){t.commitComp(this,this._renderSpriteFrame,this._assembler,this._positionType===P2.RELATIVE?this.node.parent:null)},Pe(e,[{key:"custom",get:function(){return this._custom},set:function(t){this._custom!==t&&(this._custom=t,this._applyFile())}},{key:"file",get:function(){return this._file},set:function(t){this._file!==t&&(this._file=t,t?this._applyFile():this.custom=!0)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._renderSpriteFrame!==t&&(this._renderSpriteFrame=t,t&&!t._uuid||(this._spriteFrame=t),this._applySpriteFrame())}},{key:"particleCount",get:function(){return this._simulator.particles.length}},{key:"totalParticles",get:function(){return this._totalParticles},set:function(t){this._totalParticles!==t&&(this._totalParticles=t)}},{key:"startColor",get:function(){return this._startColor},set:function(t){this._startColor.r=t.r,this._startColor.g=t.g,this._startColor.b=t.b,this._startColor.a=t.a}},{key:"startColorVar",get:function(){return this._startColorVar},set:function(t){this._startColorVar.r=t.r,this._startColorVar.g=t.g,this._startColorVar.b=t.b,this._startColorVar.a=t.a}},{key:"endColor",get:function(){return this._endColor},set:function(t){this._endColor.r=t.r,this._endColor.g=t.g,this._endColor.b=t.b,this._endColor.a=t.a}},{key:"endColorVar",get:function(){return this._endColorVar},set:function(t){this._endColorVar.r=t.r,this._endColorVar.g=t.g,this._endColorVar.b=t.b,this._endColorVar.a=t.a}},{key:"positionType",get:function(){return this._positionType},set:function(t){this._positionType=t,this._updateMaterial()}},{key:"stopped",get:function(){return this._stopped}},{key:"active",get:function(){return this._simulator.active}},{key:"assembler",get:function(){return this._assembler}}]),e}(Ap),k5.EmitterMode=M2,k5.PositionType=P2,k5.DURATION_INFINITY=-1,k5.START_SIZE_EQUAL_TO_END_SIZE=-1,k5.START_RADIUS_EQUAL_TO_END_RADIUS=-1,oi((q3=N5).prototype,"custom",[vi,e3],Object.getOwnPropertyDescriptor(q3.prototype,"custom"),q3.prototype),oi(q3.prototype,"file",[i3,r3],Object.getOwnPropertyDescriptor(q3.prototype,"file"),q3.prototype),oi(q3.prototype,"spriteFrame",[n3,s3],Object.getOwnPropertyDescriptor(q3.prototype,"spriteFrame"),q3.prototype),oi(q3.prototype,"totalParticles",[vi,a3],Object.getOwnPropertyDescriptor(q3.prototype,"totalParticles"),q3.prototype),J3=oi(q3.prototype,"duration",[_i,vi,o3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),K3=oi(q3.prototype,"emissionRate",[_i,vi,l3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),Z3=oi(q3.prototype,"life",[_i,vi,h3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Q3=oi(q3.prototype,"lifeVar",[_i,vi,u3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(q3.prototype,"startColor",[vi,c3],Object.getOwnPropertyDescriptor(q3.prototype,"startColor"),q3.prototype),oi(q3.prototype,"startColorVar",[vi,_3],Object.getOwnPropertyDescriptor(q3.prototype,"startColorVar"),q3.prototype),oi(q3.prototype,"endColor",[vi,f3],Object.getOwnPropertyDescriptor(q3.prototype,"endColor"),q3.prototype),oi(q3.prototype,"endColorVar",[vi,p3],Object.getOwnPropertyDescriptor(q3.prototype,"endColorVar"),q3.prototype),$3=oi(q3.prototype,"angle",[_i,vi,d3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 90}}),t5=oi(q3.prototype,"angleVar",[_i,vi,m3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 20}}),e5=oi(q3.prototype,"startSize",[_i,vi,y3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),i5=oi(q3.prototype,"startSizeVar",[_i,vi,g3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),r5=oi(q3.prototype,"endSize",[_i,vi,v3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),n5=oi(q3.prototype,"endSizeVar",[_i,vi,b3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),s5=oi(q3.prototype,"startSpin",[_i,vi,S3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),a5=oi(q3.prototype,"startSpinVar",[_i,vi,A3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),o5=oi(q3.prototype,"endSpin",[_i,vi,C3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),l5=oi(q3.prototype,"endSpinVar",[_i,vi,x3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),h5=oi(q3.prototype,"sourcePos",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dr.ZERO.clone()}}),u5=oi(q3.prototype,"posVar",[_i,vi,T3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dr.ZERO.clone()}}),oi(q3.prototype,"positionType",[w3,E3],Object.getOwnPropertyDescriptor(q3.prototype,"positionType"),q3.prototype),c5=oi(q3.prototype,"emitterMode",[_i,vi,B3,D3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M2.GRAVITY}}),_5=oi(q3.prototype,"gravity",[_i,vi,M3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dr.ZERO.clone()}}),f5=oi(q3.prototype,"speed",[_i,vi,P3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 180}}),p5=oi(q3.prototype,"speedVar",[_i,vi,R3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),d5=oi(q3.prototype,"tangentialAccel",[_i,vi,I3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 80}}),m5=oi(q3.prototype,"tangentialAccelVar",[_i,vi,O3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),y5=oi(q3.prototype,"radialAccel",[_i,vi,F3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),g5=oi(q3.prototype,"radialAccelVar",[_i,vi,L3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),v5=oi(q3.prototype,"rotationIsDir",[_i,vi,V3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),b5=oi(q3.prototype,"startRadius",[_i,vi,k3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),S5=oi(q3.prototype,"startRadiusVar",[_i,vi,N3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),A5=oi(q3.prototype,"endRadius",[_i,vi,G3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),C5=oi(q3.prototype,"endRadiusVar",[_i,vi,z3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),x5=oi(q3.prototype,"rotatePerS",[_i,vi,U3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),T5=oi(q3.prototype,"rotatePerSVar",[_i,vi,H3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),w5=oi(q3.prototype,"playOnLoad",[_i,vi,j3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),E5=oi(q3.prototype,"autoRemoveOnFinish",[_i,vi,W3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),B5=oi(q3.prototype,"preview",[_i,vi,X3],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),D5=oi(q3.prototype,"_custom",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),M5=oi(q3.prototype,"_file",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),P5=oi(q3.prototype,"_spriteFrame",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),R5=oi(q3.prototype,"_totalParticles",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 150}}),I5=oi(q3.prototype,"_startColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(255,255,255,255)}}),O5=oi(q3.prototype,"_startColorVar",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(0,0,0,0)}}),F5=oi(q3.prototype,"_endColor",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(255,255,255,0)}}),L5=oi(q3.prototype,"_endColorVar",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Ui(0,0,0,0)}}),V5=oi(q3.prototype,"_positionType",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P2.FREE}}),Y3=q3))||Y3)||Y3)||Y3)||Y3)),n4=function(){function t(t,e){this.point=new dr,this.dir=new dr,this.distance=0,this.time=0,t&&this.point.set(t),e&&this.dir.set(e)}var e=t.prototype;return e.setPoint=function(t,e){this.point.x=t,this.point.y=e},e.setDir=function(t,e){this.dir.x=t,this.dir.y=e},t}(),s4=t("MotionStreak",(H5=ri("cc.MotionStreak"),j5=Bi(),W5=wi(),X5=bi(qe),H5(Y5=Si(Y5=ss(Y5=j5(Y5=W5((i4=e4=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_preview",J5,hi(e)),li(e,"_fadeTime",K5,hi(e)),li(e,"_minSeg",Z5,hi(e)),li(e,"_stroke",Q5,hi(e)),li(e,"_texture",$5,hi(e)),li(e,"_fastMode",t4,hi(e)),e._points=[],e}Me(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.reset()},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.material)},i.onFocusInEditor=function(){this._preview&&this.reset()},i.onLostFocusInEditor=function(){this._preview&&this.reset()},i.reset=function(){this._points.length=0,this._renderData&&this._renderData.clear()},i.lateUpdate=function(t){this._assembler&&this._assembler.update(this,t)},i._render=function(t){t.commitComp(this,this._texture,this._assembler,null)},Pe(e,[{key:"preview",get:function(){return this._preview},set:function(t){this._preview=t,this.reset()}},{key:"fadeTime",get:function(){return this._fadeTime},set:function(t){this._fadeTime=t,this.reset()}},{key:"minSeg",get:function(){return this._minSeg},set:function(t){this._minSeg=t}},{key:"stroke",get:function(){return this._stroke},set:function(t){this._stroke=t}},{key:"texture",get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t)}},{key:"fastMode",get:function(){return this._fastMode},set:function(t){this._fastMode=t}},{key:"points",get:function(){return this._points}}]),e}(Ap),e4.Point=n4,oi((q5=i4).prototype,"preview",[vi],Object.getOwnPropertyDescriptor(q5.prototype,"preview"),q5.prototype),oi(q5.prototype,"fadeTime",[vi],Object.getOwnPropertyDescriptor(q5.prototype,"fadeTime"),q5.prototype),oi(q5.prototype,"minSeg",[vi],Object.getOwnPropertyDescriptor(q5.prototype,"minSeg"),q5.prototype),oi(q5.prototype,"stroke",[vi],Object.getOwnPropertyDescriptor(q5.prototype,"stroke"),q5.prototype),oi(q5.prototype,"texture",[X5],Object.getOwnPropertyDescriptor(q5.prototype,"texture"),q5.prototype),oi(q5.prototype,"fastMode",[vi],Object.getOwnPropertyDescriptor(q5.prototype,"fastMode"),q5.prototype),J5=oi(q5.prototype,"_preview",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),K5=oi(q5.prototype,"_fadeTime",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Z5=oi(q5.prototype,"_minSeg",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Q5=oi(q5.prototype,"_stroke",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),$5=oi(q5.prototype,"_texture",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),t4=oi(q5.prototype,"_fastMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Y5=q5))||Y5)||Y5)||Y5)||Y5)||Y5)),a4=(new dr,new dr),o4=new dr;function l4(t,e){return t.x=-e.y,t.y=e.x,t}var h4={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.vertexCount=16,e.indicesCount=42,e},update:function(t,e){var i,r=t.stroke/2,n=t.node.worldMatrix,s=n.m12,a=n.m13,o=t.points;if(o.length>1){var l=o[0],h=l.point.x-s,u=l.point.y-a;h*h+u*u<t.minSeg&&(i=l)}i||(i=new s4.Point,o.splice(0,0,i)),i.setPoint(s,a),i.time=t.fadeTime+e;var c,_=0;if(!(o.length<2)){var f=t.renderData,p=t.color,d=p.r,m=p.g,y=p.b,g=p.a,v=o[1];v.distance=dr.subtract(o4,i.point,v.point).length(),o4.normalize(),v.setDir(o4.x,o4.y),i.setDir(o4.x,o4.y),f.dataLength=2*o.length;for(var b=f.data,S=t.fadeTime,A=!1,C=o.length-1;C>=0;C--){var x=o[C],T=x.point,w=x.dir;if(x.time-=e,x.time<0)o.splice(C,1);else{var E=x.time/S,B=o[C-1];if(!A){if(!B){o.splice(C,1);continue}T.x=B.point.x-w.x*E,T.y=B.point.y-w.y*E}A=!0,l4(a4,w);var D=(E*g<<24>>>0)+(y<<16)+(m<<8)+d,M=_;b[M].x=T.x+a4.x*r,b[M].y=T.y+a4.y*r,b[M].u=1,b[M].v=E,b[M].color._val=D,b[M+=1].x=T.x-a4.x*r,b[M].y=T.y-a4.y*r,b[M].u=0,b[M].v=E,b[M].color._val=D,_+=2}}c=_<=2?0:3*(_-2),f.vertexCount=_,f.indicesCount=c}},updateRenderData:function(){},fillBuffers:function(t,e){var i=t.renderData,r=i.data,n=(t.node,e.acquireBufferBatch()),s=n.byteOffset>>2,a=n.indicesOffset,o=n.vertexOffset;n.request(i.vertexCount,i.indicesCount)||(n=e.currBufferBatch,a=0,o=0);for(var l=n.vData,h=n.iData,u=i.vertexCount,c=i.indicesCount,_=0;_<u;_++){var f=r[_];l[s++]=f.x,l[s++]=f.y,l[s++]=f.z,l[s++]=f.u,l[s++]=f.v,Ui.toArray(l,f.color,s),s+=4}for(var p=0,d=c;p<d;p+=2){var m=o+p;h[a++]=m,h[a++]=m+2,h[a++]=m+1,h[a++]=m+1,h[a++]=m+2,h[a++]=m+3}}},u4=t("MotionStreakAssemblerManager",{getAssembler:function(){return h4}});s4.Assembler=u4;var c4,_4,f4,p4={maxParticleDeltaTime:0,createData:function(){return I_.add()},updateRenderData:function(){},fillBuffers:function(t,e){if(null!==t){var i=t._simulator.renderData;if(0!==i.vertexCount&&0!==i.indicesCount){var r=e.acquireBufferBatch(),n=r.byteOffset>>2,s=r.indicesOffset,a=r.vertexOffset;r.request(i.vertexCount,i.indicesCount)||(r=e.currBufferBatch,s=0,a=0);for(var o=r.vData,l=r.iData,h=i.vData,u=i.iData,c=9*i.vertexCount,_=0;_<c;_++)o[n++]=h[_];for(var f=i.indicesCount,p=0;p<f;p++)l[s++]=u[p]+a}}}},d4=t("ParticleSystem2DAssembler",{getAssembler:function(){return p4.maxParticleDeltaTime||(p4.maxParticleDeltaTime=He.game.frameTime/1e3*2),p4}});r4.Assembler=d4,function(t){t.PLAYED="play",t.PAUSED="pause",t.STOPPED="stop",t.SEEKED="seeked",t.ENDED="ended",t.INTERRUPTION_BEGIN="interruptionBegin",t.INTERRUPTION_END="interruptionEnd",t.USER_GESTURE="on_gesture"}(c4||(c4={})),function(t){t[t.DOM_AUDIO=0]="DOM_AUDIO",t[t.WEB_AUDIO=1]="WEB_AUDIO",t[t.MINIGAME_AUDIO=2]="MINIGAME_AUDIO",t[t.NATIVE_AUDIO=3]="NATIVE_AUDIO",t[t.UNKNOWN_AUDIO=4]="UNKNOWN_AUDIO"}(_4||(_4={})),function(t){t[t.INIT=0]="INIT",t[t.PLAYING=1]="PLAYING",t[t.PAUSED=2]="PAUSED",t[t.STOPPED=3]="STOPPED",t[t.INTERRUPTED=4]="INTERRUPTED"}(f4||(f4={}));var m4,y4,g4=0;function v4(t,e){var i;e.invoking||(e.invoking=!0,(i=e.func).call.apply(i,[t].concat(e.args)).then((function(){e.invoking=!1,t._operationQueue.shift(),t._eventTarget.emit(e.id.toString());var i=t._operationQueue[0];i&&v4(t,i)})).catch((function(){})))}function b4(t,e,i){var r=i.value;i.value=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return new Promise((function(e){var n=g4++,s=t;s._operationQueue.push({id:n,func:r,args:i,invoking:!1}),s._eventTarget.once(n.toString(),e),v4(s,s._operationQueue[0])}))}}function S4(t){return new Promise((function(e){var i=t.play();return void 0===i?e():(i.then(e).catch((function(){var i=function(){t.play().catch((function(){})),e()},r=document.getElementById("GameCanvas");null==r||r.addEventListener("touchend",i,{once:!0}),null==r||r.addEventListener("mousedown",i,{once:!0})})),null)}))}var A4,C4,x4,T4=function(){function t(t,e){this._domAudio=void 0,this._onPlayCb=void 0,this._onEndCb=void 0,this._domAudio=t,t.volume=e}var e=t.prototype;return e.play=function(){var t=this;S4(this._domAudio).then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t)})).catch((function(){}))},e.stop=function(){this._domAudio.pause()},Pe(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb&&this._domAudio.removeEventListener("ended",this._onEndCb),this._onEndCb=t,t&&this._domAudio.addEventListener("ended",t)}}]),t}(),w4=(y4=function(){function t(t){var e=this;this._domAudio=void 0,this._state=f4.INIT,this._onHide=void 0,this._onShow=void 0,this._onEnded=void 0,this._eventTarget=new os,this._operationQueue=[],this._domAudio=t,this._onHide=function(){e._state===f4.PLAYING&&e.pause().then((function(){e._state=f4.INTERRUPTED,e._eventTarget.emit(c4.INTERRUPTION_BEGIN)})).catch((function(){}))},He.game.on(He.Game.EVENT_HIDE,this._onHide),this._onShow=function(){e._state===f4.INTERRUPTED&&e.play().then((function(){e._eventTarget.emit(c4.INTERRUPTION_END)})).catch((function(){}))},He.game.on(He.Game.EVENT_SHOW,this._onShow),this._onEnded=function(){e.seek(0).catch((function(){})),e._state=f4.INIT,e._eventTarget.emit(c4.ENDED)},this._domAudio.addEventListener("ended",this._onEnded)}var e=t.prototype;return e.destroy=function(){this._onShow&&(He.game.off(He.Game.EVENT_SHOW,this._onShow),this._onShow=void 0),this._onHide&&(He.game.off(He.Game.EVENT_HIDE,this._onHide),this._onHide=void 0),this._onEnded&&(this._domAudio.removeEventListener("ended",this._onEnded),this._onEnded=void 0),this._domAudio=void 0},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(e){i(new t(e))})).catch((function(){}))}))},t.loadNative=function(t){return new Promise((function(e,i){var r=document.createElement("audio"),n="canplaythrough";Le.os===Ve.IOS?n="loadedmetadata":Le.browserType===Ne.FIREFOX&&(n="canplay");var s=setTimeout((function(){0===r.readyState?l():o()}),8e3),a=function(){clearTimeout(s),r.removeEventListener(n,o,!1),r.removeEventListener("error",l,!1)},o=function(){a(),e(r)},l=function(){a(),i("load audio failure - "+t)};r.addEventListener(n,o,!1),r.addEventListener("error",l,!1),r.src=t}))},t.loadOneShotAudio=function(e,i){return new Promise((function(r,n){t.loadNative(e).then((function(t){var e=new T4(t,i);r(e)})).catch(n)}))},e.seek=function(t){return t=Gr(t,0,this.duration),this._domAudio.currentTime=t,Promise.resolve()},e.play=function(){var t=this;return new Promise((function(e){S4(t._domAudio).then((function(){t._state=f4.PLAYING,e()})).catch((function(){}))}))},e.pause=function(){return this._domAudio.pause(),this._state=f4.PAUSED,Promise.resolve()},e.stop=function(){var t=this;return new Promise((function(e){t._domAudio.pause(),t._domAudio.currentTime=0,t._state=f4.STOPPED,e()}))},e.onInterruptionBegin=function(t){this._eventTarget.on(c4.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(c4.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(c4.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(c4.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(c4.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(c4.ENDED,t)},Pe(t,[{key:"src",get:function(){return this._domAudio?this._domAudio.src:""}},{key:"type",get:function(){return _4.DOM_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._domAudio.loop},set:function(t){this._domAudio.loop=t}},{key:"volume",get:function(){return this._domAudio.volume},set:function(t){t=Cn(t),this._domAudio.volume=t}},{key:"duration",get:function(){return this._domAudio.duration}},{key:"currentTime",get:function(){return this._domAudio.currentTime}}]),t}(),oi((m4=y4).prototype,"seek",[b4],Object.getOwnPropertyDescriptor(m4.prototype,"seek"),m4.prototype),oi(m4.prototype,"play",[b4],Object.getOwnPropertyDescriptor(m4.prototype,"play"),m4.prototype),oi(m4.prototype,"pause",[b4],Object.getOwnPropertyDescriptor(m4.prototype,"pause"),m4.prototype),oi(m4.prototype,"stop",[b4],Object.getOwnPropertyDescriptor(m4.prototype,"stop"),m4.prototype),m4),E4=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,B4=function(){function t(){this._context=void 0,this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}var e=t.prototype;return e.decodeAudioData=function(t){var e=this;return new Promise((function(i){var r=e._context.decodeAudioData(t,(function(t){i(t)}),(function(t){console.error("failed to load Web Audio",t)}));null==r||r.catch((function(){}))}))},e.runContext=function(){var t=this;return new Promise((function(e){var i=t._context;if(!i.resume)return e();if("running"===i.state)return e();if(i.resume().catch((function(){})),"running"!==i.state){var r=document.getElementById("GameCanvas"),n=function(){i.resume().then(e).catch((function(){}))};null==r||r.addEventListener("touchend",n,{once:!0}),null==r||r.addEventListener("mousedown",n,{once:!0})}return null}))},e.createBufferSource=function(t,e){var i=this._context.createBufferSource();return void 0!==t&&(i.buffer=t),void 0!==e&&(i.loop=e),i},e.createGain=function(t){var e=this._context.createGain();return void 0!==t&&this.setGainValue(e,t),e},e.setGainValue=function(t,e){if(t.gain.setTargetAtTime)try{t.gain.setTargetAtTime(e,this._context.currentTime,0)}catch(i){t.gain.setTargetAtTime(e,this._context.currentTime,.01)}else t.gain.value=e},e.connectContext=function(t){this._context&&t.connect(this._context.destination)},Pe(t,[{key:"currentTime",get:function(){return this._context.currentTime}}]),t}();B4.support=!!E4,B4.support&&(x4=new B4);var D4,M4,P4,R4,I4,O4=function(){function t(t,e){this._duration=void 0,this._bufferSourceNode=void 0,this._onPlayCb=void 0,this._onEndCb=void 0,this._duration=t.duration,this._bufferSourceNode=x4.createBufferSource(t,!1);var i=x4.createGain(e);this._bufferSourceNode.connect(i),x4.connectContext(i)}var e=t.prototype;return e.play=function(){var t=this;x4.runContext().then((function(){var e;t._bufferSourceNode.start(),null===(e=t.onPlay)||void 0===e||e.call(t),window.setTimeout((function(){var e;null===(e=t.onEnd)||void 0===e||e.call(t)}),1e3*t._duration)})).catch((function(){}))},e.stop=function(){this._bufferSourceNode.stop()},Pe(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb=t}}]),t}(),F4=(C4=function(){function t(t,e){var i=this;this._src=void 0,this._audioBuffer=void 0,this._sourceNode=void 0,this._gainNode=void 0,this._currentTimer=0,this._volume=1,this._loop=!1,this._startTime=0,this._playTimeOffset=0,this._state=f4.INIT,this._eventTarget=new os,this._operationQueue=[],this._onHide=void 0,this._onShow=void 0,this._audioBuffer=t,this._gainNode=x4.createGain(),x4.connectContext(this._gainNode),this._src=e,this._onHide=function(){i._state===f4.PLAYING&&i.pause().then((function(){i._state=f4.INTERRUPTED,i._eventTarget.emit(c4.INTERRUPTION_BEGIN)})).catch((function(){}))},He.game.on(He.Game.EVENT_HIDE,this._onHide),this._onShow=function(){i._state===f4.INTERRUPTED&&i.play().then((function(){i._eventTarget.emit(c4.INTERRUPTION_END)})).catch((function(){}))},He.game.on(He.Game.EVENT_SHOW,this._onShow)}var e=t.prototype;return e.destroy=function(){this._audioBuffer&&(this._audioBuffer=void 0),this._onShow&&(He.game.off(He.Game.EVENT_SHOW,this._onShow),this._onShow=void 0),this._onHide&&(He.game.off(He.Game.EVENT_HIDE,this._onHide),this._onHide=void 0)},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(r){i(new t(r,e))})).catch((function(){}))}))},t.loadNative=function(t){return new Promise((function(e,i){var r=new XMLHttpRequest,n="load audio failed: "+t+", status: ";r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=function(){200===r.status||0===r.status?x4.decodeAudioData(r.response).then((function(t){e(t)})).catch((function(){})):i(new Error(""+n+r.status+"(no response)"))},r.onerror=function(){i(new Error(""+n+r.status+"(error)"))},r.ontimeout=function(){i(new Error(""+n+r.status+"(time out)"))},r.onabort=function(){i(new Error(""+n+r.status+"(abort)"))},r.send(null)}))},t.loadOneShotAudio=function(e,i){return new Promise((function(r,n){t.loadNative(e).then((function(t){var e=new O4(t,i);r(e)})).catch(n)}))},e.seek=function(t){var e=this;return new Promise((function(i){e._playTimeOffset=Gr(t,0,e._audioBuffer.duration),e._state===f4.PLAYING?e._doPlay().then(i).catch((function(){})):i()}))},e.play=function(){return this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){x4.runContext().then((function(){t._stopSourceNode(),t._sourceNode=x4.createBufferSource(t._audioBuffer,t.loop),t._sourceNode.connect(t._gainNode),t._sourceNode.start(0,t._playTimeOffset),t._state=f4.PLAYING,t._startTime=x4.currentTime,window.clearTimeout(t._currentTimer),t._currentTimer=window.setTimeout((function e(){t._playTimeOffset=0,t._startTime=x4.currentTime,t.loop?t._currentTimer=window.setTimeout(e,1e3*t._audioBuffer.duration):(t._eventTarget.emit(c4.ENDED),t._state=f4.INIT)}),1e3*(t._audioBuffer.duration-t._playTimeOffset)),e()})).catch((function(){}))}))},e._stopSourceNode=function(){try{var t;null===(t=this._sourceNode)||void 0===t||t.stop()}catch(t){}},e.pause=function(){return this._state===f4.PLAYING&&this._sourceNode?(this._playTimeOffset=(x4.currentTime-this._startTime+this._playTimeOffset)%this._audioBuffer.duration,this._state=f4.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return this._sourceNode?(this._playTimeOffset=0,this._state=f4.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.onInterruptionBegin=function(t){this._eventTarget.on(c4.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(c4.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(c4.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(c4.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(c4.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(c4.ENDED,t)},Pe(t,[{key:"src",get:function(){return this._src}},{key:"type",get:function(){return _4.WEB_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._sourceNode&&(this._sourceNode.loop=t)}},{key:"volume",get:function(){return this._volume},set:function(t){t=Cn(t),this._volume=t,x4.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._state!==f4.PLAYING?this._playTimeOffset:(x4.currentTime-this._startTime+this._playTimeOffset)%this._audioBuffer.duration}}]),t}(),oi((A4=C4).prototype,"seek",[b4],Object.getOwnPropertyDescriptor(A4.prototype,"seek"),A4.prototype),oi(A4.prototype,"play",[b4],Object.getOwnPropertyDescriptor(A4.prototype,"play"),A4.prototype),oi(A4.prototype,"pause",[b4],Object.getOwnPropertyDescriptor(A4.prototype,"pause"),A4.prototype),oi(A4.prototype,"stop",[b4],Object.getOwnPropertyDescriptor(A4.prototype,"stop"),A4.prototype),A4),L4=function(){function t(t){this._audio=void 0,this._audio=t}var e=t.prototype;return e.play=function(){this._audio.play()},e.stop=function(){this._audio.stop()},Pe(t,[{key:"onPlay",get:function(){return this._audio.onPlay},set:function(t){this._audio.onPlay=t}},{key:"onEnd",get:function(){return this._audio.onEnd},set:function(t){this._audio.onEnd=t}}]),t}(),V4=function(){function t(t){this._player=void 0,this._player=t}t.load=function(e,i){return new Promise((function(r){(null==i?void 0:i.audioLoadMode)!==_4.DOM_AUDIO&&B4.support?F4.load(e).then((function(e){r(new t(e))})).catch((function(){})):(B4.support||ze(5201),w4.load(e).then((function(e){r(new t(e))})).catch((function(){})))}))};var e=t.prototype;return e.destroy=function(){this._player.destroy()},t.loadNative=function(t,e){return(null==e?void 0:e.audioLoadMode)!==_4.DOM_AUDIO&&B4.support?F4.loadNative(t):(B4.support||ze(5201),w4.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(r,n){(null==i?void 0:i.audioLoadMode)!==_4.DOM_AUDIO&&B4.support?F4.loadOneShotAudio(t,e).then((function(t){r(new L4(t))})).catch(n):(B4.support||ze(5201),w4.loadOneShotAudio(t,e).then((function(t){r(new L4(t))})).catch(n))}))},e.seek=function(t){return this._player.seek(t)},e.play=function(){return this._player.play()},e.pause=function(){return this._player.pause()},e.stop=function(){return this._player.stop()},e.onInterruptionBegin=function(t){this._player.onInterruptionBegin(t)},e.offInterruptionBegin=function(t){this._player.offInterruptionBegin(t)},e.onInterruptionEnd=function(t){this._player.onInterruptionEnd(t)},e.offInterruptionEnd=function(t){this._player.offInterruptionEnd(t)},e.onEnded=function(t){this._player.onEnded(t)},e.offEnded=function(t){this._player.offEnded(t)},Pe(t,[{key:"src",get:function(){return this._player.src}},{key:"type",get:function(){return this._player.type}},{key:"state",get:function(){return this._player.state}},{key:"loop",get:function(){return this._player.loop},set:function(t){this._player.loop=t}},{key:"volume",get:function(){return this._player.volume},set:function(t){this._player.volume=t}},{key:"duration",get:function(){return this._player.duration}},{key:"currentTime",get:function(){return this._player.currentTime}}]),t}();V4.maxAudioChannel=24;var k4=t("AudioClip",ri("cc.AudioClip")((I4=R4=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_duration",P4,hi(e)),e._loadMode=_4.UNKNOWN_AUDIO,e._meta=null,e.loaded=!1,e}Me(e,t);var i=e.prototype;return i.validate=function(){return!!this._meta},i.getDuration=function(){return this._duration?this._duration:this._meta?this._meta.duration:0},Pe(e,[{key:"_nativeAsset",get:function(){return this._meta},set:function(t){this._meta=t,t?(this.loaded=!0,this._loadMode=t.type,this.emit("load")):(this._meta=null,this._loadMode=_4.UNKNOWN_AUDIO,this._duration=0,this.loaded=!1)}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,audioLoadMode:this.loadMode,ext:this._native,__isNative__:!0}}},{key:"loadMode",get:function(){return this._loadMode}}]),e}(ai),R4.AudioType=_4,P4=oi((M4=I4).prototype,"_duration",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(M4.prototype,"_nativeDep",[pr],Object.getOwnPropertyDescriptor(M4.prototype,"_nativeDep"),M4.prototype),D4=M4))||D4);function N4(t,e,i){V4.load(t,{audioLoadMode:e.audioLoadMode}).then((function(e){var r={url:t,duration:e.duration,type:e.type};e.destroy(),i(null,r)})).catch((function(t){i(t)}))}function G4(t,e,i,r){var n=new k4;n._nativeUrl=t,n._nativeAsset=e,n._duration=e.duration,r(null,n)}He.AudioClip=k4,_n.register({".mp3":N4,".ogg":N4,".wav":N4,".m4a":N4}),fn.register({".mp3":G4,".ogg":G4,".wav":G4,".m4a":G4});var z4,U4,H4,j4,W4,X4,Y4,q4,J4,K4,Z4,Q4,$4,t6,e6,i6,r6,n6,s6,a6,o6,l6,h6=new(function(){function t(){this._oneShotAudioInfoList=[],this._audioPlayerInfoList=[]}var e=t.prototype;return e._findIndex=function(t,e){return t.findIndex((function(t){return t.audio===e}))},e._tryAddPlaying=function(t,e){var i=this._findIndex(t,e);return i>-1?(t[i].playTime=performance.now(),!1):(t.push({audio:e,playTime:performance.now()}),!0)},e.addPlaying=function(t){if(t instanceof V4){if(this._tryAddPlaying(this._audioPlayerInfoList,t))return}else this._tryAddPlaying(this._oneShotAudioInfoList,t)},e._tryRemovePlaying=function(t,e){var i=this._findIndex(t,e);return-1!==i&&(Zn(t,i),!0)},e.removePlaying=function(t){if(t instanceof V4){if(this._tryRemovePlaying(this._audioPlayerInfoList,t))return}else this._tryRemovePlaying(this._oneShotAudioInfoList,t)},e.discardOnePlayingIfNeeded=function(){var t;this._audioPlayerInfoList.length+this._oneShotAudioInfoList.length<V4.maxAudioChannel||(this._oneShotAudioInfoList.length>0?this._oneShotAudioInfoList.forEach((function(e){(!t||e.playTime<t.playTime)&&(t=e)})):this._audioPlayerInfoList.forEach((function(e){(!t||e.playTime<t.playTime)&&(t=e)})),t&&(t.audio.stop(),this.removePlaying(t.audio)))},t}()),u6=function(e){return t({AudioSource:e,AudioSourceComponent:e}),e}((z4=ri("cc.AudioSource"),U4=wi(),H4=Bi(),j4=bi(k4),W4=bi(k4),X4=Di(),Y4=Di(),q4=Di(),J4=Ni(),K4=Di(),z4(Z4=U4(Z4=H4((n6=r6=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_clip",$4,hi(e)),e._player=null,li(e,"_loop",t6,hi(e)),li(e,"_playOnAwake",e6,hi(e)),li(e,"_volume",i6,hi(e)),e._cachedCurrentTime=0,e._operationsBeforeLoading=[],e._isLoaded=!1,e._lastSetClip=void 0,e}Me(e,t);var i=e.prototype;return i._syncPlayer=function(){var t=this,e=this._clip;this._isLoaded=!1,e&&this._lastSetClip!==e&&(e._nativeAsset?(this._lastSetClip=e,V4.load(e._nativeAsset.url,{audioLoadMode:e.loadMode}).then((function(i){t._lastSetClip===e&&(t._isLoaded=!0,t._player&&(t._player.offEnded(),t._player.offInterruptionBegin(),t._player.offInterruptionEnd(),t._player.destroy()),t._player=i,i.onEnded((function(){h6.removePlaying(i)})),i.onInterruptionBegin((function(){h6.removePlaying(i)})),i.onInterruptionEnd((function(){h6.addPlaying(i)})),t._syncStates())})).catch((function(){}))):console.error("Invalid audio clip"))},i.onLoad=function(){this._syncPlayer()},i.onEnable=function(){this._playOnAwake&&!this.playing&&this.play()},i.onDisable=function(){this.pause()},i.onDestroy=function(){this.stop()},i.play=function(){var t,e,i=this;this._isLoaded?(h6.discardOnePlayingIfNeeded(),this.state===f4.PLAYING&&(null===(e=this._player)||void 0===e||e.stop().catch((function(){}))),null===(t=this._player)||void 0===t||t.play().then((function(){h6.addPlaying(i._player)})).catch((function(){}))):this._operationsBeforeLoading.push("play")},i.pause=function(){var t,e=this;this._isLoaded?null===(t=this._player)||void 0===t||t.pause().then((function(){h6.removePlaying(e._player)})).catch((function(){})):this._operationsBeforeLoading.push("pause")},i.stop=function(){var t,e=this;this._isLoaded?null===(t=this._player)||void 0===t||t.stop().then((function(){h6.removePlaying(e._player)})).catch((function(){})):this._operationsBeforeLoading.push("stop")},i.playOneShot=function(t,e){void 0===e&&(e=1),t._nativeAsset?V4.loadOneShotAudio(t._nativeAsset.url,this._volume*e,{audioLoadMode:t.loadMode}).then((function(t){h6.discardOnePlayingIfNeeded(),t.onPlay=function(){h6.addPlaying(t)},t.onEnd=function(){h6.removePlaying(t)},t.play()})).catch((function(){})):console.error("Invalid audio clip")},i._syncStates=function(){var t=this;this._player&&this._player.seek(this._cachedCurrentTime).then((function(){t._player&&(t._player.loop=t._loop,t._player.volume=t._volume,t._operationsBeforeLoading.forEach((function(e){var i;null===(i=t[e])||void 0===i||i.call(t)})),t._operationsBeforeLoading.length=0)})).catch((function(){}))},Pe(e,[{key:"clip",get:function(){return this._clip},set:function(t){t!==this._clip&&(this._clip=t,this._syncPlayer())}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._player&&(this._player.loop=t)}},{key:"playOnAwake",get:function(){return this._playOnAwake},set:function(t){this._playOnAwake=t}},{key:"volume",get:function(){return this._volume},set:function(t){Number.isNaN(t)?console.warn("illegal audio volume!"):(t=Gr(t,0,1),this._player?(this._player.volume=t,this._volume=this._player.volume):this._volume=t)}},{key:"currentTime",get:function(){return this._player?this._player.currentTime:this._cachedCurrentTime},set:function(t){var e;Number.isNaN(t)?console.warn("illegal audio time!"):(t=Gr(t,0,this.duration),this._cachedCurrentTime=t,null===(e=this._player)||void 0===e||e.seek(this._cachedCurrentTime).catch((function(){})))}},{key:"duration",get:function(){var t,e;return null!==(t=null===(e=this._clip)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:this._player?this._player.currentTime:0}},{key:"state",get:function(){return this._player?this._player.state:f4.INIT}},{key:"playing",get:function(){return this.state===e.AudioState.PLAYING}}],[{key:"maxAudioChannel",get:function(){return V4.maxAudioChannel}}]),e}(zi),r6.AudioState=f4,$4=oi((Q4=n6).prototype,"_clip",[j4],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),t6=oi(Q4.prototype,"_loop",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),e6=oi(Q4.prototype,"_playOnAwake",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),i6=oi(Q4.prototype,"_volume",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),oi(Q4.prototype,"clip",[W4,X4],Object.getOwnPropertyDescriptor(Q4.prototype,"clip"),Q4.prototype),oi(Q4.prototype,"loop",[Y4],Object.getOwnPropertyDescriptor(Q4.prototype,"loop"),Q4.prototype),oi(Q4.prototype,"playOnAwake",[q4],Object.getOwnPropertyDescriptor(Q4.prototype,"playOnAwake"),Q4.prototype),oi(Q4.prototype,"volume",[J4,K4],Object.getOwnPropertyDescriptor(Q4.prototype,"volume"),Q4.prototype),Z4=Q4))||Z4)||Z4)||Z4));Ii(k4,"AudioClip",[{name:"PlayingState",newName:"AudioState",target:u6,targetName:"AudioSource"}]),Ii(k4.prototype,"AudioClip.prototype",[{name:"state",targetName:"AudioSource.prototype",customGetter:function(){return f4.INIT}}]),Ii(k4.prototype,"AudioClip.prototype",[{name:"getCurrentTime",targetName:"AudioSource.prototype",customFunction:function(){return 0}},{name:"getVolume",targetName:"AudioSource.prototype",customFunction:function(){return 0}},{name:"getLoop",targetName:"AudioSource.prototype",customFunction:function(){return!1}}]),Ii(k4.prototype,"AudioClip.prototype",["play","pause","stop","playOneShot","setCurrentTime","setVolume","setLoop"].map((function(t){return{name:t,targetName:"AudioSource.prototype",customFunction:function(){}}}))),He.AudioSourceComponent=u6,Li.setClassAlias(u6,"cc.AudioSourceComponent");var c6=t("VideoClip",ri("cc.VideoClip")((l6=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_duration",o6,hi(e)),e._video=null,e.loaded=!1,e}return Me(e,t),Pe(e,[{key:"_nativeAsset",get:function(){return this._video},set:function(t){this._video=t,t?(this._duration=t.duration,this.loaded=!0):(this._duration=0,this.loaded=!1)}}]),e}(ai),o6=oi((a6=l6).prototype,"_duration",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),s6=a6))||s6);function _6(t,e,i){var r=document.createElement("video"),n=document.createElement("source");r.appendChild(n);var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=function(){200===this.status||0===this.status?(n.src=URL.createObjectURL(this.response),i(null,r)):i(new Error(s.status+"(no response)"))},s.onerror=function(){var e="load video failure - "+t;ls(e),i(new Error(e))},s.send()}function f6(t,e,i,r){var n=new c6;n._nativeUrl=t,n._nativeAsset=e,r(null,n)}_n.register({".mp4":_6,".avi":_6,".mov":_6,".mpg":_6,".mpeg":_6,".rm":_6,".rmvb":_6}),fn.register({".mp4":f6,".avi":f6,".mov":f6,".mpg":f6,".mpeg":f6,".rm":f6,".rmvb":f6});var p6,d6,m6=yi({REMOTE:0,LOCAL:1});!function(t){t.NONE="none",t.PLAYING="playing",t.PAUSED="paused",t.STOPPED="stopped",t.COMPLETED="completed",t.META_LOADED="meta-loaded",t.READY_TO_PLAY="ready-to-play",t.ERROR="error",t.CLICKED="clicked"}(p6||(p6={})),function(t){t[t.HAVE_NOTHING=0]="HAVE_NOTHING",t[t.HAVE_METADATA=1]="HAVE_METADATA",t[t.HAVE_CURRENT_DATA=2]="HAVE_CURRENT_DATA",t[t.HAVE_FUTURE_DATA=3]="HAVE_FUTURE_DATA",t[t.HAVE_ENOUGH_DATA=4]="HAVE_ENOUGH_DATA"}(d6||(d6={}));var y6=function(){function t(t){var e=this;this._componentEventList=new Map,this._state=p6.NONE,this._video=null,this._onHide=void 0,this._onShow=void 0,this._interrupted=!1,this._loaded=!1,this._loadedMeta=!1,this._ignorePause=!1,this._fullScreenOnAwake=!1,this._visible=!0,this._playing=!1,this._cachedCurrentTime=-1,this._waitingFullscreen=!1,this._waitingPlay=!1,this._keepAspectRatio=!1,this._component=null,this._uiTrans=null,this._node=null,this._stayOnBottom=!1,this._dirty=!1,this._forceUpdate=!1,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._component=t,this._node=t.node,this._uiTrans=t.node.getComponent(j_),this._onHide=function(){e.video&&e._state===p6.PLAYING&&(e.video.pause(),e._interrupted=!0)},this._onShow=function(){e._interrupted&&e.video&&(e.video.play(),e._interrupted=!1)},He.game.on(He.Game.EVENT_HIDE,this._onHide),He.game.on(He.Game.EVENT_SHOW,this._onShow)}var e=t.prototype;return e.onLoadedMetadata=function(t){this._loadedMeta=!0,this._forceUpdate=!0,this._visible?this.enable():this.disable(),this.dispatchEvent(p6.META_LOADED);var e=t.target;this._keepAspectRatio&&e&&this.syncUITransform(e.videoWidth,e.videoHeight),this.delayedFullScreen(),this.delayedPlay()},e.onCanPlay=function(){this._loaded=!0,this.dispatchEvent(p6.READY_TO_PLAY)},e.onPlay=function(){this._playing=!0,this.dispatchEvent(p6.PLAYING)},e.onPlaying=function(){this.dispatchEvent(p6.PLAYING)},e.onPause=function(){this._ignorePause?this._ignorePause=!1:(this._playing=!1,this.dispatchEvent(p6.PAUSED))},e.onStoped=function(){this._playing=!1,this._ignorePause=!1,this.dispatchEvent(p6.STOPPED)},e.onEnded=function(){this.dispatchEvent(p6.COMPLETED)},e.onClick=function(){this.dispatchEvent(p6.CLICKED)},e.onError=function(t){this.dispatchEvent(p6.ERROR);var e=t.target;e&&e.error&&Ie("Error "+e.error.code+"; details: "+e.error.message)},e.play=function(){this._loadedMeta||this._loaded?this.canPlay():this._waitingPlay=!0},e.delayedPlay=function(){this._waitingPlay&&(this.canPlay(),this._waitingPlay=!1)},e.syncFullScreenOnAwake=function(t){this._fullScreenOnAwake=t,this._loadedMeta||this._loaded?this.canFullScreen(t):this._waitingFullscreen=!0},e.delayedFullScreen=function(){this._waitingFullscreen&&(this.canFullScreen(this._fullScreenOnAwake),this._waitingFullscreen=!1)},e.dispatchEvent=function(t){var e=this._componentEventList.get(t);e&&(this._state=t,e.call(this))},e.syncUITransform=function(t,e){this._uiTrans&&(this._uiTrans.width=t,this._uiTrans.height=e)},e.syncCurrentTime=function(){this.video&&-1!==this._cachedCurrentTime&&this.video.currentTime!==this._cachedCurrentTime&&(this.seekTo(this._cachedCurrentTime),this._cachedCurrentTime=-1)},e.destroy=function(){this.removeVideoPlayer(),this._componentEventList.clear(),He.game.off(He.Game.EVENT_HIDE,this._onHide),He.game.off(He.Game.EVENT_SHOW,this._onShow)},Pe(t,[{key:"fullScreenOnAwake",get:function(){return this._fullScreenOnAwake}},{key:"loaded",get:function(){return this._loaded}},{key:"componentEventList",get:function(){return this._componentEventList}},{key:"video",get:function(){return this._video}},{key:"state",get:function(){return this._state}},{key:"isPlaying",get:function(){return this._playing}},{key:"UICamera",get:function(){return wr.root.batcher2D.getFirstRenderCamera(this._node)}}]),t}();He.internal.VideoPlayerImpl=y6;var g6,v6,b6,S6,A6,C6,x6,T6,w6,E6,B6,D6,M6,P6,R6,I6,O6,F6,L6,V6,k6,N6,G6,z6,U6,H6,j6,W6,X6,Y6,q6,J6,K6,Z6,Q6,$6,t8,e8,i8,r8=-Math.pow(2,15),n8=hs(),s8=function(t){function e(e){var i;return(i=t.call(this,e)||this)._eventList=new Map,i._clearColorA=-1,i._clearFlag=void 0,i}Me(e,t);var i=e.prototype;return i.addListener=function(t,e){this._video&&(this._eventList.set(t,e),this._video.addEventListener(t,e))},i.removeAllListeners=function(){var t=this;this._eventList.forEach((function(e,i){t._video&&t._video.removeEventListener(i,e)})),this._eventList.clear()},i.canPlay=function(){var t=this;if(this.video){var e=this.video.play();window.Promise&&e instanceof Promise&&e.catch((function(){})).then((function(){t.syncCurrentTime()}))}},i.pause=function(){this.video&&(this.video.pause(),this._cachedCurrentTime=this.video.currentTime)},i.resume=function(){this.play()},i.stop=function(){var t=this;this.video&&(this._ignorePause=!0,this.video.currentTime=0,this.video.pause(),this._cachedCurrentTime=0,setTimeout((function(){t._ignorePause=!1,t.dispatchEvent(p6.STOPPED)}),0))},i.syncClip=function(t){this.removeVideoPlayer(),t&&this.createVideoPlayer(t.nativeUrl)},i.syncURL=function(t){this.removeVideoPlayer(),t&&this.createVideoPlayer(t)},i.syncPlaybackRate=function(t){Le.browserType!==Ne.UC?this.video&&(this.video.playbackRate=t):Ue("playbackRate is not supported by the uc mobile browser.")},i.syncVolume=function(t){this.video&&(this.video.volume=t)},i.syncMute=function(t){this.video&&(this.video.muted=t)},i.syncLoop=function(t){this.video&&(this.video.loop=t)},i.getDuration=function(){return this.video?this.video.duration:0},i.getCurrentTime=function(){return this.video?this.video.currentTime:-1},i.seekTo=function(t){this.video&&(this.video.currentTime=t)},i.canFullScreen=function(t){var e=this,i=this._video;if(i&&i.readyState===d6.HAVE_ENOUGH_DATA)return Le.os===Ve.IOS&&ke.isBrowser?(t?i.webkitEnterFullscreen&&i.webkitEnterFullscreen():i.webkitExitFullscreen&&i.webkitExitFullscreen(),void(this._fullScreenOnAwake=i.webkitDisplayingFullscreen)):vn.supportsFullScreen?void(t?(Le.browserType===Ne.IE&&(i.style.transform=""),i.setAttribute("x5-video-player-fullscreen","true"),vn.requestFullScreen(i,(function(t){var r=Le.browserType===Ne.IE?t.msFullscreenElement:t.fullscreenElement;e._fullScreenOnAwake=r===i}),(function(){e._fullScreenOnAwake=!1}))):(i.removeAttribute("x5-video-player-fullscreen"),vn.exitFullScreen())):(this._fullScreenOnAwake=t,this._forceUpdate=!0,void this.syncMatrix())},i.syncStayOnBottom=function(t){this._video&&(this._video.style["z-index"]=t?r8:0,this._stayOnBottom=t),this._dirty=!0},i.syncKeepAspectRatio=function(t){this._keepAspectRatio=t,t&&this._loadedMeta&&this._video&&this.syncUITransform(this._video.videoWidth,this._video.videoHeight)},i.removeVideoPlayer=function(){var t=this._video;t&&gn(Wr.container,t)&&(Wr.container.removeChild(t),this.removeAllListeners()),this._cachedCurrentTime=0,this._playing=!1,this._loaded=!1,this._loadedMeta=!1,this._video=null},i.createVideoPlayer=function(t){var e=this._video=document.createElement("video");e.className="cocosVideo",e.style.visibility="hidden",e.style.position="absolute",e.style.bottom="0px",e.style.left="0px",e.style["transform-origin"]="0px 100% 0px",e.style["-webkit-transform-origin"]="0px 100% 0px",e.setAttribute("preload","auto"),e.setAttribute("webkit-playsinline",""),e.setAttribute("x5-playsinline",""),e.setAttribute("playsinline",""),this._bindDomEvent(),Wr.container.appendChild(e);var i=document.createElement("source");e.appendChild(i),i.src=t},i._bindDomEvent=function(){this._video,this.addListener("loadedmetadata",this.onLoadedMetadata.bind(this)),this.addListener("canplay",this.onCanPlay.bind(this)),this.addListener("canplaythrough",this.onCanPlay.bind(this)),this.addListener("play",this.onPlay.bind(this)),this.addListener("playing",this.onPlaying.bind(this)),this.addListener("pause",this.onPause.bind(this)),this.addListener("click",this.onClick.bind(this)),this.addListener("ended",this.onEnded.bind(this)),this.addListener("error",this.onError.bind(this))},i.onCanPlay=function(e){var i=e.target;if(!this._loaded||!i)switch(i.readyState){case d6.HAVE_METADATA:case d6.HAVE_ENOUGH_DATA:t.prototype.onCanPlay.call(this,e)}},i.enable=function(){if(this._video){if(this._visible=!0,"visible"===this._video.style.visibility)return;this._video.style.visibility="visible"}},i.disable=function(t){if(this._video){if(!t&&this._playing&&this._video.pause(),this._visible=!1,"hidden"===this._video.style.visibility)return;this._video.style.visibility="hidden"}},i.syncMatrix=function(){if(this._video&&this._visible&&this._component){var t=this.UICamera;if(t&&!vn.fullScreen()){this._dirty&&(this._dirty=!1,this._stayOnBottom?(this._clearColorA=t.clearColor.w,this._clearFlag=t.clearFlag,t.clearColor.w=0,t.clearFlag=j.ALL):this._clearFlag&&(t.clearColor.w=this._clearColorA,t.clearFlag=this._clearFlag,this._clearColorA=-1,this._clearFlag=null)),this._component.node.getWorldMatrix(n8),t.update(!0),t.worldMatrixToScreen(n8,n8,Wr.canvas.width,Wr.canvas.height);var e=0,i=0;if(this._fullScreenOnAwake?(e=jr.width,i=jr.height):(e=this._uiTrans.contentSize.width,i=this._uiTrans.contentSize.height),this._forceUpdate||this._m00!==n8.m00||this._m01!==n8.m01||this._m04!==n8.m04||this._m05!==n8.m05||this._m12!==n8.m12||this._m13!==n8.m13||this._w!==e||this._h!==i){this._m00=n8.m00,this._m01=n8.m01,this._m04=n8.m04,this._m05=n8.m05,this._m12=n8.m12,this._m13=n8.m13,this._w=e,this._h=i;var r=Xr.getDevicePixelRatio(),n=1/r,s=1/r,a=Wr.container,o=n8.m00*n,l=n8.m01,h=n8.m04,u=n8.m05*s;this._video.style.width=this._w+"px",this._video.style.height=this._h+"px",Le.browserType!==Ne.MOBILE_QQ?this._video.style.objectFit=this._keepAspectRatio?"none":"fill":Ue("keepAspectRatio is not supported by the qq mobile browser.");var c=this._w*n,_=this._h*s,f=this._uiTrans.anchorPoint,p=f.x,d=f.y,m=c*n8.m00*p,y=_*n8.m05*d,g=a&&a.style.paddingLeft?parseInt(a.style.paddingLeft):0,v=a&&a.style.paddingBottom?parseInt(a.style.paddingBottom):0,b="matrix("+o+","+-l+","+-h+","+u+","+(n8.m12*n-m+g)+","+-(n8.m13*s-y+v)+")";this._video.style.transform=b,this._video.style["-webkit-transform"]=b,Le.browserType!==Ne.IE&&(this._forceUpdate=!1)}}}},e}(y6),a8=function(){function t(){}return t.getImpl=function(t){return new s8(t)},t}();He.internal.VideoPlayerImplManager=a8;var o8,l8=t("VideoPlayer",(g6=ri("cc.VideoPlayer"),v6=wi(),b6=Bi(),S6=Rr(j_),A6=bi(c6),C6=bi(m6),x6=Di(),T6=Di(),w6=bi(c6),E6=Di(),B6=Di(),D6=Ni(),M6=Di(),P6=Ni(),R6=Di(),I6=Di(),O6=Di(),F6=Di(),L6=Di(),V6=Di(),k6=bi([pn]),N6=Mr(),G6=Di(),g6(z6=v6(z6=b6(z6=S6(z6=Si((i8=e8=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_resourceType",H6,hi(e)),li(e,"_remoteURL",j6,hi(e)),li(e,"_clip",W6,hi(e)),li(e,"_playOnAwake",X6,hi(e)),li(e,"_volume",Y6,hi(e)),li(e,"_mute",q6,hi(e)),li(e,"_playbackRate",J6,hi(e)),li(e,"_loop",K6,hi(e)),li(e,"_fullScreenOnAwake",Z6,hi(e)),li(e,"_stayOnBottom",Q6,hi(e)),li(e,"_keepAspectRatio",$6,hi(e)),e._impl=null,e._cachedCurrentTime=0,li(e,"videoPlayerEvent",t8,hi(e)),e}Me(e,t);var i=e.prototype;return i.syncSource=function(){this._impl&&(this._resourceType===m6.REMOTE?this._impl.syncURL(this._remoteURL):this._impl.syncClip(this._clip))},i.__preload=function(){this._impl=a8.getImpl(this),this.syncSource(),this._impl.syncLoop(this._loop),this._impl.syncVolume(this._volume),this._impl.syncMute(this._mute),this._impl.seekTo(this._cachedCurrentTime),this._impl.syncPlaybackRate(this._playbackRate),this._impl.syncStayOnBottom(this._stayOnBottom),this._impl.syncKeepAspectRatio(this._keepAspectRatio),this._impl.syncFullScreenOnAwake(this._fullScreenOnAwake),this._impl.componentEventList.set(p6.META_LOADED,this.onMetaLoaded.bind(this)),this._impl.componentEventList.set(p6.READY_TO_PLAY,this.onReadyToPlay.bind(this)),this._impl.componentEventList.set(p6.PLAYING,this.onPlaying.bind(this)),this._impl.componentEventList.set(p6.PAUSED,this.onPasued.bind(this)),this._impl.componentEventList.set(p6.STOPPED,this.onStopped.bind(this)),this._impl.componentEventList.set(p6.COMPLETED,this.onCompleted.bind(this)),this._impl.componentEventList.set(p6.ERROR,this.onError.bind(this)),this._playOnAwake&&this._impl.loaded&&this.play()},i.onEnable=function(){this._impl&&this._impl.enable()},i.onDisable=function(){this._impl&&this._impl.disable()},i.onDestroy=function(){this._impl&&(this._impl.destroy(),this._impl=null)},i.update=function(){this._impl&&this._impl.syncMatrix()},i.onMetaLoaded=function(){pn.emitEvents(this.videoPlayerEvent,this,p6.META_LOADED),this.node.emit("meta-loaded",this)},i.onReadyToPlay=function(){this._playOnAwake&&!this.isPlaying&&this.play(),pn.emitEvents(this.videoPlayerEvent,this,p6.READY_TO_PLAY),this.node.emit(p6.READY_TO_PLAY,this)},i.onPlaying=function(){pn.emitEvents(this.videoPlayerEvent,this,p6.PLAYING),this.node.emit(p6.PLAYING,this)},i.onPasued=function(){pn.emitEvents(this.videoPlayerEvent,this,p6.PAUSED),this.node.emit(p6.PAUSED,this)},i.onStopped=function(){pn.emitEvents(this.videoPlayerEvent,this,p6.STOPPED),this.node.emit(p6.STOPPED,this)},i.onCompleted=function(){pn.emitEvents(this.videoPlayerEvent,this,p6.COMPLETED),this.node.emit(p6.COMPLETED,this)},i.onError=function(){pn.emitEvents(this.videoPlayerEvent,this,p6.ERROR),this.node.emit(p6.ERROR,this)},i.play=function(){this._impl&&this._impl.play()},i.resume=function(){this._impl&&this._impl.resume()},i.pause=function(){this._impl&&this._impl.pause()},i.stop=function(){this._impl&&this._impl.stop()},Pe(e,[{key:"resourceType",get:function(){return this._resourceType},set:function(t){this._resourceType!==t&&(this._resourceType=t,this.syncSource())}},{key:"remoteURL",get:function(){return this._remoteURL},set:function(t){this._remoteURL!==t&&(this._remoteURL=t,this.syncSource())}},{key:"clip",get:function(){return this._clip},set:function(t){this._clip!==t&&(this._clip=t,this.syncSource())}},{key:"playOnAwake",get:function(){return this._playOnAwake},set:function(t){this._playOnAwake=t}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._impl&&this._impl.syncPlaybackRate(t)}},{key:"volume",get:function(){return this._volume},set:function(t){this._volume=t,this._impl&&this._impl.syncVolume(t)}},{key:"mute",get:function(){return this._mute},set:function(t){this._mute=t,this._impl&&this._impl.syncMute(t)}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._impl&&this._impl.syncLoop(t)}},{key:"keepAspectRatio",get:function(){return this._keepAspectRatio},set:function(t){this._keepAspectRatio!==t&&(this._keepAspectRatio=t,this._impl&&this._impl.syncKeepAspectRatio(t))}},{key:"fullScreenOnAwake",get:function(){return this._impl?(this._fullScreenOnAwake=this._impl.fullScreenOnAwake,this._fullScreenOnAwake):this._fullScreenOnAwake},set:function(t){this._fullScreenOnAwake!==t&&(this._fullScreenOnAwake=t,this._impl&&this._impl.syncFullScreenOnAwake(t))}},{key:"stayOnBottom",get:function(){return this._stayOnBottom},set:function(t){this._stayOnBottom!==t&&(this._stayOnBottom=t,this._impl&&this._impl.syncStayOnBottom(t))}},{key:"nativeVideo",get:function(){return this._impl&&this._impl.video||null}},{key:"currentTime",get:function(){return this._impl?this._impl.getCurrentTime():this._cachedCurrentTime},set:function(t){Number.isNaN(t)?Ue("illegal video time! value:"+t):(t=Gr(t,0,this.duration),this._cachedCurrentTime=t,this._impl&&this._impl.seekTo(t))}},{key:"duration",get:function(){return this._impl?this._impl.getDuration():0}},{key:"state",get:function(){return this._impl?this._impl.state:p6.NONE}},{key:"isPlaying",get:function(){return!!this._impl&&this._impl.isPlaying}}]),e}(zi),e8.EventType=p6,e8.ResourceType=m6,H6=oi((U6=i8).prototype,"_resourceType",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return m6.LOCAL}}),j6=oi(U6.prototype,"_remoteURL",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),W6=oi(U6.prototype,"_clip",[A6,_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),X6=oi(U6.prototype,"_playOnAwake",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Y6=oi(U6.prototype,"_volume",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),q6=oi(U6.prototype,"_mute",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),J6=oi(U6.prototype,"_playbackRate",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),K6=oi(U6.prototype,"_loop",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Z6=oi(U6.prototype,"_fullScreenOnAwake",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Q6=oi(U6.prototype,"_stayOnBottom",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),$6=oi(U6.prototype,"_keepAspectRatio",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(U6.prototype,"resourceType",[C6,x6],Object.getOwnPropertyDescriptor(U6.prototype,"resourceType"),U6.prototype),oi(U6.prototype,"remoteURL",[T6],Object.getOwnPropertyDescriptor(U6.prototype,"remoteURL"),U6.prototype),oi(U6.prototype,"clip",[w6,E6],Object.getOwnPropertyDescriptor(U6.prototype,"clip"),U6.prototype),oi(U6.prototype,"playOnAwake",[B6],Object.getOwnPropertyDescriptor(U6.prototype,"playOnAwake"),U6.prototype),oi(U6.prototype,"playbackRate",[ki,D6,M6],Object.getOwnPropertyDescriptor(U6.prototype,"playbackRate"),U6.prototype),oi(U6.prototype,"volume",[ki,P6,R6],Object.getOwnPropertyDescriptor(U6.prototype,"volume"),U6.prototype),oi(U6.prototype,"mute",[I6],Object.getOwnPropertyDescriptor(U6.prototype,"mute"),U6.prototype),oi(U6.prototype,"loop",[O6],Object.getOwnPropertyDescriptor(U6.prototype,"loop"),U6.prototype),oi(U6.prototype,"keepAspectRatio",[F6],Object.getOwnPropertyDescriptor(U6.prototype,"keepAspectRatio"),U6.prototype),oi(U6.prototype,"fullScreenOnAwake",[L6],Object.getOwnPropertyDescriptor(U6.prototype,"fullScreenOnAwake"),U6.prototype),oi(U6.prototype,"stayOnBottom",[V6],Object.getOwnPropertyDescriptor(U6.prototype,"stayOnBottom"),U6.prototype),t8=oi(U6.prototype,"videoPlayerEvent",[_i,k6,N6,G6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),z6=U6))||z6)||z6)||z6)||z6)||z6));He.internal.VideoPlayer=l8,function(t){t.NONE="none",t.LOADING="loading",t.LOADED="loaded",t.ERROR="error"}(o8||(o8={}));var h8=function(){function t(t){this._componentEventList=new Map,this._state=o8.NONE,this._warpper=void 0,this._webview=null,this._loaded=!1,this._forceUpdate=!1,this._component=null,this._uiTrans=null,this._node=null,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._component=t,this._node=t.node,this._uiTrans=t.node.getComponent(j_),this.reset(),this.createWebView()}var e=t.prototype;return e.reset=function(){this._warpper=null,this._webview=null,this._loaded=!1,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._state=o8.NONE,this._forceUpdate=!1},e.dispatchEvent=function(t){var e=this._componentEventList.get(t);if(e){this._state=t;for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];e.call(this,r)}},e.destroy=function(){this.removeWebView(),this._warpper=null,this._webview=null,this._loaded=!1,this._component=null,this._uiTrans=null,this._forceUpdate=!1,this._componentEventList.clear()},Pe(t,[{key:"loaded",get:function(){return this._loaded}},{key:"componentEventList",get:function(){return this._componentEventList}},{key:"webview",get:function(){return this._webview}},{key:"state",get:function(){return this._state}},{key:"UICamera",get:function(){return wr.root.batcher2D.getFirstRenderCamera(this._node)}}]),t}();He.internal.WebViewImpl=h8;var u8,c8,_8,f8,p8,d8,m8,y8,g8,v8,b8,S8,A8,C8,x8=hs(),T8=function(t){function e(e){return t.call(this,e)||this}Me(e,t);var i=e.prototype;return i._bindDomEvent=function(){var t=this;this.webview&&this.webview.addEventListener("load",(function(e){t._forceUpdate=!0,t.dispatchEvent(o8.LOADED);var i=e.target,r=i.contentDocument&&i.contentDocument.body;r&&r.innerHTML.includes("404")&&t.dispatchEvent(o8.ERROR,r.innerHTML)}))},i.loadURL=function(t){this.webview&&(this.webview.src=t,this.dispatchEvent(o8.LOADING))},i.createWebView=function(){var t=document.createElement("div");this._warpper=t,t.id="webview-wrapper",t.style["-webkit-overflow"]="auto",t.style["-webkit-overflow-scrolling"]="touch",t.style.position="absolute",t.style.bottom="0px",t.style.left="0px",t.style.transformOrigin="0px 100% 0px",t.style["-webkit-transform-origin"]="0px 100% 0px",Wr.container.appendChild(t);var e=document.createElement("iframe");this._webview=e,e.id="webview",e.style.border="none",e.style.width="100%",e.style.height="100%",t.appendChild(e),this._bindDomEvent()},i.removeWebView=function(){var t=this._warpper;gn(Wr.container,t)&&Wr.container.removeChild(t),this.reset()},i.enable=function(){this._warpper&&(this._warpper.style.visibility="visible")},i.disable=function(){this._warpper&&(this._warpper.style.visibility="hidden")},i.evaluateJS=function(t){if(this.webview){var e=this.webview.contentWindow;if(e)try{e.eval(t)}catch(t){this.dispatchEvent(o8.ERROR,t),Ie(t)}}},i.setOnJSCallback=function(){Ue("The platform does not support")},i.setJavascriptInterfaceScheme=function(){Ue("The platform does not support")},i.syncMatrix=function(){if(this._warpper&&this._uiTrans&&this._component&&"hidden"!==this._warpper.style.visibility){var t=this.UICamera;if(t){this._component.node.getWorldMatrix(x8),t.update(!0),t.worldMatrixToScreen(x8,x8,Wr.canvas.width,Wr.canvas.height);var e=this._uiTrans.contentSize,i=e.width,r=e.height;if(this._forceUpdate||this._m00!==x8.m00||this._m01!==x8.m01||this._m04!==x8.m04||this._m05!==x8.m05||this._m12!==x8.m12||this._m13!==x8.m13||this._w!==i||this._h!==r){this._m00=x8.m00,this._m01=x8.m01,this._m04=x8.m04,this._m05=x8.m05,this._m12=x8.m12,this._m13=x8.m13,this._w=i,this._h=r;var n=Xr.getDevicePixelRatio(),s=1/n,a=1/n,o=Wr.container,l=x8.m00*s,h=x8.m01,u=x8.m04,c=x8.m05*a;this._warpper.style.width=i+"px",this._warpper.style.height=r+"px";var _=this._w*s,f=this._h*a,p=_*x8.m00*this._uiTrans.anchorX,d=f*x8.m05*this._uiTrans.anchorY,m=o&&o.style.paddingLeft?parseInt(o.style.paddingLeft):0,y=o&&o.style.paddingBottom?parseInt(o.style.paddingBottom):0,g="matrix("+l+","+-h+","+-u+","+c+","+(x8.m12*s-p+m)+","+-(x8.m13*a-d+y)+")";this._warpper.style.transform=g,this._warpper.style["-webkit-transform"]=g,this._forceUpdate=!1}}}},e}(h8),w8=function(){function t(){}return t.getImpl=function(t){return new T8(t)},t}();He.internal.WebViewImplManager=w8;var E8=t("WebView",(u8=ri("cc.WebView"),c8=wi(),_8=Bi(),f8=Rr(j_),p8=Di(),d8=bi([pn]),m8=Mr(),y8=Di(),u8(g8=c8(g8=_8(g8=f8(g8=Si((C8=A8=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_url",b8,hi(e)),e._impl=null,li(e,"webviewEvents",S8,hi(e)),e}Me(e,t);var i=e.prototype;return i.setJavascriptInterfaceScheme=function(t){this._impl&&this._impl.setJavascriptInterfaceScheme(t)},i.setOnJSCallback=function(t){this._impl&&this._impl.setOnJSCallback(t)},i.evaluateJS=function(t){this._impl&&this._impl.evaluateJS(t)},i.__preload=function(){this._impl=w8.getImpl(this),this._impl.componentEventList.set(o8.LOADING,this.onLoading.bind(this)),this._impl.componentEventList.set(o8.LOADED,this.onLoaded.bind(this)),this._impl.componentEventList.set(o8.ERROR,this.onError.bind(this)),this._impl.loadURL(this._url)},i.onLoading=function(){pn.emitEvents(this.webviewEvents,this,o8.LOADING),this.node.emit(o8.LOADING,this)},i.onLoaded=function(){pn.emitEvents(this.webviewEvents,this,o8.LOADED),this.node.emit(o8.LOADED,this)},i.onError=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];pn.emitEvents(this.webviewEvents,this,o8.ERROR,e),this.node.emit(o8.ERROR,this,e)},i.onEnable=function(){this._impl&&this._impl.enable()},i.onDisable=function(){this._impl&&this._impl.disable()},i.onDestroy=function(){this._impl&&(this._impl.destroy(),this._impl=null)},i.update=function(){this._impl&&this._impl.syncMatrix()},Pe(e,[{key:"url",get:function(){return this._url},set:function(t){this._url=t,this._impl&&this._impl.loadURL(t)}},{key:"nativeWebView",get:function(){return this._impl&&this._impl.webview||null}},{key:"state",get:function(){return this._impl?this._impl.state:o8.NONE}}]),e}(zi),A8.EventType=o8,b8=oi((v8=C8).prototype,"_url",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"https://cocos.com"}}),oi(v8.prototype,"url",[p8],Object.getOwnPropertyDescriptor(v8.prototype,"url"),v8.prototype),S8=oi(v8.prototype,"webviewEvents",[_i,d8,m8,y8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),g8=v8))||g8)||g8)||g8)||g8)||g8));He.internal.WebView=E8;var B8=function(){function t(){this.originalTarget=null,this.target=null,this.tag=t.TAG_INVALID}var e=t.prototype;return e.clone=function(){var e=new t;return e.originalTarget=null,e.target=null,e.tag=this.tag,e},e.isDone=function(){return!0},e.startWithTarget=function(t){this.originalTarget=t,this.target=t},e.stop=function(){this.target=null},e.step=function(){an(1006)},e.update=function(){an(1007)},e.getTarget=function(){return this.target},e.setTarget=function(t){this.target=t},e.getOriginalTarget=function(){return this.originalTarget},e.setOriginalTarget=function(t){this.originalTarget=t},e.getTag=function(){return this.tag},e.setTag=function(t){this.tag=t},e.reverse=function(){return an(1008),null},e.retain=function(){},e.release=function(){},t}();B8.TAG_INVALID=-1;var D8=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._duration=0,e._timesForRepeat=1,e}Me(e,t);var i=e.prototype;return i.getDuration=function(){return this._duration*(this._timesForRepeat||1)},i.setDuration=function(t){this._duration=t},i.clone=function(){return new e},e}(B8),M8=(function(t){function e(e,i){var r;return void 0===i&&(i=1),(r=t.call(this)||this)._speed=0,r._innerAction=null,e&&r.initWithAction(e,i),r}Me(e,t);var i=e.prototype;i.getSpeed=function(){return this._speed},i.setSpeed=function(t){this._speed=t},i.initWithAction=function(t,e){return t?(this._innerAction=t,this._speed=e,!0):(Re(1021),!1)},i.clone=function(){var t=new e;return t.initWithAction(this._innerAction.clone(),this._speed),t},i.startWithTarget=function(t){B8.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),B8.prototype.stop.call(this)},i.step=function(t){this._innerAction.step(t*this._speed)},i.isDone=function(){return this._innerAction.isDone()},i.reverse=function(){return new e(this._innerAction.reverse(),this._speed)},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction}}(B8),0),P8=function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.paused=!1,this.lock=!1},R8=function(){function t(){this._hashTargets=new Map,this._arrayTargets=[],this._elementPool=[]}var e=t.prototype;return e._searchElementByTarget=function(t,e){for(var i=0;i<t.length;i++)if(e===t[i].target)return t[i];return null},e._getElement=function(t,e){var i=this._elementPool.pop();return i||(i=new P8),i.target=t,i.paused=!!e,i},e._putElement=function(t){t.actions.length=0,t.actionIndex=0,t.currentAction=null,t.paused=!1,t.target=null,t.lock=!1,this._elementPool.push(t)},e.addAction=function(t,e,i){if(t&&e){null==e.uuid&&(e.uuid="_TWEEN_UUID_"+M8++);var r=this._hashTargets.get(e);r?r.actions||(r.actions=[]):(r=this._getElement(e,i),this._hashTargets.set(e,r),this._arrayTargets.push(r)),r.target=e,r.actions.push(t),t.startWithTarget(e)}else Re(1e3)},e.removeAllActions=function(){for(var t=this._arrayTargets,e=0;e<t.length;e++){var i=t[e];i&&this._putElement(i)}this._arrayTargets.length=0,this._hashTargets=new Map},e.removeAllActionsFromTarget=function(t){if(null!=t){var e=this._hashTargets.get(t);e&&(e.actions.length=0,this._deleteHashElement(e))}},e.removeAction=function(t){if(null!=t){var e=t.getOriginalTarget(),i=this._hashTargets.get(e);if(i)for(var r=0;r<i.actions.length;r++)if(i.actions[r]===t){i.actions.splice(r,1),i.actionIndex>=r&&i.actionIndex--;break}}},e._removeActionByTag=function(t,e,i){for(var r=0,n=e.actions.length;r<n;++r){var s=e.actions[r];if(s&&s.getTag()===t){if(i&&s.getOriginalTarget()!==i)continue;this._removeActionAtIndex(r,e);break}}},e.removeActionByTag=function(t,e){var i=this;t===B8.TAG_INVALID&&an(1002);var r=this._hashTargets;if(e){var n=r.get(e);n&&this._removeActionByTag(t,n,e)}else r.forEach((function(e){i._removeActionByTag(t,e)}))},e.getActionByTag=function(t,e){t===B8.TAG_INVALID&&an(1004);var i=this._hashTargets.get(e);if(i){if(null!=i.actions)for(var r=0;r<i.actions.length;++r){var n=i.actions[r];if(n&&n.getTag()===t)return n}an(1005,t)}return null},e.getNumberOfRunningActionsInTarget=function(t){var e=this._hashTargets.get(t);return e&&e.actions?e.actions.length:0},e.pauseTarget=function(t){var e=this._hashTargets.get(t);e&&(e.paused=!0)},e.resumeTarget=function(t){var e=this._hashTargets.get(t);e&&(e.paused=!1)},e.pauseAllRunningActions=function(){for(var t=[],e=this._arrayTargets,i=0;i<e.length;i++){var r=e[i];r&&!r.paused&&(r.paused=!0,t.push(r.target))}return t},e.resumeTargets=function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.resumeTarget(t[e])},e.pauseTargets=function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.pauseTarget(t[e])},e.purgeSharedManager=function(){He.director.getScheduler().unscheduleUpdate(this)},e._removeActionAtIndex=function(t,e){e.actions[t],e.actions.splice(t,1),e.actionIndex>=t&&e.actionIndex--,0===e.actions.length&&this._deleteHashElement(e)},e._deleteHashElement=function(t){var e=!1;if(t&&!t.lock&&this._hashTargets.get(t.target)){this._hashTargets.delete(t.target);for(var i=this._arrayTargets,r=0,n=i.length;r<n;r++)if(i[r]===t){i.splice(r,1);break}this._putElement(t),e=!0}return e},e.update=function(t){for(var e,i=this._arrayTargets,r=0;r<i.length;r++){this._currentTarget=i[r];var n=(e=this._currentTarget).target;if(n instanceof Lr&&!n.isValid)this.removeAllActionsFromTarget(n),r--;else{if(!e.paused&&e.actions){for(e.lock=!0,e.actionIndex=0;e.actionIndex<e.actions.length;e.actionIndex++)if(e.currentAction=e.actions[e.actionIndex],e.currentAction){if(e.currentAction.step(t*(e.currentAction._speedMethod?e.currentAction._speed:1)),e.currentAction&&e.currentAction.isDone()){e.currentAction.stop();var s=e.currentAction;e.currentAction=null,this.removeAction(s)}e.currentAction=null}e.lock=!1}0===e.actions.length&&this._deleteHashElement(e)&&r--}}},t}(),I8=t("TweenSystem",function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).actionMgr=new R8,e}return Me(e,t),e.prototype.update=function(t){this.actionMgr.update(t)},Pe(e,[{key:"ActionManager",get:function(){return this.actionMgr}}]),e}(Xn));I8.ID="TWEEN",I8.instance=void 0,wr.on(Er.EVENT_INIT,(function(){var t=new I8;I8.instance=t,wr.registerSystem(I8.ID,t,100)}));var O8=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.isDone=function(){return!0},i.step=function(){this.update(1)},i.update=function(){},i.reverse=function(){return this.clone()},i.clone=function(){return new e},e}(D8),F8=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(Pi),e=0;e<t.length;++e)t[e].enabled=!0},i.reverse=function(){return new L8},i.clone=function(){return new e},e}(O8),L8=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(Pi),e=0;e<t.length;++e)t[e].enabled=!1},i.reverse=function(){return new F8},i.clone=function(){return new e},e}(O8);!function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;i.update=function(){for(var t=this.target.getComponentsInChildren(Pi),e=0;e<t.length;++e){var i=t[e];i.enabled=!i.enabled}},i.reverse=function(){return new e},i.clone=function(){return new e}}(O8);var V8=function(t){function e(e){var i;return(i=t.call(this)||this)._isNeedCleanUp=!0,void 0!==e&&i.init(e),i}Me(e,t);var i=e.prototype;return i.update=function(){this.target.removeFromParent(),this._isNeedCleanUp&&this.target.destroy()},i.init=function(t){return this._isNeedCleanUp=t,!0},i.reverse=function(){return new e(this._isNeedCleanUp)},i.clone=function(){return new e(this._isNeedCleanUp)},e}(O8),k8=function(t){function e(e,i,r){var n;return(n=t.call(this)||this)._selectorTarget=null,n._function=null,n._data=null,n.initWithFunction(e,i,r),n}Me(e,t);var i=e.prototype;return i.initWithFunction=function(t,e,i){return t&&(this._function=t),e&&(this._selectorTarget=e),void 0!==i&&(this._data=i),!0},i.execute=function(){this._function&&this._function.call(this._selectorTarget,this.target,this._data)},i.update=function(){this.execute()},i.getTargetCallback=function(){return this._selectorTarget},i.setTargetCallback=function(t){t!==this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=t)},i.clone=function(){var t=new e;return t.initWithFunction(this._function,this._selectorTarget,this._data),t},e}(O8),N8=function(t){function e(e){var i;return(i=t.call(this)||this).MAX_VALUE=2,i._elapsed=0,i._firstTick=!1,i._easeList=[],i._speed=1,i._repeatForever=!1,i._repeatMethod=!1,i._speedMethod=!1,void 0===e||isNaN(e)||i.initWithDuration(e),i}Me(e,t);var i=e.prototype;return i.getElapsed=function(){return this._elapsed},i.initWithDuration=function(t){return this._duration=0===t?Oe.FLT_EPSILON:t,this._elapsed=0,this._firstTick=!0,!0},i.isDone=function(){return this._elapsed>=this._duration},i._cloneDecoration=function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},i._reverseEaseList=function(t){if(this._easeList){t._easeList=[];for(var e=0;e<this._easeList.length;e++)t._easeList.push(this._easeList[e])}},i.clone=function(){var t=new e(this._duration);return this._cloneDecoration(t),t},i.easing=function(t){this._easeList?this._easeList.length=0:this._easeList=[];for(var e=0;e<arguments.length;e++)this._easeList.push(arguments[e]);return this},i._computeEaseTime=function(t){return t},i.step=function(t){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=t;var e=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);e=e<1?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},i.startWithTarget=function(t){B8.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},i.reverse=function(){return an(1010),this},i.setAmplitudeRate=function(){an(1011)},i.getAmplitudeRate=function(){return an(1012),0},i.speed=function(t){return t<=0?(an(1013),this):(this._speedMethod=!0,this._speed*=t,this)},i.getSpeed=function(){return this._speed},i.setSpeed=function(t){return this._speed=t,this},i.repeat=function(t){return t=Math.round(t),isNaN(t)||t<1?(an(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},i.repeatForever=function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this},e}(D8),G8=function(t){function e(i){var r;(r=t.call(this)||this)._actions=[],r._split=0,r._last=0,r._reversed=!1;var n=i instanceof Array?i:arguments;if(1===n.length)return Re(1019),hi(r);var s=n.length-1;if(s>=0&&null==n[s]&&an(1015),s>=0){for(var a,o=n[0],l=1;l<s;l++)n[l]&&(a=o,o=e._actionOneTwo(a,n[l]));r.initWithTwoActions(o,n[s])}return r}Me(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return Re(1025),!1;var i=t._duration,r=e._duration,n=(i*=t._repeatMethod?t._timesForRepeat:1)+(r*=e._repeatMethod?e._timesForRepeat:1);return this.initWithDuration(n),this._actions[0]=t,this._actions[1]=e,!0},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),t},i.startWithTarget=function(t){N8.prototype.startWithTarget.call(this,t),this._split=this._actions[0]._duration/this._duration,this._split*=this._actions[0]._repeatMethod?this._actions[0]._timesForRepeat:1,this._last=-1},i.stop=function(){-1!==this._last&&this._actions[this._last].stop(),B8.prototype.stop.call(this)},i.update=function(t){var e,i,r=0,n=this._split,s=this._actions,a=this._last;(t=this._computeEaseTime(t))<n?(e=0!==n?t/n:1,0===r&&1===a&&this._reversed&&(s[1].update(0),s[1].stop())):(r=1,e=1===n?1:(t-n)/(1-n),-1===a&&(s[0].startWithTarget(this.target),s[0].update(1),s[0].stop()),0===a&&(s[0].update(1),s[0].stop())),i=s[r],a===r&&i.isDone()||(a!==r&&i.startWithTarget(this.target),e*=i._timesForRepeat,i.update(e>1?e%1:e),this._last=r)},i.reverse=function(){var t=e._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t},e}(N8);function z8(t){var e=t instanceof Array?t:arguments;if(1===e.length)return Re(1019),null;var i=e.length-1;i>=0&&null==e[i]&&an(1015);var r=null;if(i>=0){r=e[0];for(var n=1;n<=i;n++)e[n]&&(r=G8._actionOneTwo(r,e[n]))}return r}G8._actionOneTwo=function(t,e){var i=new G8;return i.initWithTwoActions(t,e),i};var U8=function(t){function e(e,i){var r;return(r=t.call(this)||this)._times=0,r._total=0,r._nextDt=0,r._actionInstant=!1,r._innerAction=null,void 0!==i&&r.initWithAction(e,i),r}Me(e,t);var i=e.prototype;return i.initWithAction=function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof O8&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},i.startWithTarget=function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,N8.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),B8.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,r=this._times,n=this._nextDt;if(t>=n){for(;t>n&&this._total<r;)e.update(1),this._total++,e.stop(),e.startWithTarget(this.target),n+=e._duration/i,this._nextDt=n>1?1:n;t>=1&&this._total<r&&(e.update(1),this._total++),this._actionInstant||(this._total===r?e.stop():e.update(t-(n-e._duration/i)))}else e.update(t*r%1)},i.isDone=function(){return this._total===this._times},i.reverse=function(){var t=new e(this._innerAction.reverse(),this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},e}(N8),H8=function(t){function e(e){var i;return(i=t.call(this)||this)._innerAction=null,e&&i.initWithAction(e),i}Me(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?(this._innerAction=t,!0):(Re(1026),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone()),t},i.startWithTarget=function(t){N8.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.step=function(t){var e=this._innerAction;e.step(t),e.isDone()&&(e.startWithTarget(this.target),e.step(e.getElapsed()-e._duration))},i.isDone=function(){return!1},i.reverse=function(){var t=new e(this._innerAction.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},e}(N8),j8=function(t){function e(i){var r;(r=t.call(this)||this)._one=null,r._two=null;var n=i instanceof Array?i:arguments;if(1===n.length)return Re(1020),hi(r);var s=n.length-1;if(s>=0&&null==n[s]&&an(1015),s>=0){for(var a,o=n[0],l=1;l<s;l++)n[l]&&(a=o,o=e._actionOneTwo(a,n[l]));r.initWithTwoActions(o,n[s])}return r}Me(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return Re(1027),!1;var i=!1,r=t._duration,n=e._duration;return this.initWithDuration(Math.max(r,n))&&(this._one=t,this._two=e,r>n?this._two=G8._actionOneTwo(e,Y8(r-n)):r<n&&(this._one=G8._actionOneTwo(t,Y8(n-r))),i=!0),i},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithTwoActions(this._one.clone(),this._two.clone()),t},i.startWithTarget=function(t){N8.prototype.startWithTarget.call(this,t),this._one.startWithTarget(t),this._two.startWithTarget(t)},i.stop=function(){this._one.stop(),this._two.stop(),B8.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t),this._one&&this._one.update(t),this._two&&this._two.update(t)},i.reverse=function(){var t=e._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},e}(N8);function W8(t){var e=t instanceof Array?t:arguments;if(1===e.length)return Re(1020),null;e.length>0&&null==e[e.length-1]&&an(1015);for(var i=e[0],r=1;r<e.length;r++)null!=e[r]&&(i=j8._actionOneTwo(i,e[r]));return i}j8._actionOneTwo=function(t,e){var i=new j8;return i.initWithTwoActions(t,e),i};var X8=function(t){function e(){return t.apply(this,arguments)||this}Me(e,t);var i=e.prototype;return i.update=function(){},i.reverse=function(){var t=new e(this._duration);return this._cloneDecoration(t),this._reverseEaseList(t),t},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithDuration(this._duration),t},e}(N8);function Y8(t){return new X8(t)}var q8=function(t){function e(e){var i;return(i=t.call(this)||this)._other=null,e&&i.initWithAction(e),i}Me(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?t===this._other?(Re(1029),!1):!!N8.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0):(Re(1028),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},i.startWithTarget=function(t){N8.prototype.startWithTarget.call(this,t),this._other.startWithTarget(t)},i.update=function(t){t=this._computeEaseTime(t),this._other&&this._other.update(1-t)},i.reverse=function(){return this._other.clone()},i.stop=function(){this._other.stop(),B8.prototype.stop.call(this)},e}(N8),J8=function(t){function e(e,i,r){var n;if((n=t.call(this)||this)._opts=void 0,n._props=void 0,n._originProps=void 0,null==r)r=Object.create(null);else if(function(t){var e=" [Tween:] ",i=" option is not support in v + "+cs,r=t;r.delay&&Ue(e+"delay"+i),r.repeat&&Ue(e+"repeat"+i),r.repeatDelay&&Ue(e+"repeatDelay"+i),r.interpolation&&Ue(e+"interpolation"+i),r.onStop&&Ue(e+"onStop"+i)}(r),r.easing&&"string"==typeof r.easing&&(r.easing=function(t){var e=t.charAt(0);if(/[A-Z]/.test(e)){var i=(t=t.replace(e,e.toLowerCase())).split("-");if(2===i.length){var r=i[0];if("linear"===r)t="linear";else{var n=i[1];switch(r){case"quadratic":t="quad"+n;break;case"quartic":t="quart"+n;break;case"quintic":t="quint"+n;break;case"sinusoidal":t="sine"+n;break;case"exponential":t="expo"+n;break;case"circular":t="circ"+n;break;default:t=r+n}}}}return t}(r.easing)),r.progress||(r.progress=n.progress),r.easing&&"string"==typeof r.easing){var s=r.easing;r.easing=us[s],r.easing||ze(1031,s)}for(var a in n._opts=r,n._props=Object.create(null),i)if(i.hasOwnProperty(a)){var o=i[a];if(null!=o&&"string"!=typeof o&&"function"!=typeof o){var l=void 0,h=void 0;void 0!==o.value&&(o.easing||o.progress)&&("string"==typeof o.easing?(l=us[o.easing])||ze(1031,o.easing):l=o.easing,h=o.progress,o=o.value);var u=Object.create(null);u.value=o,u.easing=l,u.progress=h,n._props[a]=u}}return n._originProps=i,n.initWithDuration(e),n}Me(e,t);var i=e.prototype;return i.clone=function(){var t=new e(this._duration,this._originProps,this._opts);return this._cloneDecoration(t),t},i.startWithTarget=function(t){N8.prototype.startWithTarget.call(this,t);var e=!!this._opts.relative,i=this._props;for(var r in i){var n=t[r];if(void 0!==n){var s=i[r],a=s.value;if("number"==typeof n)s.start=n,s.current=n,s.end=e?n+a:a;else if("object"==typeof n)for(var o in null==s.start&&(s.start={},s.current={},s.end={}),a)isNaN(n[o])||(s.start[o]=n[o],s.current[o]=n[o],s.end[o]=e?n[o]+a[o]:a[o])}}this._opts.onStart&&this._opts.onStart(this.target)},i.update=function(t){var e=this.target;if(e){var i=this._props,r=this._opts,n=t;r.easing&&(n=r.easing(t));var s=r.progress;for(var a in i){var o=i[a],l=o.easing?o.easing(t):n,h=o.progress?o.progress:s,u=o.start,c=o.end;if("number"==typeof u)o.current=h(u,c,o.current,l);else if("object"==typeof u)for(var _ in u)o.current[_]=h(u[_],c[_],o.current[_],l);e[a]=o.current}r.onUpdate&&r.onUpdate(this.target,t),1===t&&r.onComplete&&r.onComplete(this.target)}},i.progress=function(t,e,i,r){return t+(e-t)*r},e}(N8),K8=function(t){function e(e){var i;return(i=t.call(this)||this)._props=void 0,i._props={},void 0!==e&&i.init(e),i}Me(e,t);var i=e.prototype;return i.init=function(t){for(var e in t)this._props[e]=t[e];return!0},i.update=function(){var t=this._props,e=this.target;for(var i in t)e[i]=t[i]},i.clone=function(){var t=new e;return t.init(this._props),t},e}(O8),Z8=t("Tween",function(){function t(t){this._actions=[],this._finalAction=null,this._target=null,this._tag=B8.TAG_INVALID,this._target=void 0===t?null:t}var e=t.prototype;return e.tag=function(t){return this._tag=t,this},e.then=function(t){return t instanceof B8?this._actions.push(t.clone()):this._actions.push(t._union()),this},e.target=function(t){return this._target=t,this},e.start=function(){return this._target?(this._finalAction&&I8.instance.ActionManager.removeAction(this._finalAction),this._finalAction=this._union(),this._finalAction.setTag(this._tag),I8.instance.ActionManager.addAction(this._finalAction,this._target,!1),this):(Ue("Please set target to tween first"),this)},e.stop=function(){return this._finalAction&&I8.instance.ActionManager.removeAction(this._finalAction),this},e.clone=function(t){var e=this._union();return Q8(t).then(e.clone())},e.union=function(){var t=this._union();return this._actions.length=0,this._actions.push(t),this},e.to=function(t,e,i){(i=i||Object.create(null)).relative=!1;var r=new J8(t,e,i);return this._actions.push(r),this},e.by=function(t,e,i){(i=i||Object.create(null)).relative=!0;var r=new J8(t,e,i);return this._actions.push(r),this},e.set=function(t){var e=new K8(t);return this._actions.push(e),this},e.delay=function(t){var e=Y8(t);return this._actions.push(e),this},e.call=function(t){var e=function(t){return new k8(t,void 0,void 0)}(t);return this._actions.push(e),this},e.sequence=function(){var e=t._wrappedSequence.apply(t,arguments);return this._actions.push(e),this},e.parallel=function(){var e=t._wrappedParallel.apply(t,arguments);return this._actions.push(e),this},e.repeat=function(e,i){if(e==1/0)return this.repeatForever(i);var r,n=this._actions;return r=i instanceof t?i._union():n.pop(),n.push(function(t,e){return new U8(t,e)}(r,e)),this},e.repeatForever=function(e){var i,r=this._actions;return i=e instanceof t?e._union():r.pop(),r.push(function(t){return new H8(t)}(i)),this},e.reverseTime=function(e){var i,r=this._actions;return i=e instanceof t?e._union():r.pop(),r.push(function(t){return new q8(t)}(i)),this},e.hide=function(){var t=new L8;return this._actions.push(t),this},e.show=function(){var t=new F8;return this._actions.push(t),this},e.removeSelf=function(){var t=new V8(!1);return this._actions.push(t),this},t.stopAll=function(){I8.instance.ActionManager.removeAllActions()},t.stopAllByTag=function(t,e){I8.instance.ActionManager.removeActionByTag(t,e)},t.stopAllByTarget=function(t){I8.instance.ActionManager.removeAllActionsFromTarget(t)},e._union=function(){var t=this._actions;return 1===t.length?t[0]:z8(t)},e._destroy=function(){this.stop()},t._wrappedSequence=function(){var e=t._tmp_args;e.length=0;for(var i=arguments.length,r=0;r<i;r++){var n=e[r]=r<0||arguments.length<=r?void 0:arguments[r];n instanceof t&&(e[r]=n._union())}return z8.apply(z8,e)},t._wrappedParallel=function(){var e=t._tmp_args;e.length=0;for(var i=arguments.length,r=0;r<i;r++){var n=e[r]=r<0||arguments.length<=r?void 0:arguments[r];n instanceof t&&(e[r]=n._union())}return W8.apply(W8,e)},t}());function Q8(t){return new Z8(t)}function $8(t){return Ue("tweenUtil' is deprecated, please use 'tween' instead "),new Z8(t)}Z8._tmp_args=[],He.Tween=Z8,He.tween=Q8,He.tweenUtil=$8,t("HeightField",function(){function t(t,e){this.data=new Uint16Array,this.w=0,this.h=0,this.w=t,this.h=e,this.data=new Uint16Array(t*e);for(var i=0;i<t*e;++i)this.data[i]=0}var e=t.prototype;return e.set=function(t,e,i){this.data[e*this.w+t]=i},e.get=function(t,e){return this.data[e*this.w+t]},e.getClamp=function(t,e){return t=Gr(t,0,this.w-1),e=Gr(e,0,this.h-1),this.get(t,e)},e.getAt=function(t,e){var i=t,r=e,n=Math.floor(i),s=Math.floor(r),a=n+1,o=s+1,l=i-n,h=r-s;n=Gr(n,0,this.w-1),s=Gr(s,0,this.h-1),a=Gr(a,0,this.w-1),o=Gr(o,0,this.h-1);var u=this.get(n,s),c=this.get(a,s),_=this.get(n,o),f=this.get(a,o),p=.5*(c+_);return l+h<=1?f=p+(p-u):u=p+(p-f),(u*(1-l)+c*l)*(1-h)+(_*(1-l)+f*l)*h},t}());var t7,e7,i7,r7,n7,s7,a7,o7,l7,h7,u7,c7,_7,f7,p7,d7,m7,y7,g7,v7,b7,S7,A7,C7,x7,T7,w7,E7,B7,D7,M7,P7,R7,I7,O7,F7,L7,V7,k7,N7,G7,z7,U7,H7,j7,W7,X7,Y7,q7,J7,K7,Z7=new ii,Q7=new ii,$7=t("TerrainInfo",ri("cc.TerrainInfo")((a7=function(){function t(){li(this,"tileSize",i7,this),li(this,"blockCount",r7,this),li(this,"weightMapSize",n7,this),li(this,"lightMapSize",s7,this)}return Pe(t,[{key:"size",get:function(){var t=new vr(0,0);return t.width=this.blockCount[0]*zJ*this.tileSize,t.height=this.blockCount[1]*zJ*this.tileSize,t}},{key:"tileCount",get:function(){var t=[0,0];return t[0]=this.blockCount[0]*zJ,t[1]=this.blockCount[1]*zJ,t}},{key:"vertexCount",get:function(){var t=this.tileCount;return t[0]+=1,t[1]+=1,t}}]),t}(),i7=oi((e7=a7).prototype,"tileSize",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),r7=oi(e7.prototype,"blockCount",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[1,1]}}),n7=oi(e7.prototype,"weightMapSize",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 128}}),s7=oi(e7.prototype,"lightMapSize",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 128}}),t7=e7))||t7),t9=t("TerrainLayer",ri("cc.TerrainLayer")((h7=oi((l7=function(){li(this,"detailMap",h7,this),li(this,"normalMap",u7,this),li(this,"tileSize",c7,this),li(this,"metallic",_7,this),li(this,"roughness",f7,this)}).prototype,"detailMap",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),u7=oi(l7.prototype,"normalMap",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),c7=oi(l7.prototype,"tileSize",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),_7=oi(l7.prototype,"metallic",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),f7=oi(l7.prototype,"roughness",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),o7=l7))||o7),e9=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._model=null,e._meshData=null,e._brushMaterial=null,e._currentMaterial=null,e._currentMaterialLayers=0,e}Me(e,t);var i=e.prototype;return i.destroy=function(){return null!=this._model&&(He.director.root.destroyModel(this._model),this._model=null),t.prototype.destroy.call(this)},i._destroyModel=function(){null!=this._model&&(He.director.root.destroyModel(this._model),this._model=null)},i._invalidMaterial=function(){null!=this._currentMaterial&&(this._clearMaterials(),this._currentMaterial=null,null!=this._model&&(this._model.enabled=!1))},i._updateMaterial=function(t,e){if(null!=this._meshData&&null!=this._model){var i=t.getMaxLayer();null!=this._currentMaterial&&i===this._currentMaterialLayers||(this._currentMaterial=new cr,this._currentMaterial.initialize({effectAsset:t.getTerrain().getEffectAsset(),defines:t._getMaterialDefines(i)}),null!==this._brushMaterial&&null!==this._brushMaterial.passes&&this._brushMaterial.passes.length>0&&this._currentMaterial.passes.push(this._brushMaterial.passes[0]),e&&this._model.initSubModel(0,this._meshData,this._currentMaterial),this.setMaterial(this._currentMaterial,0),this._currentMaterialLayers=i,this._model.enabled=!0,this._model.receiveShadow=t.getTerrain().receiveShadow)}},i._onMaterialModified=function(t,e){null!=this._model&&this._onRebuildPSO(t,e||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.setSubModelMaterial(t,e)},i._clearMaterials=function(){null!=this._model&&this._onMaterialModified(0,null)},i._getBuiltinMaterial=function(){return Ci.get("missing-material")},e}(Pi),i9=t("TerrainBlockLightmapInfo",ri("cc.TerrainBlockLightmapInfo")((m7=oi((d7=function(){li(this,"texture",m7,this),li(this,"UOff",y7,this),li(this,"VOff",g7,this),li(this,"UScale",v7,this),li(this,"VScale",b7,this)}).prototype,"texture",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),y7=oi(d7.prototype,"UOff",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),g7=oi(d7.prototype,"VOff",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),v7=oi(d7.prototype,"UScale",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),b7=oi(d7.prototype,"VScale",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),p7=d7))||p7),r9=t("TerrainBlock",function(){function t(t,e,i){this._terrain=void 0,this._node=void 0,this._renderable=void 0,this._index=[1,1],this._weightMap=null,this._lightmapInfo=null,this._terrain=t,this._index[0]=e,this._index[1]=i,this._lightmapInfo=t._getLightmapInfo(e,i),this._node=new ur,this._node.setParent(this._terrain.node),this._node.hideFlags|=Lr.Flags.DontSave|Lr.Flags.HideInHierarchy,this._node.layer=this._terrain.node.layer,this._renderable=this._node.addComponent(e9)}var e=t.prototype;return e.build=function(){var t=wr.root.device,e=new Float32Array(HJ*UJ*UJ),i=0;Z7.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),Q7.set(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(var r=0;r<UJ;++r)for(var n=0;n<UJ;++n){var s=this._index[0]*zJ+n,a=this._index[1]*zJ+r,o=this._terrain.getPosition(s,a),l=this._terrain.getNormal(s,a),h=new dr(n/zJ,r/zJ);e[i++]=o.x,e[i++]=o.y,e[i++]=o.z,e[i++]=l.x,e[i++]=l.y,e[i++]=l.z,e[i++]=h.x,e[i++]=h.y,ii.min(Z7,Z7,o),ii.max(Q7,Q7,o)}var u=t.createBuffer(new nt(d.VERTEX|d.TRANSFER_DST,g.HOST|g.DEVICE,HJ*Float32Array.BYTES_PER_ELEMENT*UJ*UJ,HJ*Float32Array.BYTES_PER_ELEMENT));u.update(e);var c=[new St(Ut.ATTR_POSITION,_.RGB32F),new St(Ut.ATTR_NORMAL,_.RGB32F),new St(Ut.ATTR_TEX_COORD,_.RG32F)];this._renderable._meshData=new ui([u],c,F.TRIANGLE_LIST,this._terrain._getSharedIndexBuffer());var f=this._renderable._model=He.director.root.createModel(mi);f.createBoundingShape(Z7,Q7),f.node=f.transform=this._node,this._renderable._getRenderScene().addModel(f),this._updateWeightMap(),this._updateMaterial(!0)},e.rebuild=function(){this._updateHeight(),this._updateWeightMap(),this._renderable._invalidMaterial(),this._updateMaterial(!1)},e.destroy=function(){this._renderable._destroyModel(),null!=this._node&&this._node.destroy(),null!=this._weightMap&&this._weightMap.destroy()},e.update=function(){this._updateMaterial(!1);var t=this._terrain.useNormalMap,e=this._terrain.usePBR,i=function(t){return null!==t?t.detailMap:null},r=function(t){var e=null!==t?t.normalMap:null;return null===e&&(e=He.builtinResMgr.get("normal-texture")),e},n=this._renderable._currentMaterial;if(null!==n){var s=this.getMaxLayer(),a=new Ti(1,1,1,1),o=new Ti(1,1,1,1),l=new Ti(0,0,0,0);if(0===s)if(-1!==this.layers[0]){var h=this._terrain.getLayer(this.layers[0]);null!==h&&(a.x=1/h.tileSize,o.x=h.roughness,l.x=h.metallic),n.setProperty("detailMap0",i(h)),t&&n.setProperty("normalMap0",r(h))}else n.setProperty("detailMap0",He.builtinResMgr.get("default-texture")),t&&n.setProperty("normalMap0",He.builtinResMgr.get("normal-texture"));else if(1===s){var u=this._terrain.getLayer(this.layers[0]),c=this._terrain.getLayer(this.layers[1]);null!==u&&(a.x=1/u.tileSize,o.x=u.roughness,l.x=u.metallic),null!==c&&(a.y=1/c.tileSize,o.y=c.roughness,l.y=c.metallic),n.setProperty("weightMap",this._weightMap),n.setProperty("detailMap0",i(u)),n.setProperty("detailMap1",i(c)),t&&(n.setProperty("normalMap0",r(u)),n.setProperty("normalMap1",r(c)))}else if(2===s){var _=this._terrain.getLayer(this.layers[0]),f=this._terrain.getLayer(this.layers[1]),p=this._terrain.getLayer(this.layers[2]);null!==_&&(a.x=1/_.tileSize,o.x=_.roughness,l.x=_.metallic),null!==f&&(a.y=1/f.tileSize,o.y=f.roughness,l.y=f.metallic),null!==p&&(a.z=1/p.tileSize,o.z=p.roughness,l.z=p.metallic),n.setProperty("weightMap",this._weightMap),n.setProperty("detailMap0",i(_)),n.setProperty("detailMap1",i(f)),n.setProperty("detailMap2",i(p)),t&&(n.setProperty("normalMap0",r(_)),n.setProperty("normalMap1",r(f)),n.setProperty("normalMap2",r(p)))}else if(3===s){var d=this._terrain.getLayer(this.layers[0]),m=this._terrain.getLayer(this.layers[1]),y=this._terrain.getLayer(this.layers[2]),g=this._terrain.getLayer(this.layers[3]);null!==d&&(a.x=1/d.tileSize,o.x=d.roughness,l.x=d.metallic),null!==m&&(a.y=1/m.tileSize,o.y=m.roughness,l.y=m.metallic),null!==y&&(a.z=1/y.tileSize,o.z=y.roughness,l.z=y.metallic),null!==g&&(a.w=1/g.tileSize,o.w=g.roughness,l.w=g.metallic),n.setProperty("weightMap",this._weightMap),n.setProperty("detailMap0",i(d)),n.setProperty("detailMap1",i(m)),n.setProperty("detailMap2",i(y)),n.setProperty("detailMap3",i(g)),t&&(n.setProperty("normalMap0",r(d)),n.setProperty("normalMap1",r(m)),n.setProperty("normalMap2",r(y)),n.setProperty("normalMap3",r(g)))}n.setProperty("UVScale",a),e&&(n.setProperty("roughness",o),n.setProperty("metallic",l)),null!==this.lightmap&&(n.setProperty("lightMap",this.lightmap),n.setProperty("lightMapUVParam",this.lightmapUVParam))}},e.setBrushMaterial=function(t){this._renderable._brushMaterial!==t&&(this._renderable._brushMaterial=t,this._renderable._invalidMaterial())},e.getTerrain=function(){return this._terrain},e.getIndex=function(){return this._index},e.getRect=function(){var t=new gr;return t.x=this._index[0]*zJ,t.y=this._index[1]*zJ,t.width=zJ,t.height=zJ,t},e.setLayer=function(t,e){this.layers[t]!==e&&(this._terrain.setBlockLayer(this._index[0],this._index[1],t,e),this._renderable._invalidMaterial(),this._updateMaterial(!1))},e.getLayer=function(t){return this.layers[t]},e.getMaxLayer=function(){return this.layers[3]>=0?3:this.layers[2]>=0?2:this.layers[1]>=0?1:0},e._getMaterialDefines=function(t){return{LAYERS:t+1,USE_LIGHTMAP:null!==this.lightmap?1:0,USE_NORMALMAP:this._terrain.useNormalMap?1:0,USE_PBR:this._terrain.usePBR?1:0}},e._invalidMaterial=function(){this._renderable._invalidMaterial()},e._updateMaterial=function(t){this._renderable._updateMaterial(this,t)},e._updateHeight=function(){if(null!=this._renderable._meshData){var t=new Float32Array(HJ*UJ*UJ),e=0;Z7.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),Q7.set(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(var i=0;i<UJ;++i)for(var r=0;r<UJ;++r){var n=this._index[0]*zJ+r,s=this._index[1]*zJ+i,a=this._terrain.getPosition(n,s),o=this._terrain.getNormal(n,s),l=new dr(r/UJ,i/UJ);t[e++]=a.x,t[e++]=a.y,t[e++]=a.z,t[e++]=o.x,t[e++]=o.y,t[e++]=o.z,t[e++]=l.x,t[e++]=l.y,ii.min(Z7,Z7,a),ii.max(Q7,Q7,a)}this._renderable._meshData.vertexBuffers[0].update(t),this._renderable._model.createBoundingShape(Z7,Q7),this._renderable._model.updateWorldBound()}},e._updateWeightMap=function(){if(0!==this.getMaxLayer()){null==this._weightMap&&(this._weightMap=new qe,this._weightMap.create(this._terrain.weightMapSize,this._terrain.weightMapSize,fr.RGBA8888),this._weightMap.setFilters(_r.LINEAR,_r.LINEAR),this._weightMap.setWrapMode(In.CLAMP_TO_EDGE,In.CLAMP_TO_EDGE));for(var t=new Uint8Array(this._terrain.weightMapSize*this._terrain.weightMapSize*4),e=0,i=0;i<this._terrain.weightMapSize;++i)for(var r=0;r<this._terrain.weightMapSize;++r){var n=this._index[0]*this._terrain.weightMapSize+r,s=this._index[1]*this._terrain.weightMapSize+i,a=this._terrain.getWeight(n,s);t[4*e+0]=Math.floor(255*a.x),t[4*e+1]=Math.floor(255*a.y),t[4*e+2]=Math.floor(255*a.z),t[4*e+3]=Math.floor(255*a.w),e+=1}this._weightMap.uploadData(t)}else null!=this._weightMap&&(this._weightMap.destroy(),this._weightMap=null)},e._updateLightmap=function(t){this._lightmapInfo=t,this._invalidMaterial()},Pe(t,[{key:"valid",get:function(){if(null===this._terrain)return!1;for(var t=this._terrain.getBlocks(),e=0;e<t.length;++e)if(t[e]===this)return!0;return!1}},{key:"layers",get:function(){return this._terrain.getBlockLayers(this._index[0],this._index[1])}},{key:"lightmap",get:function(){return this._lightmapInfo?this._lightmapInfo.texture:null}},{key:"lightmapUVParam",get:function(){return null!=this._lightmapInfo?new Ti(this._lightmapInfo.UOff,this._lightmapInfo.VOff,this._lightmapInfo.UScale,this._lightmapInfo.VScale):new Ti(0,0,0,0)}}]),t}());t("Terrain",(S7=ri("cc.Terrain"),A7=wi(),C7=bi(rK),x7=bi(_s),T7=Mi(),w7=bi(i9),E7=bi(fs),B7=bi(fs),D7=bi(fs),M7=bi(rK),P7=Mi(),R7=bi(_s),I7=Mi(),O7=bi($7),S7(F7=A7(F7=Si(F7=Br((H7=function(t){function e(){var e;e=t.call(this)||this,li(e,"__asset",V7,hi(e)),li(e,"_effectAsset",k7,hi(e)),li(e,"_lightmapInfos",N7,hi(e)),li(e,"_receiveShadow",G7,hi(e)),li(e,"_useNormalmap",z7,hi(e)),li(e,"_usePBR",U7,hi(e)),e._tileSize=1,e._blockCount=[1,1],e._weightMapSize=128,e._lightMapSize=128,e._heights=new Uint16Array,e._weights=new Uint8Array,e._normals=[],e._layerList=[],e._layerBuffer=[],e._blocks=[],e._sharedIndexBuffer=null;for(var i=0;i<GJ;++i)e._layerList.push(null);return e}Me(e,t);var i=e.prototype;return i.build=function(t){return this._tileSize=t.tileSize,this._blockCount[0]=t.blockCount[0],this._blockCount[1]=t.blockCount[1],this._weightMapSize=t.weightMapSize,this._lightMapSize=t.lightMapSize,this._buildImp()},i.rebuild=function(t){for(var e=0;e<this._blocks.length;++e)this._blocks[e].destroy();this._blocks=[],this._rebuildLayerBuffer(t),this._rebuildHeights(t),this._rebuildWeights(t),this._tileSize=t.tileSize,this._blockCount[0]=t.blockCount[0],this._blockCount[1]=t.blockCount[1],this._weightMapSize=t.weightMapSize,this._lightMapSize=t.lightMapSize,this._buildNormals();for(var i=0;i<this._blockCount[1];++i)for(var r=0;r<this._blockCount[0];++r)this._blocks.push(new r9(this,r,i));for(var n=0;n<this._blocks.length;++n)this._blocks[n].build()},i.importHeightField=function(t,e){for(var i=0,r=0;r<this.vertexCount[1];++r)for(var n=0;n<this.vertexCount[0];++n){var s=n/this.tileCount[0],a=r/this.tileCount[1],o=t.getAt(s*t.w,a*t.h)*e;this._heights[i++]=o}this._buildNormals();for(var l=0;l<this._blocks.length;++l)this._blocks[l]._updateHeight()},i.exportHeightField=function(t,e){for(var i=0,r=0;r<t.h;++r)for(var n=0;n<t.w;++n){var s=n/(t.w-1),a=r/(t.h-1),o=s*this.size.width,l=a*this.size.height,h=this.getHeightAt(o,l);null!=h&&(t.data[i++]=h*e)}},i.exportAsset=function(){var t=new rK;t.tileSize=this.tileSize,t.blockCount=this.blockCount,t.lightMapSize=this.lightMapSize,t.weightMapSize=this.weightMapSize,t.heights=this.heights,t.weights=this.weights,t.layerBuffer=new Array(4*this._blocks.length);for(var e=0;e<this._blocks.length;++e)t.layerBuffer[4*e+0]=this._blocks[e].layers[0],t.layerBuffer[4*e+1]=this._blocks[e].layers[1],t.layerBuffer[4*e+2]=this._blocks[e].layers[2],t.layerBuffer[4*e+3]=this._blocks[e].layers[3];for(var i=0;i<this._layerList.length;++i){var r=this._layerList[i];if(r&&r.detailMap&&ps(r.detailMap)){var n=new eK;n.slot=i,n.tileSize=r.tileSize,n.detailMap=r.detailMap,n.normalMap=r.normalMap,n.metallic=r.metallic,n.roughness=r.roughness,t.layerInfos.push(n)}}return t},i.getEffectAsset=function(){return null===this._effectAsset?He.EffectAsset.get("terrain"):this._effectAsset},i.onLoad=function(){for(var t=He.director.root.device,e=new Uint16Array(zJ*zJ*6),i=0,r=0;r<zJ;++r)for(var n=0;n<zJ;++n){var s=r*UJ+n,a=r*UJ+n+1,o=(r+1)*UJ+n,l=(r+1)*UJ+n+1;e[i++]=s,e[i++]=o,e[i++]=a,e[i++]=a,e[i++]=o,e[i++]=l}this._sharedIndexBuffer=t.createBuffer(new nt(d.INDEX|d.TRANSFER_DST,g.HOST|g.DEVICE,Uint16Array.BYTES_PER_ELEMENT*zJ*zJ*6,Uint16Array.BYTES_PER_ELEMENT)),this._sharedIndexBuffer.update(e)},i.onEnable=function(){0===this._blocks.length&&this._buildImp()},i.onDisable=function(){for(var t=0;t<this._blocks.length;++t)this._blocks[t].destroy();this._blocks=[]},i.onDestroy=function(){for(var t=0;t<this._blocks.length;++t)this._blocks[t].destroy();this._blocks=[];for(var e=0;e<this._layerList.length;++e)this._layerList[e]=null;null!=this._sharedIndexBuffer&&this._sharedIndexBuffer.destroy()},i.onRestore=function(){this.onDisable(),this.onLoad(),this._buildImp(!0)},i.update=function(){for(var t=0;t<this._blocks.length;++t)this._blocks[t].update()},i.addLayer=function(t){for(var e=0;e<this._layerList.length;++e){var i;if(null===this._layerList[e]||this._layerList[e]&&null===(null===(i=this._layerList[e])||void 0===i?void 0:i.detailMap))return this._layerList[e]=t,e}return-1},i.setLayer=function(t,e){this._layerList[t]=e},i.removeLayer=function(t){this._layerList[t]=null},i.getLayer=function(t){return-1===t?null:this._layerList[t]},i.getPosition=function(t,e){var i=t*this._tileSize,r=e*this._tileSize,n=this.getHeight(t,e);return new ii(i,n,r)},i.getHeightField=function(){return this._heights},i.setHeight=function(t,e,i){i=Gr(i,XJ,YJ),this._heights[e*this.vertexCount[0]+t]=jJ+i/WJ},i.getHeight=function(t,e){return(this._heights[e*this.vertexCount[0]+t]-jJ)*WJ},i.getHeightClamp=function(t,e){return t=Gr(t,0,this.vertexCount[0]-1),e=Gr(e,0,this.vertexCount[1]-1),this.getHeight(t,e)},i.getHeightAt=function(t,e){var i=t/this.tileSize,r=e/this.tileSize,n=Math.floor(i),s=Math.floor(r),a=n+1,o=s+1,l=i-n,h=r-s;if(n<0||n>this.vertexCount[0]-1||s<0||s>this.vertexCount[1]-1)return null;n=Gr(n,0,this.vertexCount[0]-1),s=Gr(s,0,this.vertexCount[1]-1),a=Gr(a,0,this.vertexCount[0]-1),o=Gr(o,0,this.vertexCount[1]-1);var u=this.getHeight(n,s),c=this.getHeight(a,s),_=this.getHeight(n,o),f=this.getHeight(a,o),p=.5*(c+_);return l+h<=1?f=p+(p-u):u=p+(p-f),(u*(1-l)+c*l)*(1-h)+(_*(1-l)+f*l)*h},i._setNormal=function(t,e,i){var r=e*this.vertexCount[0]+t;this._normals[3*r+0]=i.x,this._normals[3*r+1]=i.y,this._normals[3*r+2]=i.z},i.getNormal=function(t,e){var i=e*this.vertexCount[0]+t,r=new ii;return r.x=this._normals[3*i+0],r.y=this._normals[3*i+1],r.z=this._normals[3*i+2],r},i.getNormalAt=function(t,e){var i=t/this.tileSize,r=e/this.tileSize,n=Math.floor(i),s=Math.floor(r),a=n+1,o=s+1,l=i-n,h=r-s;if(n<0||n>this.vertexCount[0]-1||s<0||s>this.vertexCount[1]-1)return null;n=Gr(n,0,this.vertexCount[0]-1),s=Gr(s,0,this.vertexCount[1]-1),a=Gr(a,0,this.vertexCount[0]-1),o=Gr(o,0,this.vertexCount[1]-1);var u=this.getNormal(n,s),c=this.getNormal(a,s),_=this.getNormal(n,o),f=this.getNormal(a,o),p=new ii;ii.add(p,c,_).multiplyScalar(.5),l+h<=1?(f.set(p),f.subtract(u),f.add(p)):(u.set(p),u.subtract(f),u.add(p));var d=new ii,m=new ii,y=new ii;return ii.lerp(d,u,c,l),ii.lerp(m,_,f,l),ii.lerp(y,d,m,h),y},i.setWeight=function(t,e,i){var r=e*this._weightMapSize*this._blockCount[0]+t;this._weights[4*r+0]=255*i.x,this._weights[4*r+1]=255*i.y,this._weights[4*r+2]=255*i.z,this._weights[4*r+3]=255*i.w},i.getWeight=function(t,e){var i=e*this._weightMapSize*this._blockCount[0]+t,r=new Ti;return r.x=this._weights[4*i+0]/255,r.y=this._weights[4*i+1]/255,r.z=this._weights[4*i+2]/255,r.w=this._weights[4*i+3]/255,r},i.getWeightAt=function(t,e){var i=this.weightMapSize*this.blockCount[0],r=this.weightMapSize*this.blockCount[1];if(0===i||0===r)return null;var n=t/i,s=e/r,a=Math.floor(n),o=Math.floor(s),l=a+1,h=o+1,u=n-a,c=s-o;if(a<0||a>i-1||o<0||o>r-1)return null;a=Gr(a,0,i-1),o=Gr(o,0,r-1),l=Gr(l,0,i-1),h=Gr(h,0,r-1);var _=this.getWeight(a,o),f=this.getWeight(l,o),p=this.getWeight(a,h),d=this.getWeight(l,h),m=new Ti;Ti.add(m,f,p).multiplyScalar(.5),u+c<=1?(d=new Ti,Ti.subtract(d,m,_).add(m)):(_=new Ti,Ti.subtract(_,m,d).add(m));var y=new Ti,g=new Ti,v=new Ti;return Ti.lerp(y,_,f,u),Ti.lerp(g,p,d,u),Ti.lerp(v,y,g,c),v},i.getMaxWeightLayerAt=function(t,e){var i=this.weightMapSize*this.blockCount[0],r=this.weightMapSize*this.blockCount[1];if(0===i||0===r)return null;var n=t/i,s=e/r,a=Math.floor(n),o=Math.floor(s);if(a<0||a>i-1||o<0||o>r-1)return null;var l=this.getWeight(a,o),h=Math.floor(t/this.weightMapSize),u=Math.floor(e/this.weightMapSize),c=this.getBlock(h,u),_=0;return l.y>l[_]&&-1!==c.getLayer(1)&&(_=1),l.y>l[_]&&-1!==c.getLayer(2)&&(_=2),l.z>l[_]&&-1!==c.getLayer(3)&&(_=3),_=c.getLayer(_),this.getLayer(_)},i.getBlockLayers=function(t,e){var i=(e*this._blockCount[0]+t)*NJ;return[this._layerBuffer[i],this._layerBuffer[i+1],this._layerBuffer[i+2],this._layerBuffer[i+3]]},i.getBlockLayer=function(t,e,i){var r=(e*this._blockCount[0]+t)*NJ;return this._layerBuffer[r+i]},i.setBlockLayer=function(t,e,i,r){var n=(e*this._blockCount[0]+t)*NJ;this._layerBuffer[n+i]=r},i.getBlock=function(t,e){return this._blocks[e*this._blockCount[0]+t]},i.getBlocks=function(){return this._blocks},i.rayCheck=function(t,e,i,r){void 0===r&&(r=!0);var n=t;r&&ii.subtract(n,t,this.node.getWorldPosition());var s=new ii;s.set(e),s.multiplyScalar(i);var a=null;if(e.equals(new ii(0,1,0))){var o=this.getHeightAt(n.x,n.z);null!=o&&n.y<=o&&(a=new ii(n.x,o,n.z))}else if(e.equals(new ii(0,-1,0))){var l=this.getHeightAt(n.x,n.z);null!=l&&n.y>=l&&(a=new ii(n.x,l,n.z))}else{for(var h=0;h++<2e3;){var u=this.getHeightAt(n.x,n.z);if(null!=u&&n.y<=u)break;n.add(e)}for(;h++<2e3;){var c=this.getHeightAt(n.x,n.z);if(null!=c&&n.y<=c){a=new ii(n.x,c,n.z);break}n.add(s)}}return a},i._getSharedIndexBuffer=function(){return this._sharedIndexBuffer},i._resetLightmap=function(t){if(this._lightmapInfos.length=0,t)for(var e=0;e<this._blockCount[0]*this._blockCount[1];++e)this._lightmapInfos.push(new i9)},i._updateLightmap=function(t,e,i,r,n,s){this._lightmapInfos[t].texture=e,this._lightmapInfos[t].UOff=i,this._lightmapInfos[t].VOff=r,this._lightmapInfos[t].UScale=n,this._lightmapInfos[t].VScale=s,this._blocks[t]._updateLightmap(this._lightmapInfos[t])},i._getLightmapInfo=function(t,e){var i=e*this._blockCount[0]+t;return i<this._lightmapInfos.length?this._lightmapInfos[i]:null},i._calcNormal=function(t,e){var i,r,n=1,s=this.getPosition(t,e);t<this.vertexCount[0]-1?i=this.getPosition(t+1,e):(n*=-1,i=this.getPosition(t-1,e)),e<this.vertexCount[1]-1?r=this.getPosition(t,e+1):(n*=-1,r=this.getPosition(t,e-1)),i.subtract(s),r.subtract(s);var a=new ii;return a.set(r),a.cross(i),a.multiplyScalar(n),a.normalize(),a},i._buildNormals=function(){for(var t=0,e=0;e<this.vertexCount[1];++e)for(var i=0;i<this.vertexCount[0];++i){var r=this._calcNormal(i,e);this._normals[3*t+0]=r.x,this._normals[3*t+1]=r.y,this._normals[3*t+2]=r.z,t+=1}},i._buildImp=function(t){var e=this;if(void 0===t&&(t=!1),!this.valid){var i=this.__asset;if(!t&&null!==i){this._tileSize=i.tileSize,this._blockCount=i.blockCount,this._weightMapSize=i.weightMapSize,this._lightMapSize=i.lightMapSize,this._heights=i.heights,this._weights=i.weights,this._layerBuffer=i.layerBuffer;for(var r=0;r<this._layerList.length;++r)this._layerList[r]=null;if(i.version<QJ)for(var n=function(t){var r=new t9,n=i.layerBinaryInfos[t];r.tileSize=n.tileSize,He.assetManager.loadAny(n.detailMapId,(function(t,e){r.detailMap=e})),""!==n.normalMapId&&He.assetManager.loadAny(n.normalMapId,(function(t,e){r.normalMap=e})),r.roughness=n.roughness,r.metallic=n.metallic,e._layerList[n.slot]=r},s=0;s<i.layerBinaryInfos.length;++s)n(s);else for(var a=0;a<i.layerInfos.length;++a){var o=new t9,l=i.layerInfos[a];o.tileSize=l.tileSize,o.detailMap=l.detailMap,o.normalMap=l.normalMap,o.roughness=l.roughness,o.metallic=l.metallic,this._layerList[l.slot]=o}}if(0!==this._blockCount[0]&&0!==this._blockCount[1]){var h=this.vertexCount[0]*this.vertexCount[1];if(null===this._heights||this._heights.length!==h){this._heights=new Uint16Array(h),this._normals=new Array(3*h);for(var u=0;u<h;++u)this._heights[u]=jJ,this._normals[3*u+0]=0,this._normals[3*u+1]=1,this._normals[3*u+2]=0}else this._normals=new Array(3*h),this._buildNormals();var c=this.blockCount[0]*this.blockCount[1]*NJ;if(null===this._layerBuffer||this._layerBuffer.length!==c){this._layerBuffer=new Array(c);for(var _=0;_<c;++_)this._layerBuffer[_]=-1}var f=this._weightMapSize*this._blockCount[0],p=this._weightMapSize*this._blockCount[1];if(this._weights.length!==f*p*4){this._weights=new Uint8Array(f*p*4);for(var d=0;d<f*p;++d)this._weights[4*d+0]=255,this._weights[4*d+1]=0,this._weights[4*d+2]=0,this._weights[4*d+3]=0}for(var m=0;m<this._blockCount[1];++m)for(var y=0;y<this._blockCount[0];++y)this._blocks.push(new r9(this,y,m));for(var g=0;g<this._blocks.length;++g)this._blocks[g].build()}}},i._rebuildHeights=function(t){if(this.vertexCount[0]===t.vertexCount[0]&&this.vertexCount[1]===t.vertexCount[1])return!1;for(var e=new Uint16Array(t.vertexCount[0]*t.vertexCount[1]),i=0;i<e.length;++i)e[i]=jJ;for(var r=Math.min(this.vertexCount[0],t.vertexCount[0]),n=Math.min(this.vertexCount[1],t.vertexCount[1]),s=0;s<n;++s)for(var a=0;a<r;++a){var o=s*t.vertexCount[0]+a,l=s*this.vertexCount[0]+a;e[o]=this._heights[l]}return this._heights=e,!0},i._rebuildLayerBuffer=function(t){if(this.blockCount[0]===t.blockCount[0]&&this.blockCount[1]===t.blockCount[1])return!1;var e=[];e.length=t.blockCount[0]*t.blockCount[1]*NJ;for(var i=0;i<e.length;++i)e[i]=-1;for(var r=Math.min(this.blockCount[0],t.blockCount[0]),n=Math.min(this.blockCount[1],t.blockCount[1]),s=0;s<n;++s)for(var a=0;a<r;++a)for(var o=s*t.blockCount[0]+a,l=s*this.blockCount[0]+a,h=0;h<NJ;++h)e[o*NJ+h]=this._layerBuffer[l*NJ+h];return this._layerBuffer=e,!0},i._rebuildWeights=function(t){var e=this,i=this._weightMapSize,r=this._weightMapSize*this._blockCount[0],n=this._weightMapSize*this._blockCount[1],s=t.weightMapSize*t.blockCount[0],a=t.weightMapSize*t.blockCount[1];if(s===r&&a===n)return!1;for(var o=new Uint8Array(s*a*4),l=0;l<s*a;++l)o[4*l+0]=255,o[4*l+1]=0,o[4*l+2]=0,o[4*l+3]=0;for(var h=Math.min(t.blockCount[0],this._blockCount[0]),u=Math.min(t.blockCount[1],this._blockCount[1]),c=function(t,e,i){var n=e*r+t,s=new Ti;return s.x=i[4*n+0]/255,s.y=i[4*n+1]/255,s.z=i[4*n+2]/255,s.w=i[4*n+3]/255,s},_=function(t,i,r,n){var s=Math.floor(t),a=Math.floor(i),o=s+1,l=a+1,h=t-s,u=i-a,_=c(s+r,a+n,e._weights),f=c(o+r,a+n,e._weights),p=c(s+r,l+n,e._weights),d=c(o+r,l+n,e._weights),m=new Ti;Ti.add(m,f,p).multiplyScalar(.5),h+u<=1?(d.set(m),d.subtract(_),d.add(m)):(_.set(m),_.subtract(d),_.add(m));var y=new Ti,g=new Ti,v=new Ti;return Ti.lerp(y,_,f,h),Ti.lerp(g,p,d,h),Ti.lerp(v,y,g,u),v},f=0;f<u;++f)for(var p=0;p<h;++p)for(var d=p*i,m=f*i,y=0;y<t.weightMapSize;++y)for(var g=0;g<t.weightMapSize;++g){var v=void 0;v=t.weightMapSize===i?c(g+d,y+m,this._weights):_(g/(t.weightMapSize-1)*(i-1),y/(t.weightMapSize-1)*(i-1),d,m,this._weights);var b=p*t.weightMapSize+g,S=(f*t.weightMapSize+y)*s+b;o[4*S+0]=255*v.x,o[4*S+1]=255*v.y,o[4*S+2]=255*v.z,o[4*S+3]=255*v.w}return this._weights=o,!0},Pe(e,[{key:"_asset",get:function(){return this.__asset},set:function(t){if(this.__asset!==t&&(this.__asset=t,null!=this.__asset&&this.valid)){for(var e=0;e<this._blocks.length;++e)this._blocks[e].destroy();this._blocks=[],this._buildImp()}}},{key:"effectAsset",get:function(){return this._effectAsset},set:function(t){if(this._effectAsset!==t){this._effectAsset=t;for(var e=0;e<this._blocks.length;++e)this._blocks[e]._invalidMaterial()}}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(t){this._receiveShadow=t;for(var e=0;e<this._blocks.length;e++)this._blocks[e]._invalidMaterial()}},{key:"useNormalMap",get:function(){return this._useNormalmap},set:function(t){this._useNormalmap=t;for(var e=0;e<this._blocks.length;e++)this._blocks[e]._invalidMaterial()}},{key:"usePBR",get:function(){return this._usePBR},set:function(t){this._usePBR=t;for(var e=0;e<this._blocks.length;e++)this._blocks[e]._invalidMaterial()}},{key:"size",get:function(){var t=new vr(0,0);return t.width=this.blockCount[0]*zJ*this.tileSize,t.height=this.blockCount[1]*zJ*this.tileSize,t}},{key:"tileSize",get:function(){return this._tileSize}},{key:"tileCount",get:function(){return[this.blockCount[0]*zJ,this.blockCount[1]*zJ]}},{key:"vertexCount",get:function(){var t=this.tileCount;return t[0]+=1,t[1]+=1,t}},{key:"blockCount",get:function(){return this._blockCount}},{key:"lightMapSize",get:function(){return this._lightMapSize}},{key:"weightMapSize",get:function(){return this._weightMapSize}},{key:"heights",get:function(){return this._heights}},{key:"weights",get:function(){return this._weights}},{key:"valid",get:function(){return this._blocks.length>0}},{key:"info",get:function(){var t=new $7;return t.tileSize=this.tileSize,t.blockCount[0]=this.blockCount[0],t.blockCount[1]=this.blockCount[1],t.weightMapSize=this.weightMapSize,t.lightMapSize=this.lightMapSize,t}}]),e}(zi),V7=oi((L7=H7).prototype,"__asset",[C7,_i,xi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),k7=oi(L7.prototype,"_effectAsset",[x7,_i,xi,T7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),N7=oi(L7.prototype,"_lightmapInfos",[w7,_i,xi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),G7=oi(L7.prototype,"_receiveShadow",[E7,_i,xi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),z7=oi(L7.prototype,"_useNormalmap",[B7,_i,xi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),U7=oi(L7.prototype,"_usePBR",[D7,_i,xi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(L7.prototype,"_asset",[M7,P7],Object.getOwnPropertyDescriptor(L7.prototype,"_asset"),L7.prototype),oi(L7.prototype,"effectAsset",[R7,I7],Object.getOwnPropertyDescriptor(L7.prototype,"effectAsset"),L7.prototype),oi(L7.prototype,"receiveShadow",[vi],Object.getOwnPropertyDescriptor(L7.prototype,"receiveShadow"),L7.prototype),oi(L7.prototype,"useNormalMap",[vi],Object.getOwnPropertyDescriptor(L7.prototype,"useNormalMap"),L7.prototype),oi(L7.prototype,"usePBR",[vi],Object.getOwnPropertyDescriptor(L7.prototype,"usePBR"),L7.prototype),oi(L7.prototype,"info",[O7],Object.getOwnPropertyDescriptor(L7.prototype,"info"),L7.prototype),F7=L7))||F7)||F7)||F7)||F7)),function(t){t[t.ORTHO=0]="ORTHO",t[t.HEX=1]="HEX",t[t.ISO=2]="ISO"}(j7||(j7={})),Pr(j7),function(t){t[t.NONE=0]="NONE",t[t.MAP=1]="MAP",t[t.LAYER=2]="LAYER",t[t.OBJECTGROUP=3]="OBJECTGROUP",t[t.OBJECT=4]="OBJECT",t[t.TILE=5]="TILE"}(W7||(W7={})),Pr(W7),function(t){t[t.HORIZONTAL=2147483648]="HORIZONTAL",t[t.VERTICAL=1073741824]="VERTICAL",t[t.DIAGONAL=536870912]="DIAGONAL",t[t.FLIPPED_ALL=4026531840]="FLIPPED_ALL",t[t.FLIPPED_MASK=268435455]="FLIPPED_MASK"}(X7||(X7={})),Pr(X7),function(t){t[t.STAGGERAXIS_X=0]="STAGGERAXIS_X",t[t.STAGGERAXIS_Y=1]="STAGGERAXIS_Y"}(Y7||(Y7={})),Pr(Y7),function(t){t[t.STAGGERINDEX_ODD=0]="STAGGERINDEX_ODD",t[t.STAGGERINDEX_EVEN=1]="STAGGERINDEX_EVEN"}(q7||(q7={})),Pr(q7),function(t){t[t.RightDown=0]="RightDown",t[t.RightUp=1]="RightUp",t[t.LeftDown=2]="LeftDown",t[t.LeftUp=3]="LeftUp"}(J7||(J7={})),Pr(J7),function(t){t[t.RECT=0]="RECT",t[t.ELLIPSE=1]="ELLIPSE",t[t.POLYGON=2]="POLYGON",t[t.POLYLINE=3]="POLYLINE",t[t.IMAGE=4]="IMAGE",t[t.TEXT=5]="TEXT"}(K7||(K7={})),Pr(K7);var n9=function(){function t(){this.name="",this.firstGid=0,this.spacing=0,this.margin=0,this.sourceImage=void 0,this.imageName=null,this.imageSize=new vr(0,0),this.tileOffset=new dr(0,0),this._tileSize=new vr(0,0),this.collection=!1}return t.prototype.rectForGID=function(t,e){var i=e||new gr(0,0,0,0);i.width=this._tileSize.width,i.height=this._tileSize.height;var r=t;r&=X7.FLIPPED_MASK,r-=this.firstGid;var n=Math.floor((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing));return i.x=Math.round(r%n*(this._tileSize.width+this.spacing)+this.margin),i.y=Math.round(Math.floor(r/n)*(this._tileSize.height+this.spacing)+this.margin),i},t}(),s9=function(){function t(){this.properties={},this.name="",this.objects=[],this.visible=!0,this.opacity=0,this.color=new Ui(255,255,255,255),this.offset=new dr(0,0),this.draworder="topdown",this.tintColor=null}var e=t.prototype;return e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},t}(),a9=function(){function t(){this.properties={},this.name="",this.layerSize=null,this.tiles=[],this.visible=!0,this.opacity=0,this.ownTiles=!0,this.minGID=1e5,this.maxGID=0,this.offset=new dr(0,0),this.tintColor=null}var e=t.prototype;return e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},t}();a9.ATTRIB_NONE=1,a9.ATTRIB_BASE64=2,a9.ATTRIB_GZIP=4,a9.ATTRIB_ZLIB=8;var o9=function(){this.name="",this.visible=!0,this.width=0,this.height=0,this.offset=new dr(0,0),this.opacity=0,this.trans=new Ui(255,255,255,255),this.sourceImage=void 0,this.tintColor=null};function l9(t){var e=wp.HorizontalAlign;switch(t){case"center":return e.CENTER;case"right":return e.RIGHT;default:return e.LEFT}}function h9(t){var e=wp.VerticalAlign;switch(t){case"center":return e.CENTER;case"bottom":return e.BOTTOM;default:return e.TOP}}function u9(t){if(!t)return new Ui(0,0,0,255);if(8===(t=-1!==t.indexOf("#")?t.substring(1):t).length){var e=parseInt(t.substr(0,2),16)||255,i=parseInt(t.substr(2,2),16)||0,r=parseInt(t.substr(4,2),16)||0,n=parseInt(t.substr(6,2),16)||0;return new Ui(i,r,n,e)}var s=parseInt(t.substr(0,2),16)||0,a=parseInt(t.substr(2,2),16)||0,o=parseInt(t.substr(4,2),16)||0;return new Ui(s,a,o,255)}function c9(t,e){for(var i=[],r=t.getElementsByTagName("properties"),n=0;n<r.length;++n)for(var s=r[n].getElementsByTagName("property"),a=0;a<s.length;++a)i.push(s[a]);e=e||{};for(var o=0;o<i.length;o++){var l=i[o],h=l.getAttribute("name"),u=l.getAttribute("type")||"string",c=l.getAttribute("value");"int"===u?c=parseInt(c):"float"===u?c=parseFloat(c):"bool"===u?c="true"===c:"color"===u&&(c=u9(c)),e[h]=c}return e}var _9,f9,p9,d9,m9,y9,g9,v9,b9,S9,A9,C9,x9,T9,w9,E9=function(){function t(t,e,i,r,n){this.properties={},this.orientation=null,this.parentElement=null,this.parentGID=0,this.layerAttrs=0,this.storingCharacters=!1,this.currentString=null,this.renderOrder=J7.RightDown,this._supportVersion=[1,4,0],this._objectGroups=[],this._allChildren=[],this._mapSize=new vr(0,0),this._tileSize=new vr(0,0),this._layers=[],this._tilesets=[],this._imageLayers=[],this._tileProperties=new Map,this._tileAnimations={},this._tsxContentMap=null,this._spriteFrameMap=null,this._spfSizeMap={},this._staggerAxis=null,this._staggerIndex=null,this._hexSideLength=0,this._imageLayerSPF=null,this.initWithXML(t,e,i,r,n)}var e=t.prototype;return e.getOrientation=function(){return this.orientation},e.setOrientation=function(t){this.orientation=t},e.getStaggerAxis=function(){return this._staggerAxis},e.setStaggerAxis=function(t){this._staggerAxis=t},e.getStaggerIndex=function(){return this._staggerIndex},e.setStaggerIndex=function(t){this._staggerIndex=t},e.getHexSideLength=function(){return this._hexSideLength},e.setHexSideLength=function(t){this._hexSideLength=t},e.getMapSize=function(){return new vr(this._mapSize.width,this._mapSize.height)},e.setMapSize=function(t){this._mapSize.width=t.width,this._mapSize.height=t.height},e.getTileSize=function(){return new vr(this._tileSize.width,this._tileSize.height)},e.setTileSize=function(t){this._tileSize.width=t.width,this._tileSize.height=t.height},e.getLayers=function(){return this._layers},e.setLayers=function(t){this._allChildren.push(t),this._layers.push(t)},e.getImageLayers=function(){return this._imageLayers},e.setImageLayers=function(t){this._allChildren.push(t),this._imageLayers.push(t)},e.getTilesets=function(){return this._tilesets},e.setTilesets=function(t){this._tilesets.push(t)},e.getObjectGroups=function(){return this._objectGroups},e.setObjectGroups=function(t){this._allChildren.push(t),this._objectGroups.push(t)},e.getAllChildren=function(){return this._allChildren},e.getParentElement=function(){return this.parentElement},e.setParentElement=function(t){this.parentElement=t},e.getParentGID=function(){return this.parentGID},e.setParentGID=function(t){this.parentGID=t},e.getLayerAttribs=function(){return this.layerAttrs},e.setLayerAttribs=function(t){this.layerAttrs=t},e.getStoringCharacters=function(){return this.storingCharacters},e.setStoringCharacters=function(t){this.storingCharacters=t},e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},e.initWithXML=function(t,e,i,r,n){return this._tilesets.length=0,this._layers.length=0,this._imageLayers.length=0,this._tsxContentMap=e,this._spriteFrameMap=i,this._imageLayerSPF=n,this._spfSizeMap=r,this._objectGroups.length=0,this._allChildren.length=0,this.properties={},this._tileProperties=new Map,this._tileAnimations=new Map,this.currentString="",this.storingCharacters=!1,this.layerAttrs=a9.ATTRIB_NONE,this.parentElement=null,this.parseXMLString(t)},e.parseXMLString=function(e,i){var r,n=(new ds).parse(e).documentElement,s=n.getAttribute("orientation"),a=n.getAttribute("staggeraxis"),o=n.getAttribute("staggerindex"),l=n.getAttribute("hexsidelength"),h=n.getAttribute("renderorder"),u=n.getAttribute("version")||"1.0.0";if("map"===n.nodeName){var c=u.split("."),_=this._supportVersion;for(r=0;r<_.length;r++){var f=parseInt(c[r])||0;if(_[r]<f){an(7216,u);break}}"orthogonal"===s?this.orientation=j7.ORTHO:"isometric"===s?this.orientation=j7.ISO:"hexagonal"===s?this.orientation=j7.HEX:null!==s&&an(7217,s),this.renderOrder="right-up"===h?J7.RightUp:"left-up"===h?J7.LeftUp:"left-down"===h?J7.LeftDown:J7.RightDown,"x"===a?this.setStaggerAxis(Y7.STAGGERAXIS_X):"y"===a&&this.setStaggerAxis(Y7.STAGGERAXIS_Y),"odd"===o?this.setStaggerIndex(q7.STAGGERINDEX_ODD):"even"===o&&this.setStaggerIndex(q7.STAGGERINDEX_EVEN),l&&this.setHexSideLength(parseFloat(l));var p=new vr(0,0);p.width=parseFloat(n.getAttribute("width")),p.height=parseFloat(n.getAttribute("height")),this.setMapSize(p),(p=new vr(0,0)).width=parseFloat(n.getAttribute("tilewidth")),p.height=parseFloat(n.getAttribute("tileheight")),this.setTileSize(p),this.properties=c9(n)}var d=n.getElementsByTagName("tileset");for("map"!==n.nodeName&&(d=[]).push(n),r=0;r<d.length;r++){var m=d[r],y=m.getAttribute("source");if(y){var g=parseInt(m.getAttribute("firstgid")),v=this._tsxContentMap[y];v&&this.parseXMLString(v,g)}else{var b=m.getElementsByTagName("image"),S=b.length>1,A=b[0],C=A.getAttribute("source");C=C.replace(/\\/g,"/");var x=m.getElementsByTagName("tile"),T=x&&x.length||1,w=null,E=m.getAttribute("name")||"",B=parseInt(m.getAttribute("spacing"))||0,D=parseInt(m.getAttribute("margin"))||0,M=i||parseInt(m.getAttribute("firstgid"))||0,P=new vr(0,0);P.width=parseFloat(m.getAttribute("tilewidth")),P.height=parseFloat(m.getAttribute("tileheight"));var R=m.getElementsByTagName("tileoffset")[0],I=0,O=0;R&&(I=parseFloat(R.getAttribute("x"))||0,O=parseFloat(R.getAttribute("y"))||0);for(var F=null,L=0;L<T;L++){if(!F||S){if((F=new n9).name=E,F.firstGid=M&X7.FLIPPED_MASK,F.tileOffset.x=I,F.tileOffset.y=O,F.collection=S,!S&&(F.imageName=C,F.imageSize.width=parseFloat(A.getAttribute("width"))||0,F.imageSize.height=parseFloat(A.getAttribute("height"))||0,F.sourceImage=this._spriteFrameMap[C],!F.sourceImage)){var V=t.getNameWithPostfix(C);if(F.imageName=V,F.sourceImage=this._spriteFrameMap[V],!F.sourceImage){var k=t.getShortName(C);F.imageName=k,F.sourceImage=this._spriteFrameMap[k],F.sourceImage||(console.error("[error]: "+k+" not find in ["+Object.keys(this._spriteFrameMap).join(", ")+"]"),Re(7221,C),console.warn("Please try asset type of "+C+" to 'sprite-frame'"))}}F.spacing=B,F.margin=D,F._tileSize.width=P.width,F._tileSize.height=P.height,this.setTilesets(F)}if(w=x&&x[L]){this.parentGID=M+(parseInt(w.getAttribute("id"))||0);var N=w.getElementsByTagName("image");if(N&&N.length>0){var G=N[0],z=G.getAttribute("source");if(z=z.replace(/\\/g,"/"),F.imageName=z,F.imageSize.width=parseFloat(G.getAttribute("width"))||0,F.imageSize.height=parseFloat(G.getAttribute("height"))||0,F._tileSize.width=F.imageSize.width,F._tileSize.height=F.imageSize.height,F.sourceImage=this._spriteFrameMap[z],!F.sourceImage){var U=t.getNameWithPostfix(C);if(F.imageName=U,F.sourceImage=this._spriteFrameMap[U],!F.sourceImage){var H=t.getShortName(z);F.imageName=H,F.sourceImage=this._spriteFrameMap[H],F.sourceImage||(Re(7221,z),console.warn("Please try asset type of "+z+" to 'sprite-frame'"))}}F.firstGid=this.parentGID&X7.FLIPPED_MASK}var j=(X7.FLIPPED_MASK&this.parentGID)>>>0;this._tileProperties.set(j,c9(w));var W=w.getElementsByTagName("animation");if(W&&W.length>0){var X=W[0].getElementsByTagName("frame"),Y={frames:[],dt:0,frameIdx:0};this._tileAnimations.set(j,Y);for(var q=Y.frames,J=0;J<X.length;J++){var K=X[J],Z=M+(parseInt(K.getAttribute("tileid"))||0),Q=parseFloat(K.getAttribute("duration"))||0;q.push({tileid:Z,duration:Q/1e3,grid:null})}}}}}}var $=n.childNodes;for(r=0;r<$.length;r++){var tt=$[r];if(!this._shouldIgnoreNode(tt)){if("imagelayer"===tt.nodeName){var et=this._parseImageLayer(tt);et&&this.setImageLayers(et)}if("layer"===tt.nodeName){var it=this._parseLayer(tt);this.setLayers(it)}if("objectgroup"===tt.nodeName){var rt=this._parseObjectGroup(tt);this.setObjectGroups(rt)}}}return n},e._shouldIgnoreNode=function(t){return 3===t.nodeType||8===t.nodeType||4===t.nodeType},e._parseImageLayer=function(t){var e=t.getElementsByTagName("image");if(!e||0===e.length)return null;var i=new o9;i.name=t.getAttribute("name"),i.offset.x=parseFloat(t.getAttribute("offsetx"))||0,i.offset.y=parseFloat(t.getAttribute("offsety"))||0;var r=t.getAttribute("visible");i.visible=!("0"===r);var n=t.getAttribute("opacity");i.opacity=n?Math.round(255*parseFloat(n)):255;var s=t.getAttribute("tintcolor");i.tintColor=s?u9(s):null;var a=e[0],o=a.getAttribute("source");return i.sourceImage=this._imageLayerSPF[o],i.width=parseInt(a.getAttribute("width"))||0,i.height=parseInt(a.getAttribute("height"))||0,i.trans=u9(a.getAttribute("trans")),i.sourceImage?i:(Re(7221,o),console.warn("Please try asset type of "+o+" to 'sprite-frame'"),null)},e._parseLayer=function(t){var e=t.getElementsByTagName("data")[0],i=new a9;i.name=t.getAttribute("name");var r=new vr(0,0);r.width=parseFloat(t.getAttribute("width")),r.height=parseFloat(t.getAttribute("height")),i.layerSize=r;var n=t.getAttribute("visible");i.visible=!("0"===n);var s=t.getAttribute("opacity");i.opacity=s?Math.round(255*parseFloat(s)):255,i.offset=new dr(parseFloat(t.getAttribute("offsetx"))||0,parseFloat(t.getAttribute("offsety"))||0);var a=t.getAttribute("tintcolor");i.tintColor=a?u9(a):null;for(var o="",l=0;l<e.childNodes.length;l++)o+=e.childNodes[l].nodeValue;o=o.trim();var h,u=e.getAttribute("compression"),c=e.getAttribute("encoding");if(u&&"gzip"!==u&&"zlib"!==u)return an(7218),null;switch(u){case"gzip":h=z5.unzipBase64AsArray(o,4);break;case"zlib":h=function(t){if(t.length%4!=0)return null;for(var e=t.length/4,i=window.Uint32Array?new Uint32Array(e):[],r=0;r<e;r++){var n=4*r;i[r]=t[n]+256*t[n+1]+65536*t[n+2]+t[n+3]*(1<<24)}return i}(new H2.Inflate(z5.Base64.decodeAsArray(o,1)).decompress());break;case null:case"":if("base64"===c)h=z5.Base64.decodeAsArray(o,4);else if("csv"===c){h=[];for(var _=o.split(","),f=0;f<_.length;f++)h.push(parseInt(_[f]))}else{var p=e.getElementsByTagName("tile");h=[];for(var d=0;d<p.length;d++)h.push(parseInt(p[d].getAttribute("gid")))}break;default:this.layerAttrs===a9.ATTRIB_NONE&&an(7219)}return h&&(i.tiles=new Uint32Array(h)),i.properties=c9(t),i},e._parseObjectGroup=function(t){var e=new s9;e.name=t.getAttribute("name")||"",e.offset=new dr(parseFloat(t.getAttribute("offsetx")),parseFloat(t.getAttribute("offsety")));var i=t.getAttribute("opacity");e.opacity=i?Math.round(255*parseFloat(i)):255;var r=t.getAttribute("tintcolor");e.tintColor=r?u9(r):null;var n=t.getAttribute("visible");n&&0===parseInt(n)&&(e.visible=!1);var s=t.getAttribute("color");s&&e.color.fromHEX(s);var a=t.getAttribute("draworder");a&&(e.draworder=a),e.setProperties(c9(t));var o=t.getElementsByTagName("object");if(o){for(var l=0;l<o.length;l++){var h=o[l],u={};u.id=h.getAttribute("id")||l,u.name=h.getAttribute("name")||"",u.width=parseFloat(h.getAttribute("width"))||0,u.height=parseFloat(h.getAttribute("height"))||0,u.x=parseFloat(h.getAttribute("x"))||0,u.y=parseFloat(h.getAttribute("y"))||0,u.rotation=parseFloat(h.getAttribute("rotation"))||0,c9(h,u);var c=h.getAttribute("visible");u.visible=!(c&&0===parseInt(c));var _=h.getElementsByTagName("text");if(_&&_.length>0){var f=_[0];u.type=K7.TEXT,u.wrap="1"===f.getAttribute("wrap"),u.color=u9(f.getAttribute("color")),u.halign=l9(f.getAttribute("halign")),u.valign=h9(f.getAttribute("valign")),u.pixelsize=parseInt(f.getAttribute("pixelsize"))||16,u.text=f.childNodes[0].nodeValue}var p=h.getAttribute("gid");p&&(u.gid=parseInt(p),u.type=K7.IMAGE);var d=h.getElementsByTagName("ellipse");d&&d.length>0&&(u.type=K7.ELLIPSE);var m=h.getElementsByTagName("polygon");if(m&&m.length>0){u.type=K7.POLYGON;var y=m[0].getAttribute("points");y&&(u.points=this._parsePointsString(y))}var g=h.getElementsByTagName("polyline");if(g&&g.length>0){u.type=K7.POLYLINE;var v=g[0].getAttribute("points");v&&(u.polylinePoints=this._parsePointsString(v))}u.type||(u.type=K7.RECT),e.objects.push(u)}"index"!==a&&e.objects.sort((function(t,e){return t.y-e.y}))}return e},e._parsePointsString=function(t){if(!t)return null;for(var e=[],i=t.split(" "),r=0;r<i.length;r++){var n=i[r].split(",");e.push({x:parseFloat(n[0]),y:parseFloat(n[1])})}return e},e.setTileAnimations=function(t){this._tileAnimations=t},e.getTileAnimations=function(){return this._tileAnimations},e.getTileProperties=function(){return this._tileProperties},e.setTileProperties=function(t){this._tileProperties=t},e.getCurrentString=function(){return this.currentString},e.setCurrentString=function(t){this.currentString=t},t.getNameWithPostfix=function(t){var e=(t=t.replace(/\\/g,"/")).lastIndexOf("/")+1,i=t.length;return t.substring(e,i)},t.getShortName=function(t){var e=(t=t.replace(/\\/g,"/")).lastIndexOf("/")+1,i=t.lastIndexOf(".");return i=i<0?t.length:i,t.substring(e,i)},Pe(t,[{key:"mapSize",get:function(){return this._mapSize}},{key:"tileSize",get:function(){return this._tileSize}},{key:"mapWidth",get:function(){return this._mapSize.width},set:function(t){this._mapSize.width=t}},{key:"mapHeight",get:function(){return this._mapSize.height},set:function(t){this._mapSize.height=t}},{key:"tileWidth",get:function(){return this._tileSize.width},set:function(t){this._tileSize.width=t}},{key:"tileHeight",get:function(){return this._tileSize.height},set:function(t){this._tileSize.height=t}}]),t}(),B9=t("TiledTile",(_9=ri("cc.TiledTile"),f9=wi(),p9=Bi(),d9=bi(ms),m9=bi(ms),y9=bi(ms),g9=bi(ms),v9=bi(ms),_9(b9=f9(b9=p9((x9=function(t){function e(){var e;return(e=t.call(this)||this)._layer=null,li(e,"_x",A9,hi(e)),li(e,"_y",C9,hi(e)),e}Me(e,t);var i=e.prototype;return i.onEnable=function(){var t=this.node.parent;this._layer=t.getComponent("cc.TiledLayer"),this._resetTile(),this.updateInfo()},i.onDisable=function(){this._resetTile()},i._resetTile=function(){this._layer&&this._layer.getTiledTileAt(this._x,this._y)===this&&this._layer.setTiledTileAt(this._x,this._y,null)},i.updateInfo=function(){if(this._layer){var t=this._x,e=this._y;if(this._layer.getTiledTileAt(t,e))Ue("There is already a TiledTile at [%s, %s]",t,e);else{var i=this._layer.getPositionAt(t,e);this.node.setPosition(i.x,i.y),this._layer.setTiledTileAt(t,e,this)}}},Pe(e,[{key:"x",get:function(){return this._x},set:function(t){t!==this._x&&(this._layer&&this._layer.isInvalidPosition(t,this._y)?Ue("Invalid x, the valid value is between [%s] ~ [%s]",0,this._layer.layerSize.width):(this._resetTile(),this._x=t,this.updateInfo()))}},{key:"y",get:function(){return this._y},set:function(t){t!==this._y&&(this._layer&&this._layer.isInvalidPosition(this._x,t)?Ue("Invalid y, the valid value is between [%s] ~ [%s]",0,this._layer.layerSize.height):(this._resetTile(),this._y=t,this.updateInfo()))}},{key:"grid",get:function(){return this._layer?this._layer.getTileGIDAt(this._x,this._y):0},set:function(t){this._layer&&this._layer.setTileGIDAt(t,this._x,this._y)}}]),e}(zi),A9=oi((S9=x9).prototype,"_x",[d9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),C9=oi(S9.prototype,"_y",[m9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),oi(S9.prototype,"x",[y9],Object.getOwnPropertyDescriptor(S9.prototype,"x"),S9.prototype),oi(S9.prototype,"y",[g9],Object.getOwnPropertyDescriptor(S9.prototype,"y"),S9.prototype),oi(S9.prototype,"grid",[v9],Object.getOwnPropertyDescriptor(S9.prototype,"grid"),S9.prototype),b9=S9))||b9)||b9)||b9));function D9(t,e,i){var r=i||t.sourceImage,n=r.texture,s=t.collection;if(!t.imageSize.width||!t.imageSize.height){var a=t.sourceImage;t.imageSize.width=a.width,t.imageSize.height=a.height}var o=t.imageSize.width,l=t.imageSize.height,h=t._tileSize.width,u=t._tileSize.height,c=r.width,_=r.height,f=t.spacing,p=t.margin,d=1;if(!s){var m=Math.floor((o-2*p+f)/(h+f)),y=Math.floor((l-2*p+f)/(u+f));d=Math.max(1,y*m)}for(var g=t.firstGid,v=null,b=!!e.get(g),S=t.firstGid+d,A=g;A<S&&(b&&!e.get(A)&&(b=!1),b||!e.get(A));++A){if(v={tileset:t,x:0,y:0,width:h,height:u,t:0,l:0,r:0,b:0,cx:0,cy:0,offsetX:0,offsetY:0,rotated:!1,gid:A,spriteFrame:r,texture:n},t.rectForGID(A,v),!i||d>1)if(i){v._name=i.name;var C=i.unbiasUV[0],x=i.rotated?i.unbiasUV[1]:i.unbiasUV[5];v.l=C+(v.x+.5)/c,v.t=x+(v.y+.5)/_,v.r=C+(v.x+v.width-.5)/c,v.b=x+(v.y+v.height-.5)/_,v._rect=new gr(v.x,v.y,v.width,v.height)}else v.l=v.x/c,v.t=v.y/_,v.r=(v.x+v.width)/c,v.b=(v.y+v.height)/_,v._rect=new gr(v.x,v.y,v.width,v.height);else i.rotated?(v._rotated=!0,v._name=i.name,v._rect=i.getRect(),v.l=i.unbiasUV[0],v.t=i.unbiasUV[1],v.r=i.unbiasUV[4],v.b=i.unbiasUV[3]):(v._name=i.name,v._rect=i.getRect(),v.l=i.unbiasUV[0],v.t=i.unbiasUV[5],v.r=i.unbiasUV[2],v.b=i.unbiasUV[1]);v.cx=(v.l+v.r)/2,v.cy=(v.t+v.b)/2,e.set(A,v)}}function M9(t,e){var i=t.length;if(0!==i)for(var r=0,n=function(){++r>=i&&e()},s=0;s<i;s++){var a=t[s];a.loaded?n():a.once("load",(function(){n()}))}else e()}for(var P9,R9,I9,O9,F9,L9,V9,k9,N9,G9,z9,U9,H9,j9,W9,X9,Y9,q9,J9,K9,Z9,Q9,$9,ttt,ett,itt,rtt,ntt,stt,att,ott,ltt,htt,utt,ctt,_tt,ftt,ptt,dtt,mtt=new Ri,ytt=new dr,gtt=new ii,vtt=new ii,btt={row:0,col:0},Stt=t("TiledUserNodeData",ri("cc.TiledUserNodeData")(T9=function(t){function e(){var e;return(e=t.call(this)||this)._index=-1,e._row=-1,e._col=-1,e._tiledLayer=null,e}return Me(e,t),e}(zi))||T9),Att=t("TiledLayer",ri("cc.TiledLayer")(w9=function(t){function e(){var e;return(e=t.call(this)||this)._userNodeGrid={},e._userNodeMap={},e._userNodeDirty=!1,e.tiledTiles=[],e._viewPort={x:-1,y:-1,width:-1,height:-1},e._cullingRect={leftDown:{row:-1,col:-1},rightTop:{row:-1,col:-1}},e._cullingDirty=!0,e._rightTop={row:-1,col:-1},e._layerInfo=null,e._mapInfo=null,e._topOffset=0,e._downOffset=0,e._leftOffset=0,e._rightOffset=0,e.tiles=[],e.vertices=[],e._verticesDirty=!0,e._layerName="",e._layerSize=void 0,e._minGID=void 0,e._maxGID=void 0,e._layerOrientation=null,e._opacity=void 0,e._tintColor=void 0,e.texGrids=null,e._textures=[],e._tilesets=[],e._leftDownToCenterX=0,e._leftDownToCenterY=0,e._hasTiledNodeGrid=!1,e._hasAniGrid=!1,e._animations=null,e._enableCulling=void 0,e.colorChanged=!1,e._properties=void 0,e.renderOrder=void 0,e._staggerAxis=void 0,e._staggerIndex=void 0,e._hexSideLength=void 0,e._mapTileSize=void 0,e._odd_even=void 0,e._diffX1=void 0,e._diffY1=void 0,e._useAutomaticVertexZ=void 0,e._vertexZvalue=void 0,e._offset=void 0,e._meshRenderDataArray=null,e._meshRenderDataArrayIdx=0,e}Me(e,t);var i=e.prototype;return i.hasTiledNode=function(){return this._hasTiledNodeGrid},i.hasAnimation=function(){return this._hasAniGrid},i.addUserNode=function(t){var e=t.getComponent(Stt);return e?(Ue("CCTiledLayer:addUserNode node has been added"),!1):(e=t.addComponent(Stt),t.parent=this.node,this._userNodeMap[t.uuid]=e,e._row=-1,e._col=-1,e._tiledLayer=this,this._nodeLocalPosToLayerPos(t.getPosition(),ytt),this._positionToRowCol(ytt.x,ytt.y,btt),this._addUserNodeToGrid(e,btt),this._updateCullingOffsetByUserNode(t),t.on(Dr.TRANSFORM_CHANGED,this._userNodePosChange,e),t.on(Dr.SIZE_CHANGED,this._userNodeSizeChange,e),!0)},i.removeUserNode=function(t){var e=t.getComponent(Stt);return e?(t.off(Dr.TRANSFORM_CHANGED,this._userNodePosChange,e),t.off(Dr.SIZE_CHANGED,this._userNodeSizeChange,e),this._removeUserNodeFromGrid(e),delete this._userNodeMap[t.uuid],t._removeComponent(e),e.destroy(),t.removeFromParent(),!0):(Ue("CCTiledLayer:removeUserNode node is not exist"),!1)},i.destroyUserNode=function(t){this.removeUserNode(t),t.destroy()},i._nodeLocalPosToLayerPos=function(t,e){e.x=t.x+this._leftDownToCenterX,e.y=t.y+this._leftDownToCenterY},i.getNodesByRowCol=function(t,e){var i=this._userNodeGrid[t];return i?i[e]:null},i.getNodesCountByRow=function(t){var e=this._userNodeGrid[t];return e?e.count:0},i._updateAllUserNode=function(){for(var t in this._userNodeGrid={},this._userNodeMap){var e=this._userNodeMap[t];this._nodeLocalPosToLayerPos(e.node.getPosition(),ytt),this._positionToRowCol(ytt.x,ytt.y,btt),this._addUserNodeToGrid(e,btt),this._updateCullingOffsetByUserNode(e.node)}},i._updateCullingOffsetByUserNode=function(t){var e=t._uiProps.uiTransformComp.contentSize;this._topOffset<e.height&&(this._topOffset=e.height),this._downOffset<e.height&&(this._downOffset=e.height),this._leftOffset<e.width&&(this._leftOffset=e.width),this._rightOffset<e.width&&(this._rightOffset=e.width)},i._userNodeSizeChange=function(){var t=this.node,e=this._tiledLayer;e._updateCullingOffsetByUserNode(t),e._userNodeDirty=!0,e.markForUpdateRenderData()},i._userNodePosChange=function(){var t=this,e=t.node,i=t._tiledLayer;i._nodeLocalPosToLayerPos(e.getPosition(),ytt),i._positionToRowCol(ytt.x,ytt.y,btt),i._limitInLayer(btt),btt.row===t._row&&btt.col===t._col||(i._removeUserNodeFromGrid(t),i._addUserNodeToGrid(t,btt))},i._removeUserNodeFromGrid=function(t){var e=t._row,i=t._col,r=t._index,n=this._userNodeGrid[e],s=n&&n[i];s&&(n.count--,s.count--,s.list[r]=null,s.count<=0&&(s.list.length=0,s.count=0)),t._row=-1,t._col=-1,t._index=-1,this._userNodeDirty=!0,this.markForUpdateRenderData()},i._limitInLayer=function(t){var e=t.row,i=t.col;e<0&&(t.row=0),e>this._rightTop.row&&(t.row=this._rightTop.row),i<0&&(t.col=0),i>this._rightTop.col&&(t.col=this._rightTop.col)},i._addUserNodeToGrid=function(t,e){var i=e.row,r=e.col,n=this._userNodeGrid[i]=this._userNodeGrid[i]||{count:0},s=n[r]=n[r]||{count:0,list:[]};t._row=i,t._col=r,t._index=s.list.length,n.count++,s.count++,s.list.push(t),this._userNodeDirty=!0},i.isUserNodeDirty=function(){return this._userNodeDirty},i.setUserNodeDirty=function(t){this._userNodeDirty=t},i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(Dr.ANCHOR_CHANGED,this._syncAnchorPoint,this),this.node.on(Dr.TRANSFORM_CHANGED,this.updateCulling,this),this.node.on(Dr.SIZE_CHANGED,this.updateCulling,this),this.node.parent.on(Dr.TRANSFORM_CHANGED,this.updateCulling,this),this.node.parent.on(Dr.SIZE_CHANGED,this.updateCulling,this),this.markForUpdateRenderData(),this.scheduleOnce(this.updateCulling.bind(this))},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.parent.off(Dr.SIZE_CHANGED,this.updateCulling,this),this.node.parent.off(Dr.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(Dr.SIZE_CHANGED,this.updateCulling,this),this.node.off(Dr.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(Dr.ANCHOR_CHANGED,this._syncAnchorPoint,this)},i._syncAnchorPoint=function(){var t=this.node,e=t._uiProps.uiTransformComp,i=t.getScale();this._leftDownToCenterX=e.width*e.anchorX*i.x,this._leftDownToCenterY=e.height*e.anchorY*i.y,this._cullingDirty=!0,this.markForUpdateRenderData()},i.onDestroy=function(){t.prototype.onDestroy.call(this)},i.getLayerName=function(){return this._layerName},i.setLayerName=function(t){this._layerName=t},i.getProperty=function(t){return this._properties[t]},i.getPositionAt=function(t,e){var i;switch(void 0!==e?(i=Math.floor(t),e=Math.floor(e)):(i=Math.floor(t.x),e=Math.floor(t.y)),this._layerOrientation){case j7.ORTHO:return this._positionForOrthoAt(i,e);case j7.ISO:return this._positionForIsoAt(i,e);case j7.HEX:return this._positionForHexAt(i,e)}return null},i.isInvalidPosition=function(t,e){return t>=this._layerSize.width||e>=this._layerSize.height||t<0||e<0},i._positionForIsoAt=function(t,e){var i=0,r=0,n=Math.floor(t)+Math.floor(e)*this._layerSize.width,s=this.tiles[n];if(s){var a=(s&X7.FLIPPED_MASK)>>>0,o=this.texGrids.get(a).tileset.tileOffset;i=o.x,r=o.y}return new dr(.5*this._mapTileSize.width*(this._layerSize.height+t-e-1)+i,.5*this._mapTileSize.height*(this._layerSize.width-t+this._layerSize.height-e-2)-r)},i._positionForOrthoAt=function(t,e){var i=0,r=0,n=Math.floor(t)+Math.floor(e)*this._layerSize.width,s=this.tiles[n];if(s){var a=(s&X7.FLIPPED_MASK)>>>0,o=this.texGrids.get(a).tileset.tileOffset;i=o.x,r=o.y}return new dr(t*this._mapTileSize.width+i,(this._layerSize.height-e-1)*this._mapTileSize.height-r)},i._positionForHexAt=function(t,e){var i,r=this._mapTileSize.width,n=this._mapTileSize.height,s=this._layerSize.height,a=Math.floor(t)+Math.floor(e)*this._layerSize.width,o=(this.tiles[a]&X7.FLIPPED_MASK)>>>0;i=this.texGrids.get(o)?this.texGrids.get(o).tileset.tileOffset:{x:0,y:0};var l=this._staggerIndex===q7.STAGGERINDEX_ODD?1:-1,h=0,u=0,c=0,_=0;switch(this._staggerAxis){case Y7.STAGGERAXIS_Y:c=0,e%2==1&&(c=r/2*l),h=t*r+c+i.x,u=(s-e-1)*(n-(n-this._hexSideLength)/2)-i.y;break;case Y7.STAGGERAXIS_X:_=0,t%2==1&&(_=n/2*-l),h=t*(r-(r-this._hexSideLength)/2)+i.x,u=(s-e-1)*n+_-i.y}return new dr(h,u)},i.setTilesGIDAt=function(t,e,i,r){if(t&&0!==t.length&&!(r<=0)){i<0&&(i=0),e<0&&(e=0);for(var n=0,s=e+r,a=i;;a++)for(var o=e;o<s;o++){if(n>=t.length)return;this._updateTileForGID(t[n],o,a),n++}}},i.setTileGIDAt=function(t,e,i,r){var n=(t&X7.FLIPPED_MASK)>>>0;if(e=Math.floor(e),i=Math.floor(i),this.isInvalidPosition(e,i))throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position");this.tiles&&this._tilesets&&0!==this._tilesets.length?0!==n&&n<this._tilesets[0].firstGid?an(7239,t):(r=r||0,this._updateTileForGID((n|r)>>>0,e,i)):an(7238)},i._updateTileForGID=function(t,e,i){var r=0|e+i*this._layerSize.width;if(!(r>=this.tiles.length)&&t!==this.tiles[r]){var n=(t&X7.FLIPPED_MASK)>>>0;this.texGrids.get(n)?(this.tiles[r]=t,this._updateVertex(e,i)):this.tiles[r]=0,this._cullingDirty=!0}},i.getTileGIDAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position");if(!this.tiles)return an(7237),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(this.tiles[i]&X7.FLIPPED_MASK)>>>0},i.getTileFlagsAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.getTileFlagsAt: invalid position");if(!this.tiles)return an(7240),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(this.tiles[i]&X7.FLIPPED_ALL)>>>0},i.setCullingDirty=function(t){this._cullingDirty=t},i.isCullingDirty=function(){return this._cullingDirty},i.updateViewPort=function(t,e,i,r){if(this._viewPort.width!==i||this._viewPort.height!==r||this._viewPort.x!==t||this._viewPort.y!==e){this._viewPort.x=t,this._viewPort.y=e,this._viewPort.width=i,this._viewPort.height=r;var n=1;this._layerOrientation===j7.ISO&&(n=2);var s=this._viewPort.x-this._offset.x+this._leftDownToCenterX,a=this._viewPort.y-this._offset.y+this._leftDownToCenterY,o=s-this._leftOffset,l=a-this._downOffset,h=s+i+this._rightOffset,u=a+r+this._topOffset,c=this._cullingRect.leftDown,_=this._cullingRect.rightTop;o<0&&(o=0),l<0&&(l=0),this._positionToRowCol(o,l,btt),btt.row-=n,btt.col-=n,btt.row=btt.row>0?btt.row:0,btt.col=btt.col>0?btt.col:0,btt.row===c.row&&btt.col===c.col||(c.row=btt.row,c.col=btt.col,this._cullingDirty=!0),h<0||u<0?(btt.row=-1,btt.col=-1):(this._positionToRowCol(h,u,btt),btt.row++,btt.col++),btt.row>this._rightTop.row&&(btt.row=this._rightTop.row),btt.col>this._rightTop.col&&(btt.col=this._rightTop.col),btt.row===_.row&&btt.col===_.col||(_.row=btt.row,_.col=btt.col,this._cullingDirty=!0,this.markForUpdateRenderData())}},i._positionToRowCol=function(t,e,i){var r=this._mapTileSize.width,n=this._mapTileSize.height,s=.5*r,a=.5*n,o=0,l=0,h=0,u=0,c=this._staggerAxis;switch(this._layerOrientation){case j7.ORTHO:l=Math.floor(t/r),o=Math.floor(e/n);break;case j7.ISO:l=Math.floor(t/s),o=Math.floor(e/a);break;case j7.HEX:c===Y7.STAGGERAXIS_Y?(h=(o=Math.floor(e/(n-this._diffY1)))%2==1?s*this._odd_even:0,l=Math.floor((t-h)/r)):(u=(l=Math.floor(t/(r-this._diffX1)))%2==1?a*-this._odd_even:0,o=Math.floor((e-u)/n))}return i.row=o,i.col=l,i},i.updateCulling=function(){if(this._enableCulling){this.node.updateWorldTransform(),Ri.invert(mtt,this.node.getWorldMatrix());var t=wr.root.batcher2D.getFirstRenderCamera(this.node);t&&(gtt.x=0,gtt.y=0,gtt.z=0,vtt.x=t.width,vtt.y=t.height,vtt.z=0,t.screenToWorld(gtt,gtt),t.screenToWorld(vtt,vtt),ii.transformMat4(gtt,gtt,mtt),ii.transformMat4(vtt,vtt,mtt),this.updateViewPort(gtt.x,gtt.y,vtt.x-gtt.x,vtt.y-gtt.y))}},i.getLayerOrientation=function(){return this._layerOrientation},i.getProperties=function(){return this._properties},i._updateVertex=function(t,e){var i=X7.FLIPPED_MASK,r=this.vertices,n=this._layerOrientation,s=this.tiles;if(s){var a,o,l,h,u=this._rightTop,c=this._mapTileSize.width,_=this._mapTileSize.height,f=.5*c,p=.5*_,d=this._layerSize.height,m=this._layerSize.width,y=this.texGrids,g=0,v=0;n===j7.HEX&&(a=this._staggerAxis,o=this._diffX1,l=this._diffY1,h=this._odd_even);var b,S,A,C=0,x=0,T=0,w=0,E=e*m+t;b=(s[E]&i)>>>0;var B=y.get(b);if(B){switch(this._animations.get(b)&&(this._hasAniGrid=this._hasAniGrid||!0),n){case j7.ORTHO:g=(C=t)*c,v=(x=d-e-1)*_;break;case j7.ISO:g=f*(C=d+t-e-1),v=p*(x=d+m-t-e-2);break;case j7.HEX:g=t*(c-o)+(a===Y7.STAGGERAXIS_Y&&e%2==1?f*h:0),v=(d-e-1)*(_-l)+(a===Y7.STAGGERAXIS_X&&t%2==1?p*-h:0),C=t,x=d-e-1}var D=r[x]=r[x]||{minCol:0,maxCol:0},M=D[C]=D[C]||{};D.minCol>C&&(D.minCol=C),D.maxCol<C&&(D.maxCol=C),u.row<x&&(u.row=x),u.col<C&&(u.col=C);var P=B.tileset.tileOffset;g+=this._offset.x+P.x+B.offsetX,v+=this._offset.y-P.y-B.offsetY,T=(T=-P.y+B.tileset._tileSize.height-_)<0?0:T,S=P.y<0?0:P.y,A=-P.x<0?0:-P.x,w=(w=P.x+B.tileset._tileSize.width-c)<0?0:w,this._rightOffset<A&&(this._rightOffset=A),this._leftOffset<w&&(this._leftOffset=w),this._topOffset<S&&(this._topOffset=S),this._downOffset<T&&(this._downOffset=T),M.left=g,M.bottom=v,M.index=E,this._cullingDirty=!0}}},i._updateVertices=function(){if(this.vertices.length=0,this.tiles){var t=this._rightTop;t.row=-1,t.col=-1;var e=this._layerSize.height,i=this._layerSize.width;this._topOffset=0,this._downOffset=0,this._leftOffset=0,this._rightOffset=0,this._hasAniGrid=!1;for(var r=0;r<e;++r)for(var n=0;n<i;++n)this._updateVertex(n,r);this._verticesDirty=!1}},i.getTiledTileAt=function(t,e,i){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.getTiledTileAt: invalid position");if(!this.tiles)return an(7236),null;var r=Math.floor(t)+Math.floor(e)*this._layerSize.width,n=this.tiledTiles[r];if(!n&&i){var s=new ur;return(n=s.addComponent(B9))._x=t,n._y=e,n._layer=this,n.updateInfo(),s.parent=this.node,n}return n},i.setTiledTileAt=function(t,e,i){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.setTiledTileAt: invalid position");if(!this.tiles)return an(7236),null;var r=Math.floor(t)+Math.floor(e)*this._layerSize.width;return this.tiledTiles[r]=i,this._cullingDirty=!0,this._hasTiledNodeGrid=!!i||this.tiledTiles.some((function(t){return!!t})),i},i.getTexture=function(t){return t=t||0,this._textures&&t>=0&&this._textures.length>t?this._textures[t]:null},i.getTextures=function(){return this._textures},i.setTexture=function(t){this.setTextures([t])},i.setTextures=function(t){this._textures=t,this.markForUpdateRenderData()},i.getLayerSize=function(){return this._layerSize},i.getMapTileSize=function(){return this._mapTileSize},i.getTileSet=function(t){return t=t||0,this._tilesets&&t>=0&&this._tilesets.length>t?this._tilesets[t]:null},i.getTileSets=function(){return this._tilesets},i.setTileSet=function(t){this.setTileSets([t])},i.setTileSets=function(t){var e=this;this._tilesets=t;var i=this._textures=[],r=this.texGrids;r.clear();for(var n=0;n<t.length;n++){var s=t[n];s&&(i[n]=s.sourceImage)}M9(i,(function(){for(var i=0,n=t.length;i<n;++i){var s=t[i];s&&D9(s,r,s.sourceImage)}e._prepareToRender()}))},i.init=function(t,e,i,r,n){this._cullingDirty=!0,this._layerInfo=t,this._mapInfo=e;var s=t.layerSize;this._layerName=t.name,this.tiles=t.tiles,this._properties=t.properties,this._layerSize=s,this._minGID=t.minGID,this._maxGID=t.maxGID,this._opacity=t.opacity,t.tintColor&&(this._tintColor=t.tintColor),this.renderOrder=e.renderOrder,this._staggerAxis=e.getStaggerAxis(),this._staggerIndex=e.getStaggerIndex(),this._hexSideLength=e.getHexSideLength(),this._animations=e.getTileAnimations(),this._tilesets=i,this._textures=r,this.texGrids=n,this._layerOrientation=e.orientation,this._mapTileSize=e.getTileSize();var a=this._mapTileSize.width,o=this._mapTileSize.height,l=this._layerSize.width,h=this._layerSize.height;if(this._layerOrientation===j7.HEX){var u=0,c=0;this._odd_even=this._staggerIndex===q7.STAGGERINDEX_ODD?1:-1,this._staggerAxis===Y7.STAGGERAXIS_X?(this._diffX1=(a-this._hexSideLength)/2,this._diffY1=0,c=o*(h+.5),u=(a+this._hexSideLength)*Math.floor(l/2)+a*(l%2)):(this._diffX1=0,this._diffY1=(o-this._hexSideLength)/2,u=a*(l+.5),c=(o+this._hexSideLength)*Math.floor(h/2)+o*(h%2)),this.node._uiProps.uiTransformComp.setContentSize(u,c)}else if(this._layerOrientation===j7.ISO){var _=l+h;this.node._uiProps.uiTransformComp.setContentSize(.5*a*_,.5*o*_)}else this.node._uiProps.uiTransformComp.setContentSize(l*a,h*o);this._offset=new dr(t.offset.x,-t.offset.y),this._useAutomaticVertexZ=!1,this._vertexZvalue=0,this._syncAnchorPoint(),this._prepareToRender()},i._prepareToRender=function(){this._updateVertices(),this._updateAllUserNode()},i.requestMeshRenderData=function(){var t=this;this._meshRenderDataArray||(this._meshRenderDataArray=[]);for(var e=this._meshRenderDataArray;e.length>0&&e[e.length-1].subNodes&&0===e[e.length-1].subNodes.length;)e.pop();if(e.length>0){var i=e[e.length-1];if(i.renderData&&0===i.renderData.byteCount)return i}var r=new I_,n={renderData:r,texture:null};return Object.defineProperty(r,"material",{get:function(){return t.getRenderMaterial(0)}}),this._meshRenderDataArray.push(n),n},i.requestSubNodesData=function(){this._meshRenderDataArray||(this._meshRenderDataArray=[]);for(var t=this._meshRenderDataArray;t.length>0&&t[t.length-1].renderData&&0===t[t.length-1].renderData.byteCount;)t.pop();if(t.length>0&&t[t.length-1].subNodes&&0===t[t.length-1].subNodes.length)return t[t.length-1];var e={subNodes:[]};return this._meshRenderDataArray.push(e),e},i.destroyRenderData=function(){this._meshRenderDataArray&&(this._meshRenderDataArray.forEach((function(t){t.renderData&&t.renderData.reset()})),this._meshRenderDataArray.length=0)},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._meshRenderDataArray||this._assembler&&this._assembler.createData&&(this._assembler.createData(this),this.markForUpdateRenderData(),this._updateColor())},i._render=function(t){if(this._meshRenderDataArray){for(var e=0;e<this._meshRenderDataArray.length;e++){this._meshRenderDataArrayIdx=e;var i=this._meshRenderDataArray[e];i.subNodes?i.subNodes.forEach((function(e){e&&t.walk(e.node)})):i.texture&&t.commitComp(this,i.texture,this._assembler,null)}this.node._static=!0}},Pe(e,[{key:"cullingRect",get:function(){return this._cullingRect}},{key:"rightTop",get:function(){return this._rightTop}},{key:"layerSize",get:function(){return this._layerSize}},{key:"meshRenderDataArray",get:function(){return this._meshRenderDataArray}},{key:"leftDownToCenterX",get:function(){return this._leftDownToCenterX}},{key:"leftDownToCenterY",get:function(){return this._leftDownToCenterY}},{key:"enableCulling",get:function(){return this._enableCulling},set:function(t){this._enableCulling!==t&&(this._enableCulling=t,this._cullingDirty=!0,this.markForUpdateRenderData())}}]),e}(Ap))||w9),Ctt=t("TiledObjectGroup",(P9=ri("cc.TiledObjectGroup"),R9=wi(),I9=Rr(j_),O9=bi(fs),P9(F9=R9(F9=I9((V9=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._premultiplyAlpha=!1,e._groupName=void 0,e._positionOffset=void 0,e._mapInfo=void 0,e._properties=void 0,e._offset=void 0,e._opacity=void 0,e._tintColor=null,e._animations=void 0,e._hasAniObj=void 0,e._texGrids=void 0,e.aniObjects=void 0,e._objects=[],e}Me(e,t);var i=e.prototype;return i.getPositionOffset=function(){return this._positionOffset},i.getProperties=function(){return this._properties},i.getGroupName=function(){return this._groupName},i.getProperty=function(t){return this._properties[t.toString()]},i.getObject=function(t){for(var e=0,i=this._objects.length;e<i;e++){var r=this._objects[e];if(r&&r.name===t)return r}return null},i.getObjects=function(){return this._objects},i._init=function(t,e,i){var r=X7.FLIPPED_MASK,n=X7.HORIZONTAL,s=X7.VERTICAL;this._groupName=t.name,this._positionOffset=t.offset,this._mapInfo=e,this._properties=t.getProperties(),this._offset=new dr(t.offset.x,-t.offset.y),this._opacity=t.opacity,t.tintColor&&(this._tintColor=t.tintColor),this._texGrids=i,this._animations=e.getTileAnimations(),this.aniObjects=[],this._hasAniObj=!1;var a=e.mapSize,o=e.tileSize,l=0,h=0,u=new Ui,c=j7.ISO===e.orientation;if(e.orientation===j7.HEX)e.getStaggerAxis()===Y7.STAGGERAXIS_X?(h=o.height*(a.height+.5),l=(o.width+e.getHexSideLength())*Math.floor(a.width/2)+o.width*(a.width%2)):(l=o.width*(a.width+.5),h=(o.height+e.getHexSideLength())*Math.floor(a.height/2)+o.height*(a.height%2));else if(c){var _=a.width+a.height;l=.5*o.width*_,h=.5*o.height*_}else l=a.width*o.width,h=a.height*o.height;var f=this.node._uiProps.uiTransformComp;f.setContentSize(l,h);for(var p=l*f.anchorX,d=h*(1-f.anchorY),m=t.objects,y={},g=0,v=m.length;g<v;g++){var b=m[g],S=b.type;b.offset=new dr(b.x,b.y);var A=b.points||b.polylinePoints;if(A)for(var C=0;C<A.length;C++)A[C].y*=-1;if(c){var x=b.x/o.height,T=b.y/o.height;b.x=.5*o.width*(a.height+x-T),b.y=.5*o.height*(a.width+a.height-x-T)}else b.y=h-b.y;if(S===K7.TEXT){var w="text"+b.id;y[w]=!0;var B=this.node.getChildByName(w);B||(B=new ur),B.setRotationFromEuler(0,0,-b.rotation),B.setPosition(b.x-p,b.y-d),B.name=w,B.parent=this.node,B.setSiblingIndex(g);var D=B.getComponent(wp);D||(D=B.addComponent(wp));var M=B._uiProps.uiTransformComp;B.active=b.visible,M.anchorX=0,M.anchorY=1,this._tintColor?(u.set(this._tintColor),u.a*=this._opacity/255,D.color.set(u)):D.color.a*=this._opacity/255,D.overflow=wp.Overflow.SHRINK,D.lineHeight=b.height,D.string=b.text,D.horizontalAlign=b.halign,D.verticalAlign=b.valign,D.fontSize=b.pixelsize,M.setContentSize(b.width,b.height)}else if(S===K7.IMAGE){var P=b.gid,R=(P&r)>>>0,I=i.get(R);if(!I)continue;var O=I.tileset,F="img"+b.id;y[F]=!0;var L=this.node.getChildByName(F);b.width=b.width||I.width,b.height=b.height||I.height,L&&L._objFlags&Lr.Flags.HideInHierarchy&&(L.removeFromParent(),L.hideFlags|=Lr.Flags.DontSave,L.destroy(),L=null),L||(L=new ur),this._animations.get(R)&&(this.aniObjects.push({object:b,imgNode:L,gridGID:R}),this._hasAniObj=!0);var V=O.tileOffset.x,k=O.tileOffset.y;L.active=b.visible,L.setRotationFromEuler(0,0,-b.rotation),L.setPosition(b.x-p,b.y-d),L.name=F,L.parent=this.node,L.setSiblingIndex(g);var N=L.getComponent(dy);N||(N=L.addComponent(dy));var G=L._uiProps.uiTransformComp;c?(G.anchorX=.5+V/b.width,G.anchorY=k/b.height):(G.anchorX=V/b.width,G.anchorY=k/b.height),this._tintColor?(u.set(this._tintColor),u.a*=this._opacity/255,N.color.set(u)):N.color.a*=this._opacity/255,N.sizeMode=dy.SizeMode.CUSTOM,N._srcBlendFactor=this._premultiplyAlpha?E.ONE:E.SRC_ALPHA,N._dstBlendFactor=E.ONE_MINUS_SRC_ALPHA,N._updateBlendFunc();var z=I.spriteFrame;z=z?z.clone():new xc,(P&n)>>>0&&(z.flipUVX=!z.flipUVX),(P&s)>>>0&&(z.flipUVY=!z.flipUVY),z.rotated=I._rotated,z.rect=I._rect,N.spriteFrame=z,G.setContentSize(b.width,b.height),N.markForUpdateRenderData()}}this._objects=m;for(var U=this.node.children,H=/^(?:img|text)\d+$/,j=0,W=U.length;j<W;j++){var X=U[j],Y=X.name;H.test(Y)&&!y[Y]&&X.destroy()}},i.update=function(){if(this._hasAniObj)for(var t=this.aniObjects,e=this._texGrids,i=j7.ISO===this._mapInfo.orientation,r=0,n=t.length;r<n;r++){var s=t[r],a=s.gridGID,o=e.get(a);if(o){var l=o.tileset,h=s.object,u=s.imgNode,c=l.tileOffset.x,_=l.tileOffset.y,f=u._uiProps.uiTransformComp;i?(f.anchorX=.5+c/h.width,f.anchorY=_/h.height):(f.anchorX=c/h.width,f.anchorY=_/h.height);var p=u.getComponent(dy),d=p.spriteFrame;d.rotated=o._rotated,d.rect=o._rect,p.spriteFrame=d,p.markForUpdateRenderData()}}},Pe(e,[{key:"premultiplyAlpha",get:function(){return this._premultiplyAlpha},set:function(t){this._premultiplyAlpha=t}},{key:"offset",get:function(){return this._offset}}]),e}(zi),oi((L9=V9).prototype,"premultiplyAlpha",[O9],Object.getOwnPropertyDescriptor(L9.prototype,"premultiplyAlpha"),L9.prototype),F9=L9))||F9)||F9)||F9)),xtt=t("TiledMapAsset",(k9=ri("cc.TiledMapAsset"),N9=bi([ys]),G9=bi([Fi]),z9=bi([xc]),U9=bi([xc]),H9=bi([Fi]),j9=bi([Fi]),W9=bi([vr]),k9((itt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"tmxXmlStr",q9,hi(e)),li(e,"tsxFiles",J9,hi(e)),li(e,"tsxFileNames",K9,hi(e)),li(e,"spriteFrames",Z9,hi(e)),li(e,"imageLayerSpriteFrame",Q9,hi(e)),li(e,"imageLayerSpriteFrameNames",$9,hi(e)),li(e,"spriteFrameNames",ttt,hi(e)),li(e,"spriteFrameSizes",ett,hi(e)),e}return Me(e,t),e}(ai),q9=oi((Y9=itt).prototype,"tmxXmlStr",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),J9=oi(Y9.prototype,"tsxFiles",[_i,N9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),K9=oi(Y9.prototype,"tsxFileNames",[_i,G9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Z9=oi(Y9.prototype,"spriteFrames",[_i,z9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Q9=oi(Y9.prototype,"imageLayerSpriteFrame",[_i,U9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),$9=oi(Y9.prototype,"imageLayerSpriteFrameNames",[_i,H9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ttt=oi(Y9.prototype,"spriteFrameNames",[_i,j9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ett=oi(Y9.prototype,"spriteFrameSizes",[_i,W9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),X9=Y9))||X9)),Ttt=(t("TiledMap",(rtt=ri("cc.TiledMap"),ntt=wi(),stt=Bi(),att=Rr(j_),ott=bi(xtt),ltt=Mr(),rtt(htt=ntt(htt=stt(htt=att(htt=Si((dtt=ptt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._texGrids=new Map,e._textures=[],e._tilesets=[],e._animations=new Map,e._imageLayers=[],e._layers=[],e._groups=[],e._images=[],e._properties={},e._tileProperties=new Map,e._mapInfo=null,e._mapSize=new vr(0,0),e._tileSize=new vr(0,0),e._preloaded=!1,e._mapOrientation=j7.ORTHO,li(e,"_tmxFile",ctt,hi(e)),li(e,"_enableCulling",_tt,hi(e)),li(e,"cleanupImageCache",ftt,hi(e)),e}Me(e,t);var i=e.prototype;return i.getMapSize=function(){return this._mapSize},i.getTileSize=function(){return this._tileSize},i.getMapOrientation=function(){return this._mapOrientation},i.getObjectGroups=function(){return this._groups},i.getObjectGroup=function(t){for(var e=this._groups,i=0,r=e.length;i<r;i++){var n=e[i];if(n&&n.getGroupName()===t)return n}return null},i.getProperties=function(){return this._properties},i.getLayers=function(){return this._layers},i.getLayer=function(t){for(var e=this._layers,i=0,r=e.length;i<r;i++){var n=e[i];if(n&&n.getLayerName()===t)return n}return null},i._changeLayer=function(t,e){for(var i=this._layers,r=0,n=i.length;r<n;r++){var s=i[r];if(s&&s.getLayerName()===t)return void(i[r]=e)}},i.getProperty=function(t){return this._properties[t.toString()]},i.getPropertiesForGID=function(t){return this._tileProperties.get(t)},i.__preload=function(){this._preloaded=!0,this._tmxFile&&this._applyFile()},i.onEnable=function(){this.node.on(Dr.ANCHOR_CHANGED,this._syncAnchorPoint,this)},i.onDisable=function(){this.node.off(Dr.ANCHOR_CHANGED,this._syncAnchorPoint,this)},i._applyFile=function(){var t=[],e={},i=this._tmxFile;if(i){for(var r=i.spriteFrameNames,n=i.spriteFrameSizes,s=i.spriteFrames,a={},o={},l=0;l<r.length;++l){var h=r[l];o[h]=n[l],t[l]=s[l];var u=t[l];u&&(e[u.name]=u,a[h]=u)}var c={},_=i.imageLayerSpriteFrame;r=i.imageLayerSpriteFrameNames;for(var f=0;f<_.length;++f)c[r[f]]=_[f];for(var p=i.tsxFileNames,d=i.tsxFiles,m={},y=0;y<p.length;++y)p[y].length>0&&(m[p[y]]=d[y].text);var g=new E9(i.tmxXmlStr,m,a,o,c),v=g.getTilesets();v&&0!==v.length||an(7241),this._buildWithMapInfo(g)}else this._releaseMapInfo()},i._releaseMapInfo=function(){for(var t=this._layers,e=0,i=t.length;e<i;e++)t[e].node.removeFromParent(),t[e].node.destroy();t.length=0;for(var r=this._groups,n=0,s=r.length;n<s;n++)r[n].node.removeFromParent(),r[n].node.destroy();r.length=0;for(var a=this._images,o=0,l=a.length;o<l;o++)a[o].removeFromParent(),a[o].destroy();a.length=0},i._syncAnchorPoint=function(){var t,e,i=this.node._uiProps.uiTransformComp.anchorPoint,r=this.node._uiProps.uiTransformComp.width*i.x,n=this.node._uiProps.uiTransformComp.height*(1-i.y);for(t=0,e=this._layers.length;t<e;t++)this._layers[t].node._uiProps.uiTransformComp.setAnchorPoint(i);for(t=0,e=this._groups.length;t<e;t++){var s=this._groups[t],a=s.node._uiProps.uiTransformComp;a.anchorX=.5,a.anchorY=.5;var o=s.offset.x-r+a.width*a.anchorX,l=s.offset.y+n-a.height*a.anchorY;s.node.setPosition(o,l)}for(t=0,e=this._images.length;t<e;t++){var h=this._images[t]._uiProps.uiTransformComp;h.anchorX=.5,h.anchorY=.5;var u=this._images[t]._offset.x-r+h.width*h.anchorX,c=this._images[t]._offset.y+n-h.height*h.anchorY;this._images[t].setPosition(u,c)}},i._fillAniGrids=function(t,e){for(var i,r=Fe(e.keys());!(i=r()).done;){var n=i.value,s=e.get(n);if(s)for(var a=s.frames,o=0;o<a.length;o++){var l=a[o];l.grid=t.get(l.tileid)}}},i._buildLayerAndGroup=function(){var t=this._tilesets,e=this._texGrids,i=this._animations;e.clear();for(var r=0,n=t.length;r<n;++r){var s=t[r];s&&(s.sourceImage?D9(s,e,s.sourceImage):console.warn("Can't find the spriteFrame of tilesets "+r))}this._fillAniGrids(e,i);for(var a=this._layers,o=this._groups,l=this._images,h={},u=0,c=a.length;u<c;u++)h[a[u].node.name]=!0;for(var _=0,f=o.length;_<f;_++)h[o[_].node.name]=!0;for(var p=0,d=l.length;p<d;p++)h[l[p].name]=!0;a=this._layers=[],o=this._groups=[],l=this._images=[];var m=this._mapInfo,y=this.node,g=m.getAllChildren(),v=this._textures,b=0,S=0;if(g&&g.length>0)for(var A=0,C=g.length;A<C;A++){var x=g[A],T=x.name,w=this.node.getChildByName(T);if(h[T]=!1,w||((w=new ur).name=T,w.layer=y.layer,y.addChild(w)),w.setSiblingIndex(A),w.active=x.visible,x instanceof a9){var E=w.getComponent(Att);E||(E=w.addComponent(Att)),E.init(x,m,t,v,e),E.enableCulling=this._enableCulling,x.ownTiles=!1,a.push(E)}else if(x instanceof s9){var B=w.getComponent(Ctt);B||(B=w.addComponent(Ctt)),B._init(x,m,e),o.push(B)}else if(x instanceof o9){var D=x.sourceImage;w.layerInfo=x,w._offset=new dr(x.offset.x,-x.offset.y);var M=w.getComponent(dy);M||(M=w.addComponent(dy)),M.color.a*=x.opacity,M.spriteFrame=D,w._uiProps.uiTransformComp.setContentSize(D.width,D.height),l.push(w)}b=Math.max(b,w._uiProps.uiTransformComp.width),S=Math.max(S,w._uiProps.uiTransformComp.height)}for(var P=y.children,R=0,I=P.length;R<I;R++){var O=P[R];h[O.name]&&O.destroy()}this.node._uiProps.uiTransformComp.setContentSize(b,S),this._syncAnchorPoint()},i._buildWithMapInfo=function(t){var e=this;this._mapInfo=t,this._mapSize=t.getMapSize(),this._tileSize=t.getTileSize(),this._mapOrientation=t.orientation,this._properties=t.properties,this._tileProperties=t.getTileProperties(),this._imageLayers=t.getImageLayers(),this._animations=t.getTileAnimations(),this._tilesets=t.getTilesets();var i=this._tilesets;this._textures.length=0;for(var r=[],n=0,s=i.length;n<s;++n){var a=i[n];a&&a.sourceImage&&(this._textures[n]=a.sourceImage,r.push(a.sourceImage))}for(var o=0;o<this._imageLayers.length;o++){var l=this._imageLayers[o];l&&l.sourceImage&&r.push(l.sourceImage)}M9(r,(function(){e._buildLayerAndGroup(),e.cleanupImageCache&&e._textures.forEach((function(t){e.doCleanupImageCache(t)}))}))},i.doCleanupImageCache=function(t){t._image instanceof HTMLImageElement?t._image.src="":ke.capabilities.imageBitmap&&t._image instanceof ImageBitmap&&t._image.close&&t._image.close(),t._image=null},i.update=function(t){for(var e,i=this._animations,r=this._texGrids,n=Fe(i.keys());!(e=n()).done;){var s=e.value,a=i.get(s),o=a.frames,l=o[a.frameIdx];a.dt+=t,l.duration<a.dt&&(a.dt=0,a.frameIdx++,a.frameIdx>=o.length&&(a.frameIdx=0),l=o[a.frameIdx]),r.set(s,l.grid)}for(var h,u=Fe(this.getLayers());!(h=u()).done;){var c=h.value;c.hasAnimation()&&c.markForUpdateRenderData()}},Pe(e,[{key:"tmxAsset",get:function(){return this._tmxFile},set:function(t){(this._tmxFile!==t||Rn)&&(this._tmxFile=t,(this._preloaded||Rn)&&this._applyFile())}},{key:"enableCulling",get:function(){return this._enableCulling},set:function(t){this._enableCulling=t;for(var e=this._layers,i=0;i<e.length;++i)e[i].enableCulling=t}}]),e}(zi),ptt.Orientation=j7,ptt.Property=W7,ptt.TileFlag=X7,ptt.StaggerAxis=Y7,ptt.StaggerIndex=q7,ptt.TMXObjectType=K7,ptt.RenderOrder=J7,ctt=oi((utt=dtt).prototype,"_tmxFile",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oi(utt.prototype,"tmxAsset",[ott,ltt],Object.getOwnPropertyDescriptor(utt.prototype,"tmxAsset"),utt.prototype),_tt=oi(utt.prototype,"_enableCulling",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(utt.prototype,"enableCulling",[vi],Object.getOwnPropertyDescriptor(utt.prototype,"enableCulling"),utt.prototype),ftt=oi(utt.prototype,"cleanupImageCache",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),htt=utt))||htt)||htt)||htt)||htt)||htt)),Math.ceil(10922.5)),wtt=[],Ett=0;Ett<4;Ett++)wtt.push(new ii);var Btt,Dtt,Mtt=new Ri,Ptt=new ii,Rtt={row:0,col:0},Itt={x:0,y:0},Ott={x:0,y:0},Ftt={x:0,y:0},Ltt={x:0,y:0},Vtt=0,ktt=0,Ntt=0,Gtt=0,ztt={createData:function(t){var e=t.requestMeshRenderData();return t.rightTop.col*t.rightTop.row*4>65535&&console.error("Vertex count exceeds 65535"),e},updateRenderData:function(t){t.updateCulling();var e=t.requestMeshRenderData();if(Ntt=t.leftDownToCenterX,Gtt=t.leftDownToCenterY,Btt=e,t.colorChanged||t.isCullingDirty()||t.isUserNodeDirty()||t.hasAnimation()||t.hasTiledNode()){var i,r;if(t.colorChanged=!1,t.destroyRenderData(),t.enableCulling){var n=t.cullingRect;i=n.leftDown,r=n.rightTop}else i=Rtt,r=t.rightTop;switch(t.renderOrder){case J7.RightDown:jtt(i,r,-1,1,t);break;case J7.LeftDown:jtt(i,r,-1,-1,t);break;case J7.RightUp:jtt(i,r,1,1,t);break;case J7.LeftUp:default:jtt(i,r,1,-1,t)}t.setCullingDirty(!1),t.setUserNodeDirty(!1)}Btt=null},updateColor:function(t){var e=t.color,i=new Float32Array(4);i[0]=e.r/255,i[1]=e.g/255,i[2]=e.b/255,i[0]=e.a/255;var r=t.meshRenderDataArray;if(r)for(var n,s=Fe(r);!(n=s()).done;){var a=n.value;if(a.renderData)for(var o=a.renderData,l=o.vData,h=o.vertexStart,u=o.vertexCount;h<u;h++)l.set(i,9*h+5)}},fillBuffers:function(t,e){if(t&&t.meshRenderDataArray){var i=t.meshRenderDataArray,r=t.node,n=e.acquireBufferBatch(),s=n.byteOffset>>2,a=n.indicesOffset,o=n.vertexOffset,l=i[t._meshRenderDataArrayIdx].renderData;n.request(l.vertexCount,l.indicesCount)||(n=e.currBufferBatch,s=0,a=0,o=0);var h=n.vData,u=n.iData,c=r.worldMatrix,_=l.vData,f=l.vertexStart;h.set(_.slice(f,f+9*l.vertexCount),s);for(var p=0;p<l.vertexCount;p++){var d=s+9*p;Ptt.set(h[d],h[d+1],h[d+2]),Ptt.transformMat4(c),h[d]=Ptt.x,h[d+1]=Ptt.y,h[d+2]=Ptt.z}for(var m=l.vertexCount/4,y=0;y<m;y+=1)u[a]=o,u[a+1]=o+1,u[a+2]=o+2,u[a+3]=o+2,u[a+4]=o+1,u[a+5]=o+3,a+=6,o+=4}}};function Utt(t,e){var i;t._rotated?(Itt.x=t.r,Itt.y=t.t,Ott.x=t.l,Ott.y=t.t,Ftt.x=t.r,Ftt.y=t.b,Ltt.x=t.l,Ltt.y=t.b):(Itt.x=t.l,Itt.y=t.t,Ott.x=t.l,Ott.y=t.b,Ftt.x=t.r,Ftt.y=t.t,Ltt.x=t.r,Ltt.y=t.b),(e&X7.DIAGONAL)>>>0&&(i=Ott,Ott=Ftt,Ftt=i),(e&X7.HORIZONTAL)>>>0&&(i=Itt,Itt=Ftt,Ftt=i,i=Ott,Ott=Ltt,Ltt=i),(e&X7.VERTICAL)>>>0&&(i=Itt,Itt=Ott,Ott=i,i=Ftt,Ftt=Ltt,Ltt=i)}function Htt(t,e,i){t||(t=e.texture),Btt.texture||(Btt.texture=t),(Btt=i.requestMeshRenderData()).texture=e.texture}function jtt(t,e,i,r,n){if(!(!Btt||e.row<0||e.col<0)){Btt.renderData||(Btt=n.requestMeshRenderData());var s=Btt.renderData.vData;Vtt=0,ktt=0;var a,o,l,h,u,c,_,f,p,d=n.tiledTiles,m=n.texGrids,y=n.tiles,g=n.vertices,v=0,b=0,S=0,A=0,C=0,x=null,T=0,w=!0;Dtt=Utt;var E=new Float32Array(4);for(E[0]=n.color.r/255,E[1]=n.color.g/255,E[2]=n.color.b/255,E[3]=n.color.a/255,-1===i?(h=e.row,u=t.row):(h=t.row,u=e.row);(u-h)*i>=0;h+=i)for(a=g[h],T=n.getNodesCountByRow(h),w=a&&0===T,1===r?(o=w&&t.col<a.minCol?a.minCol:t.col,l=w&&e.col>a.maxCol?a.maxCol:e.col):(o=w&&e.col>a.maxCol?a.maxCol:e.col,l=w&&t.col<a.minCol?a.minCol:t.col);(l-o)*r>=0;o+=r){if(c=a&&a[o],T>0){var B=n.requestSubNodesData(),D=n.getNodesByRowCol(h,o);D&&D.count>0&&(B.subNodes=n.getNodesByRowCol(h,o).list,x=null,Btt=n.requestMeshRenderData())}c&&(v=y[c.index],(f=m.get((v&X7.FLIPPED_MASK)>>>0))&&(x!==f.texture&&(Htt(x,f,n),x=f.texture),_=f.tileset._tileSize,b=c.left-Ntt,S=c.bottom-Gtt,A=b+_.width,C=S+_.height,p=d[c.index],Btt.renderData.reserve(4,0),ktt=9*Btt.renderData.vertexCount,s=Btt.renderData.vData,p?p.node.active&&Wtt(p.node,E,s,b,A,C,S,!1):(s[ktt]=b,s[ktt+1]=C,s[ktt+9]=b,s[ktt+9+1]=S,s[ktt+18]=A,s[ktt+18+1]=C,s[ktt+27]=A,s[ktt+27+1]=S,s.set(E,ktt+5),s.set(E,ktt+9+5),s.set(E,ktt+18+5),s.set(E,ktt+27+5)),Dtt(f,v),s[ktt+3]=Itt.x,s[ktt+4]=Itt.y,s[ktt+9+3]=Ott.x,s[ktt+9+4]=Ott.y,s[ktt+18+3]=Ftt.x,s[ktt+18+4]=Ftt.y,s[ktt+27+3]=Ltt.x,s[ktt+27+4]=Ltt.y,Vtt++,Btt.renderData.advance(4,6),Vtt>=Ttt&&(Htt(x,f,n),x=f.texture)))}}}function Wtt(t,e,i,r,n,s,a,o){var l=18,h=27;t.updateWorldTransform(),Ri.copy(Mtt,t.matrix),ii.set(Ptt,-(r+Ntt),-(a+Gtt),0),Ri.transform(Mtt,Mtt,Ptt);var u=Mtt,c=u.m12,_=u.m13,f=u.m00,p=u.m01,d=u.m04,m=u.m05,y=1===f&&0===p&&0===d&&1===m;if(o){var g=(r+n)/2,v=(s+a)/2;y?(i[ktt]=g+c,i[ktt+1]=s+_,i[ktt+9]=r+c,i[ktt+9+1]=v+_,i[ktt+l]=n+c,i[ktt+l+1]=v+_,i[ktt+h]=g+c,i[ktt+h+1]=a+_):(i[ktt]=g*f+s*d+c,i[ktt+1]=g*p+s*m+_,i[ktt+9]=r*f+v*d+c,i[ktt+9+1]=r*p+v*m+_,i[ktt+l]=n*f+v*d+c,i[ktt+l+1]=n*p+v*m+_,i[ktt+h]=g*f+a*d+c,i[ktt+h+1]=g*p+a*m+_)}else y?(i[ktt]=r+c,i[ktt+1]=s+_,i[ktt+9]=r+c,i[ktt+9+1]=a+_,i[ktt+l]=n+c,i[ktt+l+1]=s+_,i[ktt+h]=n+c,i[ktt+h+1]=a+_):(i[ktt]=r*f+s*d+c,i[ktt+1]=r*p+s*m+_,i[ktt+9]=r*f+a*d+c,i[ktt+9+1]=r*p+a*m+_,i[ktt+l]=n*f+s*d+c,i[ktt+l+1]=n*p+s*m+_,i[ktt+h]=n*f+a*d+c,i[ktt+h+1]=n*p+a*m+_);i.set(e,ktt+5),i.set(e,ktt+9+5),i.set(e,ktt+l+5),i.set(e,ktt+h+5)}var Xtt=t("tiledLayerAssembler",{getAssembler:function(){return ztt}});Att.Assembler=Xtt;var Ytt,qtt,Jtt=(Ytt=function(t,e){return(Ytt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}Ytt(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});!function(t){var e,i,r,n=function(){function t(t,e,i){if(null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.timelineIds=[];for(var r=0;r<e.length;r++)this.timelineIds[e[r].getPropertyId()]=!0;this.duration=i}return t.prototype.hasTimeline=function(t){return 1==this.timelineIds[t]},t.prototype.apply=function(t,e,i,r,n,s,a,o){if(null==t)throw new Error("skeleton cannot be null.");r&&0!=this.duration&&(i%=this.duration,e>0&&(e%=this.duration));for(var l=this.timelines,h=0,u=l.length;h<u;h++)l[h].apply(t,e,i,n,s,a,o)},t.binarySearch=function(t,e,i){void 0===i&&(i=1);var r=0,n=t.length/i-2;if(0==n)return i;for(var s=n>>>1;;){if(t[(s+1)*i]<=e?r=s+1:n=s,r==n)return(r+1)*i;s=r+n>>>1}},t.linearSearch=function(t,e,i){for(var r=0,n=t.length-i;r<=n;r+=i)if(t[r]>e)return r;return-1},t}();t.Animation=n,function(t){t[t.setup=0]="setup",t[t.first=1]="first",t[t.replace=2]="replace",t[t.add=3]="add"}(e=t.MixBlend||(t.MixBlend={})),function(t){t[t.mixIn=0]="mixIn",t[t.mixOut=1]="mixOut"}(i=t.MixDirection||(t.MixDirection={})),function(t){t[t.rotate=0]="rotate",t[t.translate=1]="translate",t[t.scale=2]="scale",t[t.shear=3]="shear",t[t.attachment=4]="attachment",t[t.color=5]="color",t[t.deform=6]="deform",t[t.event=7]="event",t[t.drawOrder=8]="drawOrder",t[t.ikConstraint=9]="ikConstraint",t[t.transformConstraint=10]="transformConstraint",t[t.pathConstraintPosition=11]="pathConstraintPosition",t[t.pathConstraintSpacing=12]="pathConstraintSpacing",t[t.pathConstraintMix=13]="pathConstraintMix",t[t.twoColor=14]="twoColor"}(r=t.TimelineType||(t.TimelineType={}));var s=function(){function e(i){if(i<=0)throw new Error("frameCount must be > 0: "+i);this.curves=t.Utils.newFloatArray((i-1)*e.BEZIER_SIZE)}return e.prototype.getFrameCount=function(){return this.curves.length/e.BEZIER_SIZE+1},e.prototype.setLinear=function(t){this.curves[t*e.BEZIER_SIZE]=e.LINEAR},e.prototype.setStepped=function(t){this.curves[t*e.BEZIER_SIZE]=e.STEPPED},e.prototype.getCurveType=function(t){var i=t*e.BEZIER_SIZE;if(i==this.curves.length)return e.LINEAR;var r=this.curves[i];return r==e.LINEAR?e.LINEAR:r==e.STEPPED?e.STEPPED:e.BEZIER},e.prototype.setCurve=function(t,i,r,n,s){var a=.03*(2*-i+n),o=.03*(2*-r+s),l=.006*(3*(i-n)+1),h=.006*(3*(r-s)+1),u=2*a+l,c=2*o+h,_=.3*i+a+.16666667*l,f=.3*r+o+.16666667*h,p=t*e.BEZIER_SIZE,d=this.curves;d[p++]=e.BEZIER;for(var m=_,y=f,g=p+e.BEZIER_SIZE-1;p<g;p+=2)d[p]=m,d[p+1]=y,_+=u,f+=c,u+=l,c+=h,m+=_,y+=f},e.prototype.getCurvePercent=function(i,r){r=t.MathUtils.clamp(r,0,1);var n=this.curves,s=i*e.BEZIER_SIZE,a=n[s];if(a==e.LINEAR)return r;if(a==e.STEPPED)return 0;for(var o=0,l=++s,h=s+e.BEZIER_SIZE-1;s<h;s+=2)if((o=n[s])>=r){var u=void 0,c=void 0;return s==l?(u=0,c=0):(u=n[s-2],c=n[s-1]),c+(n[s+1]-c)*(r-u)/(o-u)}var _=n[s-1];return _+(1-_)*(r-o)/(1-o)},e.LINEAR=0,e.STEPPED=1,e.BEZIER=2,e.BEZIER_SIZE=19,e}();t.CurveTimeline=s;var a=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e<<1),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.rotate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i){t<<=1,this.frames[t]=e,this.frames[t+s.ROTATION]=i},s.prototype.apply=function(t,i,r,a,o,l){var h=this.frames,u=t.bones[this.boneIndex];if(u.active)if(r<h[0])switch(l){case e.setup:return void(u.rotation=u.data.rotation);case e.first:var c=u.data.rotation-u.rotation;u.rotation+=(c-360*(16384-(16384.499999999996-c/360|0)))*o}else if(r>=h[h.length-s.ENTRIES]){var _=h[h.length+s.PREV_ROTATION];switch(l){case e.setup:u.rotation=u.data.rotation+_*o;break;case e.first:case e.replace:_+=u.data.rotation-u.rotation,_-=360*(16384-(16384.499999999996-_/360|0));case e.add:u.rotation+=_*o}}else{var f=n.binarySearch(h,r,s.ENTRIES),p=h[f+s.PREV_ROTATION],d=h[f],m=this.getCurvePercent((f>>1)-1,1-(r-d)/(h[f+s.PREV_TIME]-d)),y=h[f+s.ROTATION]-p;switch(y=p+(y-360*(16384-(16384.499999999996-y/360|0)))*m,l){case e.setup:u.rotation=u.data.rotation+(y-360*(16384-(16384.499999999996-y/360|0)))*o;break;case e.first:case e.replace:y+=u.data.rotation-u.rotation;case e.add:u.rotation+=(y-360*(16384-(16384.499999999996-y/360|0)))*o}}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_ROTATION=-1,s.ROTATION=1,s}(s);t.RotateTimeline=a;var o=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.translate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i,r){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.X]=i,this.frames[t+s.Y]=r},s.prototype.apply=function(t,i,r,a,o,l){var h=this.frames,u=t.bones[this.boneIndex];if(u.active)if(r<h[0])switch(l){case e.setup:return u.x=u.data.x,void(u.y=u.data.y);case e.first:u.x+=(u.data.x-u.x)*o,u.y+=(u.data.y-u.y)*o}else{var c=0,_=0;if(r>=h[h.length-s.ENTRIES])c=h[h.length+s.PREV_X],_=h[h.length+s.PREV_Y];else{var f=n.binarySearch(h,r,s.ENTRIES);c=h[f+s.PREV_X],_=h[f+s.PREV_Y];var p=h[f],d=this.getCurvePercent(f/s.ENTRIES-1,1-(r-p)/(h[f+s.PREV_TIME]-p));c+=(h[f+s.X]-c)*d,_+=(h[f+s.Y]-_)*d}switch(l){case e.setup:u.x=u.data.x+c*o,u.y=u.data.y+_*o;break;case e.first:case e.replace:u.x+=(u.data.x+c-u.x)*o,u.y+=(u.data.y+_-u.y)*o;break;case e.add:u.x+=c*o,u.y+=_*o}}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_X=-2,s.PREV_Y=-1,s.X=1,s.Y=2,s}(s);t.TranslateTimeline=o;var l=function(s){function a(t){return s.call(this,t)||this}return Jtt(a,s),a.prototype.getPropertyId=function(){return(r.scale<<24)+this.boneIndex},a.prototype.apply=function(r,s,o,l,h,u,c){var _=this.frames,f=r.bones[this.boneIndex];if(f.active)if(o<_[0])switch(u){case e.setup:return f.scaleX=f.data.scaleX,void(f.scaleY=f.data.scaleY);case e.first:f.scaleX+=(f.data.scaleX-f.scaleX)*h,f.scaleY+=(f.data.scaleY-f.scaleY)*h}else{var p=0,d=0;if(o>=_[_.length-a.ENTRIES])p=_[_.length+a.PREV_X]*f.data.scaleX,d=_[_.length+a.PREV_Y]*f.data.scaleY;else{var m=n.binarySearch(_,o,a.ENTRIES);p=_[m+a.PREV_X],d=_[m+a.PREV_Y];var y=_[m],g=this.getCurvePercent(m/a.ENTRIES-1,1-(o-y)/(_[m+a.PREV_TIME]-y));p=(p+(_[m+a.X]-p)*g)*f.data.scaleX,d=(d+(_[m+a.Y]-d)*g)*f.data.scaleY}if(1==h)u==e.add?(f.scaleX+=p-f.data.scaleX,f.scaleY+=d-f.data.scaleY):(f.scaleX=p,f.scaleY=d);else{var v=0,b=0;if(c==i.mixOut)switch(u){case e.setup:v=f.data.scaleX,b=f.data.scaleY,f.scaleX=v+(Math.abs(p)*t.MathUtils.signum(v)-v)*h,f.scaleY=b+(Math.abs(d)*t.MathUtils.signum(b)-b)*h;break;case e.first:case e.replace:v=f.scaleX,b=f.scaleY,f.scaleX=v+(Math.abs(p)*t.MathUtils.signum(v)-v)*h,f.scaleY=b+(Math.abs(d)*t.MathUtils.signum(b)-b)*h;break;case e.add:v=f.scaleX,b=f.scaleY,f.scaleX=v+(Math.abs(p)*t.MathUtils.signum(v)-f.data.scaleX)*h,f.scaleY=b+(Math.abs(d)*t.MathUtils.signum(b)-f.data.scaleY)*h}else switch(u){case e.setup:v=Math.abs(f.data.scaleX)*t.MathUtils.signum(p),b=Math.abs(f.data.scaleY)*t.MathUtils.signum(d),f.scaleX=v+(p-v)*h,f.scaleY=b+(d-b)*h;break;case e.first:case e.replace:v=Math.abs(f.scaleX)*t.MathUtils.signum(p),b=Math.abs(f.scaleY)*t.MathUtils.signum(d),f.scaleX=v+(p-v)*h,f.scaleY=b+(d-b)*h;break;case e.add:v=t.MathUtils.signum(p),b=t.MathUtils.signum(d),f.scaleX=Math.abs(f.scaleX)*v+(p-Math.abs(f.data.scaleX)*v)*h,f.scaleY=Math.abs(f.scaleY)*b+(d-Math.abs(f.data.scaleY)*b)*h}}}},a}(o);t.ScaleTimeline=l;var h=function(t){function i(e){return t.call(this,e)||this}return Jtt(i,t),i.prototype.getPropertyId=function(){return(r.shear<<24)+this.boneIndex},i.prototype.apply=function(t,r,s,a,o,l){var h=this.frames,u=t.bones[this.boneIndex];if(u.active)if(s<h[0])switch(l){case e.setup:return u.shearX=u.data.shearX,void(u.shearY=u.data.shearY);case e.first:u.shearX+=(u.data.shearX-u.shearX)*o,u.shearY+=(u.data.shearY-u.shearY)*o}else{var c=0,_=0;if(s>=h[h.length-i.ENTRIES])c=h[h.length+i.PREV_X],_=h[h.length+i.PREV_Y];else{var f=n.binarySearch(h,s,i.ENTRIES);c=h[f+i.PREV_X],_=h[f+i.PREV_Y];var p=h[f],d=this.getCurvePercent(f/i.ENTRIES-1,1-(s-p)/(h[f+i.PREV_TIME]-p));c+=(h[f+i.X]-c)*d,_+=(h[f+i.Y]-_)*d}switch(l){case e.setup:u.shearX=u.data.shearX+c*o,u.shearY=u.data.shearY+_*o;break;case e.first:case e.replace:u.shearX+=(u.data.shearX+c-u.shearX)*o,u.shearY+=(u.data.shearY+_-u.shearY)*o;break;case e.add:u.shearX+=c*o,u.shearY+=_*o}}},i}(o);t.ShearTimeline=h;var u=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.color<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,r,n,a){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=r,this.frames[t+s.B]=n,this.frames[t+s.A]=a},s.prototype.apply=function(t,i,r,a,o,l){var h=t.slots[this.slotIndex];if(h.bone.active){var u=this.frames;if(r<u[0])switch(l){case e.setup:return void h.color.setFromColor(h.data.color);case e.first:var c=h.color,_=h.data.color;c.add((_.r-c.r)*o,(_.g-c.g)*o,(_.b-c.b)*o,(_.a-c.a)*o)}else{var f=0,p=0,d=0,m=0;if(r>=u[u.length-s.ENTRIES]){var y=u.length;f=u[y+s.PREV_R],p=u[y+s.PREV_G],d=u[y+s.PREV_B],m=u[y+s.PREV_A]}else{var g=n.binarySearch(u,r,s.ENTRIES);f=u[g+s.PREV_R],p=u[g+s.PREV_G],d=u[g+s.PREV_B],m=u[g+s.PREV_A];var v=u[g],b=this.getCurvePercent(g/s.ENTRIES-1,1-(r-v)/(u[g+s.PREV_TIME]-v));f+=(u[g+s.R]-f)*b,p+=(u[g+s.G]-p)*b,d+=(u[g+s.B]-d)*b,m+=(u[g+s.A]-m)*b}1==o?h.color.set(f,p,d,m):(c=h.color,l==e.setup&&c.setFromColor(h.data.color),c.add((f-c.r)*o,(p-c.g)*o,(d-c.b)*o,(m-c.a)*o))}}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_R=-4,s.PREV_G=-3,s.PREV_B=-2,s.PREV_A=-1,s.R=1,s.G=2,s.B=3,s.A=4,s}(s);t.ColorTimeline=u;var c=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.twoColor<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,r,n,a,o,l,h){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=r,this.frames[t+s.B]=n,this.frames[t+s.A]=a,this.frames[t+s.R2]=o,this.frames[t+s.G2]=l,this.frames[t+s.B2]=h},s.prototype.apply=function(t,i,r,a,o,l){var h=t.slots[this.slotIndex];if(h.bone.active){var u=this.frames;if(r<u[0])switch(l){case e.setup:return h.color.setFromColor(h.data.color),void h.darkColor.setFromColor(h.data.darkColor);case e.first:var c=h.color,_=h.darkColor,f=h.data.color,p=h.data.darkColor;c.add((f.r-c.r)*o,(f.g-c.g)*o,(f.b-c.b)*o,(f.a-c.a)*o),_.add((p.r-_.r)*o,(p.g-_.g)*o,(p.b-_.b)*o,0)}else{var d=0,m=0,y=0,g=0,v=0,b=0,S=0;if(r>=u[u.length-s.ENTRIES]){var A=u.length;d=u[A+s.PREV_R],m=u[A+s.PREV_G],y=u[A+s.PREV_B],g=u[A+s.PREV_A],v=u[A+s.PREV_R2],b=u[A+s.PREV_G2],S=u[A+s.PREV_B2]}else{var C=n.binarySearch(u,r,s.ENTRIES);d=u[C+s.PREV_R],m=u[C+s.PREV_G],y=u[C+s.PREV_B],g=u[C+s.PREV_A],v=u[C+s.PREV_R2],b=u[C+s.PREV_G2],S=u[C+s.PREV_B2];var x=u[C],T=this.getCurvePercent(C/s.ENTRIES-1,1-(r-x)/(u[C+s.PREV_TIME]-x));d+=(u[C+s.R]-d)*T,m+=(u[C+s.G]-m)*T,y+=(u[C+s.B]-y)*T,g+=(u[C+s.A]-g)*T,v+=(u[C+s.R2]-v)*T,b+=(u[C+s.G2]-b)*T,S+=(u[C+s.B2]-S)*T}1==o?(h.color.set(d,m,y,g),h.darkColor.set(v,b,S,1)):(c=h.color,_=h.darkColor,l==e.setup&&(c.setFromColor(h.data.color),_.setFromColor(h.data.darkColor)),c.add((d-c.r)*o,(m-c.g)*o,(y-c.b)*o,(g-c.a)*o),_.add((v-_.r)*o,(b-_.g)*o,(S-_.b)*o,0))}}},s.ENTRIES=8,s.PREV_TIME=-8,s.PREV_R=-7,s.PREV_G=-6,s.PREV_B=-5,s.PREV_A=-4,s.PREV_R2=-3,s.PREV_G2=-2,s.PREV_B2=-1,s.R=1,s.G=2,s.B=3,s.A=4,s.R2=5,s.G2=6,s.B2=7,s}(s);t.TwoColorTimeline=c;var _=function(){function s(e){this.frames=t.Utils.newFloatArray(e),this.attachmentNames=new Array(e)}return s.prototype.getPropertyId=function(){return(r.attachment<<24)+this.slotIndex},s.prototype.getFrameCount=function(){return this.frames.length},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},s.prototype.apply=function(t,r,s,a,o,l,h){var u=t.slots[this.slotIndex];if(u.bone.active)if(h!=i.mixOut||l!=e.setup){var c=this.frames;if(s<c[0]){if(l==e.setup||l==e.first){var _=u.data.attachmentName;u.setAttachment(null==_?null:t.getAttachment(this.slotIndex,_))}}else{var f;f=s>=c[c.length-1]?c.length-1:n.binarySearch(c,s,1)-1;var p=this.attachmentNames[f];t.slots[this.slotIndex].setAttachment(null==p?null:t.getAttachment(this.slotIndex,p))}}else{var d=u.data.attachmentName;u.setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}},s}();t.AttachmentTimeline=_;var f=null,p=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e),r.frameVertices=new Array(e),null==f&&(f=t.Utils.newFloatArray(64)),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.deform<<27)+ +this.attachment.id+this.slotIndex},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.frameVertices[t]=i},s.prototype.apply=function(i,r,s,a,o,l){var h=i.slots[this.slotIndex];if(h.bone.active){var u=h.getAttachment();if(u instanceof t.VertexAttachment&&u.deformAttachment==this.attachment){var c=h.deform;0==c.length&&(l=e.setup);var _=this.frameVertices,f=_[0].length,p=this.frames;if(s<p[0]){var d=u;switch(l){case e.setup:return void(c.length=0);case e.first:if(1==o){c.length=0;break}var m=t.Utils.setArraySize(c,f);if(null==d.bones)for(var y=d.vertices,g=0;g<f;g++)m[g]+=(y[g]-m[g])*o;else for(o=1-o,g=0;g<f;g++)m[g]*=o}}else{var v=t.Utils.setArraySize(c,f);if(s>=p[p.length-1]){var b=_[p.length-1];if(1==o)if(l==e.add)if(null==(d=u).bones){y=d.vertices;for(var S=0;S<f;S++)v[S]+=b[S]-y[S]}else for(var A=0;A<f;A++)v[A]+=b[A];else t.Utils.arrayCopy(b,0,v,0,f);else switch(l){case e.setup:var C=u;if(null==C.bones){y=C.vertices;for(var x=0;x<f;x++){var T=y[x];v[x]=T+(b[x]-T)*o}}else for(var w=0;w<f;w++)v[w]=b[w]*o;break;case e.first:case e.replace:for(var E=0;E<f;E++)v[E]+=(b[E]-v[E])*o;case e.add:if(null==(d=u).bones){y=d.vertices;for(var B=0;B<f;B++)v[B]+=(b[B]-y[B])*o}else for(var D=0;D<f;D++)v[D]+=b[D]*o}}else{var M=n.binarySearch(p,s),P=_[M-1],R=_[M],I=p[M],O=this.getCurvePercent(M-1,1-(s-I)/(p[M-1]-I));if(1==o)if(l==e.add)if(null==(d=u).bones){y=d.vertices;for(var F=0;F<f;F++){var L=P[F];v[F]+=L+(R[F]-L)*O-y[F]}}else for(var V=0;V<f;V++)L=P[V],v[V]+=L+(R[V]-L)*O;else for(var k=0;k<f;k++)L=P[k],v[k]=L+(R[k]-L)*O;else switch(l){case e.setup:var N=u;if(null==N.bones){y=N.vertices;for(var G=0;G<f;G++)L=P[G],T=y[G],v[G]=T+(L+(R[G]-L)*O-T)*o}else for(var z=0;z<f;z++)L=P[z],v[z]=(L+(R[z]-L)*O)*o;break;case e.first:case e.replace:for(var U=0;U<f;U++)L=P[U],v[U]+=(L+(R[U]-L)*O-v[U])*o;break;case e.add:if(null==(d=u).bones){y=d.vertices;for(var H=0;H<f;H++)L=P[H],v[H]+=(L+(R[H]-L)*O-y[H])*o}else for(var j=0;j<f;j++)L=P[j],v[j]+=(L+(R[j]-L)*O)*o}}}}}},s}(s);t.DeformTimeline=p;var d=function(){function e(e){this.frames=t.Utils.newFloatArray(e),this.events=new Array(e)}return e.prototype.getPropertyId=function(){return r.event<<24},e.prototype.getFrameCount=function(){return this.frames.length},e.prototype.setFrame=function(t,e){this.frames[t]=e.time,this.events[t]=e},e.prototype.apply=function(t,e,i,r,s,a,o){if(null!=r){var l=this.frames,h=this.frames.length;if(e>i)this.apply(t,e,Number.MAX_VALUE,r,s,a,o),e=-1;else if(e>=l[h-1])return;if(!(i<l[0])){var u=0;if(e<l[0])u=0;else for(var c=l[u=n.binarySearch(l,e)];u>0&&l[u-1]==c;)u--;for(;u<h&&i>=l[u];u++)r.push(this.events[u])}}},e}();t.EventTimeline=d;var m=function(){function s(e){this.frames=t.Utils.newFloatArray(e),this.drawOrders=new Array(e)}return s.prototype.getPropertyId=function(){return r.drawOrder<<24},s.prototype.getFrameCount=function(){return this.frames.length},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.drawOrders[t]=i},s.prototype.apply=function(r,s,a,o,l,h,u){var c=r.drawOrder,_=r.slots;if(u!=i.mixOut||h!=e.setup){var f=this.frames;if(a<f[0])h!=e.setup&&h!=e.first||t.Utils.arrayCopy(r.slots,0,r.drawOrder,0,r.slots.length);else{var p;p=a>=f[f.length-1]?f.length-1:n.binarySearch(f,a)-1;var d=this.drawOrders[p];if(null==d)t.Utils.arrayCopy(_,0,c,0,_.length);else for(var m=0,y=d.length;m<y;m++)c[m]=_[d[m]]}}else t.Utils.arrayCopy(r.slots,0,r.drawOrder,0,r.slots.length)},s}();t.DrawOrderTimeline=m;var y=function(s){function a(e){var i=s.call(this,e)||this;return i.frames=t.Utils.newFloatArray(e*a.ENTRIES),i}return Jtt(a,s),a.prototype.getPropertyId=function(){return(r.ikConstraint<<24)+this.ikConstraintIndex},a.prototype.setFrame=function(t,e,i,r,n,s,o){t*=a.ENTRIES,this.frames[t]=e,this.frames[t+a.MIX]=i,this.frames[t+a.SOFTNESS]=r,this.frames[t+a.BEND_DIRECTION]=n,this.frames[t+a.COMPRESS]=s?1:0,this.frames[t+a.STRETCH]=o?1:0},a.prototype.apply=function(t,r,s,o,l,h,u){var c=this.frames,_=t.ikConstraints[this.ikConstraintIndex];if(_.active)if(s<c[0])switch(h){case e.setup:return _.mix=_.data.mix,_.softness=_.data.softness,_.bendDirection=_.data.bendDirection,_.compress=_.data.compress,void(_.stretch=_.data.stretch);case e.first:_.mix+=(_.data.mix-_.mix)*l,_.softness+=(_.data.softness-_.softness)*l,_.bendDirection=_.data.bendDirection,_.compress=_.data.compress,_.stretch=_.data.stretch}else if(s>=c[c.length-a.ENTRIES])h==e.setup?(_.mix=_.data.mix+(c[c.length+a.PREV_MIX]-_.data.mix)*l,_.softness=_.data.softness+(c[c.length+a.PREV_SOFTNESS]-_.data.softness)*l,u==i.mixOut?(_.bendDirection=_.data.bendDirection,_.compress=_.data.compress,_.stretch=_.data.stretch):(_.bendDirection=c[c.length+a.PREV_BEND_DIRECTION],_.compress=0!=c[c.length+a.PREV_COMPRESS],_.stretch=0!=c[c.length+a.PREV_STRETCH])):(_.mix+=(c[c.length+a.PREV_MIX]-_.mix)*l,_.softness+=(c[c.length+a.PREV_SOFTNESS]-_.softness)*l,u==i.mixIn&&(_.bendDirection=c[c.length+a.PREV_BEND_DIRECTION],_.compress=0!=c[c.length+a.PREV_COMPRESS],_.stretch=0!=c[c.length+a.PREV_STRETCH]));else{var f=n.binarySearch(c,s,a.ENTRIES),p=c[f+a.PREV_MIX],d=c[f+a.PREV_SOFTNESS],m=c[f],y=this.getCurvePercent(f/a.ENTRIES-1,1-(s-m)/(c[f+a.PREV_TIME]-m));h==e.setup?(_.mix=_.data.mix+(p+(c[f+a.MIX]-p)*y-_.data.mix)*l,_.softness=_.data.softness+(d+(c[f+a.SOFTNESS]-d)*y-_.data.softness)*l,u==i.mixOut?(_.bendDirection=_.data.bendDirection,_.compress=_.data.compress,_.stretch=_.data.stretch):(_.bendDirection=c[f+a.PREV_BEND_DIRECTION],_.compress=0!=c[f+a.PREV_COMPRESS],_.stretch=0!=c[f+a.PREV_STRETCH])):(_.mix+=(p+(c[f+a.MIX]-p)*y-_.mix)*l,_.softness+=(d+(c[f+a.SOFTNESS]-d)*y-_.softness)*l,u==i.mixIn&&(_.bendDirection=c[f+a.PREV_BEND_DIRECTION],_.compress=0!=c[f+a.PREV_COMPRESS],_.stretch=0!=c[f+a.PREV_STRETCH]))}},a.ENTRIES=6,a.PREV_TIME=-6,a.PREV_MIX=-5,a.PREV_SOFTNESS=-4,a.PREV_BEND_DIRECTION=-3,a.PREV_COMPRESS=-2,a.PREV_STRETCH=-1,a.MIX=1,a.SOFTNESS=2,a.BEND_DIRECTION=3,a.COMPRESS=4,a.STRETCH=5,a}(s);t.IkConstraintTimeline=y;var g=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.transformConstraint<<24)+this.transformConstraintIndex},s.prototype.setFrame=function(t,e,i,r,n,a){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=r,this.frames[t+s.SCALE]=n,this.frames[t+s.SHEAR]=a},s.prototype.apply=function(t,i,r,a,o,l){var h=this.frames,u=t.transformConstraints[this.transformConstraintIndex];if(u.active)if(r<h[0]){var c=u.data;switch(l){case e.setup:return u.rotateMix=c.rotateMix,u.translateMix=c.translateMix,u.scaleMix=c.scaleMix,void(u.shearMix=c.shearMix);case e.first:u.rotateMix+=(c.rotateMix-u.rotateMix)*o,u.translateMix+=(c.translateMix-u.translateMix)*o,u.scaleMix+=(c.scaleMix-u.scaleMix)*o,u.shearMix+=(c.shearMix-u.shearMix)*o}}else{var _=0,f=0,p=0,d=0;if(r>=h[h.length-s.ENTRIES]){var m=h.length;_=h[m+s.PREV_ROTATE],f=h[m+s.PREV_TRANSLATE],p=h[m+s.PREV_SCALE],d=h[m+s.PREV_SHEAR]}else{var y=n.binarySearch(h,r,s.ENTRIES);_=h[y+s.PREV_ROTATE],f=h[y+s.PREV_TRANSLATE],p=h[y+s.PREV_SCALE],d=h[y+s.PREV_SHEAR];var g=h[y],v=this.getCurvePercent(y/s.ENTRIES-1,1-(r-g)/(h[y+s.PREV_TIME]-g));_+=(h[y+s.ROTATE]-_)*v,f+=(h[y+s.TRANSLATE]-f)*v,p+=(h[y+s.SCALE]-p)*v,d+=(h[y+s.SHEAR]-d)*v}l==e.setup?(c=u.data,u.rotateMix=c.rotateMix+(_-c.rotateMix)*o,u.translateMix=c.translateMix+(f-c.translateMix)*o,u.scaleMix=c.scaleMix+(p-c.scaleMix)*o,u.shearMix=c.shearMix+(d-c.shearMix)*o):(u.rotateMix+=(_-u.rotateMix)*o,u.translateMix+=(f-u.translateMix)*o,u.scaleMix+=(p-u.scaleMix)*o,u.shearMix+=(d-u.shearMix)*o)}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_ROTATE=-4,s.PREV_TRANSLATE=-3,s.PREV_SCALE=-2,s.PREV_SHEAR=-1,s.ROTATE=1,s.TRANSLATE=2,s.SCALE=3,s.SHEAR=4,s}(s);t.TransformConstraintTimeline=g;var v=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.pathConstraintPosition<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.VALUE]=i},s.prototype.apply=function(t,i,r,a,o,l){var h=this.frames,u=t.pathConstraints[this.pathConstraintIndex];if(u.active)if(r<h[0])switch(l){case e.setup:return void(u.position=u.data.position);case e.first:u.position+=(u.data.position-u.position)*o}else{var c=0;if(r>=h[h.length-s.ENTRIES])c=h[h.length+s.PREV_VALUE];else{var _=n.binarySearch(h,r,s.ENTRIES);c=h[_+s.PREV_VALUE];var f=h[_],p=this.getCurvePercent(_/s.ENTRIES-1,1-(r-f)/(h[_+s.PREV_TIME]-f));c+=(h[_+s.VALUE]-c)*p}l==e.setup?u.position=u.data.position+(c-u.data.position)*o:u.position+=(c-u.position)*o}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_VALUE=-1,s.VALUE=1,s}(s);t.PathConstraintPositionTimeline=v;var b=function(t){function i(e){return t.call(this,e)||this}return Jtt(i,t),i.prototype.getPropertyId=function(){return(r.pathConstraintSpacing<<24)+this.pathConstraintIndex},i.prototype.apply=function(t,r,s,a,o,l){var h=this.frames,u=t.pathConstraints[this.pathConstraintIndex];if(u.active)if(s<h[0])switch(l){case e.setup:return void(u.spacing=u.data.spacing);case e.first:u.spacing+=(u.data.spacing-u.spacing)*o}else{var c=0;if(s>=h[h.length-i.ENTRIES])c=h[h.length+i.PREV_VALUE];else{var _=n.binarySearch(h,s,i.ENTRIES);c=h[_+i.PREV_VALUE];var f=h[_],p=this.getCurvePercent(_/i.ENTRIES-1,1-(s-f)/(h[_+i.PREV_TIME]-f));c+=(h[_+i.VALUE]-c)*p}l==e.setup?u.spacing=u.data.spacing+(c-u.data.spacing)*o:u.spacing+=(c-u.spacing)*o}},i}(v);t.PathConstraintSpacingTimeline=b;var S=function(i){function s(e){var r=i.call(this,e)||this;return r.frames=t.Utils.newFloatArray(e*s.ENTRIES),r}return Jtt(s,i),s.prototype.getPropertyId=function(){return(r.pathConstraintMix<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i,r){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=r},s.prototype.apply=function(t,i,r,a,o,l){var h=this.frames,u=t.pathConstraints[this.pathConstraintIndex];if(u.active)if(r<h[0])switch(l){case e.setup:return u.rotateMix=u.data.rotateMix,void(u.translateMix=u.data.translateMix);case e.first:u.rotateMix+=(u.data.rotateMix-u.rotateMix)*o,u.translateMix+=(u.data.translateMix-u.translateMix)*o}else{var c=0,_=0;if(r>=h[h.length-s.ENTRIES])c=h[h.length+s.PREV_ROTATE],_=h[h.length+s.PREV_TRANSLATE];else{var f=n.binarySearch(h,r,s.ENTRIES);c=h[f+s.PREV_ROTATE],_=h[f+s.PREV_TRANSLATE];var p=h[f],d=this.getCurvePercent(f/s.ENTRIES-1,1-(r-p)/(h[f+s.PREV_TIME]-p));c+=(h[f+s.ROTATE]-c)*d,_+=(h[f+s.TRANSLATE]-_)*d}l==e.setup?(u.rotateMix=u.data.rotateMix+(c-u.data.rotateMix)*o,u.translateMix=u.data.translateMix+(_-u.data.translateMix)*o):(u.rotateMix+=(c-u.rotateMix)*o,u.translateMix+=(_-u.translateMix)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_ROTATE=-2,s.PREV_TRANSLATE=-1,s.ROTATE=1,s.TRANSLATE=2,s}(s);t.PathConstraintMixTimeline=S}(qtt||(qtt={})),function(t){var e=function(){function e(e){this.tracks=new Array,this.timeScale=1,this.events=new Array,this.listeners=new Array,this.queue=new n(this),this.propertyIDs=new t.IntSet,this.animationsChanged=!1,this.trackEntryPool=new t.Pool((function(){return new i})),this.data=e}return e.prototype.update=function(t){t*=this.timeScale;for(var e=this.tracks,i=0,r=e.length;i<r;i++){var n=e[i];if(null!=n){n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast;var s=t*n.timeScale;if(n.delay>0){if(n.delay-=s,n.delay>0)continue;s=-n.delay,n.delay=0}var a=n.next;if(null!=a){var o=n.trackLast-a.delay;if(o>=0){for(a.delay=0,a.trackTime+=0==n.timeScale?0:(o/n.timeScale+t)*a.timeScale,n.trackTime+=s,this.setCurrent(i,a,!0);null!=a.mixingFrom;)a.mixTime+=t,a=a.mixingFrom;continue}}else if(n.trackLast>=n.trackEnd&&null==n.mixingFrom){e[i]=null,this.queue.end(n),this.disposeNext(n);continue}if(null!=n.mixingFrom&&this.updateMixingFrom(n,t)){var l=n.mixingFrom;for(n.mixingFrom=null,null!=l&&(l.mixingTo=null);null!=l;)this.queue.end(l),l=l.mixingFrom}n.trackTime+=s}}this.queue.drain()},e.prototype.updateMixingFrom=function(t,e){var i=t.mixingFrom;if(null==i)return!0;var r=this.updateMixingFrom(i,e);return i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast,t.mixTime>0&&t.mixTime>=t.mixDuration?(0!=i.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=i.mixingFrom,null!=i.mixingFrom&&(i.mixingFrom.mixingTo=t),t.interruptAlpha=i.interruptAlpha,this.queue.end(i)),r):(i.trackTime+=e*i.timeScale,t.mixTime+=e,!1)},e.prototype.apply=function(i){if(null==i)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var r=this.events,n=this.tracks,s=!1,a=0,o=n.length;a<o;a++){var l=n[a];if(!(null==l||l.delay>0)){s=!0;var h=0==a?t.MixBlend.first:l.mixBlend,u=l.alpha;null!=l.mixingFrom?u*=this.applyMixingFrom(l,i,h):l.trackTime>=l.trackEnd&&null==l.next&&(u=0);var c=l.animationLast,_=l.getAnimationTime(),f=l.animation.timelines.length,p=l.animation.timelines;if(0==a&&1==u||h==t.MixBlend.add)for(var d=0;d<f;d++)t.Utils.webkit602BugfixHelper(u,h),p[d].apply(i,c,_,r,u,h,t.MixDirection.mixIn);else{var m=l.timelineMode,y=0==l.timelinesRotation.length;y&&t.Utils.setArraySize(l.timelinesRotation,f<<1,null);var g=l.timelinesRotation;for(d=0;d<f;d++){var v=p[d],b=(m[d]&e.NOT_LAST-1)==e.SUBSEQUENT?h:t.MixBlend.setup;v instanceof t.RotateTimeline?this.applyRotateTimeline(v,i,_,u,b,g,d<<1,y):(t.Utils.webkit602BugfixHelper(u,h),v.apply(i,c,_,r,u,b,t.MixDirection.mixIn))}}this.queueEvents(l,_),r.length=0,l.nextAnimationLast=_,l.nextTrackLast=l.trackTime}}return this.queue.drain(),s},e.prototype.applyMixingFrom=function(i,r,n){var s=i.mixingFrom;null!=s.mixingFrom&&this.applyMixingFrom(s,r,n);var a=0;0==i.mixDuration?(a=1,n==t.MixBlend.first&&(n=t.MixBlend.setup)):((a=i.mixTime/i.mixDuration)>1&&(a=1),n!=t.MixBlend.first&&(n=s.mixBlend));var o=a<s.eventThreshold?this.events:null,l=a<s.attachmentThreshold,h=a<s.drawOrderThreshold,u=s.animationLast,c=s.getAnimationTime(),_=s.animation.timelines.length,f=s.animation.timelines,p=s.alpha*i.interruptAlpha,d=p*(1-a);if(n==t.MixBlend.add)for(var m=0;m<_;m++)f[m].apply(r,u,c,o,d,n,t.MixDirection.mixOut);else{var y=s.timelineMode,g=s.timelineHoldMix,v=0==s.timelinesRotation.length;v&&t.Utils.setArraySize(s.timelinesRotation,_<<1,null);var b=s.timelinesRotation;for(s.totalAlpha=0,m=0;m<_;m++){var S=f[m],A=t.MixDirection.mixOut,C=void 0,x=0;switch(y[m]&e.NOT_LAST-1){case e.SUBSEQUENT:if(C=n,!l&&S instanceof t.AttachmentTimeline){if((y[m]&e.NOT_LAST)==e.NOT_LAST)continue;C=t.MixBlend.setup}if(!h&&S instanceof t.DrawOrderTimeline)continue;x=d;break;case e.FIRST:C=t.MixBlend.setup,x=d;break;case e.HOLD:C=t.MixBlend.setup,x=p;break;default:C=t.MixBlend.setup;var T=g[m];x=p*Math.max(0,1-T.mixTime/T.mixDuration)}s.totalAlpha+=x,S instanceof t.RotateTimeline?this.applyRotateTimeline(S,r,c,x,C,b,m<<1,v):(t.Utils.webkit602BugfixHelper(x,n),C==t.MixBlend.setup&&(S instanceof t.AttachmentTimeline?(l||(y[m]&e.NOT_LAST)==e.NOT_LAST)&&(A=t.MixDirection.mixIn):S instanceof t.DrawOrderTimeline&&h&&(A=t.MixDirection.mixIn)),S.apply(r,u,c,o,x,C,A))}}return i.mixDuration>0&&this.queueEvents(s,c),this.events.length=0,s.nextAnimationLast=c,s.nextTrackLast=s.trackTime,a},e.prototype.applyRotateTimeline=function(e,i,r,n,s,a,o,l){if(l&&(a[o]=0),1!=n){var h=e,u=h.frames,c=i.bones[h.boneIndex];if(c.active){var _=0,f=0;if(r<u[0])switch(s){case t.MixBlend.setup:c.rotation=c.data.rotation;default:return;case t.MixBlend.first:_=c.rotation,f=c.data.rotation}else if(_=s==t.MixBlend.setup?c.data.rotation:c.rotation,r>=u[u.length-t.RotateTimeline.ENTRIES])f=c.data.rotation+u[u.length+t.RotateTimeline.PREV_ROTATION];else{var p=t.Animation.binarySearch(u,r,t.RotateTimeline.ENTRIES),d=u[p+t.RotateTimeline.PREV_ROTATION],m=u[p],y=h.getCurvePercent((p>>1)-1,1-(r-m)/(u[p+t.RotateTimeline.PREV_TIME]-m));f=u[p+t.RotateTimeline.ROTATION]-d,f=d+(f-=360*(16384-(16384.499999999996-f/360|0)))*y+c.data.rotation,f-=360*(16384-(16384.499999999996-f/360|0))}var g=0,v=f-_;if(0==(v-=360*(16384-(16384.499999999996-v/360|0))))g=a[o];else{var b=0,S=0;l?(b=0,S=v):(b=a[o],S=a[o+1]);var A=v>0,C=b>=0;t.MathUtils.signum(S)!=t.MathUtils.signum(v)&&Math.abs(S)<=90&&(Math.abs(b)>180&&(b+=360*t.MathUtils.signum(b)),C=A),g=v+b-b%360,C!=A&&(g+=360*t.MathUtils.signum(b)),a[o]=g}a[o+1]=v,_+=g*n,c.rotation=_-360*(16384-(16384.499999999996-_/360|0))}}else e.apply(i,0,r,null,1,s,t.MixDirection.mixIn)},e.prototype.queueEvents=function(t,e){for(var i=t.animationStart,r=t.animationEnd,n=r-i,s=t.trackLast%n,a=this.events,o=0,l=a.length;o<l;o++){var h=a[o];if(h.time<s)break;h.time>r||this.queue.event(t,h)}for((t.loop?0==n||s>t.trackTime%n:e>=r&&t.animationLast<r)&&this.queue.complete(t);o<l;o++)a[o].time<i||this.queue.event(t,a[o])},e.prototype.clearTracks=function(){var t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(var e=0,i=this.tracks.length;e<i;e++)this.clearTrack(e);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()},e.prototype.clearTrack=function(t){if(!(t>=this.tracks.length)){var e=this.tracks[t];if(null!=e){this.queue.end(e),this.disposeNext(e);for(var i=e;;){var r=i.mixingFrom;if(null==r)break;this.queue.end(r),i.mixingFrom=null,i.mixingTo=null,i=r}this.tracks[e.trackIndex]=null,this.queue.drain()}}},e.prototype.setCurrent=function(t,e,i){var r=this.expandToIndex(t);this.tracks[t]=e,null!=r&&(i&&this.queue.interrupt(r),e.mixingFrom=r,r.mixingTo=e,e.mixTime=0,null!=r.mixingFrom&&r.mixDuration>0&&(e.interruptAlpha*=Math.min(1,r.mixTime/r.mixDuration)),r.timelinesRotation.length=0),this.queue.start(e)},e.prototype.setAnimation=function(t,e,i){var r=this.data.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,r,i)},e.prototype.setAnimationWith=function(t,e,i){if(null==e)throw new Error("animation cannot be null.");var r=!0,n=this.expandToIndex(t);null!=n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.disposeNext(n),n=n.mixingFrom,r=!1):this.disposeNext(n));var s=this.trackEntry(t,e,i,n);return this.setCurrent(t,s,r),this.queue.drain(),s},e.prototype.addAnimation=function(t,e,i,r){var n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,i,r)},e.prototype.addAnimationWith=function(t,e,i,r){if(null==e)throw new Error("animation cannot be null.");var n=this.expandToIndex(t);if(null!=n)for(;null!=n.next;)n=n.next;var s=this.trackEntry(t,e,i,n);if(null==n)this.setCurrent(t,s,!0),this.queue.drain();else if(n.next=s,r<=0){var a=n.animationEnd-n.animationStart;0!=a?(n.loop?r+=a*(1+(n.trackTime/a|0)):r+=Math.max(a,n.trackTime),r-=this.data.getMix(n.animation,e)):r=n.trackTime}return s.delay=r,s},e.prototype.setEmptyAnimation=function(t,i){var r=this.setAnimationWith(t,e.emptyAnimation,!1);return r.mixDuration=i,r.trackEnd=i,r},e.prototype.addEmptyAnimation=function(t,i,r){r<=0&&(r-=i);var n=this.addAnimationWith(t,e.emptyAnimation,!1,r);return n.mixDuration=i,n.trackEnd=i,n},e.prototype.setEmptyAnimations=function(t){var e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(var i=0,r=this.tracks.length;i<r;i++){var n=this.tracks[i];null!=n&&this.setEmptyAnimation(n.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()},e.prototype.expandToIndex=function(e){return e<this.tracks.length?this.tracks[e]:(t.Utils.ensureArrayCapacity(this.tracks,e+1,null),this.tracks.length=e+1,null)},e.prototype.trackEntry=function(t,e,i,r){var n=this.trackEntryPool.obtain();return n.trackIndex=t,n.animation=e,n.loop=i,n.holdPrevious=!1,n.eventThreshold=0,n.attachmentThreshold=0,n.drawOrderThreshold=0,n.animationStart=0,n.animationEnd=e.duration,n.animationLast=-1,n.nextAnimationLast=-1,n.delay=0,n.trackTime=0,n.trackLast=-1,n.nextTrackLast=-1,n.trackEnd=Number.MAX_VALUE,n.timeScale=1,n.alpha=1,n.interruptAlpha=1,n.mixTime=0,n.mixDuration=null==r?0:this.data.getMix(r.animation,e),n},e.prototype.disposeNext=function(t){for(var e=t.next;null!=e;)this.queue.dispose(e),e=e.next;t.next=null},e.prototype._animationsChanged=function(){this.animationsChanged=!1,this.propertyIDs.clear();for(var e=0,i=this.tracks.length;e<i;e++)if(null!=(r=this.tracks[e])){for(;null!=r.mixingFrom;)r=r.mixingFrom;do{null!=r.mixingFrom&&r.mixBlend==t.MixBlend.add||this.computeHold(r),r=r.mixingTo}while(null!=r)}for(this.propertyIDs.clear(),e=this.tracks.length-1;e>=0;e--)for(var r=this.tracks[e];null!=r;)this.computeNotLast(r),r=r.mixingFrom},e.prototype.computeHold=function(i){var r=i.mixingTo,n=i.animation.timelines,s=i.animation.timelines.length,a=t.Utils.setArraySize(i.timelineMode,s);i.timelineHoldMix.length=0;var o=t.Utils.setArraySize(i.timelineHoldMix,s),l=this.propertyIDs;if(null!=r&&r.holdPrevious)for(var h=0;h<s;h++)l.add(n[h].getPropertyId()),a[h]=e.HOLD;else t:for(h=0;h<s;h++){var u=n[h],c=u.getPropertyId();if(l.add(c))if(null==r||u instanceof t.AttachmentTimeline||u instanceof t.DrawOrderTimeline||u instanceof t.EventTimeline||!r.animation.hasTimeline(c))a[h]=e.FIRST;else{for(var _=r.mixingTo;null!=_;_=_.mixingTo)if(!_.animation.hasTimeline(c)){if(i.mixDuration>0){a[h]=e.HOLD_MIX,o[h]=_;continue t}break}a[h]=e.HOLD}else a[h]=e.SUBSEQUENT}},e.prototype.computeNotLast=function(i){for(var r=i.animation.timelines,n=i.animation.timelines.length,s=i.timelineMode,a=this.propertyIDs,o=0;o<n;o++)if(r[o]instanceof t.AttachmentTimeline){var l=r[o];a.add(l.slotIndex)||(s[o]|=e.NOT_LAST)}},e.prototype.getCurrent=function(t){return t>=this.tracks.length?null:this.tracks[t]},e.prototype.addListener=function(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)},e.prototype.removeListener=function(t){var e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)},e.prototype.clearListeners=function(){this.listeners.length=0},e.prototype.clearListenerNotifications=function(){this.queue.clear()},e.emptyAnimation=new t.Animation("<empty>",[],0),e.SUBSEQUENT=0,e.FIRST=1,e.HOLD=2,e.HOLD_MIX=3,e.NOT_LAST=4,e}();t.AnimationState=e;var i=function(){function e(){this.mixBlend=t.MixBlend.replace,this.timelineMode=new Array,this.timelineHoldMix=new Array,this.timelinesRotation=new Array}return e.prototype.reset=function(){this.next=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0},e.prototype.getAnimationTime=function(){if(this.loop){var t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)},e.prototype.setAnimationLast=function(t){this.animationLast=t,this.nextAnimationLast=t},e.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart},e.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0},e}();t.TrackEntry=i;var r,n=function(){function t(t){this.objects=[],this.drainDisabled=!1,this.animState=t}return t.prototype.start=function(t){this.objects.push(r.start),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.interrupt=function(t){this.objects.push(r.interrupt),this.objects.push(t)},t.prototype.end=function(t){this.objects.push(r.end),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.dispose=function(t){this.objects.push(r.dispose),this.objects.push(t)},t.prototype.complete=function(t){this.objects.push(r.complete),this.objects.push(t)},t.prototype.event=function(t,e){this.objects.push(r.event),this.objects.push(t),this.objects.push(e)},t.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var t=this.objects,e=this.animState.listeners,i=0;i<t.length;i+=2){var n=t[i],s=t[i+1];switch(n){case r.start:null!=s.listener&&s.listener.start&&s.listener.start(s);for(var a=0;a<e.length;a++)e[a].start&&e[a].start(s);break;case r.interrupt:for(null!=s.listener&&s.listener.interrupt&&s.listener.interrupt(s),a=0;a<e.length;a++)e[a].interrupt&&e[a].interrupt(s);break;case r.end:for(null!=s.listener&&s.listener.end&&s.listener.end(s),a=0;a<e.length;a++)e[a].end&&e[a].end(s);case r.dispose:for(null!=s.listener&&s.listener.dispose&&s.listener.dispose(s),a=0;a<e.length;a++)e[a].dispose&&e[a].dispose(s);this.animState.trackEntryPool.free(s);break;case r.complete:for(null!=s.listener&&s.listener.complete&&s.listener.complete(s),a=0;a<e.length;a++)e[a].complete&&e[a].complete(s);break;case r.event:var o=t[2+i++];for(null!=s.listener&&s.listener.event&&s.listener.event(s,o),a=0;a<e.length;a++)e[a].event&&e[a].event(s,o)}}this.clear(),this.drainDisabled=!1}},t.prototype.clear=function(){this.objects.length=0},t}();t.EventQueue=n,function(t){t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event"}(r=t.EventType||(t.EventType={}));var s=function(){function t(){}return t.prototype.start=function(){},t.prototype.interrupt=function(){},t.prototype.end=function(){},t.prototype.dispose=function(){},t.prototype.complete=function(){},t.prototype.event=function(){},t}();t.AnimationStateAdapter=s}(qtt||(qtt={})),function(t){var e=function(){function t(t){if(this.animationToMixTime={},this.defaultMix=0,null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}return t.prototype.setMix=function(t,e,i){var r=this.skeletonData.findAnimation(t);if(null==r)throw new Error("Animation not found: "+t);var n=this.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);this.setMixWith(r,n,i)},t.prototype.setMixWith=function(t,e,i){if(null==t)throw new Error("from cannot be null.");if(null==e)throw new Error("to cannot be null.");var r=t.name+"."+e.name;this.animationToMixTime[r]=i},t.prototype.getMix=function(t,e){var i=t.name+"."+e.name,r=this.animationToMixTime[i];return void 0===r?this.defaultMix:r},t}();t.AnimationStateData=e}(qtt||(qtt={})),function(t){var e=function(){function e(t,e){void 0===e&&(e=""),this.assets={},this.errors={},this.toLoad=0,this.loaded=0,this.textureLoader=t,this.pathPrefix=e}return e.downloadText=function(t,e,i){var r=new XMLHttpRequest;r.open("GET",t,!0),r.onload=function(){200==r.status?e(r.responseText):i(r.status,r.responseText)},r.onerror=function(){i(r.status,r.responseText)},r.send()},e.downloadBinary=function(t,e,i){var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=function(){200==r.status?e(new Uint8Array(r.response)):i(r.status,r.responseText)},r.onerror=function(){i(r.status,r.responseText)},r.send()},e.prototype.loadBinary=function(t,i,r){var n=this;void 0===i&&(i=null),void 0===r&&(r=null),t=this.pathPrefix+t,this.toLoad++,e.downloadBinary(t,(function(e){n.assets[t]=e,i&&i(t,e),n.toLoad--,n.loaded++}),(function(e,i){n.errors[t]="Couldn't load binary "+t+": status "+status+", "+i,r&&r(t,"Couldn't load binary "+t+": status "+status+", "+i),n.toLoad--,n.loaded++}))},e.prototype.loadText=function(t,i,r){var n=this;void 0===i&&(i=null),void 0===r&&(r=null),t=this.pathPrefix+t,this.toLoad++,e.downloadText(t,(function(e){n.assets[t]=e,i&&i(t,e),n.toLoad--,n.loaded++}),(function(e,i){n.errors[t]="Couldn't load text "+t+": status "+status+", "+i,r&&r(t,"Couldn't load text "+t+": status "+status+", "+i),n.toLoad--,n.loaded++}))},e.prototype.loadTexture=function(t,e,i){var r=this;void 0===e&&(e=null),void 0===i&&(i=null),t=this.pathPrefix+t,this.toLoad++;var n=new Image;n.crossOrigin="anonymous",n.onload=function(){var i=r.textureLoader(n);r.assets[t]=i,r.toLoad--,r.loaded++,e&&e(t,n)},n.onerror=function(){r.errors[t]="Couldn't load image "+t,r.toLoad--,r.loaded++,i&&i(t,"Couldn't load image "+t)},n.src=t},e.prototype.loadTextureData=function(t,e,i,r){var n=this;void 0===i&&(i=null),void 0===r&&(r=null),t=this.pathPrefix+t,this.toLoad++;var s=new Image;s.onload=function(){var e=n.textureLoader(s);n.assets[t]=e,n.toLoad--,n.loaded++,i&&i(t,s)},s.onerror=function(){n.errors[t]="Couldn't load image "+t,n.toLoad--,n.loaded++,r&&r(t,"Couldn't load image "+t)},s.src=e},e.prototype.loadTextureAtlas=function(i,r,n){var s=this;void 0===r&&(r=null),void 0===n&&(n=null);var a=i.lastIndexOf("/")>=0?i.substring(0,i.lastIndexOf("/")):"";i=this.pathPrefix+i,this.toLoad++,e.downloadText(i,(function(e){var o={count:0},l=new Array;try{new t.TextureAtlas(e,(function(e){l.push(a+"/"+e);var i=document.createElement("img");return i.width=16,i.height=16,new t.FakeTexture(i)}))}catch(t){var h=t;return s.errors[i]="Couldn't load texture atlas "+i+": "+h.message,n&&n(i,"Couldn't load texture atlas "+i+": "+h.message),s.toLoad--,void s.loaded++}for(var u=function(h){var u=!1;s.loadTexture(h,(function(h){if(o.count++,o.count==l.length)if(u)s.errors[i]="Couldn't load texture atlas page "+h+"} of atlas "+i,n&&n(i,"Couldn't load texture atlas page "+h+" of atlas "+i),s.toLoad--,s.loaded++;else try{var c=new t.TextureAtlas(e,(function(t){return s.get(a+"/"+t)}));s.assets[i]=c,r&&r(i,c),s.toLoad--,s.loaded++}catch(t){var _=t;s.errors[i]="Couldn't load texture atlas "+i+": "+_.message,n&&n(i,"Couldn't load texture atlas "+i+": "+_.message),s.toLoad--,s.loaded++}}),(function(t){u=!0,o.count++,o.count==l.length&&(s.errors[i]="Couldn't load texture atlas page "+t+"} of atlas "+i,n&&n(i,"Couldn't load texture atlas page "+t+" of atlas "+i),s.toLoad--,s.loaded++)}))},c=0,_=l;c<_.length;c++)u(_[c])}),(function(t,e){s.errors[i]="Couldn't load texture atlas "+i+": status "+status+", "+e,n&&n(i,"Couldn't load texture atlas "+i+": status "+status+", "+e),s.toLoad--,s.loaded++}))},e.prototype.get=function(t){return t=this.pathPrefix+t,this.assets[t]},e.prototype.remove=function(t){t=this.pathPrefix+t;var e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null},e.prototype.removeAll=function(){for(var t in this.assets){var e=this.assets[t];e.dispose&&e.dispose()}this.assets={}},e.prototype.isLoadingComplete=function(){return 0==this.toLoad},e.prototype.getToLoad=function(){return this.toLoad},e.prototype.getLoaded=function(){return this.loaded},e.prototype.dispose=function(){this.removeAll()},e.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},e.prototype.getErrors=function(){return this.errors},e}();t.AssetManager=e}(qtt||(qtt={})),function(t){var e=function(){function e(t){this.atlas=t}return e.prototype.newRegionAttachment=function(e,i,r){var n=this.atlas.findRegion(r);if(null==n)return null;n.renderObject=n;var s=new t.RegionAttachment(i);return s.setRegion(n),s},e.prototype.newMeshAttachment=function(e,i,r){var n=this.atlas.findRegion(r);if(null==n)return null;n.renderObject=n;var s=new t.MeshAttachment(i);return s.region=n,s},e.prototype.newBoundingBoxAttachment=function(e,i){return new t.BoundingBoxAttachment(i)},e.prototype.newPathAttachment=function(e,i){return new t.PathAttachment(i)},e.prototype.newPointAttachment=function(e,i){return new t.PointAttachment(i)},e.prototype.newClippingAttachment=function(e,i){return new t.ClippingAttachment(i)},e}();t.AtlasAttachmentLoader=e}(qtt||(qtt={})),function(t){!function(t){t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen"}(t.BlendMode||(t.BlendMode={}))}(qtt||(qtt={})),function(t){var e=function(){function e(t,e,i){if(this.children=new Array,this.x=0,this.y=0,this.rotation=0,this.scaleX=0,this.scaleY=0,this.shearX=0,this.shearY=0,this.ax=0,this.ay=0,this.arotation=0,this.ascaleX=0,this.ascaleY=0,this.ashearX=0,this.ashearY=0,this.appliedValid=!1,this.a=0,this.b=0,this.c=0,this.d=0,this.worldY=0,this.worldX=0,this.sorted=!1,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=i,this.setToSetupPose()}return e.prototype.isActive=function(){return this.active},e.prototype.update=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},e.prototype.updateWorldTransform=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},e.prototype.updateWorldTransformWith=function(e,i,r,n,s,a,o){this.ax=e,this.ay=i,this.arotation=r,this.ascaleX=n,this.ascaleY=s,this.ashearX=a,this.ashearY=o,this.appliedValid=!0;var l=this.parent;if(null==l){var h=this.skeleton,u=r+90+o,c=h.scaleX,_=h.scaleY;return this.a=t.MathUtils.cosDeg(r+a)*n*c,this.b=t.MathUtils.cosDeg(u)*s*c,this.c=t.MathUtils.sinDeg(r+a)*n*_,this.d=t.MathUtils.sinDeg(u)*s*_,this.worldX=e*c+h.x,void(this.worldY=i*_+h.y)}var f=l.a,p=l.b,d=l.c,m=l.d;switch(this.worldX=f*e+p*i+l.worldX,this.worldY=d*e+m*i+l.worldY,this.data.transformMode){case t.TransformMode.Normal:u=r+90+o;var y=t.MathUtils.cosDeg(r+a)*n,g=t.MathUtils.cosDeg(u)*s,v=t.MathUtils.sinDeg(r+a)*n,b=t.MathUtils.sinDeg(u)*s;return this.a=f*y+p*v,this.b=f*g+p*b,this.c=d*y+m*v,void(this.d=d*g+m*b);case t.TransformMode.OnlyTranslation:u=r+90+o,this.a=t.MathUtils.cosDeg(r+a)*n,this.b=t.MathUtils.cosDeg(u)*s,this.c=t.MathUtils.sinDeg(r+a)*n,this.d=t.MathUtils.sinDeg(u)*s;break;case t.TransformMode.NoRotationOrReflection:var S=0;(x=f*f+d*d)>1e-4?(p=d*(x=Math.abs(f*m-p*d)/x),m=f*x,S=Math.atan2(d,f)*t.MathUtils.radDeg):(f=0,d=0,S=90-Math.atan2(m,p)*t.MathUtils.radDeg);var A=r+a-S,C=r+o-S+90;y=t.MathUtils.cosDeg(A)*n,g=t.MathUtils.cosDeg(C)*s,v=t.MathUtils.sinDeg(A)*n,b=t.MathUtils.sinDeg(C)*s,this.a=f*y-p*v,this.b=f*g-p*b,this.c=d*y+m*v,this.d=d*g+m*b;break;case t.TransformMode.NoScale:case t.TransformMode.NoScaleOrReflection:var x,T=t.MathUtils.cosDeg(r),w=t.MathUtils.sinDeg(r),E=(f*T+p*w)/this.skeleton.scaleX,B=(d*T+m*w)/this.skeleton.scaleY;(x=Math.sqrt(E*E+B*B))>1e-5&&(x=1/x),E*=x,B*=x,x=Math.sqrt(E*E+B*B),this.data.transformMode==t.TransformMode.NoScale&&f*m-p*d<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(x=-x);var D=Math.PI/2+Math.atan2(B,E),M=Math.cos(D)*x,P=Math.sin(D)*x;y=t.MathUtils.cosDeg(a)*n,g=t.MathUtils.cosDeg(90+o)*s,v=t.MathUtils.sinDeg(a)*n,b=t.MathUtils.sinDeg(90+o)*s,this.a=E*y+M*v,this.b=E*g+M*b,this.c=B*y+P*v,this.d=B*g+P*b}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY},e.prototype.setToSetupPose=function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY},e.prototype.getWorldRotationX=function(){return Math.atan2(this.c,this.a)*t.MathUtils.radDeg},e.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*t.MathUtils.radDeg},e.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)},e.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)},e.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var e=this.parent;if(null==e)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*t.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*t.MathUtils.radDeg);var i=e.a,r=e.b,n=e.c,s=e.d,a=1/(i*s-r*n),o=this.worldX-e.worldX,l=this.worldY-e.worldY;this.ax=o*s*a-l*r*a,this.ay=l*i*a-o*n*a;var h=a*s,u=a*i,c=a*r,_=a*n,f=h*this.a-c*this.c,p=h*this.b-c*this.d,d=u*this.c-_*this.a,m=u*this.d-_*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(f*f+d*d),this.ascaleX>1e-4){var y=f*m-p*d;this.ascaleY=y/this.ascaleX,this.ashearY=Math.atan2(f*p+d*m,y)*t.MathUtils.radDeg,this.arotation=Math.atan2(d,f)*t.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(p*p+m*m),this.ashearY=0,this.arotation=90-Math.atan2(m,p)*t.MathUtils.radDeg},e.prototype.worldToLocal=function(t){var e=this.a,i=this.b,r=this.c,n=this.d,s=1/(e*n-i*r),a=t.x-this.worldX,o=t.y-this.worldY;return t.x=a*n*s-o*i*s,t.y=o*e*s-a*r*s,t},e.prototype.localToWorld=function(t){var e=t.x,i=t.y;return t.x=e*this.a+i*this.b+this.worldX,t.y=e*this.c+i*this.d+this.worldY,t},e.prototype.worldToLocalRotation=function(e){var i=t.MathUtils.sinDeg(e),r=t.MathUtils.cosDeg(e);return Math.atan2(this.a*i-this.c*r,this.d*r-this.b*i)*t.MathUtils.radDeg+this.rotation-this.shearX},e.prototype.localToWorldRotation=function(e){e-=this.rotation-this.shearX;var i=t.MathUtils.sinDeg(e),r=t.MathUtils.cosDeg(e);return Math.atan2(r*this.c+i*this.d,r*this.a+i*this.b)*t.MathUtils.radDeg},e.prototype.rotateWorld=function(e){var i=this.a,r=this.b,n=this.c,s=this.d,a=t.MathUtils.cosDeg(e),o=t.MathUtils.sinDeg(e);this.a=a*i-o*n,this.b=a*r-o*s,this.c=o*i+a*n,this.d=o*r+a*s,this.appliedValid=!1},e}();t.Bone=e}(qtt||(qtt={})),function(t){var e;t.BoneData=function(i,r,n){if(this.x=0,this.y=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.shearX=0,this.shearY=0,this.transformMode=e.Normal,this.skinRequired=!1,this.color=new t.Color,i<0)throw new Error("index must be >= 0.");if(null==r)throw new Error("name cannot be null.");this.index=i,this.name=r,this.parent=n},function(t){t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection"}(e=t.TransformMode||(t.TransformMode={}))}(qtt||(qtt={})),function(t){t.ConstraintData=function(t,e,i){this.name=t,this.order=e,this.skinRequired=i}}(qtt||(qtt={})),function(t){t.Event=function(t,e){if(null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}(qtt||(qtt={})),function(t){t.EventData=function(t){this.name=t}}(qtt||(qtt={})),function(t){var e=function(){function e(t,e){if(this.bendDirection=0,this.compress=!1,this.stretch=!1,this.mix=1,this.softness=0,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch,this.bones=new Array;for(var i=0;i<t.bones.length;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findBone(t.target.name)}return e.prototype.isActive=function(){return this.active},e.prototype.apply=function(){this.update()},e.prototype.update=function(){var t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.stretch,this.softness,this.mix)}},e.prototype.apply1=function(e,i,r,n,s,a,o){e.appliedValid||e.updateAppliedTransform();var l=e.parent,h=1/(l.a*l.d-l.b*l.c),u=i-l.worldX,c=r-l.worldY,_=(u*l.d-c*l.b)*h-e.ax,f=(c*l.a-u*l.c)*h-e.ay,p=Math.atan2(f,_)*t.MathUtils.radDeg-e.ashearX-e.arotation;e.ascaleX<0&&(p+=180),p>180?p-=360:p<-180&&(p+=360);var d=e.ascaleX,m=e.ascaleY;if(n||s){var y=e.data.length*d,g=Math.sqrt(_*_+f*f);if(n&&g<y||s&&g>y&&y>1e-4){var v=(g/y-1)*o+1;d*=v,a&&(m*=v)}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+p*o,d,m,e.ashearX,e.ashearY)},e.prototype.apply2=function(e,i,r,n,s,a,o,l){if(0!=l){e.appliedValid||e.updateAppliedTransform(),i.appliedValid||i.updateAppliedTransform();var h=e.ax,u=e.ay,c=e.ascaleX,_=c,f=e.ascaleY,p=i.ascaleX,d=0,m=0,y=0;c<0?(c=-c,d=180,y=-1):(d=0,y=1),f<0&&(f=-f,y=-y),p<0?(p=-p,m=180):m=0;var g=i.ax,v=0,b=0,S=0,A=e.a,C=e.b,x=e.c,T=e.d,w=Math.abs(c-f)<=1e-4;w?(b=A*g+C*(v=i.ay)+e.worldX,S=x*g+T*v+e.worldY):(v=0,b=A*g+e.worldX,S=x*g+e.worldY);var E=e.parent;A=E.a,C=E.b,x=E.c;var B,D,M=1/(A*(T=E.d)-C*x),P=b-E.worldX,R=S-E.worldY,I=(P*T-R*C)*M-h,O=(R*A-P*x)*M-u,F=Math.sqrt(I*I+O*O),L=i.data.length*p;if(F<1e-4)return this.apply1(e,r,n,!1,a,!1,l),void i.updateWorldTransformWith(g,v,0,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY);var V=((P=r-E.worldX)*T-(R=n-E.worldY)*C)*M-h,k=(R*A-P*x)*M-u,N=V*V+k*k;if(0!=o){o*=c*(p+1)/2;var G=Math.sqrt(N),z=G-F-L*c+o;if(z>0){var U=Math.min(1,z/(2*o))-1;N=(V-=(U=(z-o*(1-U*U))/G)*V)*V+(k-=U*k)*k}}t:if(w){var H=(N-F*F-(L*=c)*L)/(2*F*L);H<-1?H=-1:H>1&&(H=1,a&&(_*=(Math.sqrt(N)/(F+L)-1)*l+1)),D=Math.acos(H)*s,A=F+L*H,C=L*Math.sin(D),B=Math.atan2(k*A-V*C,V*A+k*C)}else{var j=(A=c*L)*A,W=(C=f*L)*C,X=Math.atan2(k,V),Y=-2*W*F,q=W-j;if((T=Y*Y-4*q*(x=W*F*F+j*N-j*W))>=0){var J=Math.sqrt(T);Y<0&&(J=-J);var K=(J=-(Y+J)/2)/q,Z=x/J,Q=Math.abs(K)<Math.abs(Z)?K:Z;if(Q*Q<=N){R=Math.sqrt(N-Q*Q)*s,B=X-Math.atan2(R,Q),D=Math.atan2(R/f,(Q-F)/c);break t}}var $=t.MathUtils.PI,tt=F-A,et=tt*tt,it=0,rt=0,nt=F+A,st=nt*nt,at=0;(x=-A*F/(j-W))>=-1&&x<=1&&(x=Math.acos(x),(T=(P=A*Math.cos(x)+F)*P+(R=C*Math.sin(x))*R)<et&&($=x,et=T,tt=P,it=R),T>st&&(rt=x,st=T,nt=P,at=R)),N<=(et+st)/2?(B=X-Math.atan2(it*s,tt),D=$*s):(B=X-Math.atan2(at*s,nt),D=rt*s)}var ot=Math.atan2(v,g)*y,lt=e.arotation;(B=(B-ot)*t.MathUtils.radDeg+d-lt)>180?B-=360:B<-180&&(B+=360),e.updateWorldTransformWith(h,u,lt+B*l,_,e.ascaleY,0,0),lt=i.arotation,(D=((D+ot)*t.MathUtils.radDeg-i.ashearX)*y+m-lt)>180?D-=360:D<-180&&(D+=360),i.updateWorldTransformWith(g,v,lt+D*l,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY)}else i.updateWorldTransform()},e}();t.IkConstraint=e}(qtt||(qtt={})),function(t){var e=function(t){function e(e){var i=t.call(this,e,0,!1)||this;return i.bones=new Array,i.bendDirection=1,i.compress=!1,i.stretch=!1,i.uniform=!1,i.mix=1,i.softness=0,i}return Jtt(e,t),e}(t.ConstraintData);t.IkConstraintData=e}(qtt||(qtt={})),function(t){var e=function(){function e(t,e){if(this.position=0,this.spacing=0,this.rotateMix=0,this.translateMix=0,this.spaces=new Array,this.positions=new Array,this.world=new Array,this.curves=new Array,this.lengths=new Array,this.segments=new Array,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(var i=0,r=t.bones.length;i<r;i++)this.bones.push(e.findBone(t.bones[i].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}return e.prototype.isActive=function(){return this.active},e.prototype.apply=function(){this.update()},e.prototype.update=function(){var i=this.target.getAttachment();if(i instanceof t.PathAttachment){var r=this.rotateMix,n=this.translateMix,s=r>0;if(n>0||s){var a=this.data,o=a.spacingMode==t.SpacingMode.Percent,l=a.rotateMode,h=l==t.RotateMode.Tangent,u=l==t.RotateMode.ChainScale,c=this.bones.length,_=h?c:c+1,f=this.bones,p=t.Utils.setArraySize(this.spaces,_),d=null,m=this.spacing;if(u||!o){u&&(d=t.Utils.setArraySize(this.lengths,c));for(var y=a.spacingMode==t.SpacingMode.Length,g=0,v=_-1;g<v;){var b=(P=f[g]).data.length;if(b<e.epsilon)u&&(d[g]=0),p[++g]=0;else if(o){if(u){var S=b*P.a,A=b*P.c,C=Math.sqrt(S*S+A*A);d[g]=C}p[++g]=m}else{S=b*P.a,A=b*P.c;var x=Math.sqrt(S*S+A*A);u&&(d[g]=x),p[++g]=(y?b+m:m)*x/b}}}else for(g=1;g<_;g++)p[g]=m;var T=this.computeWorldPositions(i,_,h,a.positionMode==t.PositionMode.Percent,o),w=T[0],E=T[1],B=a.offsetRotation,D=!1;0==B?D=l==t.RotateMode.Chain:(D=!1,B*=(M=this.target.bone).a*M.d-M.b*M.c>0?t.MathUtils.degRad:-t.MathUtils.degRad),g=0;for(var M=3;g<c;g++,M+=3){var P;(P=f[g]).worldX+=(w-P.worldX)*n,P.worldY+=(E-P.worldY)*n;var R=(S=T[M])-w,I=(A=T[M+1])-E;if(u){var O=d[g];if(0!=O){var F=(Math.sqrt(R*R+I*I)/O-1)*r+1;P.a*=F,P.c*=F}}if(w=S,E=A,s){var L=P.a,V=P.b,k=P.c,N=P.d,G=0,z=0,U=0;if(G=h?T[M-1]:0==p[g+1]?T[M+2]:Math.atan2(I,R),G-=Math.atan2(k,L),D){z=Math.cos(G),U=Math.sin(G);var H=P.data.length;w+=(H*(z*L-U*k)-R)*r,E+=(H*(U*L+z*k)-I)*r}else G+=B;G>t.MathUtils.PI?G-=t.MathUtils.PI2:G<-t.MathUtils.PI&&(G+=t.MathUtils.PI2),G*=r,z=Math.cos(G),U=Math.sin(G),P.a=z*L-U*k,P.b=z*V-U*N,P.c=U*L+z*k,P.d=U*V+z*N}P.appliedValid=!1}}}},e.prototype.computeWorldPositions=function(i,r,n,s,a){var o=this.target,l=this.position,h=this.spaces,u=t.Utils.setArraySize(this.positions,3*r+2),c=null,_=i.closed,f=i.worldVerticesLength,p=f/6,d=e.NONE;if(!i.constantSpeed){var m=i.lengths,y=m[p-=_?1:2];if(s&&(l*=y),a)for(var g=1;g<r;g++)h[g]*=y;c=t.Utils.setArraySize(this.world,8),g=0;for(var v=0,b=0;g<r;g++,v+=3){var S=l+=W=h[g];if(_)(S%=y)<0&&(S+=y),b=0;else{if(S<0){d!=e.BEFORE&&(d=e.BEFORE,i.computeWorldVertices(o,2,4,c,0,2)),this.addBeforePosition(S,c,0,u,v);continue}if(S>y){d!=e.AFTER&&(d=e.AFTER,i.computeWorldVertices(o,f-6,4,c,0,2)),this.addAfterPosition(S-y,c,0,u,v);continue}}for(;;b++){var A=m[b];if(!(S>A)){0==b?S/=A:S=(S-(J=m[b-1]))/(A-J);break}}b!=d&&(d=b,_&&b==p?(i.computeWorldVertices(o,f-4,4,c,0,2),i.computeWorldVertices(o,0,4,c,4,2)):i.computeWorldVertices(o,6*b+2,8,c,0,2)),this.addCurvePosition(S,c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],u,v,n||g>0&&0==W)}return u}_?(f+=2,c=t.Utils.setArraySize(this.world,f),i.computeWorldVertices(o,2,f-4,c,0,2),i.computeWorldVertices(o,0,2,c,f-4,2),c[f-2]=c[0],c[f-1]=c[1]):(p--,f-=4,c=t.Utils.setArraySize(this.world,f),i.computeWorldVertices(o,2,f,c,0,2));for(var C=t.Utils.setArraySize(this.curves,p),x=0,T=c[0],w=c[1],E=0,B=0,D=0,M=0,P=0,R=0,I=0,O=0,F=0,L=0,V=0,k=0,N=0,G=0,z=(g=0,2);g<p;g++,z+=6)E=c[z],B=c[z+1],D=c[z+2],M=c[z+3],V=2*(I=.1875*(T-2*E+D))+(F=.09375*(3*(E-D)-T+(P=c[z+4]))),k=2*(O=.1875*(w-2*B+M))+(L=.09375*(3*(B-M)-w+(R=c[z+5]))),N=.75*(E-T)+I+.16666667*F,G=.75*(B-w)+O+.16666667*L,x+=Math.sqrt(N*N+G*G),N+=V,G+=k,V+=F,k+=L,x+=Math.sqrt(N*N+G*G),N+=V,G+=k,x+=Math.sqrt(N*N+G*G),N+=V+F,G+=k+L,x+=Math.sqrt(N*N+G*G),C[g]=x,T=P,w=R;if(l*=s?x:x/i.lengths[p-1],a)for(g=1;g<r;g++)h[g]*=x;for(var U=this.segments,H=0,j=(g=0,v=0,b=0,0);g<r;g++,v+=3){var W;if(S=l+=W=h[g],_)(S%=x)<0&&(S+=x),b=0;else{if(S<0){this.addBeforePosition(S,c,0,u,v);continue}if(S>x){this.addAfterPosition(S-x,c,f-4,u,v);continue}}for(;;b++){var X=C[b];if(!(S>X)){0==b?S/=X:S=(S-(J=C[b-1]))/(X-J);break}}if(b!=d){d=b;var Y=6*b;for(T=c[Y],w=c[Y+1],E=c[Y+2],B=c[Y+3],D=c[Y+4],M=c[Y+5],V=2*(I=.03*(T-2*E+D))+(F=.006*(3*(E-D)-T+(P=c[Y+6]))),k=2*(O=.03*(w-2*B+M))+(L=.006*(3*(B-M)-w+(R=c[Y+7]))),N=.3*(E-T)+I+.16666667*F,G=.3*(B-w)+O+.16666667*L,H=Math.sqrt(N*N+G*G),U[0]=H,Y=1;Y<8;Y++)N+=V,G+=k,V+=F,k+=L,H+=Math.sqrt(N*N+G*G),U[Y]=H;N+=V,G+=k,H+=Math.sqrt(N*N+G*G),U[8]=H,N+=V+F,G+=k+L,H+=Math.sqrt(N*N+G*G),U[9]=H,j=0}for(S*=H;;j++){var q=U[j];if(!(S>q)){var J;0==j?S/=q:S=j+(S-(J=U[j-1]))/(q-J);break}}this.addCurvePosition(.1*S,T,w,E,B,D,M,P,R,u,v,n||g>0&&0==W)}return u},e.prototype.addBeforePosition=function(t,e,i,r,n){var s=e[i],a=e[i+1],o=e[i+2]-s,l=e[i+3]-a,h=Math.atan2(l,o);r[n]=s+t*Math.cos(h),r[n+1]=a+t*Math.sin(h),r[n+2]=h},e.prototype.addAfterPosition=function(t,e,i,r,n){var s=e[i+2],a=e[i+3],o=s-e[i],l=a-e[i+1],h=Math.atan2(l,o);r[n]=s+t*Math.cos(h),r[n+1]=a+t*Math.sin(h),r[n+2]=h},e.prototype.addCurvePosition=function(t,e,i,r,n,s,a,o,l,h,u,c){if(0==t||isNaN(t))return h[u]=e,h[u+1]=i,void(h[u+2]=Math.atan2(n-i,r-e));var _=t*t,f=_*t,p=1-t,d=p*p,m=d*p,y=p*t,g=3*y,v=p*g,b=g*t,S=e*m+r*v+s*b+o*f,A=i*m+n*v+a*b+l*f;h[u]=S,h[u+1]=A,c&&(h[u+2]=t<.001?Math.atan2(n-i,r-e):Math.atan2(A-(i*d+n*y*2+a*_),S-(e*d+r*y*2+s*_)))},e.NONE=-1,e.BEFORE=-2,e.AFTER=-3,e.epsilon=1e-5,e}();t.PathConstraint=e}(qtt||(qtt={})),function(t){var e,i,r,n=function(t){function e(e){var i=t.call(this,e,0,!1)||this;return i.bones=new Array,i}return Jtt(e,t),e}(t.ConstraintData);t.PathConstraintData=n,(r=t.PositionMode||(t.PositionMode={}))[r.Fixed=0]="Fixed",r[r.Percent=1]="Percent",(i=t.SpacingMode||(t.SpacingMode={}))[i.Length=0]="Length",i[i.Fixed=1]="Fixed",i[i.Percent=2]="Percent",(e=t.RotateMode||(t.RotateMode={}))[e.Tangent=0]="Tangent",e[e.Chain=1]="Chain",e[e.ChainScale=2]="ChainScale"}(qtt||(qtt={})),function(t){var e=function(){function t(t){this.toLoad=new Array,this.assets={},this.clientId=t}return t.prototype.loaded=function(){var t=0;for(var e in this.assets)t++;return t},t}(),i=function(){function t(t){void 0===t&&(t=""),this.clientAssets={},this.queuedAssets={},this.rawAssets={},this.errors={},this.pathPrefix=t}return t.prototype.queueAsset=function(t,i,r){var n=this.clientAssets[t];return null==n&&(n=new e(t),this.clientAssets[t]=n),null!==i&&(n.textureLoader=i),n.toLoad.push(r),this.queuedAssets[r]!==r&&(this.queuedAssets[r]=r,!0)},t.prototype.loadText=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var r=new XMLHttpRequest;r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&(r.status>=200&&r.status<300?i.rawAssets[e]=r.responseText:i.errors[e]="Couldn't load text "+e+": status "+r.status+", "+r.responseText)},r.open("GET",e,!0),r.send()}},t.prototype.loadJson=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var r=new XMLHttpRequest;r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&(r.status>=200&&r.status<300?i.rawAssets[e]=JSON.parse(r.responseText):i.errors[e]="Couldn't load text "+e+": status "+r.status+", "+r.responseText)},r.open("GET",e,!0),r.send()}},t.prototype.loadTexture=function(t,e,i){var r=this;if(i=this.pathPrefix+i,this.queueAsset(t,e,i)){var n=new Image;n.src=i,n.crossOrigin="anonymous",n.onload=function(){r.rawAssets[i]=n},n.onerror=function(){r.errors[i]="Couldn't load image "+i}}},t.prototype.get=function(t,e){e=this.pathPrefix+e;var i=this.clientAssets[t];return null==i||i.assets[e]},t.prototype.updateClientAssets=function(t){for(var e=0;e<t.toLoad.length;e++){var i=t.toLoad[e];if(null==t.assets[i]){var r=this.rawAssets[i];if(null==r)continue;r instanceof HTMLImageElement?t.assets[i]=t.textureLoader(r):t.assets[i]=r}}},t.prototype.isLoadingComplete=function(t){var e=this.clientAssets[t];return null==e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())},t.prototype.dispose=function(){},t.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},t.prototype.getErrors=function(){return this.errors},t}();t.SharedAssetManager=i}(qtt||(qtt={})),function(t){var e=function(){function e(e){if(this._updateCache=new Array,this.updateCacheReset=new Array,this.time=0,this.scaleX=1,this.scaleY=1,this.x=0,this.y=0,null==e)throw new Error("data cannot be null.");this.data=e,this.bones=new Array;for(var i=0;i<e.bones.length;i++){var r=e.bones[i],n=void 0;if(null==r.parent)n=new t.Bone(r,this,null);else{var s=this.bones[r.parent.index];n=new t.Bone(r,this,s),s.children.push(n)}this.bones.push(n)}for(this.slots=new Array,this.drawOrder=new Array,i=0;i<e.slots.length;i++){var a=e.slots[i],o=(n=this.bones[a.boneData.index],new t.Slot(a,n));this.slots.push(o),this.drawOrder.push(o)}for(this.ikConstraints=new Array,i=0;i<e.ikConstraints.length;i++){var l=e.ikConstraints[i];this.ikConstraints.push(new t.IkConstraint(l,this))}for(this.transformConstraints=new Array,i=0;i<e.transformConstraints.length;i++){var h=e.transformConstraints[i];this.transformConstraints.push(new t.TransformConstraint(h,this))}for(this.pathConstraints=new Array,i=0;i<e.pathConstraints.length;i++){var u=e.pathConstraints[i];this.pathConstraints.push(new t.PathConstraint(u,this))}this.color=new t.Color(1,1,1,1),this.updateCache()}return e.prototype.updateCache=function(){this._updateCache.length=0,this.updateCacheReset.length=0;for(var t=this.bones,e=0,i=t.length;e<i;e++)(n=t[e]).sorted=n.data.skinRequired,n.active=!n.sorted;if(null!=this.skin){var r=this.skin.bones;for(e=0,i=this.skin.bones.length;e<i;e++){var n=this.bones[r[e].index];do{n.sorted=!1,n.active=!0,n=n.parent}while(null!=n)}}var s=this.ikConstraints,a=this.transformConstraints,o=this.pathConstraints,l=s.length,h=a.length,u=o.length,c=l+h+u;t:for(e=0;e<c;e++){for(var _=0;_<l;_++)if((f=s[_]).data.order==e){this.sortIkConstraint(f);continue t}for(_=0;_<h;_++)if((f=a[_]).data.order==e){this.sortTransformConstraint(f);continue t}for(_=0;_<u;_++){var f;if((f=o[_]).data.order==e){this.sortPathConstraint(f);continue t}}}for(e=0,i=t.length;e<i;e++)this.sortBone(t[e])},e.prototype.sortIkConstraint=function(e){if(e.active=e.target.isActive()&&(!e.data.skinRequired||null!=this.skin&&t.Utils.contains(this.skin.constraints,e.data,!0)),e.active){var i=e.target;this.sortBone(i);var r=e.bones,n=r[0];if(this.sortBone(n),r.length>1){var s=r[r.length-1];this._updateCache.indexOf(s)>-1||this.updateCacheReset.push(s)}this._updateCache.push(e),this.sortReset(n.children),r[r.length-1].sorted=!0}},e.prototype.sortPathConstraint=function(e){if(e.active=e.target.bone.isActive()&&(!e.data.skinRequired||null!=this.skin&&t.Utils.contains(this.skin.constraints,e.data,!0)),e.active){var i=e.target,r=i.data.index,n=i.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,r,n),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,r,n);for(var s=0,a=this.data.skins.length;s<a;s++)this.sortPathConstraintAttachment(this.data.skins[s],r,n);var o=i.getAttachment();o instanceof t.PathAttachment&&this.sortPathConstraintAttachmentWith(o,n);var l=e.bones,h=l.length;for(s=0;s<h;s++)this.sortBone(l[s]);for(this._updateCache.push(e),s=0;s<h;s++)this.sortReset(l[s].children);for(s=0;s<h;s++)l[s].sorted=!0}},e.prototype.sortTransformConstraint=function(e){if(e.active=e.target.isActive()&&(!e.data.skinRequired||null!=this.skin&&t.Utils.contains(this.skin.constraints,e.data,!0)),e.active){this.sortBone(e.target);var i=e.bones,r=i.length;if(e.data.local)for(var n=0;n<r;n++){var s=i[n];this.sortBone(s.parent),this._updateCache.indexOf(s)>-1||this.updateCacheReset.push(s)}else for(n=0;n<r;n++)this.sortBone(i[n]);this._updateCache.push(e);for(var a=0;a<r;a++)this.sortReset(i[a].children);for(a=0;a<r;a++)i[a].sorted=!0}},e.prototype.sortPathConstraintAttachment=function(t,e,i){var r=t.attachments[e];if(r)for(var n in r)this.sortPathConstraintAttachmentWith(r[n],i)},e.prototype.sortPathConstraintAttachmentWith=function(e,i){if(e instanceof t.PathAttachment){var r=e.bones;if(null==r)this.sortBone(i);else for(var n=this.bones,s=0;s<r.length;)for(var a=r[s++],o=s+a;s<o;s++){var l=r[s];this.sortBone(n[l])}}},e.prototype.sortBone=function(t){if(!t.sorted){var e=t.parent;null!=e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}},e.prototype.sortReset=function(t){for(var e=0,i=t.length;e<i;e++){var r=t[e];r.active&&(r.sorted&&this.sortReset(r.children),r.sorted=!1)}},e.prototype.updateWorldTransform=function(){for(var t=this.updateCacheReset,e=0,i=t.length;e<i;e++){var r=t[e];r.ax=r.x,r.ay=r.y,r.arotation=r.rotation,r.ascaleX=r.scaleX,r.ascaleY=r.scaleY,r.ashearX=r.shearX,r.ashearY=r.shearY,r.appliedValid=!0}var n=this._updateCache;for(e=0,i=n.length;e<i;e++)n[e].update()},e.prototype.setToSetupPose=function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},e.prototype.setBonesToSetupPose=function(){for(var t=this.bones,e=0,i=t.length;e<i;e++)t[e].setToSetupPose();var r=this.ikConstraints;for(e=0,i=r.length;e<i;e++)(o=r[e]).mix=o.data.mix,o.softness=o.data.softness,o.bendDirection=o.data.bendDirection,o.compress=o.data.compress,o.stretch=o.data.stretch;var n=this.transformConstraints;for(e=0,i=n.length;e<i;e++){var s=(o=n[e]).data;o.rotateMix=s.rotateMix,o.translateMix=s.translateMix,o.scaleMix=s.scaleMix,o.shearMix=s.shearMix}var a=this.pathConstraints;for(e=0,i=a.length;e<i;e++){var o;s=(o=a[e]).data,o.position=s.position,o.spacing=s.spacing,o.rotateMix=s.rotateMix,o.translateMix=s.translateMix}},e.prototype.setSlotsToSetupPose=function(){var e=this.slots;t.Utils.arrayCopy(e,0,this.drawOrder,0,e.length);for(var i=0,r=e.length;i<r;i++)e[i].setToSetupPose()},e.prototype.getRootBone=function(){return 0==this.bones.length?null:this.bones[0]},e.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,r=e.length;i<r;i++){var n=e[i];if(n.data.name==t)return n}return null},e.prototype.findBoneIndex=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,r=e.length;i<r;i++)if(e[i].data.name==t)return i;return-1},e.prototype.findSlot=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,r=e.length;i<r;i++){var n=e[i];if(n.data.name==t)return n}return null},e.prototype.findSlotIndex=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,r=e.length;i<r;i++)if(e[i].data.name==t)return i;return-1},e.prototype.setSkinByName=function(t){var e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)},e.prototype.setSkin=function(t){if(t!=this.skin){if(null!=t)if(null!=this.skin)t.attachAll(this,this.skin);else for(var e=this.slots,i=0,r=e.length;i<r;i++){var n=e[i],s=n.data.attachmentName;if(null!=s){var a=t.getAttachment(i,s);null!=a&&n.setAttachment(a)}}this.skin=t,this.updateCache()}},e.prototype.getAttachmentByName=function(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)},e.prototype.getAttachment=function(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){var i=this.skin.getAttachment(t,e);if(null!=i)return i}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null},e.prototype.setAttachment=function(t,e){if(null==t)throw new Error("slotName cannot be null.");for(var i=this.slots,r=0,n=i.length;r<n;r++){var s=i[r];if(s.data.name==t){var a=null;if(null!=e&&null==(a=this.getAttachment(r,e)))throw new Error("Attachment not found: "+e+", for slot: "+t);return void s.setAttachment(a)}}throw new Error("Slot not found: "+t)},e.prototype.findIkConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.ikConstraints,i=0,r=e.length;i<r;i++){var n=e[i];if(n.data.name==t)return n}return null},e.prototype.findTransformConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.transformConstraints,i=0,r=e.length;i<r;i++){var n=e[i];if(n.data.name==t)return n}return null},e.prototype.findPathConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.pathConstraints,i=0,r=e.length;i<r;i++){var n=e[i];if(n.data.name==t)return n}return null},e.prototype.getBounds=function(e,i,r){if(void 0===r&&(r=new Array(2)),null==e)throw new Error("offset cannot be null.");if(null==i)throw new Error("size cannot be null.");for(var n=this.drawOrder,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,h=0,u=n.length;h<u;h++){var c=n[h];if(c.bone.active){var _=0,f=null,p=c.getAttachment();if(p instanceof t.RegionAttachment)_=8,f=t.Utils.setArraySize(r,_,0),p.computeWorldVertices(c.bone,f,0,2);else if(p instanceof t.MeshAttachment){var d=p;_=d.worldVerticesLength,f=t.Utils.setArraySize(r,_,0),d.computeWorldVertices(c,0,_,f,0,2)}if(null!=f)for(var m=0,y=f.length;m<y;m+=2){var g=f[m],v=f[m+1];s=Math.min(s,g),a=Math.min(a,v),o=Math.max(o,g),l=Math.max(l,v)}}}e.set(s,a),i.set(o-s,l-a)},e.prototype.update=function(t){this.time+=t},e}();t.Skeleton=e}(qtt||(qtt={})),function(t){var e=function(){function e(t){this.scale=1,this.linkedMeshes=new Array,this.attachmentLoader=t}return e.prototype.readSkeletonData=function(r){var n=this.scale,s=new t.SkeletonData;s.name="";var a=new i(r);s.hash=a.readString(),s.version=a.readString(),s.x=a.readFloat(),s.y=a.readFloat(),s.width=a.readFloat(),s.height=a.readFloat();var o=a.readBoolean();o&&(s.fps=a.readFloat(),s.imagesPath=a.readString(),s.audioPath=a.readString());var l=0;l=a.readInt(!0);for(var h=0;h<l;h++)a.strings.push(a.readString());for(l=a.readInt(!0),h=0;h<l;h++){var u=a.readString(),c=0==h?null:s.bones[a.readInt(!0)];(p=new t.BoneData(h,u,c)).rotation=a.readFloat(),p.x=a.readFloat()*n,p.y=a.readFloat()*n,p.scaleX=a.readFloat(),p.scaleY=a.readFloat(),p.shearX=a.readFloat(),p.shearY=a.readFloat(),p.length=a.readFloat()*n,p.transformMode=e.TransformModeValues[a.readInt(!0)],p.skinRequired=a.readBoolean(),o&&t.Color.rgba8888ToColor(p.color,a.readInt32()),s.bones.push(p)}for(l=a.readInt(!0),h=0;h<l;h++){var _=a.readString(),f=s.bones[a.readInt(!0)],p=new t.SlotData(h,_,f);t.Color.rgba8888ToColor(p.color,a.readInt32());var d=a.readInt32();-1!=d&&t.Color.rgb888ToColor(p.darkColor=new t.Color,d),p.attachmentName=a.readStringRef(),p.blendMode=e.BlendModeValues[a.readInt(!0)],s.slots.push(p)}l=a.readInt(!0),h=0;for(var m=void 0;h<l;h++){(p=new t.IkConstraintData(a.readString())).order=a.readInt(!0),p.skinRequired=a.readBoolean(),m=a.readInt(!0);for(var y=0;y<m;y++)p.bones.push(s.bones[a.readInt(!0)]);p.target=s.bones[a.readInt(!0)],p.mix=a.readFloat(),p.softness=a.readFloat()*n,p.bendDirection=a.readByte(),p.compress=a.readBoolean(),p.stretch=a.readBoolean(),p.uniform=a.readBoolean(),s.ikConstraints.push(p)}for(l=a.readInt(!0),h=0,m=void 0;h<l;h++){for((p=new t.TransformConstraintData(a.readString())).order=a.readInt(!0),p.skinRequired=a.readBoolean(),m=a.readInt(!0),y=0;y<m;y++)p.bones.push(s.bones[a.readInt(!0)]);p.target=s.bones[a.readInt(!0)],p.local=a.readBoolean(),p.relative=a.readBoolean(),p.offsetRotation=a.readFloat(),p.offsetX=a.readFloat()*n,p.offsetY=a.readFloat()*n,p.offsetScaleX=a.readFloat(),p.offsetScaleY=a.readFloat(),p.offsetShearY=a.readFloat(),p.rotateMix=a.readFloat(),p.translateMix=a.readFloat(),p.scaleMix=a.readFloat(),p.shearMix=a.readFloat(),s.transformConstraints.push(p)}for(l=a.readInt(!0),h=0,m=void 0;h<l;h++){for((p=new t.PathConstraintData(a.readString())).order=a.readInt(!0),p.skinRequired=a.readBoolean(),m=a.readInt(!0),y=0;y<m;y++)p.bones.push(s.bones[a.readInt(!0)]);p.target=s.slots[a.readInt(!0)],p.positionMode=e.PositionModeValues[a.readInt(!0)],p.spacingMode=e.SpacingModeValues[a.readInt(!0)],p.rotateMode=e.RotateModeValues[a.readInt(!0)],p.offsetRotation=a.readFloat(),p.position=a.readFloat(),p.positionMode==t.PositionMode.Fixed&&(p.position*=n),p.spacing=a.readFloat(),p.spacingMode!=t.SpacingMode.Length&&p.spacingMode!=t.SpacingMode.Fixed||(p.spacing*=n),p.rotateMix=a.readFloat(),p.translateMix=a.readFloat(),s.pathConstraints.push(p)}var g=this.readSkin(a,s,!0,o);for(null!=g&&(s.defaultSkin=g,s.skins.push(g)),h=s.skins.length,t.Utils.setArraySize(s.skins,l=h+a.readInt(!0));h<l;h++)s.skins[h]=this.readSkin(a,s,!1,o);for(l=this.linkedMeshes.length,h=0;h<l;h++){var v=this.linkedMeshes[h],b=null==v.skin?s.defaultSkin:s.findSkin(v.skin);if(null==b)throw new Error("Skin not found: "+v.skin);var S=b.getAttachment(v.slotIndex,v.parent);if(null==S)throw new Error("Parent mesh not found: "+v.parent);v.mesh.deformAttachment=v.inheritDeform?S:v.mesh,v.mesh.setParentMesh(S),v.mesh.updateUVs()}for(this.linkedMeshes.length=0,l=a.readInt(!0),h=0;h<l;h++)(p=new t.EventData(a.readStringRef())).intValue=a.readInt(!1),p.floatValue=a.readFloat(),p.stringValue=a.readString(),p.audioPath=a.readString(),null!=p.audioPath&&(p.volume=a.readFloat(),p.balance=a.readFloat()),s.events.push(p);for(l=a.readInt(!0),h=0;h<l;h++)s.animations.push(this.readAnimation(a,a.readString(),s));return s},e.prototype.readSkin=function(e,i,r,n){var s=null,a=0;if(r){if(0==(a=e.readInt(!0)))return null;s=new t.Skin("default")}else{(s=new t.Skin(e.readStringRef())).bones.length=e.readInt(!0);for(var o=0,l=s.bones.length;o<l;o++)s.bones[o]=i.bones[e.readInt(!0)];for(o=0,l=e.readInt(!0);o<l;o++)s.constraints.push(i.ikConstraints[e.readInt(!0)]);for(o=0,l=e.readInt(!0);o<l;o++)s.constraints.push(i.transformConstraints[e.readInt(!0)]);for(o=0,l=e.readInt(!0);o<l;o++)s.constraints.push(i.pathConstraints[e.readInt(!0)]);a=e.readInt(!0)}for(o=0;o<a;o++)for(var h=e.readInt(!0),u=0,c=e.readInt(!0);u<c;u++){var _=e.readStringRef(),f=this.readAttachment(e,i,s,h,_,n);null!=f&&s.setAttachment(h,_,f)}return s},e.prototype.readAttachment=function(i,n,s,a,o,l){var h=this.scale,u=i.readStringRef();null==u&&(u=o);var c=i.readByte();switch(e.AttachmentTypeValues[c]){case t.AttachmentType.Region:var _=i.readStringRef(),f=i.readFloat(),p=i.readFloat(),d=i.readFloat(),m=i.readFloat(),y=i.readFloat(),g=i.readFloat(),v=i.readFloat(),b=i.readInt32();null==_&&(_=u);var S=this.attachmentLoader.newRegionAttachment(s,u,_);return null==S?null:(S.path=_,S.x=p*h,S.y=d*h,S.scaleX=m,S.scaleY=y,S.rotation=f,S.width=g*h,S.height=v*h,t.Color.rgba8888ToColor(S.color,b),S.updateOffset(),S);case t.AttachmentType.BoundingBox:var A=i.readInt(!0),C=this.readVertices(i,A),x=(b=l?i.readInt32():0,this.attachmentLoader.newBoundingBoxAttachment(s,u));return null==x?null:(x.worldVerticesLength=A<<1,x.vertices=C.vertices,x.bones=C.bones,l&&t.Color.rgba8888ToColor(x.color,b),x);case t.AttachmentType.Mesh:_=i.readStringRef(),b=i.readInt32(),A=i.readInt(!0);var T=this.readFloatArray(i,A<<1,1),w=this.readShortArray(i),E=(C=this.readVertices(i,A),i.readInt(!0)),B=null;return g=0,v=0,l&&(B=this.readShortArray(i),g=i.readFloat(),v=i.readFloat()),null==_&&(_=u),null==(D=this.attachmentLoader.newMeshAttachment(s,u,_))?null:(D.path=_,t.Color.rgba8888ToColor(D.color,b),D.bones=C.bones,D.vertices=C.vertices,D.worldVerticesLength=A<<1,D.triangles=w,D.regionUVs=T,D.updateUVs(),D.hullLength=E<<1,l&&(D.edges=B,D.width=g*h,D.height=v*h),D);case t.AttachmentType.LinkedMesh:_=i.readStringRef(),b=i.readInt32();var D,M=i.readStringRef(),P=i.readStringRef(),R=i.readBoolean();return g=0,v=0,l&&(g=i.readFloat(),v=i.readFloat()),null==_&&(_=u),null==(D=this.attachmentLoader.newMeshAttachment(s,u,_))?null:(D.path=_,t.Color.rgba8888ToColor(D.color,b),l&&(D.width=g*h,D.height=v*h),this.linkedMeshes.push(new r(D,M,a,P,R)),D);case t.AttachmentType.Path:for(var I=i.readBoolean(),O=i.readBoolean(),F=(A=i.readInt(!0),C=this.readVertices(i,A),t.Utils.newArray(A/3,0)),L=0,V=F.length;L<V;L++)F[L]=i.readFloat()*h;return b=l?i.readInt32():0,null==(_=this.attachmentLoader.newPathAttachment(s,u))?null:(_.closed=I,_.constantSpeed=O,_.worldVerticesLength=A<<1,_.vertices=C.vertices,_.bones=C.bones,_.lengths=F,l&&t.Color.rgba8888ToColor(_.color,b),_);case t.AttachmentType.Point:f=i.readFloat(),p=i.readFloat(),d=i.readFloat(),b=l?i.readInt32():0;var k=this.attachmentLoader.newPointAttachment(s,u);return null==k?null:(k.x=p*h,k.y=d*h,k.rotation=f,l&&t.Color.rgba8888ToColor(k.color,b),k);case t.AttachmentType.Clipping:var N=i.readInt(!0),G=(A=i.readInt(!0),C=this.readVertices(i,A),b=l?i.readInt32():0,this.attachmentLoader.newClippingAttachment(s,u));return null==G?null:(G.endSlot=n.slots[N],G.worldVerticesLength=A<<1,G.vertices=C.vertices,G.bones=C.bones,l&&t.Color.rgba8888ToColor(G.color,b),G)}return null},e.prototype.readVertices=function(e,i){var r=i<<1,s=new n,a=this.scale;if(!e.readBoolean())return s.vertices=this.readFloatArray(e,r,a),s;for(var o=new Array,l=new Array,h=0;h<i;h++){var u=e.readInt(!0);l.push(u);for(var c=0;c<u;c++)l.push(e.readInt(!0)),o.push(e.readFloat()*a),o.push(e.readFloat()*a),o.push(e.readFloat())}return s.vertices=t.Utils.toFloatArray(o),s.bones=l,s},e.prototype.readFloatArray=function(t,e,i){var r=new Array(e);if(1==i)for(var n=0;n<e;n++)r[n]=t.readFloat();else for(n=0;n<e;n++)r[n]=t.readFloat()*i;return r},e.prototype.readShortArray=function(t){for(var e=t.readInt(!0),i=new Array(e),r=0;r<e;r++)i[r]=t.readShort();return i},e.prototype.readAnimation=function(i,r,n){for(var s=new Array,a=this.scale,o=0,l=new t.Color,h=new t.Color,u=0,c=i.readInt(!0);u<c;u++)for(var _=i.readInt(!0),f=0,p=i.readInt(!0);f<p;f++){var d=i.readByte(),m=i.readInt(!0);switch(d){case e.SLOT_ATTACHMENT:(b=new t.AttachmentTimeline(m)).slotIndex=_;for(var y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readStringRef());s.push(b),o=Math.max(o,b.frames[m-1]);break;case e.SLOT_COLOR:for((b=new t.ColorTimeline(m)).slotIndex=_,y=0;y<m;y++){var g=i.readFloat();t.Color.rgba8888ToColor(l,i.readInt32()),b.setFrame(y,g,l.r,l.g,l.b,l.a),y<m-1&&this.readCurve(i,y,b)}s.push(b),o=Math.max(o,b.frames[(m-1)*t.ColorTimeline.ENTRIES]);break;case e.SLOT_TWO_COLOR:for((b=new t.TwoColorTimeline(m)).slotIndex=_,y=0;y<m;y++)g=i.readFloat(),t.Color.rgba8888ToColor(l,i.readInt32()),t.Color.rgb888ToColor(h,i.readInt32()),b.setFrame(y,g,l.r,l.g,l.b,l.a,h.r,h.g,h.b),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.TwoColorTimeline.ENTRIES])}}for(u=0,c=i.readInt(!0);u<c;u++){var v=i.readInt(!0);for(f=0,p=i.readInt(!0);f<p;f++)switch(d=i.readByte(),m=i.readInt(!0),d){case e.BONE_ROTATE:for((b=new t.RotateTimeline(m)).boneIndex=v,y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readFloat()),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.RotateTimeline.ENTRIES]);break;case e.BONE_TRANSLATE:case e.BONE_SCALE:case e.BONE_SHEAR:var b=void 0,S=1;for(d==e.BONE_SCALE?b=new t.ScaleTimeline(m):d==e.BONE_SHEAR?b=new t.ShearTimeline(m):(b=new t.TranslateTimeline(m),S=a),b.boneIndex=v,y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readFloat()*S,i.readFloat()*S),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.TranslateTimeline.ENTRIES])}}for(u=0,c=i.readInt(!0);u<c;u++){var A=i.readInt(!0);for(m=i.readInt(!0),(b=new t.IkConstraintTimeline(m)).ikConstraintIndex=A,y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readFloat(),i.readFloat()*a,i.readByte(),i.readBoolean(),i.readBoolean()),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.IkConstraintTimeline.ENTRIES])}for(u=0,c=i.readInt(!0);u<c;u++){for(A=i.readInt(!0),m=i.readInt(!0),(b=new t.TransformConstraintTimeline(m)).transformConstraintIndex=A,y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readFloat(),i.readFloat(),i.readFloat(),i.readFloat()),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.TransformConstraintTimeline.ENTRIES])}for(u=0,c=i.readInt(!0);u<c;u++){A=i.readInt(!0);var C=n.pathConstraints[A];for(f=0,p=i.readInt(!0);f<p;f++)switch(d=i.readByte(),m=i.readInt(!0),d){case e.PATH_POSITION:case e.PATH_SPACING:for(b=void 0,S=1,d==e.PATH_SPACING?(b=new t.PathConstraintSpacingTimeline(m),C.spacingMode!=t.SpacingMode.Length&&C.spacingMode!=t.SpacingMode.Fixed||(S=a)):(b=new t.PathConstraintPositionTimeline(m),C.positionMode==t.PositionMode.Fixed&&(S=a)),b.pathConstraintIndex=A,y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readFloat()*S),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.PathConstraintPositionTimeline.ENTRIES]);break;case e.PATH_MIX:for((b=new t.PathConstraintMixTimeline(m)).pathConstraintIndex=A,y=0;y<m;y++)b.setFrame(y,i.readFloat(),i.readFloat(),i.readFloat()),y<m-1&&this.readCurve(i,y,b);s.push(b),o=Math.max(o,b.frames[(m-1)*t.PathConstraintMixTimeline.ENTRIES])}}for(u=0,c=i.readInt(!0);u<c;u++){var x=n.skins[i.readInt(!0)];for(f=0,p=i.readInt(!0);f<p;f++){_=i.readInt(!0);for(var T=0,w=i.readInt(!0);T<w;T++){var E=x.getAttachment(_,i.readStringRef()),B=null!=E.bones,D=E.vertices,M=B?D.length/3*2:D.length;for(m=i.readInt(!0),(b=new t.DeformTimeline(m)).slotIndex=_,b.attachment=E,y=0;y<m;y++){g=i.readFloat();var P=void 0,R=i.readInt(!0);if(0==R)P=B?t.Utils.newFloatArray(M):D;else{P=t.Utils.newFloatArray(M);var I=i.readInt(!0);if(R+=I,1==a)for(var O=I;O<R;O++)P[O]=i.readFloat();else for(O=I;O<R;O++)P[O]=i.readFloat()*a;if(!B){O=0;for(var F=P.length;O<F;O++)P[O]+=D[O]}}b.setFrame(y,g,P),y<m-1&&this.readCurve(i,y,b)}s.push(b),o=Math.max(o,b.frames[m-1])}}}var L=i.readInt(!0);if(L>0){b=new t.DrawOrderTimeline(L);var V=n.slots.length;for(u=0;u<L;u++){g=i.readFloat();var k=i.readInt(!0),N=t.Utils.newArray(V,0);for(f=V-1;f>=0;f--)N[f]=-1;var G=t.Utils.newArray(V-k,0),z=0,U=0;for(f=0;f<k;f++){for(_=i.readInt(!0);z!=_;)G[U++]=z++;N[z+i.readInt(!0)]=z++}for(;z<V;)G[U++]=z++;for(f=V-1;f>=0;f--)-1==N[f]&&(N[f]=G[--U]);b.setFrame(u,g,N)}s.push(b),o=Math.max(o,b.frames[L-1])}var H=i.readInt(!0);if(H>0){for(b=new t.EventTimeline(H),u=0;u<H;u++){g=i.readFloat();var j=n.events[i.readInt(!0)],W=new t.Event(g,j);W.intValue=i.readInt(!1),W.floatValue=i.readFloat(),W.stringValue=i.readBoolean()?i.readString():j.stringValue,null!=W.data.audioPath&&(W.volume=i.readFloat(),W.balance=i.readFloat()),b.setFrame(u,W)}s.push(b),o=Math.max(o,b.frames[H-1])}return new t.Animation(r,s,o)},e.prototype.readCurve=function(t,i,r){switch(t.readByte()){case e.CURVE_STEPPED:r.setStepped(i);break;case e.CURVE_BEZIER:this.setCurve(r,i,t.readFloat(),t.readFloat(),t.readFloat(),t.readFloat())}},e.prototype.setCurve=function(t,e,i,r,n,s){t.setCurve(e,i,r,n,s)},e.AttachmentTypeValues=[0,1,2,3,4,5,6],e.TransformModeValues=[t.TransformMode.Normal,t.TransformMode.OnlyTranslation,t.TransformMode.NoRotationOrReflection,t.TransformMode.NoScale,t.TransformMode.NoScaleOrReflection],e.PositionModeValues=[t.PositionMode.Fixed,t.PositionMode.Percent],e.SpacingModeValues=[t.SpacingMode.Length,t.SpacingMode.Fixed,t.SpacingMode.Percent],e.RotateModeValues=[t.RotateMode.Tangent,t.RotateMode.Chain,t.RotateMode.ChainScale],e.BlendModeValues=[t.BlendMode.Normal,t.BlendMode.Additive,t.BlendMode.Multiply,t.BlendMode.Screen],e.BONE_ROTATE=0,e.BONE_TRANSLATE=1,e.BONE_SCALE=2,e.BONE_SHEAR=3,e.SLOT_ATTACHMENT=0,e.SLOT_COLOR=1,e.SLOT_TWO_COLOR=2,e.PATH_POSITION=0,e.PATH_SPACING=1,e.PATH_MIX=2,e.CURVE_LINEAR=0,e.CURVE_STEPPED=1,e.CURVE_BEZIER=2,e}();t.SkeletonBinary=e;var i=function(){function t(t,e,i,r){void 0===e&&(e=new Array),void 0===i&&(i=0),void 0===r&&(r=new DataView(t.buffer)),this.strings=e,this.index=i,this.buffer=r}return t.prototype.readByte=function(){return this.buffer.getInt8(this.index++)},t.prototype.readShort=function(){var t=this.buffer.getInt16(this.index);return this.index+=2,t},t.prototype.readInt32=function(){var t=this.buffer.getInt32(this.index);return this.index+=4,t},t.prototype.readInt=function(t){var e=this.readByte(),i=127&e;return 0!=(128&e)&&(i|=(127&(e=this.readByte()))<<7,0!=(128&e)&&(i|=(127&(e=this.readByte()))<<14,0!=(128&e)&&(i|=(127&(e=this.readByte()))<<21,0!=(128&e)&&(i|=(127&(e=this.readByte()))<<28)))),t?i:i>>>1^-(1&i)},t.prototype.readStringRef=function(){var t=this.readInt(!0);return 0==t?null:this.strings[t-1]},t.prototype.readString=function(){var t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;for(var e="",i=0;i<t;){var r=this.readByte();switch(r>>4){case 12:case 13:e+=String.fromCharCode((31&r)<<6|63&this.readByte()),i+=2;break;case 14:e+=String.fromCharCode((15&r)<<12|(63&this.readByte())<<6|63&this.readByte()),i+=3;break;default:e+=String.fromCharCode(r),i++}}return e},t.prototype.readFloat=function(){var t=this.buffer.getFloat32(this.index);return this.index+=4,t},t.prototype.readBoolean=function(){return 0!=this.readByte()},t}(),r=function(t,e,i,r,n){this.mesh=t,this.skin=e,this.slotIndex=i,this.parent=r,this.inheritDeform=n},n=function(t,e){void 0===t&&(t=null),void 0===e&&(e=null),this.bones=t,this.vertices=e}}(qtt||(qtt={})),function(t){var e=function(){function e(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.boundingBoxes=new Array,this.polygons=new Array,this.polygonPool=new t.Pool((function(){return t.Utils.newFloatArray(16)}))}return e.prototype.update=function(e,i){if(null==e)throw new Error("skeleton cannot be null.");var r=this.boundingBoxes,n=this.polygons,s=this.polygonPool,a=e.slots,o=a.length;r.length=0,s.freeAll(n),n.length=0;for(var l=0;l<o;l++){var h=a[l];if(h.bone.active){var u=h.getAttachment();if(u instanceof t.BoundingBoxAttachment){var c=u;r.push(c);var _=s.obtain();_.length!=c.worldVerticesLength&&(_=t.Utils.newFloatArray(c.worldVerticesLength)),n.push(_),c.computeWorldVertices(h,0,c.worldVerticesLength,_,0,2)}}}i?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)},e.prototype.aabbCompute=function(){for(var t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=this.polygons,s=0,a=n.length;s<a;s++)for(var o=n[s],l=o,h=0,u=o.length;h<u;h+=2){var c=l[h],_=l[h+1];t=Math.min(t,c),e=Math.min(e,_),i=Math.max(i,c),r=Math.max(r,_)}this.minX=t,this.minY=e,this.maxX=i,this.maxY=r},e.prototype.aabbContainsPoint=function(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY},e.prototype.aabbIntersectsSegment=function(t,e,i,r){var n=this.minX,s=this.minY,a=this.maxX,o=this.maxY;if(t<=n&&i<=n||e<=s&&r<=s||t>=a&&i>=a||e>=o&&r>=o)return!1;var l=(r-e)/(i-t),h=l*(n-t)+e;if(h>s&&h<o)return!0;if((h=l*(a-t)+e)>s&&h<o)return!0;var u=(s-e)/l+t;return u>n&&u<a||(u=(o-e)/l+t)>n&&u<a},e.prototype.aabbIntersectsSkeleton=function(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY},e.prototype.containsPoint=function(t,e){for(var i=this.polygons,r=0,n=i.length;r<n;r++)if(this.containsPointPolygon(i[r],t,e))return this.boundingBoxes[r];return null},e.prototype.containsPointPolygon=function(t,e,i){for(var r=t,n=t.length,s=n-2,a=!1,o=0;o<n;o+=2){var l=r[o+1],h=r[s+1];if(l<i&&h>=i||h<i&&l>=i){var u=r[o];u+(i-l)/(h-l)*(r[s]-u)<e&&(a=!a)}s=o}return a},e.prototype.intersectsSegment=function(t,e,i,r){for(var n=this.polygons,s=0,a=n.length;s<a;s++)if(this.intersectsSegmentPolygon(n[s],t,e,i,r))return this.boundingBoxes[s];return null},e.prototype.intersectsSegmentPolygon=function(t,e,i,r,n){for(var s=t,a=t.length,o=e-r,l=i-n,h=e*n-i*r,u=s[a-2],c=s[a-1],_=0;_<a;_+=2){var f=s[_],p=s[_+1],d=u*p-c*f,m=u-f,y=c-p,g=o*y-l*m,v=(h*m-o*d)/g;if((v>=u&&v<=f||v>=f&&v<=u)&&(v>=e&&v<=r||v>=r&&v<=e)){var b=(h*y-l*d)/g;if((b>=c&&b<=p||b>=p&&b<=c)&&(b>=i&&b<=n||b>=n&&b<=i))return!0}u=f,c=p}return!1},e.prototype.getPolygon=function(t){if(null==t)throw new Error("boundingBox cannot be null.");var e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]},e.prototype.getWidth=function(){return this.maxX-this.minX},e.prototype.getHeight=function(){return this.maxY-this.minY},e}();t.SkeletonBounds=e}(qtt||(qtt={})),function(t){var e=function(){function e(){this.triangulator=new t.Triangulator,this.clippingPolygon=new Array,this.clipOutput=new Array,this.clippedVertices=new Array,this.clippedTriangles=new Array,this.scratch=new Array}return e.prototype.clipStart=function(i,r){if(null!=this.clipAttachment)return 0;this.clipAttachment=r;var n=r.worldVerticesLength,s=t.Utils.setArraySize(this.clippingPolygon,n);r.computeWorldVertices(i,0,n,s,0,2);var a=this.clippingPolygon;e.makeClockwise(a);for(var o=this.clippingPolygons=this.triangulator.decompose(a,this.triangulator.triangulate(a)),l=0,h=o.length;l<h;l++){var u=o[l];e.makeClockwise(u),u.push(u[0]),u.push(u[1])}return o.length},e.prototype.clipEndWithSlot=function(t){null!=this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()},e.prototype.clipEnd=function(){null!=this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)},e.prototype.isClipping=function(){return null!=this.clipAttachment},e.prototype.clipTriangles=function(e,i,r,n,s,a,o,l,h,u,c){void 0===h&&(h=2),void 0===u&&(u=0),void 0===c&&(c=0);var _=this.clipOutput,f=this.clippedVertices,p=this.clippedTriangles,d=this.clippingPolygons,m=this.clippingPolygons.length,y=l?12:8,g=0;f.length=0,p.length=0;t:for(var v=0;v<n;v+=3)for(var b=r[v]*h,S=e[b+u],A=e[b+u+1],C=s[b+c],x=s[b+c+1],T=e[(b=r[v+1]*h)+u],w=e[b+u+1],E=s[b+c],B=s[b+c+1],D=e[(b=r[v+2]*h)+u],M=e[b+u+1],P=s[b+c],R=s[b+c+1],I=0;I<m;I++){var O=f.length;if(!this.clip(S,A,T,w,D,M,d[I],_)){(H=t.Utils.setArraySize(f,O+3*y))[O]=S,H[O+1]=A,H[O+2]=a.r,H[O+3]=a.g,H[O+4]=a.b,H[O+5]=a.a,l?(H[O+6]=C,H[O+7]=x,H[O+8]=o.r,H[O+9]=o.g,H[O+10]=o.b,H[O+11]=o.a,H[O+12]=T,H[O+13]=w,H[O+14]=a.r,H[O+15]=a.g,H[O+16]=a.b,H[O+17]=a.a,H[O+18]=E,H[O+19]=B,H[O+20]=o.r,H[O+21]=o.g,H[O+22]=o.b,H[O+23]=o.a,H[O+24]=D,H[O+25]=M,H[O+26]=a.r,H[O+27]=a.g,H[O+28]=a.b,H[O+29]=a.a,H[O+30]=P,H[O+31]=R,H[O+32]=o.r,H[O+33]=o.g,H[O+34]=o.b,H[O+35]=o.a):(H[O+6]=C,H[O+7]=x,H[O+8]=T,H[O+9]=w,H[O+10]=a.r,H[O+11]=a.g,H[O+12]=a.b,H[O+13]=a.a,H[O+14]=E,H[O+15]=B,H[O+16]=D,H[O+17]=M,H[O+18]=a.r,H[O+19]=a.g,H[O+20]=a.b,H[O+21]=a.a,H[O+22]=P,H[O+23]=R),O=p.length,(Q=t.Utils.setArraySize(p,O+3))[O]=g,Q[O+1]=g+1,Q[O+2]=g+2,g+=3;continue t}var F=_.length;if(0!=F){for(var L=w-M,V=D-T,k=S-D,N=M-A,G=1/(L*k+V*(A-M)),z=F>>1,U=this.clipOutput,H=t.Utils.setArraySize(f,O+z*y),j=0;j<F;j+=2){var W=U[j],X=U[j+1];H[O]=W,H[O+1]=X,H[O+2]=a.r,H[O+3]=a.g,H[O+4]=a.b,H[O+5]=a.a;var Y=W-D,q=X-M,J=(L*Y+V*q)*G,K=(N*Y+k*q)*G,Z=1-J-K;H[O+6]=C*J+E*K+P*Z,H[O+7]=x*J+B*K+R*Z,l&&(H[O+8]=o.r,H[O+9]=o.g,H[O+10]=o.b,H[O+11]=o.a),O+=y}O=p.length;var Q=t.Utils.setArraySize(p,O+3*(z-2));for(z--,j=1;j<z;j++)Q[O]=g,Q[O+1]=g+j,Q[O+2]=g+j+1,O+=3;g+=z+1}}},e.prototype.clip=function(t,e,i,r,n,s,a,o){var l=o,h=!1,u=null;a.length%4>=2?(u=o,o=this.scratch):u=this.scratch,u.length=0,u.push(t),u.push(e),u.push(i),u.push(r),u.push(n),u.push(s),u.push(t),u.push(e),o.length=0;for(var c=a,_=a.length-4,f=0;;f+=2){for(var p=c[f],d=c[f+1],m=c[f+2],y=c[f+3],g=p-m,v=d-y,b=u,S=u.length-2,A=o.length,C=0;C<S;C+=2){var x=b[C],T=b[C+1],w=b[C+2],E=b[C+3],B=g*(E-y)-v*(w-m)>0;if(g*(T-y)-v*(x-m)>0){if(B){o.push(w),o.push(E);continue}var D=(P=E-T)*(m-p)-(R=w-x)*(y-d);if(Math.abs(D)>1e-6){var M=(R*(d-T)-P*(p-x))/D;o.push(p+(m-p)*M),o.push(d+(y-d)*M)}else o.push(p),o.push(d)}else if(B){var P,R;D=(P=E-T)*(m-p)-(R=w-x)*(y-d),Math.abs(D)>1e-6?(M=(R*(d-T)-P*(p-x))/D,o.push(p+(m-p)*M),o.push(d+(y-d)*M)):(o.push(p),o.push(d)),o.push(w),o.push(E)}h=!0}if(A==o.length)return l.length=0,!0;if(o.push(o[0]),o.push(o[1]),f==_)break;var I=o;(o=u).length=0,u=I}if(l!=o){l.length=0,f=0;for(var O=o.length-2;f<O;f++)l[f]=o[f]}else l.length=l.length-2;return h},e.makeClockwise=function(t){for(var e=t,i=t.length,r=e[i-2]*e[1]-e[0]*e[i-1],n=0,s=0,a=0,o=0,l=i-3;o<l;o+=2)n=e[o],s=e[o+1],a=e[o+2],r+=n*e[o+3]-a*s;if(!(r<0)){o=0;var h=i-2;for(l=i>>1;o<l;o+=2){var u=e[o],c=e[o+1],_=h-o;e[o]=e[_],e[o+1]=e[_+1],e[_]=u,e[_+1]=c}}},e}();t.SkeletonClipping=e}(qtt||(qtt={})),function(t){var e=function(){function t(){this.bones=new Array,this.slots=new Array,this.skins=new Array,this.events=new Array,this.animations=new Array,this.ikConstraints=new Array,this.transformConstraints=new Array,this.pathConstraints=new Array,this.fps=0}return t.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findBoneIndex=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,r=e.length;i<r;i++)if(e[i].name==t)return i;return-1},t.prototype.findSlot=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findSlotIndex=function(t){if(null==t)throw new Error("slotName cannot be null.");for(var e=this.slots,i=0,r=e.length;i<r;i++)if(e[i].name==t)return i;return-1},t.prototype.findSkin=function(t){if(null==t)throw new Error("skinName cannot be null.");for(var e=this.skins,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findEvent=function(t){if(null==t)throw new Error("eventDataName cannot be null.");for(var e=this.events,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findAnimation=function(t){if(null==t)throw new Error("animationName cannot be null.");for(var e=this.animations,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findIkConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.ikConstraints,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findTransformConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.transformConstraints,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findPathConstraint=function(t){if(null==t)throw new Error("constraintName cannot be null.");for(var e=this.pathConstraints,i=0,r=e.length;i<r;i++){var n=e[i];if(n.name==t)return n}return null},t.prototype.findPathConstraintIndex=function(t){if(null==t)throw new Error("pathConstraintName cannot be null.");for(var e=this.pathConstraints,i=0,r=e.length;i<r;i++)if(e[i].name==t)return i;return-1},t}();t.SkeletonData=e}(qtt||(qtt={})),function(t){var e=function(){function e(t){this.scale=1,this.linkedMeshes=new Array,this.attachmentLoader=t}return e.prototype.readSkeletonData=function(i){var r=this.scale,n=new t.SkeletonData,s="string"==typeof i?JSON.parse(i):i,a=s.skeleton;if(null!=a&&(n.hash=a.hash,n.version=a.spine,n.x=a.x,n.y=a.y,n.width=a.width,n.height=a.height,n.fps=a.fps,n.imagesPath=a.images),s.bones)for(var o=0;o<s.bones.length;o++){var l=s.bones[o],h=null,u=this.getValue(l,"parent",null);if(null!=u&&null==(h=n.findBone(u)))throw new Error("Parent bone not found: "+u);(p=new t.BoneData(n.bones.length,l.name,h)).length=this.getValue(l,"length",0)*r,p.x=this.getValue(l,"x",0)*r,p.y=this.getValue(l,"y",0)*r,p.rotation=this.getValue(l,"rotation",0),p.scaleX=this.getValue(l,"scaleX",1),p.scaleY=this.getValue(l,"scaleY",1),p.shearX=this.getValue(l,"shearX",0),p.shearY=this.getValue(l,"shearY",0),p.transformMode=e.transformModeFromString(this.getValue(l,"transform","normal")),p.skinRequired=this.getValue(l,"skin",!1),n.bones.push(p)}if(s.slots)for(o=0;o<s.slots.length;o++){var c=(D=s.slots[o]).name,_=D.bone,f=n.findBone(_);if(null==f)throw new Error("Slot bone not found: "+_);var p=new t.SlotData(n.slots.length,c,f),d=this.getValue(D,"color",null);null!=d&&p.color.setFromString(d);var m=this.getValue(D,"dark",null);null!=m&&(p.darkColor=new t.Color(1,1,1,1),p.darkColor.setFromString(m)),p.attachmentName=this.getValue(D,"attachment",null),p.blendMode=e.blendModeFromString(this.getValue(D,"blend","normal")),n.slots.push(p)}if(s.ik)for(o=0;o<s.ik.length;o++){var y=s.ik[o];(p=new t.IkConstraintData(y.name)).order=this.getValue(y,"order",0),p.skinRequired=this.getValue(y,"skin",!1);for(var g=0;g<y.bones.length;g++){if(_=y.bones[g],null==(w=n.findBone(_)))throw new Error("IK bone not found: "+_);p.bones.push(w)}var v=y.target;if(p.target=n.findBone(v),null==p.target)throw new Error("IK target bone not found: "+v);p.mix=this.getValue(y,"mix",1),p.softness=this.getValue(y,"softness",0)*r,p.bendDirection=this.getValue(y,"bendPositive",!0)?1:-1,p.compress=this.getValue(y,"compress",!1),p.stretch=this.getValue(y,"stretch",!1),p.uniform=this.getValue(y,"uniform",!1),n.ikConstraints.push(p)}if(s.transform)for(o=0;o<s.transform.length;o++){for(y=s.transform[o],(p=new t.TransformConstraintData(y.name)).order=this.getValue(y,"order",0),p.skinRequired=this.getValue(y,"skin",!1),g=0;g<y.bones.length;g++){if(_=y.bones[g],null==(w=n.findBone(_)))throw new Error("Transform constraint bone not found: "+_);p.bones.push(w)}if(v=y.target,p.target=n.findBone(v),null==p.target)throw new Error("Transform constraint target bone not found: "+v);p.local=this.getValue(y,"local",!1),p.relative=this.getValue(y,"relative",!1),p.offsetRotation=this.getValue(y,"rotation",0),p.offsetX=this.getValue(y,"x",0)*r,p.offsetY=this.getValue(y,"y",0)*r,p.offsetScaleX=this.getValue(y,"scaleX",0),p.offsetScaleY=this.getValue(y,"scaleY",0),p.offsetShearY=this.getValue(y,"shearY",0),p.rotateMix=this.getValue(y,"rotateMix",1),p.translateMix=this.getValue(y,"translateMix",1),p.scaleMix=this.getValue(y,"scaleMix",1),p.shearMix=this.getValue(y,"shearMix",1),n.transformConstraints.push(p)}if(s.path)for(o=0;o<s.path.length;o++){for(y=s.path[o],(p=new t.PathConstraintData(y.name)).order=this.getValue(y,"order",0),p.skinRequired=this.getValue(y,"skin",!1),g=0;g<y.bones.length;g++){if(_=y.bones[g],null==(w=n.findBone(_)))throw new Error("Transform constraint bone not found: "+_);p.bones.push(w)}if(v=y.target,p.target=n.findSlot(v),null==p.target)throw new Error("Path target slot not found: "+v);p.positionMode=e.positionModeFromString(this.getValue(y,"positionMode","percent")),p.spacingMode=e.spacingModeFromString(this.getValue(y,"spacingMode","length")),p.rotateMode=e.rotateModeFromString(this.getValue(y,"rotateMode","tangent")),p.offsetRotation=this.getValue(y,"rotation",0),p.position=this.getValue(y,"position",0),p.positionMode==t.PositionMode.Fixed&&(p.position*=r),p.spacing=this.getValue(y,"spacing",0),p.spacingMode!=t.SpacingMode.Length&&p.spacingMode!=t.SpacingMode.Fixed||(p.spacing*=r),p.rotateMix=this.getValue(y,"rotateMix",1),p.translateMix=this.getValue(y,"translateMix",1),n.pathConstraints.push(p)}if(s.skins){var b=s.skins;if(!(b instanceof Array)){var S=[];for(var A in b)S.push({name:A,attachments:b[A]});b=S}for(o=0;o<b.length;o++){var C=b[o],x=new t.Skin(C.name);if(C.bones)for(var T=0;T<C.bones.length;T++){var w;if(null==(w=n.findBone(C.bones[T])))throw new Error("Skin bone not found: "+C.bones[o]);x.bones.push(w)}if(C.ik)for(T=0;T<C.ik.length;T++){if(null==(E=n.findIkConstraint(C.ik[T])))throw new Error("Skin IK constraint not found: "+C.ik[o]);x.constraints.push(E)}if(C.transform)for(T=0;T<C.transform.length;T++){if(null==(E=n.findTransformConstraint(C.transform[T])))throw new Error("Skin transform constraint not found: "+C.transform[o]);x.constraints.push(E)}if(C.path)for(T=0;T<C.path.length;T++){var E;if(null==(E=n.findPathConstraint(C.path[T])))throw new Error("Skin path constraint not found: "+C.path[o]);x.constraints.push(E)}for(var c in C.attachments){var B=n.findSlot(c);if(null==B)throw new Error("Slot not found: "+c);var D=C.attachments[c];for(var M in D){var P=this.readAttachment(D[M],x,B.index,M,n);null!=P&&x.setAttachment(B.index,M,P)}}n.skins.push(x),"default"==x.name&&(n.defaultSkin=x)}}o=0;for(var R=this.linkedMeshes.length;o<R;o++){var I=this.linkedMeshes[o];if(null==(x=null==I.skin?n.defaultSkin:n.findSkin(I.skin)))throw new Error("Skin not found: "+I.skin);var O=x.getAttachment(I.slotIndex,I.parent);if(null==O)throw new Error("Parent mesh not found: "+I.parent);I.mesh.deformAttachment=I.inheritDeform?O:I.mesh,I.mesh.setParentMesh(O),I.mesh.updateUVs()}if(this.linkedMeshes.length=0,s.events)for(var F in s.events){var L=s.events[F];(p=new t.EventData(F)).intValue=this.getValue(L,"int",0),p.floatValue=this.getValue(L,"float",0),p.stringValue=this.getValue(L,"string",""),p.audioPath=this.getValue(L,"audio",null),null!=p.audioPath&&(p.volume=this.getValue(L,"volume",1),p.balance=this.getValue(L,"balance",0)),n.events.push(p)}if(s.animations)for(var V in s.animations){var k=s.animations[V];this.readAnimation(k,V,n)}return n},e.prototype.readAttachment=function(e,r,n,s,a){var o=this.scale;switch(s=this.getValue(e,"name",s),this.getValue(e,"type","region")){case"region":var l=this.getValue(e,"path",s),h=this.attachmentLoader.newRegionAttachment(r,s,l);return null==h?null:(h.path=l,h.x=this.getValue(e,"x",0)*o,h.y=this.getValue(e,"y",0)*o,h.scaleX=this.getValue(e,"scaleX",1),h.scaleY=this.getValue(e,"scaleY",1),h.rotation=this.getValue(e,"rotation",0),h.width=e.width*o,h.height=e.height*o,null!=(v=this.getValue(e,"color",null))&&h.color.setFromString(v),h.updateOffset(),h);case"boundingbox":var u=this.attachmentLoader.newBoundingBoxAttachment(r,s);return null==u?null:(this.readVertices(e,u,e.vertexCount<<1),null!=(v=this.getValue(e,"color",null))&&u.color.setFromString(v),u);case"mesh":case"linkedmesh":l=this.getValue(e,"path",s);var c=this.attachmentLoader.newMeshAttachment(r,s,l);if(null==c)return null;c.path=l,null!=(v=this.getValue(e,"color",null))&&c.color.setFromString(v),c.width=this.getValue(e,"width",0)*o,c.height=this.getValue(e,"height",0)*o;var _=this.getValue(e,"parent",null);if(null!=_)return this.linkedMeshes.push(new i(c,this.getValue(e,"skin",null),n,_,this.getValue(e,"deform",!0))),c;var f=e.uvs;return this.readVertices(e,c,f.length),c.triangles=e.triangles,c.regionUVs=f,c.updateUVs(),c.edges=this.getValue(e,"edges",null),c.hullLength=2*this.getValue(e,"hull",0),c;case"path":if(null==(l=this.attachmentLoader.newPathAttachment(r,s)))return null;l.closed=this.getValue(e,"closed",!1),l.constantSpeed=this.getValue(e,"constantSpeed",!0);var p=e.vertexCount;this.readVertices(e,l,p<<1);for(var d=t.Utils.newArray(p/3,0),m=0;m<e.lengths.length;m++)d[m]=e.lengths[m]*o;return l.lengths=d,null!=(v=this.getValue(e,"color",null))&&l.color.setFromString(v),l;case"point":var y=this.attachmentLoader.newPointAttachment(r,s);return null==y?null:(y.x=this.getValue(e,"x",0)*o,y.y=this.getValue(e,"y",0)*o,y.rotation=this.getValue(e,"rotation",0),null!=(v=this.getValue(e,"color",null))&&y.color.setFromString(v),y);case"clipping":var g=this.attachmentLoader.newClippingAttachment(r,s);if(null==g)return null;var v,b=this.getValue(e,"end",null);if(null!=b){var S=a.findSlot(b);if(null==S)throw new Error("Clipping end slot not found: "+b);g.endSlot=S}return p=e.vertexCount,this.readVertices(e,g,p<<1),null!=(v=this.getValue(e,"color",null))&&g.color.setFromString(v),g}return null},e.prototype.readVertices=function(e,i,r){var n=this.scale;i.worldVerticesLength=r;var s=e.vertices;if(r!=s.length){var a=new Array,o=new Array;for(c=0,_=s.length;c<_;){var l=s[c++];o.push(l);for(var h=c+4*l;c<h;c+=4)o.push(s[c]),a.push(s[c+1]*n),a.push(s[c+2]*n),a.push(s[c+3])}i.bones=o,i.vertices=t.Utils.toFloatArray(a)}else{var u=t.Utils.toFloatArray(s);if(1!=n)for(var c=0,_=s.length;c<_;c++)u[c]*=n;i.vertices=u}},e.prototype.readAnimation=function(e,i,r){var n=this.scale,s=new Array,a=0;if(e.slots)for(var o in e.slots){var l=e.slots[o];if(-1==(Z=r.findSlotIndex(o)))throw new Error("Slot not found: "+o);for(var h in l){var u=l[h];if("attachment"==h){(b=new t.AttachmentTimeline(u.length)).slotIndex=Z;for(var c=0,_=0;_<u.length;_++){var f=u[_];b.setFrame(c++,this.getValue(f,"time",0),f.name)}s.push(b),a=Math.max(a,b.frames[b.getFrameCount()-1])}else if("color"==h){for((b=new t.ColorTimeline(u.length)).slotIndex=Z,c=0,_=0;_<u.length;_++){f=u[_];var p=new t.Color;p.setFromString(f.color),b.setFrame(c,this.getValue(f,"time",0),p.r,p.g,p.b,p.a),this.readCurve(f,b,c),c++}s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.ColorTimeline.ENTRIES])}else{if("twoColor"!=h)throw new Error("Invalid timeline type for a slot: "+h+" ("+o+")");for((b=new t.TwoColorTimeline(u.length)).slotIndex=Z,c=0,_=0;_<u.length;_++){f=u[_];var d=new t.Color,m=new t.Color;d.setFromString(f.light),m.setFromString(f.dark),b.setFrame(c,this.getValue(f,"time",0),d.r,d.g,d.b,d.a,m.r,m.g,m.b),this.readCurve(f,b,c),c++}s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.TwoColorTimeline.ENTRIES])}}}if(e.bones)for(var y in e.bones){var g=e.bones[y],v=r.findBoneIndex(y);if(-1==v)throw new Error("Bone not found: "+y);for(var h in g)if(u=g[h],"rotate"===h){for((b=new t.RotateTimeline(u.length)).boneIndex=v,c=0,_=0;_<u.length;_++)f=u[_],b.setFrame(c,this.getValue(f,"time",0),this.getValue(f,"angle",0)),this.readCurve(f,b,c),c++;s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.RotateTimeline.ENTRIES])}else{if("translate"!==h&&"scale"!==h&&"shear"!==h)throw new Error("Invalid timeline type for a bone: "+h+" ("+y+")");var b=null,S=1,A=0;for("scale"===h?(b=new t.ScaleTimeline(u.length),A=1):"shear"===h?b=new t.ShearTimeline(u.length):(b=new t.TranslateTimeline(u.length),S=n),b.boneIndex=v,c=0,_=0;_<u.length;_++){f=u[_];var C=this.getValue(f,"x",A),x=this.getValue(f,"y",A);b.setFrame(c,this.getValue(f,"time",0),C*S,x*S),this.readCurve(f,b,c),c++}s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.TranslateTimeline.ENTRIES])}}if(e.ik)for(var T in e.ik){var w=e.ik[T],E=r.findIkConstraint(T);for((b=new t.IkConstraintTimeline(w.length)).ikConstraintIndex=r.ikConstraints.indexOf(E),c=0,_=0;_<w.length;_++)f=w[_],b.setFrame(c,this.getValue(f,"time",0),this.getValue(f,"mix",1),this.getValue(f,"softness",0)*n,this.getValue(f,"bendPositive",!0)?1:-1,this.getValue(f,"compress",!1),this.getValue(f,"stretch",!1)),this.readCurve(f,b,c),c++;s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.IkConstraintTimeline.ENTRIES])}if(e.transform)for(var T in e.transform){for(w=e.transform[T],E=r.findTransformConstraint(T),(b=new t.TransformConstraintTimeline(w.length)).transformConstraintIndex=r.transformConstraints.indexOf(E),c=0,_=0;_<w.length;_++)f=w[_],b.setFrame(c,this.getValue(f,"time",0),this.getValue(f,"rotateMix",1),this.getValue(f,"translateMix",1),this.getValue(f,"scaleMix",1),this.getValue(f,"shearMix",1)),this.readCurve(f,b,c),c++;s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.TransformConstraintTimeline.ENTRIES])}var B=e.path||e.paths;if(B)for(var T in B){w=B[T];var D=r.findPathConstraintIndex(T);if(-1==D)throw new Error("Path constraint not found: "+T);var M=r.pathConstraints[D];for(var h in w)if(u=w[h],"position"===h||"spacing"===h){for(b=null,S=1,"spacing"===h?(b=new t.PathConstraintSpacingTimeline(u.length),M.spacingMode!=t.SpacingMode.Length&&M.spacingMode!=t.SpacingMode.Fixed||(S=n)):(b=new t.PathConstraintPositionTimeline(u.length),M.positionMode==t.PositionMode.Fixed&&(S=n)),b.pathConstraintIndex=D,c=0,_=0;_<u.length;_++)f=u[_],b.setFrame(c,this.getValue(f,"time",0),this.getValue(f,h,0)*S),this.readCurve(f,b,c),c++;s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.PathConstraintPositionTimeline.ENTRIES])}else if("mix"===h){for((b=new t.PathConstraintMixTimeline(u.length)).pathConstraintIndex=D,c=0,_=0;_<u.length;_++)f=u[_],b.setFrame(c,this.getValue(f,"time",0),this.getValue(f,"rotateMix",1),this.getValue(f,"translateMix",1)),this.readCurve(f,b,c),c++;s.push(b),a=Math.max(a,b.frames[(b.getFrameCount()-1)*t.PathConstraintMixTimeline.ENTRIES])}}if(e.deform)for(var P in e.deform){var R=e.deform[P],I=r.findSkin(P);if(null==I)throw new Error("Skin not found: "+P);for(var o in R){if(l=R[o],-1==(Z=r.findSlotIndex(o)))throw new Error("Slot not found: "+l.name);for(var h in l){u=l[h];var O=I.getAttachment(Z,h);if(null!=O){var F=null!=O.bones,L=O.vertices,V=F?L.length/3*2:L.length;(b=new t.DeformTimeline(u.length)).slotIndex=Z,b.attachment=O,c=0;for(var k=0;k<u.length;k++){f=u[k];var N=void 0,G=this.getValue(f,"vertices",null);if(null==G)N=F?t.Utils.newFloatArray(V):L;else{N=t.Utils.newFloatArray(V);var z=this.getValue(f,"offset",0);if(t.Utils.arrayCopy(G,0,N,z,G.length),1!=n)for(var U=(_=z)+G.length;_<U;_++)N[_]*=n;if(!F)for(_=0;_<V;_++)N[_]+=L[_]}b.setFrame(c,this.getValue(f,"time",0),N),this.readCurve(f,b,c),c++}s.push(b),a=Math.max(a,b.frames[b.getFrameCount()-1])}}}}var H=e.drawOrder;if(null==H&&(H=e.draworder),null!=H){b=new t.DrawOrderTimeline(H.length);var j=r.slots.length;for(c=0,k=0;k<H.length;k++){var W=H[k],X=null,Y=this.getValue(W,"offsets",null);if(null!=Y){X=t.Utils.newArray(j,-1);var q=t.Utils.newArray(j-Y.length,0),J=0,K=0;for(_=0;_<Y.length;_++){var Z,Q=Y[_];if(-1==(Z=r.findSlotIndex(Q.slot)))throw new Error("Slot not found: "+Q.slot);for(;J!=Z;)q[K++]=J++;X[J+Q.offset]=J++}for(;J<j;)q[K++]=J++;for(_=j-1;_>=0;_--)-1==X[_]&&(X[_]=q[--K])}b.setFrame(c++,this.getValue(W,"time",0),X)}s.push(b),a=Math.max(a,b.frames[b.getFrameCount()-1])}if(e.events){for(b=new t.EventTimeline(e.events.length),c=0,_=0;_<e.events.length;_++){var $=e.events[_],tt=r.findEvent($.name);if(null==tt)throw new Error("Event not found: "+$.name);var et=new t.Event(t.Utils.toSinglePrecision(this.getValue($,"time",0)),tt);et.intValue=this.getValue($,"int",tt.intValue),et.floatValue=this.getValue($,"float",tt.floatValue),et.stringValue=this.getValue($,"string",tt.stringValue),null!=et.data.audioPath&&(et.volume=this.getValue($,"volume",1),et.balance=this.getValue($,"balance",0)),b.setFrame(c++,et)}s.push(b),a=Math.max(a,b.frames[b.getFrameCount()-1])}if(isNaN(a))throw new Error("Error while parsing animation, duration is NaN");r.animations.push(new t.Animation(i,s,a))},e.prototype.readCurve=function(t,e,i){var r=t.curve;r&&("stepped"==r?e.setStepped(i):"[object Array]"===Object.prototype.toString.call(r)?e.setCurve(i,r[0],r[1],r[2],r[3]):e.setCurve(i,r,this.getValue(t,"c2",0),this.getValue(t,"c3",1),this.getValue(t,"c4",1)))},e.prototype.getValue=function(t,e,i){return void 0!==t[e]?t[e]:i},e.blendModeFromString=function(e){if("normal"==(e=e.toLowerCase()))return t.BlendMode.Normal;if("additive"==e)return t.BlendMode.Additive;if("multiply"==e)return t.BlendMode.Multiply;if("screen"==e)return t.BlendMode.Screen;throw new Error("Unknown blend mode: "+e)},e.positionModeFromString=function(e){if("fixed"==(e=e.toLowerCase()))return t.PositionMode.Fixed;if("percent"==e)return t.PositionMode.Percent;throw new Error("Unknown position mode: "+e)},e.spacingModeFromString=function(e){if("length"==(e=e.toLowerCase()))return t.SpacingMode.Length;if("fixed"==e)return t.SpacingMode.Fixed;if("percent"==e)return t.SpacingMode.Percent;throw new Error("Unknown position mode: "+e)},e.rotateModeFromString=function(e){if("tangent"==(e=e.toLowerCase()))return t.RotateMode.Tangent;if("chain"==e)return t.RotateMode.Chain;if("chainscale"==e)return t.RotateMode.ChainScale;throw new Error("Unknown rotate mode: "+e)},e.transformModeFromString=function(e){if("normal"==(e=e.toLowerCase()))return t.TransformMode.Normal;if("onlytranslation"==e)return t.TransformMode.OnlyTranslation;if("norotationorreflection"==e)return t.TransformMode.NoRotationOrReflection;if("noscale"==e)return t.TransformMode.NoScale;if("noscaleorreflection"==e)return t.TransformMode.NoScaleOrReflection;throw new Error("Unknown transform mode: "+e)},e}();t.SkeletonJson=e;var i=function(t,e,i,r,n){this.mesh=t,this.skin=e,this.slotIndex=i,this.parent=r,this.inheritDeform=n}}(qtt||(qtt={})),function(t){var e=function(t,e,i){this.slotIndex=t,this.name=e,this.attachment=i};t.SkinEntry=e;var i=function(){function i(t){if(this.attachments=new Array,this.bones=Array(),this.constraints=new Array,null==t)throw new Error("name cannot be null.");this.name=t}return i.prototype.setAttachment=function(t,e,i){if(null==i)throw new Error("attachment cannot be null.");var r=this.attachments;t>=r.length&&(r.length=t+1),r[t]||(r[t]={}),r[t][e]=i},i.prototype.addSkin=function(t){for(var e=0;e<t.bones.length;e++){for(var i=t.bones[e],r=!1,n=0;n<this.bones.length;n++)if(this.bones[n]==i){r=!0;break}r||this.bones.push(i)}for(e=0;e<t.constraints.length;e++){var s=t.constraints[e];for(r=!1,n=0;n<this.constraints.length;n++)if(this.constraints[n]==s){r=!0;break}r||this.constraints.push(s)}var a=t.getAttachments();for(e=0;e<a.length;e++){var o=a[e];this.setAttachment(o.slotIndex,o.name,o.attachment)}},i.prototype.copySkin=function(e){for(var i=0;i<e.bones.length;i++){for(var r=e.bones[i],n=!1,s=0;s<this.bones.length;s++)if(this.bones[s]==r){n=!0;break}n||this.bones.push(r)}for(i=0;i<e.constraints.length;i++){var a=e.constraints[i];for(n=!1,s=0;s<this.constraints.length;s++)if(this.constraints[s]==a){n=!0;break}n||this.constraints.push(a)}var o=e.getAttachments();for(i=0;i<o.length;i++){var l=o[i];null!=l.attachment&&(l.attachment instanceof t.MeshAttachment?(l.attachment=l.attachment.newLinkedMesh(),this.setAttachment(l.slotIndex,l.name,l.attachment)):(l.attachment=l.attachment.copy(),this.setAttachment(l.slotIndex,l.name,l.attachment)))}},i.prototype.getAttachment=function(t,e){var i=this.attachments[t];return i?i[e]:null},i.prototype.removeAttachment=function(t,e){var i=this.attachments[t];i&&(i[e]=null)},i.prototype.getAttachments=function(){for(var t=new Array,i=0;i<this.attachments.length;i++){var r=this.attachments[i];if(r)for(var n in r){var s=r[n];s&&t.push(new e(i,n,s))}}return t},i.prototype.getAttachmentsForSlot=function(t,i){var r=this.attachments[t];if(r)for(var n in r){var s=r[n];s&&i.push(new e(t,n,s))}},i.prototype.clear=function(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0},i.prototype.attachAll=function(t,e){for(var i=0,r=0;r<t.slots.length;r++){var n=t.slots[r],s=n.getAttachment();if(s&&i<e.attachments.length){var a=e.attachments[i];for(var o in a)if(s==a[o]){var l=this.getAttachment(i,o);null!=l&&n.setAttachment(l);break}}i++}},i}();t.Skin=i}(qtt||(qtt={})),function(t){var e=function(){function e(e,i){if(this.deform=new Array,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("bone cannot be null.");this.data=e,this.bone=i,this.color=new t.Color,this.darkColor=null==e.darkColor?null:new t.Color,this.setToSetupPose()}return e.prototype.getSkeleton=function(){return this.bone.skeleton},e.prototype.getAttachment=function(){return this.attachment},e.prototype.setAttachment=function(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.deform.length=0)},e.prototype.setAttachmentTime=function(t){this.attachmentTime=this.bone.skeleton.time-t},e.prototype.getAttachmentTime=function(){return this.bone.skeleton.time-this.attachmentTime},e.prototype.setToSetupPose=function(){this.color.setFromColor(this.data.color),null!=this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))},e}();t.Slot=e}(qtt||(qtt={})),function(t){t.SlotData=function(e,i,r){if(this.color=new t.Color(1,1,1,1),e<0)throw new Error("index must be >= 0.");if(null==i)throw new Error("name cannot be null.");if(null==r)throw new Error("boneData cannot be null.");this.index=e,this.name=i,this.boneData=r}}(qtt||(qtt={})),function(t){var e,i,r=function(){function t(t){this._image=t}return t.prototype.getImage=function(){return this._image},t.filterFromString=function(t){switch(t.toLowerCase()){case"nearest":return e.Nearest;case"linear":return e.Linear;case"mipmap":return e.MipMap;case"mipmapnearestnearest":return e.MipMapNearestNearest;case"mipmaplinearnearest":return e.MipMapLinearNearest;case"mipmapnearestlinear":return e.MipMapNearestLinear;case"mipmaplinearlinear":return e.MipMapLinearLinear;default:throw new Error("Unknown texture filter "+t)}},t.wrapFromString=function(t){switch(t.toLowerCase()){case"mirroredtepeat":return i.MirroredRepeat;case"clamptoedge":return i.ClampToEdge;case"repeat":return i.Repeat;default:throw new Error("Unknown texture wrap "+t)}},t}();t.Texture=r,function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear"}(e=t.TextureFilter||(t.TextureFilter={})),function(t){t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat"}(i=t.TextureWrap||(t.TextureWrap={}));t.TextureRegion=function(){this.u=0,this.v=0,this.u2=0,this.v2=0,this.width=0,this.height=0,this.rotate=!1,this.offsetX=0,this.offsetY=0,this.originalWidth=0,this.originalHeight=0};var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Jtt(e,t),e.prototype.setFilters=function(){},e.prototype.setWraps=function(){},e.prototype.dispose=function(){},e}(r);t.FakeTexture=n}(qtt||(qtt={})),function(t){var e=function(){function e(t,e){this.pages=new Array,this.regions=new Array,this.load(t,e)}return e.prototype.load=function(e,s){if(null==s)throw new Error("textureLoader cannot be null.");for(var a=new i(e),o=new Array(4),l=null;;){var h=a.readLine();if(null==h)break;if(0==(h=h.trim()).length)l=null;else if(l){var u=new n;u.name=h,u.page=l;var c=a.readValue();"true"==c.toLocaleLowerCase()?u.degrees=90:"false"==c.toLocaleLowerCase()?u.degrees=0:u.degrees=parseFloat(c),u.rotate=90==u.degrees,a.readTuple(o);var _=parseInt(o[0]),f=parseInt(o[1]);a.readTuple(o);var p=parseInt(o[0]),d=parseInt(o[1]);u.u=_/l.width,u.v=f/l.height,u.rotate?(u.u2=(_+d)/l.width,u.v2=(f+p)/l.height):(u.u2=(_+p)/l.width,u.v2=(f+d)/l.height),u.x=_,u.y=f,u.width=Math.abs(p),u.height=Math.abs(d),4==a.readTuple(o)&&4==a.readTuple(o)&&a.readTuple(o),u.originalWidth=parseInt(o[0]),u.originalHeight=parseInt(o[1]),a.readTuple(o),u.offsetX=parseInt(o[0]),u.offsetY=parseInt(o[1]),u.index=parseInt(a.readValue()),u.texture=l.texture,this.regions.push(u)}else{(l=new r).name=h,2==a.readTuple(o)&&(l.width=parseInt(o[0]),l.height=parseInt(o[1]),a.readTuple(o)),a.readTuple(o),l.minFilter=t.Texture.filterFromString(o[0]),l.magFilter=t.Texture.filterFromString(o[1]);var m=a.readValue();l.uWrap=t.TextureWrap.ClampToEdge,l.vWrap=t.TextureWrap.ClampToEdge,"x"==m?l.uWrap=t.TextureWrap.Repeat:"y"==m?l.vWrap=t.TextureWrap.Repeat:"xy"==m&&(l.uWrap=l.vWrap=t.TextureWrap.Repeat),l.texture=s(h),l.texture.setFilters(l.minFilter,l.magFilter),l.texture.setWraps(l.uWrap,l.vWrap),l.width=l.texture.getImage().width,l.height=l.texture.getImage().height,this.pages.push(l)}}},e.prototype.findRegion=function(t){for(var e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null},e.prototype.dispose=function(){for(var t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()},e}();t.TextureAtlas=e;var i=function(){function t(t){this.index=0,this.lines=t.split(/\r\n|\r|\n/)}return t.prototype.readLine=function(){return this.index>=this.lines.length?null:this.lines[this.index++]},t.prototype.readValue=function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()},t.prototype.readTuple=function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw new Error("Invalid line: "+e);for(var r=0,n=i+1;r<3;r++){var s=e.indexOf(",",n);if(-1==s)break;t[r]=e.substr(n,s-n).trim(),n=s+1}return t[r]=e.substring(n).trim(),r+1},t}(),r=function(){};t.TextureAtlasPage=r;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Jtt(e,t),e}(t.TextureRegion);t.TextureAtlasRegion=n}(qtt||(qtt={})),function(t){var e=function(){function e(e,i){if(this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.temp=new t.Vector2,this.active=!1,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("skeleton cannot be null.");this.data=e,this.rotateMix=e.rotateMix,this.translateMix=e.translateMix,this.scaleMix=e.scaleMix,this.shearMix=e.shearMix,this.bones=new Array;for(var r=0;r<e.bones.length;r++)this.bones.push(i.findBone(e.bones[r].name));this.target=i.findBone(e.target.name)}return e.prototype.isActive=function(){return this.active},e.prototype.apply=function(){this.update()},e.prototype.update=function(){this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld()},e.prototype.applyAbsoluteWorld=function(){for(var e=this.rotateMix,i=this.translateMix,r=this.scaleMix,n=this.shearMix,s=this.target,a=s.a,o=s.b,l=s.c,h=s.d,u=a*h-o*l>0?t.MathUtils.degRad:-t.MathUtils.degRad,c=this.data.offsetRotation*u,_=this.data.offsetShearY*u,f=this.bones,p=0,d=f.length;p<d;p++){var m=f[p],y=!1;if(0!=e){var g=m.a,v=m.b,b=m.c,S=m.d;(E=Math.atan2(l,a)-Math.atan2(b,g)+c)>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E*=e;var A=Math.cos(E),C=Math.sin(E);m.a=A*g-C*b,m.b=A*v-C*S,m.c=C*g+A*b,m.d=C*v+A*S,y=!0}if(0!=i){var x=this.temp;s.localToWorld(x.set(this.data.offsetX,this.data.offsetY)),m.worldX+=(x.x-m.worldX)*i,m.worldY+=(x.y-m.worldY)*i,y=!0}if(r>0){var T=Math.sqrt(m.a*m.a+m.c*m.c),w=Math.sqrt(a*a+l*l);T>1e-5&&(T=(T+(w-T+this.data.offsetScaleX)*r)/T),m.a*=T,m.c*=T,T=Math.sqrt(m.b*m.b+m.d*m.d),w=Math.sqrt(o*o+h*h),T>1e-5&&(T=(T+(w-T+this.data.offsetScaleY)*r)/T),m.b*=T,m.d*=T,y=!0}if(n>0){v=m.b,S=m.d;var E,B=Math.atan2(S,v);(E=Math.atan2(h,o)-Math.atan2(l,a)-(B-Math.atan2(m.c,m.a)))>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E=B+(E+_)*n,T=Math.sqrt(v*v+S*S),m.b=Math.cos(E)*T,m.d=Math.sin(E)*T,y=!0}y&&(m.appliedValid=!1)}},e.prototype.applyRelativeWorld=function(){for(var e=this.rotateMix,i=this.translateMix,r=this.scaleMix,n=this.shearMix,s=this.target,a=s.a,o=s.b,l=s.c,h=s.d,u=a*h-o*l>0?t.MathUtils.degRad:-t.MathUtils.degRad,c=this.data.offsetRotation*u,_=this.data.offsetShearY*u,f=this.bones,p=0,d=f.length;p<d;p++){var m,y=f[p],g=!1;if(0!=e){var v=y.a,b=y.b,S=y.c,A=y.d;(m=Math.atan2(l,a)+c)>t.MathUtils.PI?m-=t.MathUtils.PI2:m<-t.MathUtils.PI&&(m+=t.MathUtils.PI2),m*=e;var C=Math.cos(m),x=Math.sin(m);y.a=C*v-x*S,y.b=C*b-x*A,y.c=x*v+C*S,y.d=x*b+C*A,g=!0}if(0!=i){var T=this.temp;s.localToWorld(T.set(this.data.offsetX,this.data.offsetY)),y.worldX+=T.x*i,y.worldY+=T.y*i,g=!0}if(r>0){var w=(Math.sqrt(a*a+l*l)-1+this.data.offsetScaleX)*r+1;y.a*=w,y.c*=w,w=(Math.sqrt(o*o+h*h)-1+this.data.offsetScaleY)*r+1,y.b*=w,y.d*=w,g=!0}if(n>0)(m=Math.atan2(h,o)-Math.atan2(l,a))>t.MathUtils.PI?m-=t.MathUtils.PI2:m<-t.MathUtils.PI&&(m+=t.MathUtils.PI2),b=y.b,A=y.d,m=Math.atan2(A,b)+(m-t.MathUtils.PI/2+_)*n,w=Math.sqrt(b*b+A*A),y.b=Math.cos(m)*w,y.d=Math.sin(m)*w,g=!0;g&&(y.appliedValid=!1)}},e.prototype.applyAbsoluteLocal=function(){var t=this.rotateMix,e=this.translateMix,i=this.scaleMix,r=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();for(var s=this.bones,a=0,o=s.length;a<o;a++){var l=s[a];l.appliedValid||l.updateAppliedTransform();var h=l.arotation;if(0!=t){var u=n.arotation-h+this.data.offsetRotation;h+=(u-=360*(16384-(16384.499999999996-u/360|0)))*t}var c=l.ax,_=l.ay;0!=e&&(c+=(n.ax-c+this.data.offsetX)*e,_+=(n.ay-_+this.data.offsetY)*e);var f=l.ascaleX,p=l.ascaleY;0!=i&&(f>1e-5&&(f=(f+(n.ascaleX-f+this.data.offsetScaleX)*i)/f),p>1e-5&&(p=(p+(n.ascaleY-p+this.data.offsetScaleY)*i)/p));var d=l.ashearY;0!=r&&(u=n.ashearY-d+this.data.offsetShearY,u-=360*(16384-(16384.499999999996-u/360|0)),l.shearY+=u*r),l.updateWorldTransformWith(c,_,h,f,p,l.ashearX,d)}},e.prototype.applyRelativeLocal=function(){var t=this.rotateMix,e=this.translateMix,i=this.scaleMix,r=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();for(var s=this.bones,a=0,o=s.length;a<o;a++){var l=s[a];l.appliedValid||l.updateAppliedTransform();var h=l.arotation;0!=t&&(h+=(n.arotation+this.data.offsetRotation)*t);var u=l.ax,c=l.ay;0!=e&&(u+=(n.ax+this.data.offsetX)*e,c+=(n.ay+this.data.offsetY)*e);var _=l.ascaleX,f=l.ascaleY;0!=i&&(_>1e-5&&(_*=(n.ascaleX-1+this.data.offsetScaleX)*i+1),f>1e-5&&(f*=(n.ascaleY-1+this.data.offsetScaleY)*i+1));var p=l.ashearY;0!=r&&(p+=(n.ashearY+this.data.offsetShearY)*r),l.updateWorldTransformWith(u,c,h,_,f,l.ashearX,p)}},e}();t.TransformConstraint=e}(qtt||(qtt={})),function(t){var e=function(t){function e(e){var i=t.call(this,e,0,!1)||this;return i.bones=new Array,i.rotateMix=0,i.translateMix=0,i.scaleMix=0,i.shearMix=0,i.offsetRotation=0,i.offsetX=0,i.offsetY=0,i.offsetScaleX=0,i.offsetScaleY=0,i.offsetShearY=0,i.relative=!1,i.local=!1,i}return Jtt(e,t),e}(t.ConstraintData);t.TransformConstraintData=e}(qtt||(qtt={})),function(t){var e=function(){function e(){this.convexPolygons=new Array,this.convexPolygonsIndices=new Array,this.indicesArray=new Array,this.isConcaveArray=new Array,this.triangles=new Array,this.polygonPool=new t.Pool((function(){return new Array})),this.polygonIndicesPool=new t.Pool((function(){return new Array}))}return e.prototype.triangulate=function(t){var i=t,r=t.length>>1,n=this.indicesArray;n.length=0;for(var s=0;s<r;s++)n[s]=s;var a=this.isConcaveArray;a.length=0,s=0;for(var o=r;s<o;++s)a[s]=e.isConcave(s,r,i,n);var l=this.triangles;for(l.length=0;r>3;){for(var h=r-1,u=(s=0,1);;){t:if(!a[s]){for(var c=n[h]<<1,_=n[s]<<1,f=n[u]<<1,p=i[c],d=i[c+1],m=i[_],y=i[_+1],g=i[f],v=i[f+1],b=(u+1)%r;b!=h;b=(b+1)%r)if(a[b]){var S=n[b]<<1,A=i[S],C=i[S+1];if(e.positiveArea(g,v,p,d,A,C)&&e.positiveArea(p,d,m,y,A,C)&&e.positiveArea(m,y,g,v,A,C))break t}break}if(0==u){do{if(!a[s])break;s--}while(s>0);break}h=s,s=u,u=(u+1)%r}l.push(n[(r+s-1)%r]),l.push(n[s]),l.push(n[(s+1)%r]),n.splice(s,1),a.splice(s,1);var x=(--r+s-1)%r,T=s==r?0:s;a[x]=e.isConcave(x,r,i,n),a[T]=e.isConcave(T,r,i,n)}return 3==r&&(l.push(n[2]),l.push(n[0]),l.push(n[1])),l},e.prototype.decompose=function(t,i){var r=t,n=this.convexPolygons;this.polygonPool.freeAll(n),n.length=0;var s=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(s),s.length=0;var a=this.polygonIndicesPool.obtain();a.length=0;var o=this.polygonPool.obtain();o.length=0;for(var l=-1,h=0,u=0,c=i.length;u<c;u+=3){var _=i[u]<<1,f=i[u+1]<<1,p=i[u+2]<<1,d=r[_],m=r[_+1],y=r[f],g=r[f+1],v=r[p],b=r[p+1],S=!1;if(l==_){var A=o.length-4,C=e.winding(o[A],o[A+1],o[A+2],o[A+3],v,b),x=e.winding(v,b,o[0],o[1],o[2],o[3]);C==h&&x==h&&(o.push(v),o.push(b),a.push(p),S=!0)}S||(o.length>0?(n.push(o),s.push(a)):(this.polygonPool.free(o),this.polygonIndicesPool.free(a)),(o=this.polygonPool.obtain()).length=0,o.push(d),o.push(m),o.push(y),o.push(g),o.push(v),o.push(b),(a=this.polygonIndicesPool.obtain()).length=0,a.push(_),a.push(f),a.push(p),h=e.winding(d,m,y,g,v,b),l=_)}for(o.length>0&&(n.push(o),s.push(a)),u=0,c=n.length;u<c;u++)if(0!=(a=s[u]).length)for(var T=a[0],w=a[a.length-1],E=(o=n[u])[A=o.length-4],B=o[A+1],D=o[A+2],M=o[A+3],P=o[0],R=o[1],I=o[2],O=o[3],F=e.winding(E,B,D,M,P,R),L=0;L<c;L++)if(L!=u){var V=s[L];if(3==V.length){var k=V[0],N=V[1],G=V[2],z=n[L];v=z[z.length-2],b=z[z.length-1],k==T&&N==w&&(C=e.winding(E,B,D,M,v,b),x=e.winding(v,b,P,R,I,O),C==F&&x==F&&(z.length=0,V.length=0,o.push(v),o.push(b),a.push(G),E=D,B=M,D=v,M=b,L=0))}}for(u=n.length-1;u>=0;u--)0==(o=n[u]).length&&(n.splice(u,1),this.polygonPool.free(o),a=s[u],s.splice(u,1),this.polygonIndicesPool.free(a));return n},e.isConcave=function(t,e,i,r){var n=r[(e+t-1)%e]<<1,s=r[t]<<1,a=r[(t+1)%e]<<1;return!this.positiveArea(i[n],i[n+1],i[s],i[s+1],i[a],i[a+1])},e.positiveArea=function(t,e,i,r,n,s){return t*(s-r)+i*(e-s)+n*(r-e)>=0},e.winding=function(t,e,i,r,n,s){var a=i-t,o=r-e;return n*o-s*a+a*e-t*o>=0?1:-1},e}();t.Triangulator=e}(qtt||(qtt={})),function(t){var e=function(){function t(){this.array=new Array}return t.prototype.add=function(t){var e=this.contains(t);return this.array[0|t]=0|t,!e},t.prototype.contains=function(t){return null!=this.array[0|t]},t.prototype.remove=function(t){this.array[0|t]=void 0},t.prototype.clear=function(){this.array.length=0},t}();t.IntSet=e;var i=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),this.r=t,this.g=e,this.b=i,this.a=r}return t.prototype.set=function(t,e,i,r){return this.r=t,this.g=e,this.b=i,this.a=r,this.clamp(),this},t.prototype.setFromColor=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.setFromString=function(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this},t.prototype.add=function(t,e,i,r){return this.r+=t,this.g+=e,this.b+=i,this.a+=r,this.clamp(),this},t.prototype.clamp=function(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this},t.rgba8888ToColor=function(t,e){t.r=((4278190080&e)>>>24)/255,t.g=((16711680&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255},t.rgb888ToColor=function(t,e){t.r=((16711680&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255},t.WHITE=new t(1,1,1,1),t.RED=new t(1,0,0,1),t.GREEN=new t(0,1,0,1),t.BLUE=new t(0,0,1,1),t.MAGENTA=new t(1,0,1,1),t}();t.Color=i;var r=function(){function t(){}return t.clamp=function(t,e,i){return t<e?e:t>i?i:t},t.cosDeg=function(e){return Math.cos(e*t.degRad)},t.sinDeg=function(e){return Math.sin(e*t.degRad)},t.signum=function(t){return t>0?1:t<0?-1:0},t.toInt=function(t){return t>0?Math.floor(t):Math.ceil(t)},t.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},t.randomTriangular=function(e,i){return t.randomTriangularWith(e,i,.5*(e+i))},t.randomTriangularWith=function(t,e,i){var r=Math.random(),n=e-t;return r<=(i-t)/n?t+Math.sqrt(r*n*(i-t)):e-Math.sqrt((1-r)*n*(e-i))},t.PI=3.1415927,t.PI2=2*t.PI,t.radiansToDegrees=180/t.PI,t.radDeg=t.radiansToDegrees,t.degreesToRadians=t.PI/180,t.degRad=t.degreesToRadians,t}();t.MathUtils=r;var n=function(){function t(){}return t.prototype.apply=function(t,e,i){return t+(e-t)*this.applyInternal(i)},t}();t.Interpolation=n;var s=function(t){function e(e){var i=t.call(this)||this;return i.power=2,i.power=e,i}return Jtt(e,t),e.prototype.applyInternal=function(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1},e}(n);t.Pow=s;var a=function(t){function e(e){return t.call(this,e)||this}return Jtt(e,t),e.prototype.applyInternal=function(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1},e}(s);t.PowOut=a;var o=function(){function t(){}return t.arrayCopy=function(t,e,i,r,n){for(var s=e,a=r;s<e+n;s++,a++)i[a]=t[s]},t.setArraySize=function(t,e,i){void 0===i&&(i=0);var r=t.length;if(r==e)return t;if(t.length=e,r<e)for(var n=r;n<e;n++)t[n]=i;return t},t.ensureArrayCapacity=function(e,i,r){return void 0===r&&(r=0),e.length>=i?e:t.setArraySize(e,i,r)},t.newArray=function(t,e){for(var i=new Array(t),r=0;r<t;r++)i[r]=e;return i},t.newFloatArray=function(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);for(var i=new Array(e),r=0;r<i.length;r++)i[r]=0;return i},t.newShortArray=function(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);for(var i=new Array(e),r=0;r<i.length;r++)i[r]=0;return i},t.toFloatArray=function(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e},t.toSinglePrecision=function(e){return t.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e},t.webkit602BugfixHelper=function(){},t.contains=function(t,e){for(var i=0;i<t.length;i++)if(t[i]==e)return!0;return!1},t.SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array,t}();t.Utils=o;var l=function(){function t(){}return t.logBones=function(t){for(var e=0;e<t.bones.length;e++){var i=t.bones[e];console.log(i.data.name+", "+i.a+", "+i.b+", "+i.c+", "+i.d+", "+i.worldX+", "+i.worldY)}},t}();t.DebugUtils=l;var h=function(){function t(t){this.items=new Array,this.instantiator=t}return t.prototype.obtain=function(){return this.items.length>0?this.items.pop():this.instantiator()},t.prototype.free=function(t){t.reset&&t.reset(),this.items.push(t)},t.prototype.freeAll=function(t){for(var e=0;e<t.length;e++)t[e].reset&&t[e].reset(),this.items[e]=t[e]},t.prototype.clear=function(){this.items.length=0},t}();t.Pool=h;var u=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.set=function(t,e){return this.x=t,this.y=e,this},t.prototype.length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},t.prototype.normalize=function(){var t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this},t}();t.Vector2=u;var c=function(){function t(){this.maxDelta=.064,this.framesPerSecond=0,this.delta=0,this.totalTime=0,this.lastTime=Date.now()/1e3,this.frameCount=0,this.frameTime=0}return t.prototype.update=function(){var t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)},t}();t.TimeKeeper=c;var _=function(){function t(t){void 0===t&&(t=32),this.addedValues=0,this.lastValue=0,this.mean=0,this.dirty=!0,this.values=new Array(t)}return t.prototype.hasEnoughData=function(){return this.addedValues>=this.values.length},t.prototype.addValue=function(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0},t.prototype.getMean=function(){if(this.hasEnoughData()){if(this.dirty){for(var t=0,e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0},t}();t.WindowedMean=_}(qtt||(qtt={})),Math.fround||(Math.fround=function(t){return function(e){return t[0]=e,t[0]}}(new Float32Array(1))),function(t){var e=function(t){if(null==t)throw new Error("name cannot be null.");this.name=t};t.Attachment=e;var i=function(e){function i(t){var r=e.call(this,t)||this;return r.id=(65535&i.nextID++)<<11,r.worldVerticesLength=0,r.deformAttachment=r,r}return Jtt(i,e),i.prototype.computeWorldVertices=function(t,e,i,r,n,s){i=n+(i>>1)*s;var a=t.bone.skeleton,o=t.deform,l=this.vertices,h=this.bones;if(null!=h){for(var u=0,c=0,_=0;_<e;_+=2)u+=(m=h[u])+1,c+=m;var f=a.bones;if(0==o.length)for(B=n,x=3*c;B<i;B+=s){var p=0,d=0,m=h[u++];for(m+=u;u<m;u++,x+=3){b=f[h[u]],D=l[x],M=l[x+1];var y=l[x+2];p+=(D*b.a+M*b.b+b.worldX)*y,d+=(D*b.c+M*b.d+b.worldY)*y}r[B]=p,r[B+1]=d}else for(var g=o,v=(B=n,x=3*c,c<<1);B<i;B+=s){for(p=0,d=0,m=h[u++],m+=u;u<m;u++,x+=3,v+=2)b=f[h[u]],D=l[x]+g[v],M=l[x+1]+g[v+1],y=l[x+2],p+=(D*b.a+M*b.b+b.worldX)*y,d+=(D*b.c+M*b.d+b.worldY)*y;r[B]=p,r[B+1]=d}}else{o.length>0&&(l=o);for(var b,S=(b=t.bone).worldX,A=b.worldY,C=b.a,x=b.b,T=b.c,w=b.d,E=e,B=n;B<i;E+=2,B+=s){var D=l[E],M=l[E+1];r[B]=D*C+M*x+S,r[B+1]=D*T+M*w+A}}},i.prototype.copyTo=function(e){null!=this.bones?(e.bones=new Array(this.bones.length),t.Utils.arrayCopy(this.bones,0,e.bones,0,this.bones.length)):e.bones=null,null!=this.vertices?(e.vertices=t.Utils.newFloatArray(this.vertices.length),t.Utils.arrayCopy(this.vertices,0,e.vertices,0,this.vertices.length)):e.vertices=null,e.worldVerticesLength=this.worldVerticesLength,e.deformAttachment=this.deformAttachment},i.nextID=0,i}(e);t.VertexAttachment=i}(qtt||(qtt={})),function(t){var e;(e=t.AttachmentType||(t.AttachmentType={}))[e.Region=0]="Region",e[e.BoundingBox=1]="BoundingBox",e[e.Mesh=2]="Mesh",e[e.LinkedMesh=3]="LinkedMesh",e[e.Path=4]="Path",e[e.Point=5]="Point",e[e.Clipping=6]="Clipping"}(qtt||(qtt={})),function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r.color=new t.Color(1,1,1,1),r}return Jtt(i,e),i.prototype.copy=function(){var t=new i(name);return this.copyTo(t),t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.BoundingBoxAttachment=e}(qtt||(qtt={})),function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r.color=new t.Color(.2275,.2275,.8078,1),r}return Jtt(i,e),i.prototype.copy=function(){var t=new i(name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.ClippingAttachment=e}(qtt||(qtt={})),function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r.color=new t.Color(1,1,1,1),r.tempColor=new t.Color(0,0,0,0),r}return Jtt(i,e),i.prototype.updateUVs=function(){var e=this.regionUVs;null!=this.uvs&&this.uvs.length==e.length||(this.uvs=t.Utils.newFloatArray(e.length));var i=this.uvs,r=this.uvs.length,n=this.region.u,s=this.region.v,a=0,o=0;if(this.region instanceof t.TextureAtlasRegion){var l=this.region,h=l.texture.getImage().width,u=l.texture.getImage().height;switch(l.degrees){case 90:n-=(l.originalHeight-l.offsetY-l.height)/h,s-=(l.originalWidth-l.offsetX-l.width)/u,a=l.originalHeight/h,o=l.originalWidth/u;for(var c=0;c<r;c+=2)i[c]=n+e[c+1]*a,i[c+1]=s+(1-e[c])*o;return;case 180:for(n-=(l.originalWidth-l.offsetX-l.width)/h,s-=l.offsetY/u,a=l.originalWidth/h,o=l.originalHeight/u,c=0;c<r;c+=2)i[c]=n+(1-e[c])*a,i[c+1]=s+(1-e[c+1])*o;return;case 270:for(n-=l.offsetY/h,s-=l.offsetX/u,a=l.originalHeight/h,o=l.originalWidth/u,c=0;c<r;c+=2)i[c]=n+(1-e[c+1])*a,i[c+1]=s+e[c]*o;return}n-=l.offsetX/h,s-=(l.originalHeight-l.offsetY-l.height)/u,a=l.originalWidth/h,o=l.originalHeight/u}else null==this.region?(n=s=0,a=o=1):(a=this.region.u2-n,o=this.region.v2-s);for(c=0;c<r;c+=2)i[c]=n+e[c]*a,i[c+1]=s+e[c+1]*o},i.prototype.getParentMesh=function(){return this.parentMesh},i.prototype.setParentMesh=function(t){this.parentMesh=t,null!=t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)},i.prototype.copy=function(){if(null!=this.parentMesh)return this.newLinkedMesh();var e=new i(this.name);return e.region=this.region,e.path=this.path,e.color.setFromColor(this.color),this.copyTo(e),e.regionUVs=new Array(this.regionUVs.length),t.Utils.arrayCopy(this.regionUVs,0,e.regionUVs,0,this.regionUVs.length),e.uvs=new Array(this.uvs.length),t.Utils.arrayCopy(this.uvs,0,e.uvs,0,this.uvs.length),e.triangles=new Array(this.triangles.length),t.Utils.arrayCopy(this.triangles,0,e.triangles,0,this.triangles.length),e.hullLength=this.hullLength,null!=this.edges&&(e.edges=new Array(this.edges.length),t.Utils.arrayCopy(this.edges,0,e.edges,0,this.edges.length)),e.width=this.width,e.height=this.height,e},i.prototype.newLinkedMesh=function(){var t=new i(this.name);return t.region=this.region,t.path=this.path,t.color.setFromColor(this.color),t.deformAttachment=this.deformAttachment,t.setParentMesh(null!=this.parentMesh?this.parentMesh:this),t.updateUVs(),t},i}(t.VertexAttachment);t.MeshAttachment=e}(qtt||(qtt={})),function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r.closed=!1,r.constantSpeed=!1,r.color=new t.Color(1,1,1,1),r}return Jtt(i,e),i.prototype.copy=function(){var e=new i(name);return this.copyTo(e),e.lengths=new Array(this.lengths.length),t.Utils.arrayCopy(this.lengths,0,e.lengths,0,this.lengths.length),e.closed=closed,e.constantSpeed=this.constantSpeed,e.color.setFromColor(this.color),e},i}(t.VertexAttachment);t.PathAttachment=e}(qtt||(qtt={})),function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r.color=new t.Color(.38,.94,0,1),r}return Jtt(i,e),i.prototype.computeWorldPosition=function(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e},i.prototype.computeWorldRotation=function(e){var i=t.MathUtils.cosDeg(this.rotation),r=t.MathUtils.sinDeg(this.rotation),n=i*e.a+r*e.b,s=i*e.c+r*e.d;return Math.atan2(s,n)*t.MathUtils.radDeg},i.prototype.copy=function(){var t=new i(name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t},i}(t.VertexAttachment);t.PointAttachment=e}(qtt||(qtt={})),function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r.x=0,r.y=0,r.scaleX=1,r.scaleY=1,r.rotation=0,r.width=0,r.height=0,r.color=new t.Color(1,1,1,1),r.offset=t.Utils.newFloatArray(8),r.uvs=t.Utils.newFloatArray(8),r.tempColor=new t.Color(1,1,1,1),r}return Jtt(i,e),i.prototype.updateOffset=function(){var t=this.width/this.region.originalWidth*this.scaleX,e=this.height/this.region.originalHeight*this.scaleY,r=-this.width/2*this.scaleX+this.region.offsetX*t,n=-this.height/2*this.scaleY+this.region.offsetY*e,s=r+this.region.width*t,a=n+this.region.height*e,o=this.rotation*Math.PI/180,l=Math.cos(o),h=Math.sin(o),u=r*l+this.x,c=r*h,_=n*l+this.y,f=n*h,p=s*l+this.x,d=s*h,m=a*l+this.y,y=a*h,g=this.offset;g[i.OX1]=u-f,g[i.OY1]=_+c,g[i.OX2]=u-y,g[i.OY2]=m+c,g[i.OX3]=p-y,g[i.OY3]=m+d,g[i.OX4]=p-f,g[i.OY4]=_+d},i.prototype.setRegion=function(t){this.region=t;var e=this.uvs;t.rotate?(e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v,e[0]=t.u2,e[1]=t.v2):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)},i.prototype.computeWorldVertices=function(t,e,r,n){var s=this.offset,a=t.worldX,o=t.worldY,l=t.a,h=t.b,u=t.c,c=t.d,_=0,f=0;_=s[i.OX1],f=s[i.OY1],e[r]=_*l+f*h+a,e[r+1]=_*u+f*c+o,r+=n,_=s[i.OX2],f=s[i.OY2],e[r]=_*l+f*h+a,e[r+1]=_*u+f*c+o,r+=n,_=s[i.OX3],f=s[i.OY3],e[r]=_*l+f*h+a,e[r+1]=_*u+f*c+o,r+=n,_=s[i.OX4],f=s[i.OY4],e[r]=_*l+f*h+a,e[r+1]=_*u+f*c+o},i.prototype.copy=function(){var e=new i(name);return e.region=this.region,e.rendererObject=this.rendererObject,e.path=this.path,e.x=this.x,e.y=this.y,e.scaleX=this.scaleX,e.scaleY=this.scaleY,e.rotation=this.rotation,e.width=this.width,e.height=this.height,t.Utils.arrayCopy(this.uvs,0,e.uvs,0,8),t.Utils.arrayCopy(this.offset,0,e.offset,0,8),e.color.setFromColor(this.color),e},i.OX1=0,i.OY1=1,i.OX2=2,i.OY2=3,i.OX3=4,i.OY3=5,i.OX4=6,i.OY4=7,i.X1=0,i.Y1=1,i.C1R=2,i.C1G=3,i.C1B=4,i.C1A=5,i.U1=6,i.V1=7,i.X2=8,i.Y2=9,i.C2R=10,i.C2G=11,i.C2B=12,i.C2A=13,i.U2=14,i.V2=15,i.X3=16,i.Y3=17,i.C3R=18,i.C3G=19,i.C3B=20,i.C3A=21,i.U3=22,i.V3=23,i.X4=24,i.Y4=25,i.C4R=26,i.C4G=27,i.C4B=28,i.C4A=29,i.U4=30,i.V4=31,i}(t.Attachment);t.RegionAttachment=e}(qtt||(qtt={})),function(t){var e=function(){function e(t,e){this.jitterX=0,this.jitterY=0,this.jitterX=t,this.jitterY=e}return e.prototype.begin=function(){},e.prototype.transform=function(e){e.x+=t.MathUtils.randomTriangular(-this.jitterX,this.jitterY),e.y+=t.MathUtils.randomTriangular(-this.jitterX,this.jitterY)},e.prototype.end=function(){},e}();t.JitterEffect=e}(qtt||(qtt={})),function(t){var e=function(){function e(t,e){this.centerX=0,this.centerY=0,this.radius=0,this.angle=0,this.worldX=0,this.worldY=0,this.radius=t,this.interpolation=e}return e.prototype.begin=function(t){this.worldX=t.x+this.centerX,this.worldY=t.y+this.centerY},e.prototype.transform=function(e){var i=this.angle*t.MathUtils.degreesToRadians,r=e.x-this.worldX,n=e.y-this.worldY,s=Math.sqrt(r*r+n*n);if(s<this.radius){var a=this.interpolation.apply(0,i,(this.radius-s)/this.radius),o=Math.cos(a),l=Math.sin(a);e.x=o*r-l*n+this.worldX,e.y=l*r+o*n+this.worldY}},e.prototype.end=function(){},e.interpolation=new t.PowOut(2),e}();t.SwirlEffect=e}(qtt||(qtt={}));var Ktt,Ztt,Qtt,$tt,tet,eet,iet=qtt,ret=function(){function t(){this.start=void 0,this.interrupt=void 0,this.end=void 0,this.dispose=void 0,this.complete=void 0,this.event=void 0}return t.getListeners=function(e){return e.listener||(e.listener=new t),e.listener},t}(),net=1/60,set=[],aet=[],oet=0,het=0,uet=0,cet=null,_et=null,fet=0,pet=0,det=0,met=0,yet=null,get=null,vet=0,bet=0,Aet=new iet.Color(1,1,1,1),Cet=new iet.Color(1,1,1,1),xet=[0,1,2,2,3,0],Tet=function(){function t(){this.frames=[],this.totalTime=0,this.isCompleted=!1,this._privateMode=!1,this._inited=!1,this._invalid=!0,this._enableCacheAttachedInfo=!1,this._frameIdx=-1,this._skeletonInfo=null,this._animationName=null,this._tempSegments=null,this._tempColors=null,this._tempBoneInfos=null,this._privateMode=!1,this._inited=!1,this._invalid=!0,this._enableCacheAttachedInfo=!1,this.frames=[],this.totalTime=0,this._frameIdx=-1,this.isCompleted=!1,this._skeletonInfo=null,this._animationName=null,this._tempSegments=null,this._tempColors=null,this._tempBoneInfos=null}var e=t.prototype;return e.init=function(t,e){this._inited=!0,this._animationName=e,this._skeletonInfo=t},e.clear=function(){this._inited=!1;for(var t=0,e=this.frames.length;t<e;t++)this.frames[t].segments.length=0;this.invalidAllFrame()},e.bind=function(t){var e=this;t.complete=function(t){t&&t.animation.name===e._animationName&&(e.isCompleted=!0)}},e.unbind=function(t){t.complete=null},e.begin=function(){if(this._invalid){var t=this._skeletonInfo,e=null==t?void 0:t.curAnimationCache;e&&e!==this&&(this._privateMode?e.invalidAllFrame():e.updateToFrame());var i=null==t?void 0:t.skeleton,r=null==t?void 0:t.listener,n=null==t?void 0:t.state,s=null==i?void 0:i.data.findAnimation(this._animationName);null==n||n.setAnimationWith(0,s,!1),this.bind(r),t.curAnimationCache=this,this._frameIdx=-1,this.isCompleted=!1,this.totalTime=0,this._invalid=!1}},e.end=function(){this.needToUpdate()||(this._skeletonInfo.curAnimationCache=null,this.frames.length=this._frameIdx+1,this.isCompleted=!0,this.unbind(this._skeletonInfo.listener))},e.updateToFrame=function(t){if(this._inited&&(this.begin(),this.needToUpdate(t))){var e=this._skeletonInfo,i=null==e?void 0:e.skeleton,r=null==e?void 0:e.clipper,n=null==e?void 0:e.state;do{null==i||i.update(net),null==n||n.update(net),null==n||n.apply(i),null==i||i.updateWorldTransform(),this._frameIdx++,this.updateFrame(i,r,this._frameIdx),this.totalTime+=net}while(this.needToUpdate(t));this.end()}},e.isInited=function(){return this._inited},e.isInvalid=function(){return this._invalid},e.invalidAllFrame=function(){this.isCompleted=!1,this._invalid=!0},e.updateAllFrame=function(){this.invalidAllFrame(),this.updateToFrame()},e.enableCacheAttachedInfo=function(){this._enableCacheAttachedInfo||(this._enableCacheAttachedInfo=!0,this.invalidAllFrame())},e.fillVertices=function(t,e,i,r,n){if($tt=i.a*e.a*t.a*255,Ktt=e.r*t.r*255,Ztt=e.g*t.g*255,Qtt=e.b*t.b*255,Aet.r=Ktt*i.r,Aet.g=Ztt*i.g,Aet.b=Qtt*i.b,Aet.a=$tt,null==n.darkColor?Cet.set(0,0,0,1):(Cet.r=n.darkColor.r*Ktt,Cet.g=n.darkColor.g*Ztt,Cet.b=n.darkColor.b*Qtt),Cet.a=0,tet=(Aet.a<<24>>>0)+(Aet.b<<16)+(Aet.g<<8)+Aet.r,eet=(Cet.a<<24>>>0)+(Cet.b<<16)+(Cet.g<<8)+Cet.r,yet!==tet||get!==eet){var s=this._tempColors;yet=tet,get=eet,met>0&&(s[met-1].vfOffset=uet),s[met++]={fr:Aet.r,fg:Aet.g,fb:Aet.b,fa:Aet.a,dr:Cet.r,dg:Cet.g,db:Cet.b,da:Cet.a,vfOffset:0}}if(r.isClipping()){r.clipTriangles(set,vet,aet,bet,set,Aet,Cet,!0,6,uet,uet+2);var a=r.clippedVertices,o=r.clippedTriangles;bet=o.length,vet=a.length/12*6;for(var l=0,h=het,u=o.length;l<u;)aet[h++]=o[l++];for(var c=0,_=a.length,f=uet;c<_;c+=12,f+=6)set[f]=a[c],set[f+1]=a[c+1],set[f+2]=a[c+6],set[f+3]=a[c+7],set[f+4]=tet,set[f+5]=eet}else for(var p=uet,d=uet+vet;p<d;p+=6)set[p+4]=tet,set[p+5]=eet},e.updateFrame=function(t,e,i){uet=0,oet=0,het=0,cet=null,_et=null,fet=0,pet=0,det=0,met=0,yet=null,get=null,this.frames[i]=this.frames[i]||{segments:[],colors:[],boneInfos:[],vertices:null,uintVert:null,indices:null};var r=this.frames[i],n=this._tempSegments=r.segments,s=this._tempColors=r.colors,a=this._tempBoneInfos=r.boneInfos;this.traverseSkeleton(t,e),met>0&&(s[met-1].vfOffset=uet),s.length=met,a.length=oet;var o=det-1;if(o>=0)if(pet>0){var l=n[o];l.indexCount=pet,l.vfCount=13*fet,l.vertexCount=fet,n.length=det}else n.length=det-1;if(0!==n.length){var h=r.vertices,u=uet/6*13;(!h||h.length<u)&&(h=r.vertices=new Float32Array(u));for(var c=0,_=0;c<u;)h[c]=set[_++],h[c+1]=set[_++],h[c+3]=set[_++],h[c+4]=set[_++],this._setVerticeColor(set[_++],h,c+5),this._setVerticeColor(set[_++],h,c+9),c+=13;var f=r.indices;(!f||f.length<het)&&(f=r.indices=new Uint16Array(het));for(var p=0;p<het;p++)f[p]=aet[p];r.vertices=h,r.indices=f}},e.needToUpdate=function(t){return!this.isCompleted&&this.totalTime<30&&(void 0===t||this._frameIdx<t)},e.traverseSkeleton=function(t,e){var i,r,n,s,a,o,l,h,u,c,_,f,p=this._tempSegments,d=this._tempBoneInfos,m=t.color,y=t.bones;if(this._enableCacheAttachedInfo)for(var g=0,v=y.length;g<v;g++,oet++){var b=y[g],S=d[oet];S||(S=d[oet]={}),S.a=b.a,S.b=b.b,S.c=b.c,S.d=b.d,S.worldX=b.worldX,S.worldY=b.worldY}for(var A=0,C=t.drawOrder.length;A<C;A++)if(f=t.drawOrder[A],vet=0,bet=0,i=f.getAttachment())if(o=i instanceof iet.RegionAttachment,l=i instanceof iet.MeshAttachment,i instanceof iet.ClippingAttachment)e.clipStart(f,i);else if(o||l)if(h=i.region.texture.getRealTexture()){if(_=f.data.blendMode,cet===h.nativeUrl&&_et===_||(cet=h.nativeUrl,_et=_,(u=det-1)>=0&&(pet>0?((c=p[u]).indexCount=pet,c.vertexCount=fet,c.vfCount=13*fet):det--),p[det]={tex:h,blendMode:_,indexCount:0,vertexCount:0,vfCount:0},det++,pet=0,fet=0),o)a=xet,vet=24,bet=6,i.computeWorldVertices(f.bone,set,uet,6);else if(l){var x=i;a=x.triangles,vet=6*(x.worldVerticesLength>>1),bet=a.length,x.computeWorldVertices(f,0,x.worldVerticesLength,set,uet,6)}if(0!==vet&&0!==bet){for(var T=0,w=het,E=a.length;T<E;)aet[w++]=a[T++];s=i.uvs;for(var B=uet,D=uet+vet,M=0;B<D;B+=6,M+=2)set[B+2]=s[M],set[B+3]=s[M+1];if(r=i.color,n=f.color,this.fillVertices(m,r,n,e,f),bet>0){for(var P=het,R=het+bet;P<R;P++)aet[P]+=fet;het+=bet,uet+=vet,pet+=bet,fet+=vet/6}e.clipEndWithSlot(f)}else e.clipEndWithSlot(f)}else e.clipEndWithSlot(f);else e.clipEndWithSlot(f);else e.clipEndWithSlot(f);e.clipEnd()},e._setVerticeColor=function(t,e,i){e[i]=(255&t)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(t>>16&255)/255,e[i+3]=(t>>24&255)/255},t}(),wet=function(){function t(){this._privateMode=void 0,this._skeletonCache=void 0,this._animationPool=void 0,this._privateMode=!1,this._animationPool={},this._skeletonCache={}}var e=t.prototype;return e.enablePrivateMode=function(){this._privateMode=!0},e.clear=function(){this._animationPool={},this._skeletonCache={}},e.removeSkeleton=function(t){var e=this._skeletonCache[t];if(e){var i=e.animationsCache;for(var r in i){var n=i[r];n&&(this._animationPool[t+"#"+r]=n,n.clear())}delete this._skeletonCache[t]}},e.getSkeletonCache=function(t,e){var i=this._skeletonCache[t];if(!i){var r=new iet.Skeleton(e),n=new iet.SkeletonClipping,s=new iet.AnimationStateData(r.data),a=new iet.AnimationState(s),o=new ret;a.addListener(o),this._skeletonCache[t]=i={skeleton:r,clipper:n,state:a,listener:o,animationsCache:{},curAnimationCache:null}}return i},e.getAnimationCache=function(t,e){var i=this._skeletonCache[t];return i?i.animationsCache[e]:null},e.invalidAnimationCache=function(t){var e=this._skeletonCache[t];if(e&&e.skeleton){var i=e.animationsCache;for(var r in i)i[r].invalidAllFrame()}},e.initAnimationCache=function(t,e){if(!e)return null;var i=this._skeletonCache[t],r=i&&i.skeleton;if(!r)return null;if(!r.data.findAnimation(e))return null;var n=i.animationsCache,s=n[e];if(!s){var a=t+"#"+e;(s=this._animationPool[a])?delete this._animationPool[a]:(s=new Tet)._privateMode=this._privateMode,s.init(i,e),n[e]=s}return s},e.updateAnimationCache=function(t,e){if(e){var i=this.initAnimationCache(t,e);if(!i)return null;i.updateAllFrame()}else{var r=this._skeletonCache[t];if(!r||!r.skeleton)return;var n=r.animationsCache;for(var s in n)n[s].updateAllFrame()}},t}();wet.FrameTime=net,wet.sharedCache=new wet;var Eet,Bet,Det,Met,Pet,Ret,Iet,Oet,Fet,Let,Vet,ket=new Ri,Net=function(){function t(){this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null,this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null}var e=t.prototype;return e.init=function(t){this._inited=!0,this._skeleton=t._skeleton,this._skeletonNode=t.node,this._skeletonComp=t},e.reset=function(){this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null},e._syncAttachedNode=function(){var t=this;if(this._inited){var e=this._skeletonComp.socketNodes;if(0!==e.size){var i;if(i=this._skeletonComp.isAnimationCached()?this._skeletonComp._curFrame&&this._skeletonComp._curFrame.boneInfos:this._skeleton.bones)for(var r,n=function(e,i){var r=ket;r.m00=i.a,r.m01=i.c,r.m04=i.b,r.m05=i.d,r.m12=i.worldX,r.m13=i.worldY,e.matrix=ket,e.scale=t._skeletonNode.scale},s=Fe(e.keys());!(r=s()).done;){var a=r.value,o=e.get(a);if(o&&o.isValid){var l=i[a];l?n(o,l):(o.removeFromParent(),o.destroy(),e.delete(a))}else e.delete(a)}}}},t}(),Get=function(t){function e(e){var i;return(i=t.call(this,e)||this).name="sp.SkeletonTexture",i._texture=null,i._material=null,i}Me(e,t);var i=e.prototype;return i.setRealTexture=function(t){this._texture=t},i.getRealTexture=function(){return this._texture?this._texture instanceof Ye?this._texture._texture:this._texture:null},i.setFilters=function(t,e){this._texture&&this.getRealTexture().setFilters(zet(t),zet(e))},i.setWraps=function(t,e){this._texture&&this.getRealTexture().setWrapMode(Uet(t),Uet(e))},i.dispose=function(){},e}(iet.Texture);function zet(t){switch(t){case iet.TextureFilter.Nearest:case iet.TextureFilter.MipMapNearestNearest:case iet.TextureFilter.MipMapLinearNearest:return _r.NEAREST;case iet.TextureFilter.MipMap:case iet.TextureFilter.MipMapNearestLinear:case iet.TextureFilter.MipMapLinearLinear:case iet.TextureFilter.Linear:default:return _r.LINEAR}}function Uet(t){switch(t){case iet.TextureWrap.MirroredRepeat:return In.MIRRORED_REPEAT;case iet.TextureWrap.ClampToEdge:return In.CLAMP_TO_EDGE;case iet.TextureWrap.Repeat:default:return In.REPEAT}}var Het,jet,Wet,Xet,Yet,qet,Jet,Ket,Zet,Qet,$et,tit,eit,iit,rit,nit,sit,ait,oit,lit,hit,uit,cit,_it,fit,pit,dit,mit,yit,git,vit,bit,Sit,Ait,Cit,xit,Tit,wit,Eit,Bit,Dit,Mit,Pit,Rit,Iit,Oit,Fit,Lit,Vit,kit,Nit,Git,zit,Uit,Hit,jit,Wit,Xit=(Eet=ri("sp.SkeletonData"),Bet=bi([qe]),Det=bi([Fi]),Eet((Vet=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_skeletonJson",Ret,hi(e)),li(e,"textures",Iet,hi(e)),li(e,"textureNames",Oet,hi(e)),li(e,"scale",Fet,hi(e)),li(e,"_atlasText",Let,hi(e)),e._buffer=void 0,e._skeletonCache=null,e._atlasCache=null,e._skinsEnum=null,e._animsEnum=null,e.reset(),e}Me(e,t);var i=e.prototype;return i.createNode=function(t){var e=new ur(this.name);return e.addComponent("cc.Skeleton").skeletonData=this,t(null,e)},i.reset=function(){this._skeletonCache=null,this._atlasCache=null},i.resetEnums=function(){},i.ensureTexturesLoaded=function(t,e){var i=this.textures,r=i.length;if(0!==r)for(var n=0,s=function(){++n>=r&&(t&&t.call(e,!0),t=null)},a=0;a<r;a++){var o=i[a];o.loaded?s():o.once("load",s)}else t&&t.call(e,!1)},i.isTexturesLoaded=function(){for(var t=this.textures,e=t.length,i=0;i<e;i++)if(!t[i].loaded)return!1;return!0},i.getRuntimeData=function(t){if(this._skeletonCache)return this._skeletonCache;if(!(this.textures&&this.textures.length>0)&&this.textureNames&&this.textureNames.length>0)return t||console.error(this.name+" no textures found!"),null;var e=this._getAtlas(t);if(!e)return null;var i=new iet.AtlasAttachmentLoader(e),r=null,n=null;return this.skeletonJson?(n=new iet.SkeletonJson(i),r=this.skeletonJson):(n=new iet.SkeletonBinary(i),r=new Uint8Array(this._nativeAsset)),n.scale=this.scale,this._skeletonCache=n.readSkeletonData(r),e.dispose(),this._skeletonCache},i.getSkinsEnum=function(){if(this._skinsEnum)return this._skinsEnum;var t=this.getRuntimeData(!0);if(t){for(var e=t.skins,i={},r=0;r<e.length;r++)i[e[r].name]=r;return this._skinsEnum=yi(i)}return null},i.getAnimsEnum=function(){if(this._animsEnum&&Object.keys(this._animsEnum).length>1)return this._animsEnum;var t=this.getRuntimeData(!0);if(t){for(var e={"<None>":0},i=t.animations,r=0;r<i.length;r++)e[i[r].name]=r+1;return this._animsEnum=yi(e)}return null},i.destroy=function(){return wet.sharedCache.removeSkeleton(this._uuid),t.prototype.destroy.call(this)},i._getTexture=function(t){for(var e=this.textureNames,i=0;i<e.length;i++)if(e[i]===t){var r=this.textures[i],n=new Get({width:r.width,height:r.height});return n.setRealTexture(r),n}return console.error(this.name+" no textures found!"),null},i._getAtlas=function(t){return this._atlasCache?this._atlasCache:this.atlasText?this._atlasCache=new iet.TextureAtlas(this.atlasText,this._getTexture.bind(this)):(t||console.error(this.name+" no atlas found!"),null)},Pe(e,[{key:"skeletonJsonStr",get:function(){return this._skeletonJson?JSON.stringify(this._skeletonJson):""}},{key:"skeletonJson",get:function(){return this._skeletonJson},set:function(t){this.reset(),this._skeletonJson="string"==typeof t?JSON.parse(t):t,!this._uuid&&t.skeleton&&(this._uuid=t.skeleton.hash)}},{key:"atlasText",get:function(){return this._atlasText},set:function(t){this._atlasText=t,this.reset()}},{key:"_nativeAsset",get:function(){return this._buffer},set:function(t){this._buffer=t,this.reset()}}]),e}(ai),Ret=oi((Pet=Vet).prototype,"_skeletonJson",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Iet=oi(Pet.prototype,"textures",[_i,Bet],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Oet=oi(Pet.prototype,"textureNames",[_i,Det],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Fet=oi(Pet.prototype,"scale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Let=oi(Pet.prototype,"_atlasText",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Met=Pet))||Met);function Yit(t,e,i){gs.Attr.setClassAttr(t,e,"type","Enum"),gs.Attr.setClassAttr(t,e,"enumList",yi.getList(i))}He.internal.SpineSkeletonData=Xit,function(t){t[t.default=0]="default"}(Uit||(Uit={})),Pr(Uit),function(t){t[t["<None>"]=0]="<None>"}(Hit||(Hit={})),Pr(Hit),function(t){t[t.REALTIME=0]="REALTIME",t[t.SHARED_CACHE=1]="SHARED_CACHE",t[t.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(jit||(jit={})),Pr(jit),function(t){t[t.COLORED_TEXTURED=0]="COLORED_TEXTURED",t[t.TWO_COLORED=1]="TWO_COLORED"}(Wit||(Wit={}));var qit=(Het=ri("sp.Skeleton.SpineSocket"),jet=bi(ur),Het((Yet=oi((Xet=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),li(this,"path",Yet,this),li(this,"target",qet,this),this.path=t,this.target=e}).prototype,"path",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),qet=oi(Xet.prototype,"target",[jet,vi,_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Wet=Xet))||Wet);Li.setClassAlias(qit,"sp.Skeleton.SpineSocket");var Jit=(Jet=ri("sp.Skeleton"),Ket=wi(),Zet=Bi(),Qet=bi(cr),$et=Mr(),tit=Ir(),eit=Mi(),iit=bi(Xit),rit=Ir(),nit=bi(Uit),sit=Di(),ait=Ir(),oit=bi(Hit),lit=Di(),hit=Ir(),uit=Di(),cit=bi(jit),_it=Di(),fit=Di(),pit=Di(),dit=Di(),mit=Di(),yit=Di(),git=Di(),vit=bi([qit]),bit=Di(),Sit=Mi(),Ait=Mi(),Jet(Cit=Ket(Cit=Zet(Cit=Si((zit=Git=function(t){function e(){var e;return e=t.call(this)||this,li(e,"paused",Tit,hi(e)),li(e,"loop",wit,hi(e)),li(e,"_premultipliedAlpha",Eit,hi(e)),li(e,"_timeScale",Bit,hi(e)),e.enableBatch=!1,e._frameCache=null,e._curFrame=null,e._effectDelegate=null,e._skeleton=void 0,e._clipper=void 0,e._debugRenderer=void 0,e._startSlotIndex=void 0,e._endSlotIndex=void 0,e._startEntry=void 0,e._endEntry=void 0,e.attachUtil=void 0,e._materialCache={},e._enumSkins=yi({}),e._enumAnimations=yi({}),e._accTime=0,e._playCount=0,e._skeletonCache=null,e._animationName="",e._animationQueue=[],e._headAniInfo=null,e._playTimes=0,e._isAniComplete=!0,li(e,"_useTint",Dit,hi(e)),li(e,"_preCacheMode",Mit,hi(e)),li(e,"_cacheMode",Pit,hi(e)),li(e,"_defaultCacheMode",Rit,hi(e)),li(e,"_debugBones",Iit,hi(e)),li(e,"_debugSlots",Oit,hi(e)),li(e,"_skeletonData",Fit,hi(e)),li(e,"defaultSkin",Lit,hi(e)),li(e,"defaultAnimation",Vit,hi(e)),li(e,"_sockets",kit,hi(e)),e._meshRenderDataArray=[],li(e,"_debugMesh",Nit,hi(e)),e._rootBone=void 0,e._state=void 0,e._listener=void 0,e._socketNodes=new Map,e._cachedSockets=new Map,e._meshRenderDataArrayIdx=0,e._effectDelegate=null,e._skeleton=null,e._rootBone=null,e._listener=null,e._debugRenderer=null,e._startSlotIndex=-1,e._endSlotIndex=-1,e._startEntry={animation:{name:""},trackIndex:0},e._endEntry={animation:{name:""},trackIndex:0},e.attachUtil=new Net,Yit(hi(e),"_defaultSkinIndex",e._enumSkins),Yit(hi(e),"_animationIndex",e._enumAnimations),e}Me(e,t);var i=e.prototype;return i.disableRender=function(){this.destroyRenderData()},i.setSkeletonData=function(t){var e=this.node._uiProps.uiTransformComp;if(null!=t.width&&null!=t.height&&e.setContentSize(t.width,t.height),this._cacheMode===jit.SHARED_CACHE?this._skeletonCache=wet.sharedCache:this._cacheMode===jit.PRIVATE_CACHE&&(this._skeletonCache=new wet,this._skeletonCache.enablePrivateMode()),this.isAnimationCached()){(this.debugBones||this.debugSlots)&&Ue("Debug bones or slots is invalid in cached mode");var i=this._skeletonCache.getSkeletonCache(this.skeletonData._uuid,t);this._skeleton=i.skeleton,this._clipper=i.clipper,this._rootBone=this._skeleton.getRootBone()}else this._skeleton=new iet.Skeleton(t),this._clipper=new iet.SkeletonClipping,this._rootBone=this._skeleton.getRootBone();this.markForUpdateRenderData()},i.setSlotsRange=function(t,e){this.isAnimationCached()?Ue("Slots visible range can not be modified in cached mode."):(this._startSlotIndex=t,this._endSlotIndex=e)},i.setAnimationStateData=function(t){if(this.isAnimationCached())Ue("'setAnimationStateData' interface can not be invoked in cached mode.");else{var e=new iet.AnimationState(t);this._listener&&(this._state&&this._state.removeListener(this._listener),e.addListener(this._listener)),this._state=e}},i.__preload=function(){t.prototype.__preload.call(this);for(var e=this.node.children,i=0,r=e.length;i<r;i++){var n=e[i];n&&"DEBUG_DRAW_NODE"===n.name&&n.destroy()}this._updateSkeletonData(),this._updateDebugDraw(),this._updateUseTint(),this._indexBoneSockets(),this._updateSocketBindings()},i.setAnimationCacheMode=function(t){this._preCacheMode!==t&&(this._cacheMode=t,this._updateSkeletonData(),this._updateUseTint(),this._updateSocketBindings(),this.markForUpdateRenderData())},i.isAnimationCached=function(){return this._cacheMode!==jit.REALTIME},i.update=function(t){if(!this.paused)if(t*=1*this._timeScale,this.isAnimationCached()){if(this._isAniComplete){if(0===this._animationQueue.length&&!this._headAniInfo){var e=this._frameCache;if(e&&e.isInvalid()){e.updateToFrame();var i=e.frames;this._curFrame=i[i.length-1]}return}if(this._headAniInfo||(this._headAniInfo=this._animationQueue.shift()),this._accTime+=t,this._accTime>this._headAniInfo.delay){var r=this._headAniInfo;this._headAniInfo=null,this.setAnimation(0,r.animationName,r.loop)}return}this._updateCache(t)}else this._updateRealtime(t)},i.setVertexEffectDelegate=function(t){this._effectDelegate=t},i.setToSetupPose=function(){this._skeleton&&this._skeleton.setToSetupPose()},i.setBonesToSetupPose=function(){this._skeleton&&this._skeleton.setBonesToSetupPose()},i.setSlotsToSetupPose=function(){this._skeleton&&this._skeleton.setSlotsToSetupPose()},i.updateAnimationCache=function(t){if(this.isAnimationCached()){var e=this._skeletonData._uuid;this._skeletonCache&&this._skeletonCache.updateAnimationCache(e,t)}},i.invalidAnimationCache=function(){this.isAnimationCached()&&this._skeletonCache&&this._skeletonCache.invalidAnimationCache(this._skeletonData._uuid)},i.findBone=function(t){return this._skeleton?this._skeleton.findBone(t):null},i.findSlot=function(t){return this._skeleton?this._skeleton.findSlot(t):null},i.setSkin=function(t){this._skeleton&&(this._skeleton.setSkinByName(t),this._skeleton.setSlotsToSetupPose()),this.invalidAnimationCache()},i.getAttachment=function(t,e){return this._skeleton?this._skeleton.getAttachmentByName(t,e):null},i.setAttachment=function(t,e){this._skeleton&&this._skeleton.setAttachment(t,e),this.invalidAnimationCache()},i.getTextureAtlas=function(t){return t.region},i.setMix=function(t,e,i){this._state&&this._state.data.setMix(t,e,i)},i.setAnimation=function(t,e,i){if(this._playTimes=i?0:1,this._animationName=e,this.isAnimationCached()){if(0!==t&&Ue("Track index can not greater than 0 in cached mode."),!this._skeletonCache)return null;var r=this._skeletonCache.getAnimationCache(this._skeletonData._uuid,e);r||(r=this._skeletonCache.initAnimationCache(this._skeletonData._uuid,e)),r&&(this._isAniComplete=!1,this._accTime=0,this._playCount=0,this._frameCache=r,this._socketNodes.size>0&&this._frameCache.enableCacheAttachedInfo(),this._frameCache.updateToFrame(0),this._curFrame=this._frameCache.frames[0])}else if(this._skeleton){var n=this._skeleton.data.findAnimation(e);if(!n)return an(7509,e),null;var s=this._state.setAnimationWith(t,n,i);return this._state.apply(this._skeleton),s}return null},i.addAnimation=function(t,e,i,r){if(r=r||0,this.isAnimationCached())0!==t&&Ue("Track index can not greater than 0 in cached mode."),this._animationQueue.push({animationName:e,loop:i,delay:r});else if(this._skeleton){var n,s=this._skeleton.data.findAnimation(e);return s?null===(n=this._state)||void 0===n?void 0:n.addAnimationWith(t,s,i,r):(an(7510,e),null)}return null},i.findAnimation=function(t){return this._skeleton?this._skeleton.data.findAnimation(t):null},i.getCurrent=function(t){if(this.isAnimationCached())Ue("'getCurrent' interface can not be invoked in cached mode.");else if(this._state)return this._state.getCurrent(t);return null},i.clearTracks=function(){this.isAnimationCached()?Ue("'clearTracks' interface can not be invoked in cached mode."):this._state&&this._state.clearTracks()},i.clearTrack=function(t){this.isAnimationCached()?Ue("'clearTrack' interface can not be invoked in cached mode."):this._state&&this._state.clearTrack(t)},i.setStartListener=function(t){this._ensureListener(),this._listener.start=t},i.setInterruptListener=function(t){this._ensureListener(),this._listener.interrupt=t},i.setEndListener=function(t){this._ensureListener(),this._listener.end=t},i.setDisposeListener=function(t){this._ensureListener(),this._listener.dispose=t},i.setCompleteListener=function(t){this._ensureListener(),this._listener.complete=t},i.setEventListener=function(t){this._ensureListener(),this._listener.event=t},i.setTrackStartListener=function(t,e){ret.getListeners(t).start=e},i.setTrackInterruptListener=function(t,e){ret.getListeners(t).interrupt=e},i.setTrackEndListener=function(t,e){ret.getListeners(t).end=e},i.setTrackDisposeListener=function(t,e){ret.getListeners(t).dispose=e},i.setTrackCompleteListener=function(t,e){ret.getListeners(t).complete=function(t){var i=Math.floor(t.trackTime/t.animationEnd);e(t,i)}},i.setTrackEventListener=function(t,e){ret.getListeners(t).event=e},i.getState=function(){return this._state},i.onEnable=function(){t.prototype.onEnable.call(this),this._flushAssembler()},i.onDisable=function(){t.prototype.onDisable.call(this)},i.onDestroy=function(){this._cleanMaterialCache(),this.destroyRenderData(),t.prototype.onDestroy.call(this)},i.requestMeshRenderData=function(t){if(this._meshRenderDataArray.length>0&&0===this._meshRenderDataArray[this._meshRenderDataArray.length-1].renderData.vertexCount)return this._meshRenderDataArray[this._meshRenderDataArray.length-1];var e=new I_(t),i={renderData:e};return e.material=null,this._meshRenderDataArray.push(i),i},i.destroyRenderData=function(){this._meshRenderDataArray.length>0&&(this._meshRenderDataArray.forEach((function(t){t.renderData.reset()})),this._meshRenderDataArray.length=0)},i.getMaterialForBlendAndTint=function(t,e,i){var r=i+"/"+t+"/"+e,n=this._materialCache[r];if(n)return n;var s=this.customMaterial;null===s&&(s=Ci.get("default-spine-material"));var a=!1;switch(i){case Wit.TWO_COLORED:a=!0;break;case Wit.COLORED_TEXTURED:}return n=new Vr({parent:s,subModelIdx:0,owner:this}),this._materialCache[r]=n,n.overridePipelineStates({blendState:{blendColor:Ui.WHITE,targets:[{blendEq:B.ADD,blendAlphaEq:B.ADD,blendSrc:t,blendDst:e,blendSrcAlpha:t,blendDstAlpha:e}]}}),n.recompileShaders({TWO_COLORED:a}),n},i.updateMaterial=function(){if(this._customMaterial)return this.setMaterial(this._customMaterial,0),void(this._blendHash=-1);var t=this._updateBuiltinMaterial();this.setMaterial(t,0),this._updateBlendFunc(),this.premultipliedAlpha&&(this._blendHash=-1)},i._updateBuiltinMaterial=function(){return Ci.get("ui-sprite-material")},i.querySockets=function(){return this._skeleton?(0===this._cachedSockets.size&&this._indexBoneSockets(),this._cachedSockets.size>0?Array.from(this._cachedSockets.keys()).sort():[]):[]},i._render=function(t){if(this._meshRenderDataArray)for(var e=0;e<this._meshRenderDataArray.length;e++){var i=this.material;this._meshRenderDataArrayIdx=e;var r=this._meshRenderDataArray[e];r.renderData.material&&(this.material=r.renderData.material),r.texture&&t.commitComp(this,r.texture,this._assembler,null),this.material=i}},i.updateWorldTransform=function(){this.isAnimationCached()&&this._skeleton&&this._skeleton.updateWorldTransform()},i._emitCacheCompleteEvent=function(){this._listener&&(this._endEntry.animation.name=this._animationName,this._listener.complete&&this._listener.complete(this._endEntry),this._listener.end&&this._listener.end(this._endEntry))},i._updateCache=function(t){var e=this._frameCache;if(e.isInited()){var i=e.frames,r=wet.FrameTime;0===this._accTime&&0===this._playCount&&(this._startEntry.animation.name=this._animationName,this._listener&&this._listener.start&&this._listener.start(this._startEntry)),this._accTime+=t;var n=Math.floor(this._accTime/r);if(e.isCompleted||e.updateToFrame(n),e.isCompleted&&n>=i.length){if(this._playCount++,this._playTimes>0&&this._playCount>=this._playTimes)return this._curFrame=i[i.length-1],this._accTime=0,this._playCount=0,this._isAniComplete=!0,this._emitCacheCompleteEvent(),void this.markForUpdateRenderData();this._accTime=0,n=0,this._emitCacheCompleteEvent()}this._curFrame=i[n],this.markForUpdateRenderData()}},i._updateRealtime=function(t){var e=this._skeleton,i=this._state;e&&(e.update(t),i&&(i.update(t),i.apply(e)),this.markForUpdateRenderData())},i._indexBoneSockets=function(){if(this._skeleton){this._cachedSockets.clear();for(var t=this._skeleton.bones,e=function e(i){return null==i.parent?i.data.name||"<Unamed>":e(t[i.parent.data.index])+"/"+i.data.name},i=0,r=t.length;i<r;i++){var n=t[i].data,s=e(t[i]);this._cachedSockets.set(s,n.index)}}},i._updateUseTint=function(){this.destroyRenderData()},i._updateBatch=function(){this.markForUpdateRenderData()},i._validateRender=function(){var t=this.skeletonData;t&&t.isTexturesLoaded()||this.disableRender()},i._updateAnimEnum=function(){var t;t=this.skeletonData?this.skeletonData.getAnimsEnum():Hit,this._enumAnimations=yi({}),Object.assign(this._enumAnimations,t),yi.update(this._enumAnimations),Yit(this,"_animationIndex",this._enumAnimations)},i._updateSkinEnum=function(){var t;t=this.skeletonData?this.skeletonData.getSkinsEnum():Uit,this._enumSkins=yi({}),Object.assign(this._enumSkins,t),yi.update(this._enumSkins),Yit(this,"_defaultSkinIndex",this._enumSkins)},i._ensureListener=function(){this._listener||(this._listener=new ret,this._state&&this._state.addListener(this._listener))},i._updateSkeletonData=function(){if(this.skeletonData){var t=this.skeletonData.getRuntimeData();if(t){try{this.setSkeletonData(t),this.isAnimationCached()||this.setAnimationStateData(new iet.AnimationStateData(this._skeleton.data)),this.defaultSkin&&this.setSkin(this.defaultSkin)}catch(t){Ue(t)}this.attachUtil.init(this),this._preCacheMode=this._cacheMode,this.animation=this.defaultAnimation}else this.disableRender()}else this.disableRender()},i._refreshInspector=function(){this._updateAnimEnum(),this._updateSkinEnum()},i._updateDebugDraw=function(){if(this.debugBones||this.debugSlots||this.debugMesh){if(!this._debugRenderer){var t=new ur("DEBUG_DRAW_NODE");t.hideFlags|=Lr.Flags.DontSave|Lr.Flags.HideInHierarchy;var e=t.addComponent(Hd);e.lineWidth=1,e.strokeColor=new Ui(255,0,0,255),this._debugRenderer=e,t.parent=this.node}this.isAnimationCached()&&Ue("Debug bones or slots is invalid in cached mode")}else this._debugRenderer&&(this._debugRenderer.node.destroy(),this._debugRenderer=null)},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),0===this._meshRenderDataArray.length&&this._assembler&&this._assembler.createData&&(this._assembler.createData(this),this.markForUpdateRenderData(),this._updateColor())},i._updateColor=function(){},i._updateSocketBindings=function(){if(this._skeleton){this._socketNodes.clear();for(var t=0,e=this._sockets.length;t<e;t++){var i=this._sockets[t];if(i.path&&i.target){var r=this._cachedSockets.get(i.path);if(!r){console.error("Skeleton data does not contain path "+i.path);continue}this._socketNodes.set(r,i.target)}}}},i._verifySockets=function(t){for(var e=0,i=t.length;e<i;e++){var r=t[e].target;!r||r.parent&&r.parent==this.node||console.error("Target node "+r.name+" is expected to be a direct child of "+this.node.name)}var n=new Map;t.forEach((function(t){t.target&&(n.get(t.target)?console.error("Target node "+t.target.name+" has existed."):n.set(t.target,!0))}))},i._cleanMaterialCache=function(){for(var t in this._materialCache)this._materialCache[t].destroy();this._materialCache={}},Pe(e,[{key:"meshRenderDataArray",get:function(){return this._meshRenderDataArray}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this._cleanMaterialCache()}},{key:"skeletonData",get:function(){return this._skeletonData},set:function(t){t&&t.resetEnums(),this._skeletonData!=t&&(this._skeletonData=t,this.defaultSkin="",this.defaultAnimation="",this._updateSkeletonData())}},{key:"animation",get:function(){if(this.isAnimationCached())return this._animationName;var t=this.getCurrent(0);return t&&t.animation.name||""},set:function(t){t?(this.setAnimation(0,t,this.loop),this.destroyRenderData(),this.markForUpdateRenderData()):this.isAnimationCached()||(this.clearTrack(0),this.setToSetupPose())}},{key:"_defaultSkinIndex",get:function(){if(this.skeletonData){var t=this.skeletonData.getSkinsEnum();if(t)if(""===this.defaultSkin){if(t.hasOwnProperty(0))return this._defaultSkinIndex=0,0}else{var e=t[this.defaultSkin];if(void 0!==e)return e}}return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getSkinsEnum()),e){var i=e[t];void 0!==i?(this.defaultSkin=i,this.setSkin(this.defaultSkin)):console.error(this.name+" skin enums are invalid")}else console.error(this.name+" skin enums are invalid")}},{key:"_animationIndex",get:function(){var t=this.animation;if(this.skeletonData)if(t){var e=this.skeletonData.getAnimsEnum();if(e){var i=e[t];if(void 0!==i)return i}}else this._refreshInspector();return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getAnimsEnum()),e){var i=e[t];void 0!==i?(this.animation=i,this.animation=i):console.error(this.name+" animation enums are invalid")}else console.error(this.name+" animation enums are invalid")}},{key:"defaultCacheMode",get:function(){return this._defaultCacheMode},set:function(t){this._defaultCacheMode=t,this.setAnimationCacheMode(this._defaultCacheMode)}},{key:"premultipliedAlpha",get:function(){return this._premultipliedAlpha},set:function(t){t!==this._premultipliedAlpha&&(this._premultipliedAlpha=t,this.markForUpdateRenderData())}},{key:"timeScale",get:function(){return this._timeScale},set:function(t){t!==this._timeScale&&(this._timeScale=t)}},{key:"debugSlots",get:function(){return this._debugSlots},set:function(t){t!==this._debugSlots&&(this._debugSlots=t,this._updateDebugDraw(),this.markForUpdateRenderData())}},{key:"debugBones",get:function(){return this._debugBones},set:function(t){t!==this._debugBones&&(this._debugBones=t,this._updateDebugDraw(),this.markForUpdateRenderData())}},{key:"debugMesh",get:function(){return this._debugMesh},set:function(t){t!==this._debugMesh&&(this._debugMesh=t,this._updateDebugDraw(),this.markForUpdateRenderData())}},{key:"useTint",get:function(){return this._useTint},set:function(t){t!==this._useTint&&(this._useTint=t,this._updateUseTint(),this.markForUpdateRenderData())}},{key:"sockets",get:function(){return this._sockets},set:function(t){this._sockets=t,this._updateSocketBindings(),this.attachUtil._syncAttachedNode()}},{key:"socketNodes",get:function(){return this._socketNodes}}]),e}(Ap),Git.SpineSocket=qit,Git.AnimationCacheMode=jit,oi((xit=zit).prototype,"customMaterial",[pr,Qet,$et,tit],Object.getOwnPropertyDescriptor(xit.prototype,"customMaterial"),xit.prototype),Tit=oi(xit.prototype,"paused",[eit],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(xit.prototype,"skeletonData",[vi,iit],Object.getOwnPropertyDescriptor(xit.prototype,"skeletonData"),xit.prototype),oi(xit.prototype,"_defaultSkinIndex",[rit,nit,sit],Object.getOwnPropertyDescriptor(xit.prototype,"_defaultSkinIndex"),xit.prototype),oi(xit.prototype,"_animationIndex",[ait,oit,lit],Object.getOwnPropertyDescriptor(xit.prototype,"_animationIndex"),xit.prototype),oi(xit.prototype,"defaultCacheMode",[hit,uit,vi,cit],Object.getOwnPropertyDescriptor(xit.prototype,"defaultCacheMode"),xit.prototype),wit=oi(xit.prototype,"loop",[_i,_it],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Eit=oi(xit.prototype,"_premultipliedAlpha",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),oi(xit.prototype,"premultipliedAlpha",[vi,fit],Object.getOwnPropertyDescriptor(xit.prototype,"premultipliedAlpha"),xit.prototype),Bit=oi(xit.prototype,"_timeScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),oi(xit.prototype,"timeScale",[pit,vi],Object.getOwnPropertyDescriptor(xit.prototype,"timeScale"),xit.prototype),oi(xit.prototype,"debugSlots",[vi,dit],Object.getOwnPropertyDescriptor(xit.prototype,"debugSlots"),xit.prototype),oi(xit.prototype,"debugBones",[vi,mit],Object.getOwnPropertyDescriptor(xit.prototype,"debugBones"),xit.prototype),oi(xit.prototype,"debugMesh",[vi,yit],Object.getOwnPropertyDescriptor(xit.prototype,"debugMesh"),xit.prototype),oi(xit.prototype,"useTint",[vi,git],Object.getOwnPropertyDescriptor(xit.prototype,"useTint"),xit.prototype),oi(xit.prototype,"sockets",[vit,bit],Object.getOwnPropertyDescriptor(xit.prototype,"sockets"),xit.prototype),Dit=oi(xit.prototype,"_useTint",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Mit=oi(xit.prototype,"_preCacheMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Pit=oi(xit.prototype,"_cacheMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jit.REALTIME}}),Rit=oi(xit.prototype,"_defaultCacheMode",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jit.REALTIME}}),Iit=oi(xit.prototype,"_debugBones",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Oit=oi(xit.prototype,"_debugSlots",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Fit=oi(xit.prototype,"_skeletonData",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Lit=oi(xit.prototype,"defaultSkin",[_i,Sit],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Vit=oi(xit.prototype,"defaultAnimation",[Ait,_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),kit=oi(xit.prototype,"_sockets",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Nit=oi(xit.prototype,"_debugMesh",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Cit=xit))||Cit)||Cit)||Cit)||Cit);He.internal.SpineSkeleton=Jit;var Kit,Zit,Qit,$it,trt,ert,irt,rrt,nrt,srt,art,ort,lrt,hrt,urt,crt,_rt,frt,prt,drt,mrt,yrt,grt,vrt,brt,Srt,Art,Crt,xrt,Trt,wrt,Ert,Brt,Drt,Mrt,Prt,Rrt,Irt,Ort,Frt,Lrt,Vrt,krt=function(){function t(){this.name="sp.VertexEffectDelegate",this._vertexEffect=null,this._interpolation=null,this._effectType=void 0,this._vertexEffect=null,this._interpolation=null,this._effectType="none"}var e=t.prototype;return e.clear=function(){this._vertexEffect=null,this._interpolation=null,this._effectType="none"},e.initJitter=function(t,e){return this._effectType="jitter",this._vertexEffect=new iet.JitterEffect(t,e),this._vertexEffect},e.initSwirlWithPow=function(t,e){return this._interpolation=new iet.Pow(e),this._vertexEffect=new iet.SwirlEffect(t,this._interpolation),this._vertexEffect},e.initSwirlWithPowOut=function(t,e){return this._interpolation=new iet.PowOut(e),this._vertexEffect=new iet.SwirlEffect(t,this._interpolation),this._vertexEffect},e.getJitterVertexEffect=function(){return this._vertexEffect},e.getSwirlVertexEffect=function(){return this._vertexEffect},e.getVertexEffect=function(){return this._vertexEffect},e.getEffectType=function(){return this._effectType},t}(),Nrt=0,Grt=[0,1,2,2,3,0],zrt=new Ui(0,0,255,255),Urt=new Ui(255,0,0,255),Hrt=new Ui(0,255,0,255),jrt=new Ui(255,255,0,255),Wrt=new iet.Color(1,1,1,1),Xrt=new iet.Color(1,1,1,1),Yrt=new iet.Vector2,qrt=new iet.Vector2,Jrt=new Float32Array(4),Krt=new Float32Array(4),Zrt=new ii,Qrt=0,$rt=0,tnt=0,ent=0,int=0,rnt=0,nnt=0,snt=null,ant=null,ont=null;function lnt(t){var e,i;switch(t){case iet.BlendMode.Additive:e=Kit?E.ONE:E.SRC_ALPHA,i=E.ONE;break;case iet.BlendMode.Multiply:e=E.DST_COLOR,i=E.ONE_MINUS_SRC_ALPHA;break;case iet.BlendMode.Screen:e=E.ONE,i=E.ONE_MINUS_SRC_COLOR;break;case iet.BlendMode.Normal:default:e=Kit?E.ONE:E.SRC_ALPHA,i=E.ONE_MINUS_SRC_ALPHA}return Ort.getMaterialForBlendAndTint(e,i,trt?Wit.TWO_COLORED:Wit.COLORED_TEXTURED)}function hnt(t){Drt=t.fa*ort,Crt=nrt*(Zit=Kit?Drt/255:1),xrt=srt*Zit,Trt=art*Zit,wrt=t.fr*Crt,Ert=t.fg*xrt,Brt=t.fb*Trt,Jrt[0]=wrt/255,Jrt[1]=Ert/255,Jrt[2]=Brt/255,Jrt[3]=Drt/255,Mrt=t.dr*Crt,Prt=t.dg*xrt,Rrt=t.db*Trt,Irt=Kit?255:0,Krt[0]=Mrt/255,Krt[1]=Prt/255,Krt[2]=Rrt/255,Krt[3]=Irt/255}var unt=new Float32Array(4);function cnt(t){return unt[0]=t.r/255,unt[1]=t.g/255,unt[2]=t.b/255,unt[3]=t.a/255,unt}function _nt(t){return t?13:9}var fnt={createData:function(){},updateRenderData:function(t){Ort=t;var e=t._skeleton;!t.isAnimationCached()&&e&&e.updateWorldTransform(),e&&function(t){if(t._skeleton){var e,i=t.color;nrt=i.r/255,srt=i.g/255,art=i.b/255,ort=i.a/255,trt=t.useTint||t.isAnimationCached(),lrt=_nt(trt),Lrt=t.node,t.destroyRenderData(),Frt=t.requestMeshRenderData(lrt),Ort=t,ant=null,prt=!0,Kit=t.premultipliedAlpha,Zit=1,Nrt=0,Vrt=!1,snt=t._effectDelegate&&t._effectDelegate._vertexEffect,(4294967295!==i._val||Kit)&&(Vrt=!0),trt&&(Nrt|=1),Ort.enableBatch&&(e=Lrt.worldMatrix,prt=!1,Nrt|=16),t.isAnimationCached()?function(t){var e=Ort._curFrame;if(e){var i,r,n=e.segments;if(0!==n.length){hrt=12;var s=null,a=e.vertices,o=e.indices,l=0,h=0,u=0;t&&(yrt=t.m00,brt=t.m01,grt=t.m04,Srt=t.m05,vrt=t.m12,Art=t.m13);var c=16&Nrt,_=c&&(1===yrt&&0===brt&&0===grt&&1===Srt),f=0,p=e.colors,d=p[f++],m=d.vfOffset;hnt(d);for(var y=0,g=n.length;y<g;y++){var v=n[y];if(s=lnt(v.blendMode)){ant||(ant=s),ont||(ont=v.tex),Frt.renderData.material&&(Frt.renderData.material=ant),(prt||s.hash!==ant.hash||v.tex&&v.tex!==ont)&&(prt=!1,Frt.texture||(Frt.texture=v.tex),Frt=Ort.requestMeshRenderData(_nt(trt)),ant=s,ont=v.tex,Frt.texture=v.tex,Frt.renderData.material=ant),$rt=v.vertexCount,int=v.indexCount,Frt.renderData.reserve($rt,int),rnt=Frt.renderData.indicesCount,tnt=Frt.renderData.vertexCount,nnt=Frt.renderData.vDataOffset,i=Frt.renderData.vData,r=Frt.renderData.iData;for(var b=rnt,S=rnt+int;b<S;b++)r[b]=tnt+o[h++];u=v.vfCount;var A=a.subarray(l,l+u);l+=u;var C=nnt;lrt=_nt(trt);for(var x=0;x<A.length;)i[C+0]=A[x+0],i[C+1]=A[x+1],i[C+3]=A[x+3],i[C+4]=A[x+4],i[C+5]=A[x+5],i[C+6]=A[x+6],i[C+7]=A[x+7],i[C+8]=A[x+8],trt&&(i[C+9]=A[x+9],i[C+10]=A[x+10],i[C+11]=A[x+11],i[C+12]=A[x+12]),C+=lrt,x+=13;if(_)for(var T=nnt,w=nnt+u;T<w;T+=lrt)i[T]+=vrt,i[T+1]+=Art;else if(c)for(var E=nnt,B=nnt+u;E<B;E+=lrt)drt=i[E],mrt=i[E+1],i[E]=drt*yrt+mrt*grt+vrt,i[E+1]=drt*brt+mrt*Srt+Art;if(Frt.renderData.advance($rt,int),Vrt)for(var D=l-u,M=nnt,P=nnt+u;M<P;M+=lrt,D+=6)D>=m&&(hnt(d=p[f++]),m=d.vfOffset),i.set(Jrt,M+5),i.set(Krt,M+9)}}}}}(e):(snt&&snt.begin(t._skeleton),function(t){var e,i,r,n,s,a,o,l,h=Ort._skeleton,u=h.color,c=Ort._debugRenderer,_=Ort._clipper,f=null;Qit=Ort._startSlotIndex,$it=Ort._endSlotIndex,frt=!1,-1===Qit&&(frt=!0),ert=Ort.debugSlots,irt=Ort.debugBones,rrt=Ort.debugMesh,c&&(irt||ert||rrt)&&(c.clear(),c.lineWidth=5),hrt=12,Qrt=0,tnt=0,ent=0,int=0,rnt=0;for(var p=0,d=h.drawOrder.length;p<d;p++){var m;if(void 0!==(l=h.drawOrder[p]))if(Qit>=0&&Qit===l.data.index&&(frt=!0),frt)if($it>=0&&$it===l.data.index&&(frt=!1),Qrt=0,int=0,r=l.getAttachment())if(a=r instanceof iet.RegionAttachment,o=r instanceof iet.MeshAttachment,r instanceof iet.ClippingAttachment)_.clipStart(l,r);else if(a||o){var y=r.region.texture.getRealTexture();if(f=lnt(l.data.blendMode)){if(ant||(ant=f),(null===(m=Frt)||void 0===m?void 0:m.renderData.material)||(Frt.renderData.material=ant),(prt||f.hash!==ant.hash||y&&ont!==y)&&(prt=!1,Frt=Ort.requestMeshRenderData(lrt),ant=f,ont=y,Frt.texture=y,Frt.renderData.material=ant),a){if(s=Grt,Qrt=4*lrt,int=6,Frt.renderData.reserve(4,6),rnt=Frt.renderData.indicesCount,tnt=Frt.renderData.vertexCount,ent=Frt.renderData.vDataOffset,e=Frt.renderData.vData,i=Frt.renderData.iData,r.computeWorldVertices(l.bone,e,ent,lrt),c&&ert){c.strokeColor=zrt,c.moveTo(e[ent],e[ent+1]);for(var g=ent+lrt,v=ent+Qrt;g<v;g+=lrt)c.lineTo(e[g],e[g+1]);c.close(),c.stroke()}}else if(o){var b=r;if(s=b.triangles,Qrt=(b.worldVerticesLength>>1)*lrt,int=s.length,Frt.renderData.reserve(b.worldVerticesLength>>1,int),rnt=Frt.renderData.indicesCount,tnt=Frt.renderData.vertexCount,ent=Frt.renderData.vDataOffset,e=Frt.renderData.vData,i=Frt.renderData.iData,b.computeWorldVertices(l,0,b.worldVerticesLength,e,ent,lrt),c&&rrt){c.strokeColor=jrt;for(var S=0,A=s.length;S<A;S+=3){var C=s[S]*lrt+ent,x=s[S+1]*lrt+ent,T=s[S+2]*lrt+ent;c.moveTo(e[C],e[C+1]),c.lineTo(e[x],e[x+1]),c.lineTo(e[T],e[T+1]),c.close(),c.stroke()}}}if(0!==Qrt&&0!==int){var w=r;i.set(s,rnt),n=w.uvs;for(var E=ent,B=ent+Qrt,D=0;E<B;E+=lrt,D+=2)e[E+3]=n[D],e[E+4]=n[D+1];if(pnt(u,w.color,l.color,_,l),e=Frt.renderData.vData,i=Frt.renderData.iData,int>0){for(var M=rnt,P=rnt+int;M<P;M++)i[M]+=tnt;if(t){yrt=t.m00,grt=t.m04,vrt=t.m12,brt=t.m01,Srt=t.m05,Art=t.m13;for(var R=ent,I=ent+Qrt;R<I;R+=lrt)drt=e[R],mrt=e[R+1],e[R]=drt*yrt+mrt*grt+vrt,e[R+1]=drt*brt+mrt*Srt+Art}Frt.renderData.advance(Qrt/lrt,int)}_.clipEndWithSlot(l)}else _.clipEndWithSlot(l)}else _.clipEndWithSlot(l)}else _.clipEndWithSlot(l);else _.clipEndWithSlot(l);else _.clipEndWithSlot(l)}if(_.clipEnd(),c&&irt){var O;c.strokeColor=Urt,c.fillColor=zrt;for(var F=0,L=h.bones.length;F<L;F++){var V=(O=h.bones[F]).data.length*O.a+O.worldX,k=O.data.length*O.c+O.worldY;c.moveTo(O.worldX,O.worldY),c.lineTo(V,k),c.stroke(),c.circle(O.worldX,O.worldY,1.5*Math.PI),c.fill(),0===F&&(c.fillColor=Hrt)}}}(e),snt&&snt.end()),t.attachUtil._syncAttachedNode(),Lrt=void 0,Frt=void 0,Ort=void 0,snt=null}}(t)},updateColor:function(t){Ort=t},fillBuffers:function(t,e){if(t&&t.meshRenderDataArray){Ort=t;var i=t.meshRenderDataArray,r=t.node,n=i[t._meshRenderDataArrayIdx].renderData,s=e.acquireBufferBatch(9===n.floatStride?ud:cd),a=s.byteOffset>>2,o=s.indicesOffset,l=s.vertexOffset;s.request(n.vertexCount,n.indicesCount)||(s=e.currBufferBatch,a=0,o=0,l=0);var h=s.vData,u=s.iData,c=r.worldMatrix,_=n.vData,f=n.vertexStart,p=n.iData,d=n.floatStride;h.set(_.subarray(f,f+n.vertexCount*d),a);for(var m=0;m<n.vertexCount;m++){var y=a+m*d;Zrt.set(h[y],h[y+1],h[y+2]),Zrt.transformMat4(c),h[y]=Zrt.x,h[y+1]=Zrt.y,h[y+2]=Zrt.z}for(var g=n.indicesStart,v=0;v<n.indicesCount;v+=1)u[v+o]=p[v+g]+l}}};function pnt(t,e,i,r,n){var s=Frt.renderData.vData,a=Frt.renderData.iData;if(Wrt.a=i.a*e.a*t.a*ort*255,Zit=Kit?Wrt.a:255,urt=nrt*e.r*t.r*Zit,crt=srt*e.g*t.g*Zit,_rt=art*e.b*t.b*Zit,Wrt.r=urt*i.r,Wrt.g=crt*i.g,Wrt.b=_rt*i.b,null==n.darkColor?Xrt.set(0,0,0,1):(Xrt.r=n.darkColor.r*urt,Xrt.g=n.darkColor.g*crt,Xrt.b=n.darkColor.b*_rt),Xrt.a=Kit?255:0,r.isClipping()){hrt=trt?12:8;var o=s.subarray(ent),l=s.subarray(ent+3);r.clipTriangles(o,Qrt,a.subarray(rnt),int,l,Wrt,Xrt,trt,lrt);var h=new Float32Array(r.clippedVertices),u=r.clippedTriangles;if(int=u.length,Qrt=h.length/hrt*lrt,Frt.renderData.reserve(Qrt/lrt,int),rnt=Frt.renderData.indicesCount,tnt=Frt.renderData.vertexCount,ent=Frt.renderData.vDataOffset,s=Frt.renderData.vData,a=Frt.renderData.iData,u.length>0&&a.set(u,rnt),snt)for(var c=0,_=h.length,f=ent;c<_;c+=hrt,f+=lrt)Yrt.x=h[c],Yrt.y=h[c+1],Wrt.set(h[c+2],h[c+3],h[c+4],h[c+5]),qrt.x=h[c+6],qrt.y=h[c+7],trt?Xrt.set(h[c+8],h[c+9],h[c+10],h[c+11]):Xrt.set(0,0,0,0),snt.transform(Yrt,qrt,Wrt,Xrt),s[f]=Yrt.x,s[f+1]=Yrt.y,s[f+3]=qrt.x,s[f+4]=qrt.y,s.set(cnt(Wrt),f+5),trt&&s.set(cnt(Xrt),f+9);else for(var p=0,d=h.length,m=ent;p<d;p+=hrt,m+=lrt)s[m]=h[p],s[m+1]=h[p+1],s[m+3]=h[p+6],s[m+4]=h[p+7],s[m+5]=h[p+2]/255,s[m+6]=h[p+3]/255,s[m+7]=h[p+4]/255,s[m+8]=h[p+5]/255,trt&&(s[m+9]=h[p+8]/255,s[m+10]=h[p+9]/255,s[m+11]=h[p+10]/255,s[m+12]=h[p+11]/255)}else if(snt)for(var y=ent,g=ent+Qrt;y<g;y+=lrt)Yrt.x=s[y],Yrt.y=s[y+1],qrt.x=s[y+3],qrt.y=s[y+4],snt.transform(Yrt,qrt,Wrt,Xrt),s[y]=Yrt.x,s[y+1]=Yrt.y,s[y+3]=qrt.x,s[y+4]=qrt.y,s.set(cnt(Wrt),y+5),trt&&s.set(cnt(Xrt),y+9);else{Jrt.set(cnt(Wrt)),Krt.set(cnt(Xrt));for(var v=ent,b=ent+Qrt;v<b;v+=lrt)s.set(Jrt,v+5),trt&&s.set(Krt,v+9)}}He.internal.SpineAssembler=fnt;var dnt,mnt,ynt={getAssembler:function(){return fnt}};Jit.Assembler=ynt,function(t){t[t.REGION=0]="REGION",t[t.BOUNDING_BOX=1]="BOUNDING_BOX",t[t.MESH=2]="MESH",t[t.SKINNED_MESH=3]="SKINNED_MESH"}(dnt||(dnt={})),Pr(dnt),function(t){t[t.START=0]="START",t[t.INTERRUPT=1]="INTERRUPT",t[t.END=2]="END",t[t.DISPOSE=3]="DISPOSE",t[t.COMPLETE=4]="COMPLETE",t[t.EVENT=5]="EVENT"}(mnt||(mnt={})),Pr(mnt),t("sp",Object.freeze({__proto__:null,spine:iet,get ATTACHMENT_TYPE(){return dnt},get AnimationEventType(){return mnt},timeScale:1,get DefaultSkinsEnum(){return Uit},get DefaultAnimsEnum(){return Hit},get AnimationCacheMode(){return jit},get SpineMaterialType(){return Wit},SpineSocket:qit,Skeleton:Jit,SkeletonData:Xit,SkeletonTexture:Get,convertFilter:zet,convertWraps:Uet,VertexEffectDelegate:krt,simpleSpineAssembler:ynt}));var gnt=Object.setPrototypeOf,vnt={};vnt||(vnt={}),function(t){var e=function(){function e(i){this._clock=new t.WorldClock,this._events=[],this._objects=[],this._eventManager=null,this._eventManager=i,console.info("DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}return e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var i=0,r=this._objects;i<r.length;i++)r[i].returnToPool();this._objects.length=0}if(this._clock.advanceTime(e),this._events.length>0){for(var n=0;n<this._events.length;++n){var s=this._events[n],a=s.armature;null!==a._armatureData&&(a.eventDispatcher.dispatchDBEvent(s.type,s),s.type===t.EventObject.SOUND_EVENT&&this._eventManager.dispatchDBEvent(s.type,s)),this.bufferObject(s)}this._events.length=0}},e.prototype.bufferEvent=function(t){this._events.indexOf(t)<0&&this._events.push(t)},e.prototype.bufferObject=function(t){this._objects.indexOf(t)<0&&this._objects.push(t)},Object.defineProperty(e.prototype,"clock",{get:function(){return this._clock},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventManager",{get:function(){return this._eventManager},enumerable:!0,configurable:!0}),e.VERSION="5.6.300",e.yDown=!1,e.debug=!1,e.debugDraw=!1,e.webAssembly=!1,e}();t.DragonBones=e}(vnt||(vnt={})),console.warn||(console.warn=function(){}),console.assert||(console.assert=function(){}),Date.now||(Date.now=function(){return(new Date).getTime()}),gnt=function(t,e){function i(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);i.prototype=e.prototype,t.prototype=new i},function(t){var e=function(){function t(){this.hashCode=t._hashCode++,this._isInPool=!1}return t._returnObject=function(e){var i=String(e.constructor),r=i in t._maxCountMap?t._maxCountMap[i]:t._defaultMaxCount,n=t._poolsMap[i]=t._poolsMap[i]||[];n.length<r&&(e._isInPool?console.warn("The object is already in the pool."):(e._isInPool=!0,n.push(e)))},t.toString=function(){throw new Error},t.setMaxCount=function(e,i){if((i<0||i!=i)&&(i=0),null!==e)null!==(n=(r=String(e))in t._poolsMap?t._poolsMap[r]:null)&&n.length>i&&(n.length=i),t._maxCountMap[r]=i;else for(var r in t._defaultMaxCount=i,t._poolsMap){var n;(n=t._poolsMap[r]).length>i&&(n.length=i),r in t._maxCountMap&&(t._maxCountMap[r]=i)}},t.clearPool=function(e){if(void 0===e&&(e=null),null!==e){var i=String(e);null!==(n=i in t._poolsMap?t._poolsMap[i]:null)&&n.length>0&&(n.length=0)}else for(var r in t._poolsMap){var n;(n=t._poolsMap[r]).length=0}},t.borrowObject=function(e){var i=String(e),r=i in t._poolsMap?t._poolsMap[i]:null;if(null!==r&&r.length>0){var n=r.pop();return n._isInPool=!1,n}var s=new e;return s._onClear(),s},t.prototype.returnToPool=function(){this._onClear(),t._returnObject(this)},t._hashCode=0,t._defaultMaxCount=3e3,t._maxCountMap={},t._poolsMap={},t}();t.BaseObject=e}(vnt||(vnt={})),function(t){var e=function(){function t(t,e,i,r,n,s){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=s}return t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty},t.prototype.copyFrom=function(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},t.prototype.copyFromArray=function(t,e){return void 0===e&&(e=0),this.a=t[e],this.b=t[e+1],this.c=t[e+2],this.d=t[e+3],this.tx=t[e+4],this.ty=t[e+5],this},t.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this},t.prototype.concat=function(t){var e=this.a*t.a,i=0,r=0,n=this.d*t.d,s=this.tx*t.a+t.tx,a=this.ty*t.d+t.ty;return 0===this.b&&0===this.c||(e+=this.b*t.c,i+=this.b*t.d,r+=this.c*t.a,n+=this.c*t.b),0===t.b&&0===t.c||(i+=this.a*t.b,r+=this.d*t.c,s+=this.ty*t.c,a+=this.tx*t.b),this.a=e,this.b=i,this.c=r,this.d=n,this.tx=s,this.ty=a,this},t.prototype.invert=function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,s=this.ty;if(0===e&&0===i)return this.b=this.c=0,0===t||0===r?this.a=this.b=this.tx=this.ty=0:(t=this.a=1/t,r=this.d=1/r,this.tx=-t*n,this.ty=-r*s),this;var a=t*r-e*i;if(0===a)return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this;a=1/a;var o=this.a=r*a;return e=this.b=-e*a,i=this.c=-i*a,r=this.d=t*a,this.tx=-(o*n+i*s),this.ty=-(e*n+r*s),this},t.prototype.transformPoint=function(t,e,i,r){void 0===r&&(r=!1),i.x=this.a*t+this.c*e,i.y=this.b*t+this.d*e,r||(i.x+=this.tx,i.y+=this.ty)},t.prototype.transformRectangle=function(t,e){void 0===e&&(e=!1);var i=this.a,r=this.b,n=this.c,s=this.d,a=e?0:this.tx,o=e?0:this.ty,l=t.x,h=t.y,u=l+t.width,c=h+t.height,_=i*l+n*h+a,f=r*l+s*h+o,p=i*u+n*h+a,d=r*u+s*h+o,m=i*u+n*c+a,y=r*u+s*c+o,g=i*l+n*c+a,v=r*l+s*c+o,b=0;_>p&&(b=_,_=p,p=b),m>g&&(b=m,m=g,g=b),t.x=Math.floor(_<m?_:m),t.width=Math.ceil((p>g?p:g)-t.x),f>d&&(b=f,f=d,d=b),y>v&&(b=y,y=v,v=b),t.y=Math.floor(f<y?f:y),t.height=Math.ceil((d>v?d:v)-t.y)},t}();t.Matrix=e}(vnt||(vnt={})),function(t){var e=function(){function t(t,e,i,r,n,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=1),void 0===s&&(s=1),this.x=t,this.y=e,this.skew=i,this.rotation=r,this.scaleX=n,this.scaleY=s}return t.normalizeRadian=function(t){return(t=(t+Math.PI)%(2*Math.PI))+(t>0?-Math.PI:Math.PI)},t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skew/Math.PI+" skewY:"+180*this.rotation/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.skew=t.skew,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this},t.prototype.identity=function(){return this.x=this.y=0,this.skew=this.rotation=0,this.scaleX=this.scaleY=1,this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.skew+=t.skew,this.rotation+=t.rotation,this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this},t.prototype.minus=function(t){return this.x-=t.x,this.y-=t.y,this.skew-=t.skew,this.rotation-=t.rotation,this.scaleX/=t.scaleX,this.scaleY/=t.scaleY,this},t.prototype.fromMatrix=function(e){var i=this.scaleX,r=this.scaleY,n=t.PI_Q;this.x=e.tx,this.y=e.ty,this.rotation=Math.atan(e.b/e.a);var s=Math.atan(-e.c/e.d);return this.scaleX=this.rotation>-n&&this.rotation<n?e.a/Math.cos(this.rotation):e.b/Math.sin(this.rotation),this.scaleY=s>-n&&s<n?e.d/Math.cos(s):-e.c/Math.sin(s),i>=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.rotation=this.rotation-Math.PI),r>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,s-=Math.PI),this.skew=s-this.rotation,this},t.prototype.toMatrix=function(t){return 0===this.rotation?(t.a=1,t.b=0):(t.a=Math.cos(this.rotation),t.b=Math.sin(this.rotation)),0===this.skew?(t.c=-t.b,t.d=t.a):(t.c=-Math.sin(this.skew+this.rotation),t.d=Math.cos(this.skew+this.rotation)),1!==this.scaleX&&(t.a*=this.scaleX,t.b*=this.scaleX),1!==this.scaleY&&(t.c*=this.scaleY,t.d*=this.scaleY),t.tx=this.x,t.ty=this.y,this},t.PI=Math.PI,t.PI_D=2*Math.PI,t.PI_H=Math.PI/2,t.PI_Q=Math.PI/4,t.RAD_DEG=180/Math.PI,t.DEG_RAD=Math.PI/180,t}();t.Transform=e}(vnt||(vnt={})),function(t){var e=function(){function t(t,e,i,r,n,s,a,o){void 0===t&&(t=1),void 0===e&&(e=1),void 0===i&&(i=1),void 0===r&&(r=1),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),this.alphaMultiplier=t,this.redMultiplier=e,this.greenMultiplier=i,this.blueMultiplier=r,this.alphaOffset=n,this.redOffset=s,this.greenOffset=a,this.blueOffset=o}return t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.greenOffset=t.greenOffset,this.blueOffset=t.blueOffset},t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0},t}();t.ColorTransform=e}(vnt||(vnt={})),function(t){var e=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t.prototype.clear=function(){this.x=this.y=0},t}();t.Point=e}(vnt||(vnt={})),function(t){var e=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),this.x=t,this.y=e,this.width=i,this.height=r}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},t.prototype.clear=function(){this.x=this.y=0,this.width=this.height=0},t}();t.Rectangle=e}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ints=[],e.floats=[],e.strings=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.UserData]"},e.prototype._onClear=function(){this.ints.length=0,this.floats.length=0,this.strings.length=0},e.prototype.addInt=function(t){this.ints.push(t)},e.prototype.addFloat=function(t){this.floats.push(t)},e.prototype.addString=function(t){this.strings.push(t)},e.prototype.getInt=function(t){return void 0===t&&(t=0),t>=0&&t<this.ints.length?this.ints[t]:0},e.prototype.getFloat=function(t){return void 0===t&&(t=0),t>=0&&t<this.floats.length?this.floats[t]:0},e.prototype.getString=function(t){return void 0===t&&(t=0),t>=0&&t<this.strings.length?this.strings[t]:""},e}(t.BaseObject);t.UserData=e;var i=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.data=null,e}return gnt(e,t),e.toString=function(){return"[class dragonBones.ActionData]"},e.prototype._onClear=function(){null!==this.data&&this.data.returnToPool(),this.type=0,this.name="",this.bone=null,this.slot=null,this.data=null},e}(t.BaseObject);t.ActionData=i}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.frameIndices=[],e.cachedFrames=[],e.armatureNames=[],e.armatures={},e.userData=null,e}return gnt(e,t),e.toString=function(){return"[class dragonBones.DragonBonesData]"},e.prototype._onClear=function(){for(var t in this.armatures)this.armatures[t].returnToPool(),delete this.armatures[t];null!==this.userData&&this.userData.returnToPool(),this.autoSearch=!1,this.frameRate=0,this.version="",this.name="",this.stage=null,this.frameIndices.length=0,this.cachedFrames.length=0,this.armatureNames.length=0,this.binary=null,this.intArray=null,this.floatArray=null,this.frameIntArray=null,this.frameFloatArray=null,this.frameArray=null,this.timelineArray=null,this.userData=null},e.prototype.addArmature=function(t){t.name in this.armatures?console.warn("Same armature: "+t.name):(t.parent=this,this.armatures[t.name]=t,this.armatureNames.push(t.name))},e.prototype.getArmature=function(t){return t in this.armatures?this.armatures[t]:null},e.prototype.dispose=function(){console.warn("已废弃"),this.returnToPool()},e}(t.BaseObject);t.DragonBonesData=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.aabb=new t.Rectangle,i.animationNames=[],i.sortedBones=[],i.sortedSlots=[],i.defaultActions=[],i.actions=[],i.bones={},i.slots={},i.constraints={},i.skins={},i.animations={},i.canvas=null,i.userData=null,i}return gnt(i,e),i.toString=function(){return"[class dragonBones.ArmatureData]"},i.prototype._onClear=function(){for(var t=0,e=this.defaultActions;t<e.length;t++)e[t].returnToPool();for(var i=0,r=this.actions;i<r.length;i++)r[i].returnToPool();for(var n in this.bones)this.bones[n].returnToPool(),delete this.bones[n];for(var n in this.slots)this.slots[n].returnToPool(),delete this.slots[n];for(var n in this.constraints)this.constraints[n].returnToPool(),delete this.constraints[n];for(var n in this.skins)this.skins[n].returnToPool(),delete this.skins[n];for(var n in this.animations)this.animations[n].returnToPool(),delete this.animations[n];null!==this.canvas&&this.canvas.returnToPool(),null!==this.userData&&this.userData.returnToPool(),this.type=0,this.frameRate=0,this.cacheFrameRate=0,this.scale=1,this.name="",this.aabb.clear(),this.animationNames.length=0,this.sortedBones.length=0,this.sortedSlots.length=0,this.defaultActions.length=0,this.actions.length=0,this.defaultSkin=null,this.defaultAnimation=null,this.canvas=null,this.userData=null,this.parent=null},i.prototype.sortBones=function(){var t=this.sortedBones.length;if(!(t<=0)){var e=this.sortedBones.concat(),i=0,r=0;for(this.sortedBones.length=0;r<t;){var n=e[i++];if(i>=t&&(i=0),!(this.sortedBones.indexOf(n)>=0)){var s=!1;for(var a in this.constraints){var o=this.constraints[a];if(o.root===n&&this.sortedBones.indexOf(o.target)<0){s=!0;break}}s||null!==n.parent&&this.sortedBones.indexOf(n.parent)<0||(this.sortedBones.push(n),r++)}}}},i.prototype.cacheFrames=function(t){if(!(this.cacheFrameRate>0))for(var e in this.cacheFrameRate=t,this.animations)this.animations[e].cacheFrames(this.cacheFrameRate)},i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames,r=i.length;return i.length+=10,i[r]=t.a,i[r+1]=t.b,i[r+2]=t.c,i[r+3]=t.d,i[r+4]=t.tx,i[r+5]=t.ty,i[r+6]=e.rotation,i[r+7]=e.skew,i[r+8]=e.scaleX,i[r+9]=e.scaleY,r},i.prototype.getCacheFrame=function(t,e,i){var r=this.parent.cachedFrames;t.a=r[i],t.b=r[i+1],t.c=r[i+2],t.d=r[i+3],t.tx=r[i+4],t.ty=r[i+5],e.rotation=r[i+6],e.skew=r[i+7],e.scaleX=r[i+8],e.scaleY=r[i+9],e.x=t.tx,e.y=t.ty},i.prototype.addBone=function(t){t.name in this.bones?console.warn("Same bone: "+t.name):(this.bones[t.name]=t,this.sortedBones.push(t))},i.prototype.addSlot=function(t){t.name in this.slots?console.warn("Same slot: "+t.name):(this.slots[t.name]=t,this.sortedSlots.push(t))},i.prototype.addConstraint=function(t){t.name in this.constraints?console.warn("Same constraint: "+t.name):this.constraints[t.name]=t},i.prototype.addSkin=function(t){t.name in this.skins?console.warn("Same skin: "+t.name):(t.parent=this,this.skins[t.name]=t,null===this.defaultSkin&&(this.defaultSkin=t),"default"===t.name&&(this.defaultSkin=t))},i.prototype.addAnimation=function(t){t.name in this.animations?console.warn("Same animation: "+t.name):(t.parent=this,this.animations[t.name]=t,this.animationNames.push(t.name),null===this.defaultAnimation&&(this.defaultAnimation=t))},i.prototype.addAction=function(t,e){e?this.defaultActions.push(t):this.actions.push(t)},i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null},i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null},i.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null},i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null},i.prototype.getMesh=function(t,e,i){var r=this.getSkin(t);return null===r?null:r.getDisplay(e,i)},i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null},i}(t.BaseObject);t.ArmatureData=e;var i=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.transform=new t.Transform,i.userData=null,i}return gnt(i,e),i.toString=function(){return"[class dragonBones.BoneData]"},i.prototype._onClear=function(){null!==this.userData&&this.userData.returnToPool(),this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.inheritReflection=!1,this.type=0,this.length=0,this.name="",this.transform.identity(),this.userData=null,this.parent=null},i}(t.BaseObject);t.BoneData=i;var r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.SurfaceData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=1,this.segmentX=0,this.segmentY=0,this.vertices.length=0},e}(i);t.SurfaceData=r;var n=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.color=null,t.userData=null,t}return gnt(i,e),i.createColor=function(){return new t.ColorTransform},i.toString=function(){return"[class dragonBones.SlotData]"},i.prototype._onClear=function(){null!==this.userData&&this.userData.returnToPool(),this.blendMode=0,this.displayIndex=0,this.zOrder=0,this.name="",this.color=null,this.userData=null,this.parent=null},i.DEFAULT_COLOR=new t.ColorTransform,i}(t.BaseObject);t.SlotData=n}(vnt||(vnt={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.prototype._onClear=function(){this.order=0,this.name="",this.type=0,this.target=null,this.root=null,this.bone=null},e}(t.BaseObject);t.ConstraintData=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.IKConstraintData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.scaleEnabled=!1,this.bendPositive=!1,this.weight=1},e}(e);t.IKConstraintData=i;var r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bones=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.PathConstraintData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.pathSlot=null,this.pathDisplayData=null,this.bones.length=0,this.positionMode=0,this.spacingMode=1,this.rotateMode=1,this.position=0,this.spacing=0,this.rotateOffset=0,this.rotateMix=0,this.translateMix=0},e.prototype.AddBone=function(t){this.bones.push(t)},e}(e);t.PathConstraintData=r}(vnt||(vnt={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.CanvasData]"},e.prototype._onClear=function(){this.hasBackground=!1,this.color=0,this.x=0,this.y=0,this.width=0,this.height=0},e}(t.BaseObject);t.CanvasData=e}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.displays={},e}return gnt(e,t),e.toString=function(){return"[class dragonBones.SkinData]"},e.prototype._onClear=function(){for(var t in this.displays){for(var e=0,i=this.displays[t];e<i.length;e++){var r=i[e];null!==r&&r.returnToPool()}delete this.displays[t]}this.name="",this.parent=null},e.prototype.addDisplay=function(t,e){t in this.displays||(this.displays[t]=[]),null!==e&&(e.parent=this),this.displays[t].push(e)},e.prototype.getDisplay=function(t,e){var i=this.getDisplays(t);if(null!==i)for(var r=0,n=i;r<n.length;r++){var s=n[r];if(null!==s&&s.name===e)return s}return null},e.prototype.getDisplays=function(t){return t in this.displays?this.displays[t]:null},e}(t.BaseObject);t.SkinData=e}(vnt||(vnt={})),function(t){var e=function(){function t(){this.weight=null}return t.prototype.clear=function(){this.isShared||null===this.weight||this.weight.returnToPool(),this.isShared=!1,this.inheritDeform=!1,this.offset=0,this.data=null,this.weight=null},t.prototype.shareFrom=function(t){this.isShared=!0,this.offset=t.offset,this.weight=t.weight},t}();t.VerticesData=e;var i=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.transform=new t.Transform,i}return gnt(i,e),i.prototype._onClear=function(){this.name="",this.path="",this.transform.identity(),this.parent=null},i}(t.BaseObject);t.DisplayData=i;var r=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.pivot=new t.Point,i}return gnt(i,e),i.toString=function(){return"[class dragonBones.ImageDisplayData]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.type=0,this.pivot.clear(),this.texture=null},i}(i);t.ImageDisplayData=r;var n=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.actions=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.ArmatureDisplayData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this);for(var e=0,i=this.actions;e<i.length;e++)i[e].returnToPool();this.type=1,this.inheritAnimation=!1,this.actions.length=0,this.armature=null},e.prototype.addAction=function(t){this.actions.push(t)},e}(i);t.ArmatureDisplayData=n;var s=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.vertices=new e,i}return gnt(i,t),i.toString=function(){return"[class dragonBones.MeshDisplayData]"},i.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=2,this.vertices.clear(),this.texture=null},i}(i);t.MeshDisplayData=s;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.boundingBox=null,e}return gnt(e,t),e.toString=function(){return"[class dragonBones.BoundingBoxDisplayData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),null!==this.boundingBox&&this.boundingBox.returnToPool(),this.type=3,this.boundingBox=null},e}(i);t.BoundingBoxDisplayData=a;var o=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.vertices=new e,i.curveLengths=[],i}return gnt(i,t),i.toString=function(){return"[class dragonBones.PathDisplayData]"},i.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=4,this.closed=!1,this.constantSpeed=!1,this.vertices.clear(),this.curveLengths.length=0},i}(i);t.PathDisplayData=o;var l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bones=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.WeightData]"},e.prototype._onClear=function(){this.count=0,this.offset=0,this.bones.length=0},e.prototype.addBone=function(t){this.bones.push(t)},e}(t.BaseObject);t.WeightData=l}(vnt||(vnt={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.prototype._onClear=function(){this.color=0,this.width=0,this.height=0},e}(t.BaseObject);t.BoundingBoxData=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.RectangleBoundingBoxData]"},e._computeOutCode=function(t,e,i,r,n,s){var a=0;return t<i?a|=1:t>n&&(a|=2),e<r?a|=4:e>s&&(a|=8),a},e.rectangleIntersectsSegment=function(t,i,r,n,s,a,o,l,h,u,c){void 0===h&&(h=null),void 0===u&&(u=null),void 0===c&&(c=null);var _=t>s&&t<o&&i>a&&i<l,f=r>s&&r<o&&n>a&&n<l;if(_&&f)return-1;for(var p=0,d=e._computeOutCode(t,i,s,a,o,l),m=e._computeOutCode(r,n,s,a,o,l);;){if(0==(d|m)){p=2;break}if(0!=(d&m))break;var y=0,g=0,v=0,b=0!==d?d:m;0!=(4&b)?(y=t+(r-t)*(a-i)/(n-i),g=a,null!==c&&(v=.5*-Math.PI)):0!=(8&b)?(y=t+(r-t)*(l-i)/(n-i),g=l,null!==c&&(v=.5*Math.PI)):0!=(2&b)?(g=i+(n-i)*(o-t)/(r-t),y=o,null!==c&&(v=0)):0!=(1&b)&&(g=i+(n-i)*(s-t)/(r-t),y=s,null!==c&&(v=Math.PI)),b===d?(t=y,i=g,d=e._computeOutCode(t,i,s,a,o,l),null!==c&&(c.x=v)):(r=y,n=g,m=e._computeOutCode(r,n,s,a,o,l),null!==c&&(c.y=v))}return p&&(_?(p=2,null!==h&&(h.x=r,h.y=n),null!==u&&(u.x=r,u.y=r),null!==c&&(c.x=c.y+Math.PI)):f?(p=1,null!==h&&(h.x=t,h.y=i),null!==u&&(u.x=t,u.y=i),null!==c&&(c.y=c.x+Math.PI)):(p=3,null!==h&&(h.x=t,h.y=i),null!==u&&(u.x=r,u.y=n))),p},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=0},e.prototype.containsPoint=function(t,e){var i=.5*this.width;if(t>=-i&&t<=i){var r=.5*this.height;if(e>=-r&&e<=r)return!0}return!1},e.prototype.intersectsSegment=function(t,i,r,n,s,a,o){void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null);var l=.5*this.width,h=.5*this.height;return e.rectangleIntersectsSegment(t,i,r,n,-l,-h,l,h,s,a,o)},e}(e);t.RectangleBoundingBoxData=i;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.EllipseData]"},e.ellipseIntersectsSegment=function(t,e,i,r,n,s,a,o,l,h,u){void 0===l&&(l=null),void 0===h&&(h=null),void 0===u&&(u=null);var c=a/o,_=c*c,f=i-t,p=(r*=c)-(e*=c),d=Math.sqrt(f*f+p*p),m=f/d,y=p/d,g=(n-t)*m+(s-e)*y,v=a*a,b=v-(t*t+e*e)+g*g,S=0;if(b>=0){var A=Math.sqrt(b),C=g-A,x=g+A,T=C<0?-1:C<=d?0:1,w=x<0?-1:x<=d?0:1,E=T*w;if(E<0)return-1;0===E&&(-1===T?(S=2,i=t+x*m,r=(e+x*y)/c,null!==l&&(l.x=i,l.y=r),null!==h&&(h.x=i,h.y=r),null!==u&&(u.x=Math.atan2(r/v*_,i/v),u.y=u.x+Math.PI)):1===w?(S=1,t+=C*m,e=(e+C*y)/c,null!==l&&(l.x=t,l.y=e),null!==h&&(h.x=t,h.y=e),null!==u&&(u.x=Math.atan2(e/v*_,t/v),u.y=u.x+Math.PI)):(S=3,null!==l&&(l.x=t+C*m,l.y=(e+C*y)/c,null!==u&&(u.x=Math.atan2(l.y/v*_,l.x/v))),null!==h&&(h.x=t+x*m,h.y=(e+x*y)/c,null!==u&&(u.y=Math.atan2(h.y/v*_,h.x/v)))))}return S},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=1},e.prototype.containsPoint=function(t,e){var i=.5*this.width;if(t>=-i&&t<=i){var r=.5*this.height;if(e>=-r&&e<=r)return e*=i/r,Math.sqrt(t*t+e*e)<=i}return!1},e.prototype.intersectsSegment=function(t,i,r,n,s,a,o){return void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null),e.ellipseIntersectsSegment(t,i,r,n,0,0,.5*this.width,.5*this.height,s,a,o)},e}(e);t.EllipseBoundingBoxData=r;var n=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"},e.polygonIntersectsSegment=function(t,e,i,r,n,s,a,o){void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null),t===i&&(t=i+1e-6),e===r&&(e=r+1e-6);for(var l=n.length,h=t-i,u=e-r,c=t*r-e*i,_=0,f=n[l-2],p=n[l-1],d=0,m=0,y=0,g=0,v=0,b=0,S=0;S<l;S+=2){var A=n[S],C=n[S+1];f===A&&(f=A+1e-4),p===C&&(p=C+1e-4);var x=f-A,T=p-C,w=f*C-p*A,E=h*T-u*x,B=(c*x-h*w)/E;if((B>=f&&B<=A||B>=A&&B<=f)&&(0===h||B>=t&&B<=i||B>=i&&B<=t)){var D=(c*T-u*w)/E;if((D>=p&&D<=C||D>=C&&D<=p)&&(0===u||D>=e&&D<=r||D>=r&&D<=e)){if(null===a){y=B,g=D,v=B,b=D,_++,null!==o&&(o.x=Math.atan2(C-p,A-f)-.5*Math.PI,o.y=o.x);break}var M=B-t;M<0&&(M=-M),0===_?(d=M,m=M,y=B,g=D,v=B,b=D,null!==o&&(o.x=Math.atan2(C-p,A-f)-.5*Math.PI,o.y=o.x)):(M<d&&(d=M,y=B,g=D,null!==o&&(o.x=Math.atan2(C-p,A-f)-.5*Math.PI)),M>m&&(m=M,v=B,b=D,null!==o&&(o.y=Math.atan2(C-p,A-f)-.5*Math.PI))),_++}}f=A,p=C}return 1===_?(null!==s&&(s.x=y,s.y=g),null!==a&&(a.x=y,a.y=g),null!==o&&(o.y=o.x+Math.PI)):_>1&&(_++,null!==s&&(s.x=y,s.y=g),null!==a&&(a.x=v,a.y=b)),_},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=2,this.x=0,this.y=0,this.vertices.length=0},e.prototype.containsPoint=function(t,e){var i=!1;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height)for(var r=0,n=this.vertices.length,s=n-2;r<n;r+=2){var a=this.vertices[s+1],o=this.vertices[r+1];if(o<e&&a>=e||a<e&&o>=e){var l=this.vertices[s],h=this.vertices[r];(e-o)*(l-h)/(a-o)+h<t&&(i=!i)}s=r}return i},e.prototype.intersectsSegment=function(t,r,n,s,a,o,l){void 0===a&&(a=null),void 0===o&&(o=null),void 0===l&&(l=null);var h=0;return 0!==i.rectangleIntersectsSegment(t,r,n,s,this.x,this.y,this.x+this.width,this.y+this.height,null,null,null)&&(h=e.polygonIntersectsSegment(t,r,n,s,this.vertices,a,o,l)),h},e}(e);t.PolygonBoundingBoxData=n}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.cachedFrames=[],e.boneTimelines={},e.surfaceTimelines={},e.slotTimelines={},e.constraintTimelines={},e.animationTimelines={},e.boneCachedFrameIndices={},e.slotCachedFrameIndices={},e.actionTimeline=null,e.zOrderTimeline=null,e}return gnt(e,t),e.toString=function(){return"[class dragonBones.AnimationData]"},e.prototype._onClear=function(){for(var t in this.boneTimelines){for(var e=0,i=this.boneTimelines[t];e<i.length;e++)i[e].returnToPool();delete this.boneTimelines[t]}for(var t in this.surfaceTimelines){for(var r=0,n=this.surfaceTimelines[t];r<n.length;r++)n[r].returnToPool();delete this.surfaceTimelines[t]}for(var t in this.slotTimelines){for(var s=0,a=this.slotTimelines[t];s<a.length;s++)a[s].returnToPool();delete this.slotTimelines[t]}for(var t in this.constraintTimelines){for(var o=0,l=this.constraintTimelines[t];o<l.length;o++)l[o].returnToPool();delete this.constraintTimelines[t]}for(var t in this.animationTimelines){for(var h=0,u=this.animationTimelines[t];h<u.length;h++)u[h].returnToPool();delete this.animationTimelines[t]}for(var t in this.boneCachedFrameIndices)delete this.boneCachedFrameIndices[t];for(var t in this.slotCachedFrameIndices)delete this.slotCachedFrameIndices[t];null!==this.actionTimeline&&this.actionTimeline.returnToPool(),null!==this.zOrderTimeline&&this.zOrderTimeline.returnToPool(),this.frameIntOffset=0,this.frameFloatOffset=0,this.frameOffset=0,this.frameCount=0,this.playTimes=0,this.duration=0,this.scale=1,this.fadeInTime=0,this.cacheFrameRate=0,this.name="",this.cachedFrames.length=0,this.actionTimeline=null,this.zOrderTimeline=null,this.parent=null},e.prototype.cacheFrames=function(t){if(!(this.cacheFrameRate>0)){this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var i=0,r=this.cacheFrames.length;i<r;++i)this.cachedFrames[i]=!1;for(var n=0,s=this.parent.sortedBones;n<s.length;n++){var a=s[n];for(i=0,r=(h=new Array(e)).length;i<r;++i)h[i]=-1;this.boneCachedFrameIndices[a.name]=h}for(var o=0,l=this.parent.sortedSlots;o<l.length;o++){var h,u=l[o];for(i=0,r=(h=new Array(e)).length;i<r;++i)h[i]=-1;this.slotCachedFrameIndices[u.name]=h}}},e.prototype.addBoneTimeline=function(t,e){var i=t.name in this.boneTimelines?this.boneTimelines[t.name]:this.boneTimelines[t.name]=[];i.indexOf(e)<0&&i.push(e)},e.prototype.addSurfaceTimeline=function(t,e){var i=t.name in this.surfaceTimelines?this.surfaceTimelines[t.name]:this.surfaceTimelines[t.name]=[];i.indexOf(e)<0&&i.push(e)},e.prototype.addSlotTimeline=function(t,e){var i=t.name in this.slotTimelines?this.slotTimelines[t.name]:this.slotTimelines[t.name]=[];i.indexOf(e)<0&&i.push(e)},e.prototype.addConstraintTimeline=function(t,e){var i=t.name in this.constraintTimelines?this.constraintTimelines[t.name]:this.constraintTimelines[t.name]=[];i.indexOf(e)<0&&i.push(e)},e.prototype.addAnimationTimeline=function(t,e){var i=t in this.animationTimelines?this.animationTimelines[t]:this.animationTimelines[t]=[];i.indexOf(e)<0&&i.push(e)},e.prototype.getBoneTimelines=function(t){return t in this.boneTimelines?this.boneTimelines[t]:null},e.prototype.getSurfaceTimelines=function(t){return t in this.surfaceTimelines?this.surfaceTimelines[t]:null},e.prototype.getSlotTimelines=function(t){return t in this.slotTimelines?this.slotTimelines[t]:null},e.prototype.getConstraintTimelines=function(t){return t in this.constraintTimelines?this.constraintTimelines[t]:null},e.prototype.getAnimationTimelines=function(t){return t in this.animationTimelines?this.animationTimelines[t]:null},e.prototype.getBoneCachedFrameIndices=function(t){return t in this.boneCachedFrameIndices?this.boneCachedFrameIndices[t]:null},e.prototype.getSlotCachedFrameIndices=function(t){return t in this.slotCachedFrameIndices?this.slotCachedFrameIndices[t]:null},e}(t.BaseObject);t.AnimationData=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.TimelineData]"},e.prototype._onClear=function(){this.type=10,this.offset=0,this.frameIndicesOffset=-1},e}(t.BaseObject);t.TimelineData=i}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.boneMask=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.AnimationConfig]"},e.prototype._onClear=function(){this.pauseFadeOut=!0,this.fadeOutMode=4,this.fadeOutTweenType=1,this.fadeOutTime=-1,this.actionEnabled=!0,this.additiveBlending=!1,this.displayControl=!0,this.pauseFadeIn=!0,this.resetToPose=!0,this.fadeInTweenType=1,this.playTimes=-1,this.layer=0,this.position=0,this.duration=-1,this.timeScale=-100,this.weight=1,this.fadeInTime=-1,this.autoFadeOutTime=-1,this.name="",this.animation="",this.group="",this.boneMask.length=0},e.prototype.clear=function(){this._onClear()},e.prototype.copyFrom=function(t){this.pauseFadeOut=t.pauseFadeOut,this.fadeOutMode=t.fadeOutMode,this.autoFadeOutTime=t.autoFadeOutTime,this.fadeOutTweenType=t.fadeOutTweenType,this.actionEnabled=t.actionEnabled,this.additiveBlending=t.additiveBlending,this.displayControl=t.displayControl,this.pauseFadeIn=t.pauseFadeIn,this.resetToPose=t.resetToPose,this.playTimes=t.playTimes,this.layer=t.layer,this.position=t.position,this.duration=t.duration,this.timeScale=t.timeScale,this.fadeInTime=t.fadeInTime,this.fadeOutTime=t.fadeOutTime,this.fadeInTweenType=t.fadeInTweenType,this.weight=t.weight,this.name=t.name,this.animation=t.animation,this.group=t.group,this.boneMask.length=t.boneMask.length;for(var e=0,i=this.boneMask.length;e<i;++e)this.boneMask[e]=t.boneMask[e]},e.prototype.containsBoneMask=function(t){return 0===this.boneMask.length||this.boneMask.indexOf(t)>=0},e.prototype.addBoneMask=function(t,e,i){void 0===i&&(i=!0);var r=t.getBone(e);if(null!==r&&(this.boneMask.indexOf(e)<0&&this.boneMask.push(e),i))for(var n=0,s=t.getBones();n<s.length;n++){var a=s[n];this.boneMask.indexOf(a.name)<0&&r.contains(a)&&this.boneMask.push(a.name)}},e.prototype.removeBoneMask=function(t,e,i){void 0===i&&(i=!0);var r=this.boneMask.indexOf(e);if(r>=0&&this.boneMask.splice(r,1),i){var n=t.getBone(e);if(null!==n)if(this.boneMask.length>0)for(var s=0,a=t.getBones();s<a.length;s++){var o=a[s],l=this.boneMask.indexOf(o.name);l>=0&&n.contains(o)&&this.boneMask.splice(l,1)}else for(var h=0,u=t.getBones();h<u.length;h++)(o=u[h])!==n&&(n.contains(o)||this.boneMask.push(o.name))}},e}(t.BaseObject);t.AnimationConfig=e}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.textures={},e}return gnt(e,t),e.prototype._onClear=function(){for(var t in this.textures)this.textures[t].returnToPool(),delete this.textures[t];this.autoSearch=!1,this.width=0,this.height=0,this.scale=1,this.name="",this.imagePath=""},e.prototype.copyFrom=function(t){for(var e in this.autoSearch=t.autoSearch,this.scale=t.scale,this.width=t.width,this.height=t.height,this.name=t.name,this.imagePath=t.imagePath,this.textures)this.textures[e].returnToPool(),delete this.textures[e];for(var e in t.textures){var i=this.createTexture();i.copyFrom(t.textures[e]),this.textures[e]=i}},e.prototype.addTexture=function(t){t.name in this.textures?console.warn("Same texture: "+t.name):(t.parent=this,this.textures[t.name]=t)},e.prototype.getTexture=function(t){return t in this.textures?this.textures[t]:null},e}(t.BaseObject);t.TextureAtlasData=e;var i=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.region=new t.Rectangle,i.frame=null,i}return gnt(i,e),i.createRectangle=function(){return new t.Rectangle},i.prototype._onClear=function(){this.rotated=!1,this.name="",this.region.clear(),this.parent=null,this.frame=null},i.prototype.copyFrom=function(t){this.rotated=t.rotated,this.name=t.name,this.region.copyFrom(t.region),this.parent=t.parent,null===this.frame&&null!==t.frame?this.frame=i.createRectangle():null!==this.frame&&null===t.frame&&(this.frame=null),null!==this.frame&&null!==t.frame&&this.frame.copyFrom(t.frame)},i}(t.BaseObject);t.TextureData=i}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e.bones=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.DeformVertices]"},e.prototype._onClear=function(){this.verticesDirty=!1,this.vertices.length=0,this.bones.length=0,this.verticesData=null},e.prototype.init=function(t,e){if(this.verticesData=t,null!==this.verticesData){var i;i=null!==this.verticesData.weight?2*this.verticesData.weight.count:2*this.verticesData.data.intArray[this.verticesData.offset+0],this.verticesDirty=!0,this.vertices.length=i,this.bones.length=0;for(var r=0,n=this.vertices.length;r<n;++r)this.vertices[r]=0;if(null!==this.verticesData.weight)for(r=0,n=this.verticesData.weight.bones.length;r<n;++r){var s=e.getBone(this.verticesData.weight.bones[r].name);this.bones.push(s)}}else this.verticesDirty=!1,this.vertices.length=0,this.bones.length=0,this.verticesData=null},e.prototype.isBonesUpdate=function(){for(var t=0,e=this.bones;t<e.length;t++){var i=e[t];if(null!==i&&i._childrenTransformDirty)return!0}return!1},e}(t.BaseObject);t.DeformVertices=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._bones=[],t._slots=[],t._constraints=[],t._actions=[],t._animation=null,t._proxy=null,t._replaceTextureAtlasData=null,t._clock=null,t}return gnt(i,e),i.toString=function(){return"[class dragonBones.Armature]"},i._onSortSlots=function(t,e){return t._zOrder>e._zOrder?1:-1},i.prototype._onClear=function(){null!==this._clock&&this._clock.remove(this);for(var t=0,e=this._bones;t<e.length;t++)e[t].returnToPool();for(var i=0,r=this._slots;i<r.length;i++)r[i].returnToPool();for(var n=0,s=this._constraints;n<s.length;n++)s[n].returnToPool();for(var a=0,o=this._actions;a<o.length;a++)o[a].returnToPool();null!==this._animation&&this._animation.returnToPool(),null!==this._proxy&&this._proxy.dbClear(),null!==this._replaceTextureAtlasData&&this._replaceTextureAtlasData.returnToPool(),this.inheritAnimation=!0,this.userData=null,this._lockUpdate=!1,this._slotsDirty=!0,this._zOrderDirty=!1,this._flipX=!1,this._flipY=!1,this._cacheFrameIndex=-1,this._bones.length=0,this._slots.length=0,this._constraints.length=0,this._actions.length=0,this._armatureData=null,this._animation=null,this._proxy=null,this._display=null,this._replaceTextureAtlasData=null,this._replacedTexture=null,this._dragonBones=null,this._clock=null,this._parent=null},i.prototype._sortZOrder=function(t,e){var i=this._armatureData.sortedSlots,r=null===t;if(this._zOrderDirty||!r){for(var n=0,s=i.length;n<s;++n){var a=r?n:t[e+n];if(!(a<0||a>=s)){var o=i[a],l=this.getSlot(o.name);null!==l&&l._setZorder(n)}}this._slotsDirty=!0,this._zOrderDirty=!r}},i.prototype._addBone=function(t){this._bones.indexOf(t)<0&&this._bones.push(t)},i.prototype._addSlot=function(t){this._slots.indexOf(t)<0&&this._slots.push(t)},i.prototype._addConstraint=function(t){this._constraints.indexOf(t)<0&&this._constraints.push(t)},i.prototype._bufferAction=function(t,e){this._actions.indexOf(t)<0&&(e?this._actions.push(t):this._actions.unshift(t))},i.prototype.dispose=function(){null!==this._armatureData&&(this._lockUpdate=!0,this._dragonBones.bufferObject(this))},i.prototype.init=function(e,i,r,n){null===this._armatureData&&(this._armatureData=e,this._animation=t.BaseObject.borrowObject(t.Animation),this._proxy=i,this._display=r,this._dragonBones=n,this._proxy.dbInit(this),this._animation.init(this),this._animation.animations=this._armatureData.animations)},i.prototype.advanceTime=function(t){if(!this._lockUpdate)if(null!==this._armatureData)if(null!==this._armatureData.parent){var e=this._cacheFrameIndex;if(this._animation.advanceTime(t),this._slotsDirty&&(this._slotsDirty=!1,this._slots.sort(i._onSortSlots)),this._cacheFrameIndex<0||this._cacheFrameIndex!==e){var r=0,n=0;for(r=0,n=this._bones.length;r<n;++r)this._bones[r].update(this._cacheFrameIndex);for(r=0,n=this._slots.length;r<n;++r)this._slots[r].update(this._cacheFrameIndex)}if(this._actions.length>0){this._lockUpdate=!0;for(var s=0,a=this._actions;s<a.length;s++){var o=a[s],l=o.actionData;if(null!==l&&0===l.type)if(null!==o.slot)null!==(c=o.slot.childArmature)&&c.animation.fadeIn(l.name);else if(null!==o.bone)for(var h=0,u=this.getSlots();h<u.length;h++){var c,_=u[h];_.parent===o.bone&&null!==(c=_.childArmature)&&c.animation.fadeIn(l.name)}else this._animation.fadeIn(l.name);o.returnToPool()}this._actions.length=0,this._lockUpdate=!1}this._proxy.dbUpdate()}else console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");else console.warn("The armature has been disposed.")},i.prototype.invalidUpdate=function(t,e){if(void 0===t&&(t=null),void 0===e&&(e=!1),null!==t&&t.length>0){if(null!==(a=this.getBone(t))&&(a.invalidUpdate(),e))for(var i=0,r=this._slots;i<r.length;i++)(h=r[i]).parent===a&&h.invalidUpdate()}else{for(var n=0,s=this._bones;n<s.length;n++){var a;(a=s[n]).invalidUpdate()}if(e)for(var o=0,l=this._slots;o<l.length;o++){var h;(h=l[o]).invalidUpdate()}}},i.prototype.containsPoint=function(t,e){for(var i=0,r=this._slots;i<r.length;i++){var n=r[i];if(n.containsPoint(t,e))return n}return null},i.prototype.intersectsSegment=function(t,e,i,r,n,s,a){void 0===n&&(n=null),void 0===s&&(s=null),void 0===a&&(a=null);for(var o=t===i,l=0,h=0,u=0,c=0,_=0,f=0,p=0,d=0,m=null,y=null,g=0,v=this._slots;g<v.length;g++){var b=v[g];if(b.intersectsSegment(t,e,i,r,n,s,a)>0){if(null===n&&null===s){m=b;break}var S;null!==n&&((S=o?n.y-e:n.x-t)<0&&(S=-S),(null===m||S<l)&&(l=S,u=n.x,c=n.y,m=b,a&&(p=a.x))),null!==s&&((S=s.x-t)<0&&(S=-S),(null===y||S>h)&&(h=S,_=s.x,f=s.y,y=b,null!==a&&(d=a.y)))}}return null!==m&&null!==n&&(n.x=u,n.y=c,null!==a&&(a.x=p)),null!==y&&null!==s&&(s.x=_,s.y=f,null!==a&&(a.y=d)),m},i.prototype.getBone=function(t){for(var e=0,i=this._bones;e<i.length;e++){var r=i[e];if(r.name===t)return r}return null},i.prototype.getBoneByDisplay=function(t){var e=this.getSlotByDisplay(t);return null!==e?e.parent:null},i.prototype.getSlot=function(t){for(var e=0,i=this._slots;e<i.length;e++){var r=i[e];if(r.name===t)return r}return null},i.prototype.getSlotByDisplay=function(t){if(null!==t)for(var e=0,i=this._slots;e<i.length;e++){var r=i[e];if(r.display===t)return r}return null},i.prototype.getBones=function(){return this._bones},i.prototype.getSlots=function(){return this._slots},Object.defineProperty(i.prototype,"flipX",{get:function(){return this._flipX},set:function(t){this._flipX!==t&&(this._flipX=t,this.invalidUpdate())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"flipY",{get:function(){return this._flipY},set:function(t){this._flipY!==t&&(this._flipY=t,this.invalidUpdate())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cacheFrameRate",{get:function(){return this._armatureData.cacheFrameRate},set:function(t){if(this._armatureData.cacheFrameRate!==t){this._armatureData.cacheFrames(t);for(var e=0,i=this._slots;e<i.length;e++){var r=i[e].childArmature;null!==r&&(r.cacheFrameRate=t)}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._armatureData.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"armatureData",{get:function(){return this._armatureData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"proxy",{get:function(){return this._proxy},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"eventDispatcher",{get:function(){return this._proxy},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"display",{get:function(){return this._display},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"replacedTexture",{get:function(){return this._replacedTexture},set:function(t){if(this._replacedTexture!==t){null!==this._replaceTextureAtlasData&&(this._replaceTextureAtlasData.returnToPool(),this._replaceTextureAtlasData=null),this._replacedTexture=t;for(var e=0,i=this._slots;e<i.length;e++){var r=i[e];r.invalidUpdate(),r.update(-1)}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"clock",{get:function(){return this._clock},set:function(t){if(this._clock!==t){null!==this._clock&&this._clock.remove(this),this._clock=t,this._clock&&this._clock.add(this);for(var e=0,i=this._slots;e<i.length;e++){var r=i[e].childArmature;null!==r&&(r.clock=this._clock)}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),i.prototype.replaceTexture=function(t){this.replacedTexture=t},i.prototype.hasEventListener=function(t){return this._proxy.hasDBEventListener(t)},i.prototype.addEventListener=function(t,e,i){this._proxy.addDBEventListener(t,e,i)},i.prototype.removeEventListener=function(t,e,i){this._proxy.removeDBEventListener(t,e,i)},i.prototype.enableAnimationCache=function(t){console.warn("Deprecated."),this.cacheFrameRate=t},i.prototype.getDisplay=function(){return this._display},i}(t.BaseObject);t.Armature=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.globalTransformMatrix=new t.Matrix,i.global=new t.Transform,i.offset=new t.Transform,i}return gnt(i,e),i.prototype._onClear=function(){this.globalTransformMatrix.identity(),this.global.identity(),this.offset.identity(),this.origin=null,this.userData=null,this._globalDirty=!1,this._armature=null},i.prototype.updateGlobalTransform=function(){this._globalDirty&&(this._globalDirty=!1,this.global.fromMatrix(this.globalTransformMatrix))},Object.defineProperty(i.prototype,"armature",{get:function(){return this._armature},enumerable:!0,configurable:!0}),i._helpMatrix=new t.Matrix,i._helpTransform=new t.Transform,i._helpPoint=new t.Point,i}(t.BaseObject);t.TransformObject=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.animationPose=new t.Transform,i._blendState=new t.BlendState,i}return gnt(i,e),i.toString=function(){return"[class dragonBones.Bone]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.offsetMode=1,this.animationPose.identity(),this._transformDirty=!1,this._childrenTransformDirty=!1,this._localDirty=!0,this._hasConstraint=!1,this._visible=!0,this._cachedFrameIndex=-1,this._blendState.clear(),this._boneData=null,this._parent=null,this._cachedFrameIndices=null},i.prototype._updateGlobalTransformMatrix=function(e){var i=this._boneData,r=this.global,n=this.globalTransformMatrix,s=this.origin,a=this.offset,o=this.animationPose,l=this._parent,h=this._armature.flipX,u=this._armature.flipY===t.DragonBones.yDown,c=null!==l,_=0;if(1===this.offsetMode?null!==s?(r.x=s.x+a.x+o.x,r.scaleX=s.scaleX*a.scaleX*o.scaleX,r.scaleY=s.scaleY*a.scaleY*o.scaleY,t.DragonBones.yDown?(r.y=s.y+a.y+o.y,r.skew=s.skew+a.skew+o.skew,r.rotation=s.rotation+a.rotation+o.rotation):(r.y=s.y-a.y+o.y,r.skew=s.skew-a.skew+o.skew,r.rotation=s.rotation-a.rotation+o.rotation)):(r.copyFrom(a),t.DragonBones.yDown||(r.y=-r.y,r.skew=-r.skew,r.rotation=-r.rotation),r.add(o)):0===this.offsetMode?null!==s?r.copyFrom(s).add(o):r.copyFrom(o):(c=!1,r.copyFrom(a),t.DragonBones.yDown||(r.y=-r.y,r.skew=-r.skew,r.rotation=-r.rotation)),c){var f=0===l._boneData.type?l.globalTransformMatrix:l._getGlobalTransformMatrix(r.x,r.y);if(i.inheritScale)i.inheritRotation||(l.updateGlobalTransform(),_=h&&u?r.rotation-(l.global.rotation+Math.PI):h?r.rotation+l.global.rotation+Math.PI:u?r.rotation+l.global.rotation:r.rotation-l.global.rotation,r.rotation=_),r.toMatrix(n),n.concat(f),i.inheritTranslation?(r.x=n.tx,r.y=n.ty):(n.tx=r.x,n.ty=r.y),e?r.fromMatrix(n):this._globalDirty=!0;else{if(i.inheritTranslation){var p=r.x,d=r.y;r.x=f.a*p+f.c*d+f.tx,r.y=f.b*p+f.d*d+f.ty}else h&&(r.x=-r.x),u&&(r.y=-r.y);i.inheritRotation?(l.updateGlobalTransform(),_=l.global.scaleX<0?r.rotation+l.global.rotation+Math.PI:r.rotation+l.global.rotation,f.a*f.d-f.b*f.c<0&&(_-=2*r.rotation,(h!==u||i.inheritReflection)&&(r.skew+=Math.PI),t.DragonBones.yDown||(r.skew=-r.skew)),r.rotation=_):(h||u)&&(h&&u?_=r.rotation+Math.PI:(_=h?Math.PI-r.rotation:-r.rotation,r.skew+=Math.PI),r.rotation=_),r.toMatrix(n)}}else(h||u)&&(h&&(r.x=-r.x),u&&(r.y=-r.y),h&&u?_=r.rotation+Math.PI:(_=h?Math.PI-r.rotation:-r.rotation,r.skew+=Math.PI),r.rotation=_),r.toMatrix(n)},i.prototype.init=function(t,e){null===this._boneData&&(this._boneData=t,this._armature=e,null!==this._boneData.parent&&(this._parent=this._armature.getBone(this._boneData.parent.name)),this._armature._addBone(this),this.origin=this._boneData.transform)},i.prototype.update=function(t){if(this._blendState.dirty=!1,t>=0&&null!==this._cachedFrameIndices){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e)this._transformDirty=!1;else if(e>=0)this._transformDirty=!0,this._cachedFrameIndex=e;else{if(this._hasConstraint)for(var i=0,r=this._armature._constraints;i<r.length;i++)(a=r[i])._root===this&&a.update();this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(var n=0,s=this._armature._constraints;n<s.length;n++){var a;(a=s[n])._root===this&&a.update()}(this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1)}if(this._transformDirty)if(this._transformDirty=!1,this._childrenTransformDirty=!0,this._cachedFrameIndex<0){var o=t>=0;this._localDirty&&this._updateGlobalTransformMatrix(o),o&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},i.prototype.updateByConstraint=function(){this._localDirty&&(this._localDirty=!1,(this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty)&&this._updateGlobalTransformMatrix(!0),this._transformDirty=!0)},i.prototype.invalidUpdate=function(){this._transformDirty=!0},i.prototype.contains=function(t){if(t===this)return!1;for(var e=t;e!==this&&null!==e;)e=e.parent;return e===this},Object.defineProperty(i.prototype,"boneData",{get:function(){return this._boneData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible!==t){this._visible=t;for(var e=0,i=this._armature.getSlots();e<i.length;e++){var r=i[e];r.parent===this&&r._updateVisible()}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._boneData.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),i.prototype.getBones=function(){console.warn("Deprecated.");for(var t=new Array,e=0,i=this._armature.getBones();e<i.length;e++){var r=i[e];r.parent===this&&t.push(r)}return t},i.prototype.getSlots=function(){console.warn("Deprecated.");for(var t=new Array,e=0,i=this._armature.getSlots();e<i.length;e++){var r=i[e];r.parent===this&&t.push(r)}return t},Object.defineProperty(i.prototype,"slot",{get:function(){console.warn("Deprecated.");for(var t=0,e=this._armature.getSlots();t<e.length;t++){var i=e[t];if(i.parent===this)return i}return null},enumerable:!0,configurable:!0}),i}(t.TransformObject);t.Bone=e}(vnt||(vnt={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._vertices=[],e._deformVertices=[],e._hullCache=[],e._matrixCahce=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.Surface]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._dX=0,this._dY=0,this._k=0,this._kX=0,this._kY=0,this._vertices.length=0,this._deformVertices.length=0,this._matrixCahce.length=0,this._hullCache.length=0},e.prototype._getAffineTransform=function(t,e,i,r,n,s,a,o,l,h,u,c,_){var f=a-n,p=o-s,d=l-n,m=h-s;u.rotation=Math.atan2(p,f),u.skew=Math.atan2(m,d)-.5*Math.PI-u.rotation,_&&(u.rotation+=Math.PI),u.scaleX=Math.sqrt(f*f+p*p)/i,u.scaleY=Math.sqrt(d*d+m*m)/r,u.toMatrix(c),u.x=c.tx=n-(c.a*t+c.c*e),u.y=c.ty=s-(c.b*t+c.d*e)},e.prototype._updateVertices=function(){var t=this._boneData.vertices,e=this._vertices,i=this._deformVertices;if(null!==this._parent)if(1===this._parent._boneData.type)for(var r=0,n=t.length;r<n;r+=2){var s=t[r]+i[r],a=t[r+1]+i[r],o=this._parent._getGlobalTransformMatrix(s,a);e[r]=o.a*s+o.c*a+o.tx,e[r+1]=o.b*s+o.d*a+o.ty}else{var l=this._parent.globalTransformMatrix;for(r=0,n=t.length;r<n;r+=2)s=t[r]+i[r],a=t[r+1]+i[r+1],e[r]=l.a*s+l.c*a+l.tx,e[r+1]=l.b*s+l.d*a+l.ty}else for(r=0,n=t.length;r<n;r+=2)e[r]=t[r]+i[r],e[r+1]=t[r+1]+i[r+1]},e.prototype._updateGlobalTransformMatrix=function(){var t=2*this._boneData.segmentX,e=this._vertices.length-2,i=this._vertices[0],r=this._vertices[1],n=this._vertices[t],s=this._vertices[t+1],a=this._vertices[e],o=this._vertices[e+1],l=this._vertices[e-t],h=this._vertices[e-t+1],u=i+.5*(a-i),c=r+.5*(o-r),_=u+.5*(n+.5*(l-n)-u),f=c+.5*(s+.5*(h-s)-c),p=n+.5*(a-n),d=s+.5*(o-s),m=l+.5*(a-l),y=h+.5*(o-h);this._globalDirty=!1,this._getAffineTransform(0,0,200,200,_,f,p,d,m,y,this.global,this.globalTransformMatrix,!1)},e.prototype._getGlobalTransformMatrix=function(t,i){var r=1e3;if(t<-r||r<t||i<-r||r<i)return this.globalTransformMatrix;var n=!1,s=200,a=this._boneData,o=a.segmentX,l=a.segmentY,h=2*a.segmentX,u=this._dX,c=this._dY,_=Math.floor((t+s)/u),f=Math.floor((i+s)/c),p=0,d=_*u-s,m=f*c-s,y=this._matrixCahce,g=e._helpMatrix;if(t<-s){if(i<-s||i>=s)return this.globalTransformMatrix;if(p=7*(2*(o*(l+1)+2*o+l+f)+((n=i>this._kX*(t+s)+m)?1:0)),this._matrixCahce[p]>0)g.copyFromArray(y,p+1);else{var v=f*(h+2),b=this._hullCache[4],S=this._hullCache[5],A=this._hullCache[2]-(l-f)*b,C=this._hullCache[3]-(l-f)*S,x=this._vertices;n?this._getAffineTransform(-s,m+c,800,c,x[v+h+2],x[v+h+3],A+b,C+S,x[v],x[v+1],e._helpTransform,g,!0):this._getAffineTransform(-r,m,800,c,A,C,x[v],x[v+1],A+b,C+S,e._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty}}else if(t>=s){if(i<-s||i>=s)return this.globalTransformMatrix;p=7*(2*(o*(l+1)+o+f)+((n=i>this._kX*(t-r)+m)?1:0)),this._matrixCahce[p]>0?g.copyFromArray(y,p+1):(v=(f+1)*(h+2)-2,b=this._hullCache[4],S=this._hullCache[5],A=this._hullCache[0]+f*b,C=this._hullCache[1]+f*S,x=this._vertices,n?this._getAffineTransform(r,m+c,800,c,A+b,C+S,x[v+h+2],x[v+h+3],A,C,e._helpTransform,g,!0):this._getAffineTransform(s,m,800,c,x[v],x[v+1],A,C,x[v+h+2],x[v+h+3],e._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty)}else if(i<-s){if(t<-s||t>=s)return this.globalTransformMatrix;p=7*(o*(l+1)+2*_+((n=i>this._kY*(t-d-u)-r)?1:0)),this._matrixCahce[p]>0?g.copyFromArray(y,p+1):(v=2*_,b=this._hullCache[10],S=this._hullCache[11],A=this._hullCache[8]+_*b,C=this._hullCache[9]+_*S,x=this._vertices,n?this._getAffineTransform(d+u,-s,u,800,x[v+2],x[v+3],x[v],x[v+1],A+b,C+S,e._helpTransform,g,!0):this._getAffineTransform(d,-r,u,800,A,C,A+b,C+S,x[v],x[v+1],e._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty)}else if(i>=s){if(t<-s||t>=s)return this.globalTransformMatrix;p=7*(2*(o*(l+1)+o+l+f)+((n=i>this._kY*(t-d-u)+s)?1:0)),this._matrixCahce[p]>0?g.copyFromArray(y,p+1):(v=l*(h+2)+2*_,b=this._hullCache[10],S=this._hullCache[11],A=this._hullCache[6]-(o-_)*b,C=this._hullCache[7]-(o-_)*S,x=this._vertices,n?this._getAffineTransform(d+u,r,u,800,A+b,C+S,A,C,x[v+2],x[v+3],e._helpTransform,g,!0):this._getAffineTransform(d,s,u,800,x[v],x[v+1],x[v+2],x[v+3],A,C,e._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty)}else p=7*(2*(o*f+_)+((n=i>this._k*(t-d-u)+m)?1:0)),this._matrixCahce[p]>0?g.copyFromArray(y,p+1):(v=2*_+f*(h+2),x=this._vertices,n?this._getAffineTransform(d+u,m+c,u,c,x[v+h+4],x[v+h+5],x[v+h+2],x[v+h+3],x[v+2],x[v+3],e._helpTransform,g,!0):this._getAffineTransform(d,m,u,c,x[v],x[v+1],x[v+2],x[v+3],x[v+h+2],x[v+h+3],e._helpTransform,g,!1),y[p]=1,y[p+1]=g.a,y[p+2]=g.b,y[p+3]=g.c,y[p+4]=g.d,y[p+5]=g.tx,y[p+6]=g.ty);return g},e.prototype.init=function(e,i){if(null===this._boneData){t.prototype.init.call(this,e,i);var r=e.segmentX,n=e.segmentY,s=e.vertices.length;this._dX=400/r,this._dY=400/n,this._k=-this._dY/this._dX,this._kX=-this._dY/800,this._kY=-800/this._dX,this._vertices.length=s,this._deformVertices.length=s,this._matrixCahce.length=14*(r*n+2*r+2*n),this._hullCache.length=10;for(var a=0;a<s;++a)this._deformVertices[a]=0}},e.prototype.update=function(t){if(this._blendState.dirty=!1,t>=0&&null!==this._cachedFrameIndices){var i=this._cachedFrameIndices[t];if(i>=0&&this._cachedFrameIndex===i)this._transformDirty=!1;else if(i>=0)this._transformDirty=!0,this._cachedFrameIndex=i;else{if(this._hasConstraint)for(var r=0,n=this._armature._constraints;r<n.length;r++)(o=n[r])._root===this&&o.update();this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(var s=0,a=this._armature._constraints;s<a.length;s++){var o;(o=a[s])._root===this&&o.update()}(this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1)}if(this._transformDirty){this._transformDirty=!1,this._childrenTransformDirty=!0;for(var l=0,h=this._matrixCahce.length;l<h;l+=7)this._matrixCahce[l]=-1;if(this._updateVertices(),this._cachedFrameIndex<0){var u=t>=0;this._localDirty&&this._updateGlobalTransformMatrix(u),u&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);var c=2*this.global.x,_=2*this.global.y,f=e._helpPoint;this.globalTransformMatrix.transformPoint(1e3,-200,f),this._hullCache[0]=f.x,this._hullCache[1]=f.y,this._hullCache[2]=c-f.x,this._hullCache[3]=_-f.y,this.globalTransformMatrix.transformPoint(0,this._dY,f,!0),this._hullCache[4]=f.x,this._hullCache[5]=f.y,this.globalTransformMatrix.transformPoint(200,1e3,f),this._hullCache[6]=f.x,this._hullCache[7]=f.y,this._hullCache[8]=c-f.x,this._hullCache[9]=_-f.y,this.globalTransformMatrix.transformPoint(this._dX,0,f,!0),this._hullCache[10]=f.x,this._hullCache[11]=f.y}else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},e}(t.Bone);t.Surface=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._localMatrix=new t.Matrix,i._colorTransform=new t.ColorTransform,i._displayDatas=[],i._displayList=[],i._deformVertices=null,i._rawDisplay=null,i._meshDisplay=null,i}return gnt(i,e),i.prototype._onClear=function(){e.prototype._onClear.call(this);for(var i=[],r=0,n=this._displayList;r<n.length;r++)null!==(o=n[r])&&o!==this._rawDisplay&&o!==this._meshDisplay&&i.indexOf(o)<0&&i.push(o);for(var s=0,a=i;s<a.length;s++){var o;(o=a[s])instanceof t.Armature?o.dispose():this._disposeDisplay(o,!0)}null!==this._deformVertices&&this._deformVertices.returnToPool(),null!==this._meshDisplay&&this._meshDisplay!==this._rawDisplay&&this._disposeDisplay(this._meshDisplay,!1),null!==this._rawDisplay&&this._disposeDisplay(this._rawDisplay,!1),this.displayController=null,this._displayDirty=!1,this._zOrderDirty=!1,this._blendModeDirty=!1,this._colorDirty=!1,this._transformDirty=!1,this._visible=!0,this._blendMode=0,this._displayIndex=-1,this._animationDisplayIndex=-1,this._zOrder=0,this._cachedFrameIndex=-1,this._pivotX=0,this._pivotY=0,this._localMatrix.identity(),this._colorTransform.identity(),this._displayList.length=0,this._displayDatas.length=0,this._slotData=null,this._rawDisplayDatas=null,this._displayData=null,this._boundingBoxData=null,this._textureData=null,this._deformVertices=null,this._rawDisplay=null,this._meshDisplay=null,this._display=null,this._childArmature=null,this._parent=null,this._cachedFrameIndices=null},i.prototype._getDefaultRawDisplayData=function(t){var e=this._armature._armatureData.defaultSkin;if(null!==e){var i=e.getDisplays(this._slotData.name);if(null!==i)return t<i.length?i[t]:null}return null},i.prototype._updateDisplayData=function(){var e=this._displayData,r=null!==this._deformVertices?this._deformVertices.verticesData:null,n=this._textureData,s=null,a=null;if(this._displayData=null,this._boundingBoxData=null,this._textureData=null,this._displayIndex>=0&&(null!==this._rawDisplayDatas&&(s=this._displayIndex<this._rawDisplayDatas.length?this._rawDisplayDatas[this._displayIndex]:null),null===s&&(s=this._getDefaultRawDisplayData(this._displayIndex)),this._displayIndex<this._displayDatas.length&&(this._displayData=this._displayDatas[this._displayIndex])),null!==this._displayData&&(2===this._displayData.type||4===this._displayData.type?a=this._displayData.vertices:null!==s&&(2===s.type||4===s.type)&&(a=s.vertices),3===this._displayData.type?this._boundingBoxData=this._displayData.boundingBox:null!==s&&3===s.type&&(this._boundingBoxData=s.boundingBox),(0===this._displayData.type||2===this._displayData.type)&&(this._textureData=this._displayData.texture)),this._displayData!==e||a!==r||this._textureData!==n){if(null===a&&null!==this._textureData){var o=this._displayData,l=this._textureData.parent.scale*this._armature._armatureData.scale,h=this._textureData.frame;this._pivotX=o.pivot.x,this._pivotY=o.pivot.y;var u=null!==h?h:this._textureData.region,c=u.width,_=u.height;this._textureData.rotated&&null===h&&(c=u.height,_=u.width),this._pivotX*=c*l,this._pivotY*=_*l,null!==h&&(this._pivotX+=h.x*l,this._pivotY+=h.y*l),null!==this._displayData&&null!==s&&this._displayData!==s&&(s.transform.toMatrix(i._helpMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(0,0,i._helpPoint),this._pivotX-=i._helpPoint.x,this._pivotY-=i._helpPoint.y,this._displayData.transform.toMatrix(i._helpMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(0,0,i._helpPoint),this._pivotX+=i._helpPoint.x,this._pivotY+=i._helpPoint.y),t.DragonBones.yDown||(this._pivotY=(this._textureData.rotated?this._textureData.region.width:this._textureData.region.height)*l-this._pivotY)}else this._pivotX=0,this._pivotY=0;null!==s?this.origin=s.transform:null!==this._displayData?this.origin=this._displayData.transform:this.origin=null,a!==r?(null===this._deformVertices&&(this._deformVertices=t.BaseObject.borrowObject(t.DeformVertices)),this._deformVertices.init(a,this._armature)):null!==this._deformVertices&&this._textureData!==n&&(this._deformVertices.verticesDirty=!0),this._displayDirty=!0,this._transformDirty=!0}},i.prototype._updateDisplay=function(){var e=null!==this._display?this._display:this._rawDisplay,i=this._childArmature;this._displayIndex>=0&&this._displayIndex<this._displayList.length?(this._display=this._displayList[this._displayIndex],null!==this._display&&this._display instanceof t.Armature?(this._childArmature=this._display,this._display=this._childArmature.display):this._childArmature=null):(this._display=null,this._childArmature=null);var r=null!==this._display?this._display:this._rawDisplay;if(r!==e&&(this._onUpdateDisplay(),this._replaceDisplay(e),this._transformDirty=!0,this._visibleDirty=!0,this._blendModeDirty=!0,this._colorDirty=!0),r!==this._rawDisplay&&r!==this._meshDisplay||this._updateFrame(),this._childArmature!==i&&(null!==i&&(i._parent=null,i.clock=null,i.inheritAnimation&&i.animation.reset()),null!==this._childArmature&&(this._childArmature._parent=this,this._childArmature.clock=this._armature.clock,this._childArmature.inheritAnimation))){if(0===this._childArmature.cacheFrameRate){var n=this._armature.cacheFrameRate;0!==n&&(this._childArmature.cacheFrameRate=n)}var s=null;if(null!==this._displayData&&1===this._displayData.type)s=this._displayData.actions;else if(this._displayIndex>=0&&null!==this._rawDisplayDatas){var a=this._displayIndex<this._rawDisplayDatas.length?this._rawDisplayDatas[this._displayIndex]:null;null===a&&(a=this._getDefaultRawDisplayData(this._displayIndex)),null!==a&&1===a.type&&(s=a.actions)}if(null!==s&&s.length>0)for(var o=0,l=s;o<l.length;o++){var h=l[o],u=t.BaseObject.borrowObject(t.EventObject);t.EventObject.actionDataToInstance(h,u,this._armature),u.slot=this,this._armature._bufferAction(u,!1)}else this._childArmature.animation.play()}},i.prototype._updateGlobalTransformMatrix=function(t){var e=0===this._parent._boneData.type?this._parent.globalTransformMatrix:this._parent._getGlobalTransformMatrix(this.global.x,this.global.y);this.globalTransformMatrix.copyFrom(this._localMatrix),this.globalTransformMatrix.concat(e),t?this.global.fromMatrix(this.globalTransformMatrix):this._globalDirty=!0},i.prototype._setDisplayIndex=function(t,e){if(void 0===e&&(e=!1),e){if(this._animationDisplayIndex===t)return!1;this._animationDisplayIndex=t}return this._displayIndex!==t&&(this._displayIndex=t,this._displayDirty=!0,this._updateDisplayData(),this._displayDirty)},i.prototype._setZorder=function(t){return this._zOrder,this._zOrder=t,this._zOrderDirty=!0,this._zOrderDirty},i.prototype._setColor=function(t){return this._colorTransform.copyFrom(t),this._colorDirty=!0,this._colorDirty},i.prototype._setDisplayList=function(e){if(null!==e&&e.length>0){this._displayList.length!==e.length&&(this._displayList.length=e.length);for(var i=0,r=e.length;i<r;++i){var n=e[i];null!==n&&n!==this._rawDisplay&&n!==this._meshDisplay&&!(n instanceof t.Armature)&&this._displayList.indexOf(n)<0&&this._initDisplay(n,!0),this._displayList[i]=n}}else this._displayList.length>0&&(this._displayList.length=0);return this._displayIndex>=0&&this._displayIndex<this._displayList.length?this._displayDirty=this._display!==this._displayList[this._displayIndex]:this._displayDirty=null!==this._display,this._updateDisplayData(),this._displayDirty},i.prototype.init=function(t,e,i,r){if(null===this._slotData){this._slotData=t,this._isFromCache=!1,this._visibleDirty=!0,this._blendModeDirty=!0,this._colorDirty=!0,this._blendMode=this._slotData.blendMode,this._zOrder=this._slotData.zOrder,this._colorTransform.copyFrom(this._slotData.color),this._rawDisplay=i,this._meshDisplay=r,this._armature=e;var n=this._armature.getBone(this._slotData.parent.name);null!==n&&(this._parent=n),this._armature._addSlot(this),this._initDisplay(this._rawDisplay,!1),this._rawDisplay!==this._meshDisplay&&this._initDisplay(this._meshDisplay,!1),this._onUpdateDisplay(),this._addDisplay()}},i.prototype.update=function(t){if(this._isFromCache=!1,this._displayDirty&&(this._displayDirty=!1,this._updateDisplay(),this._transformDirty&&(null!==this.origin?this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix):this.global.copyFrom(this.offset).toMatrix(this._localMatrix))),this._zOrderDirty&&(this._zOrderDirty=!1,this._updateZOrder()),t>=0&&null!==this._cachedFrameIndices){var e=this._cachedFrameIndices[t];e>=0&&this._cachedFrameIndex===e?this._transformDirty=!1:e>=0?(this._transformDirty=!0,this._cachedFrameIndex=e):this._transformDirty||this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}else(this._transformDirty||this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1);if(null!==this._display){if(this._visibleDirty&&(this._visibleDirty=!1,this._updateVisible()),this._blendModeDirty&&(this._blendModeDirty=!1,this._updateBlendMode()),this._colorDirty&&(this._colorDirty=!1,this._updateColor()),null!==this._deformVertices&&null!==this._deformVertices.verticesData&&this._display===this._meshDisplay){var i=null!==this._deformVertices.verticesData.weight,r=0!==this._parent._boneData.type;if((this._deformVertices.verticesDirty||i&&this._deformVertices.isBonesUpdate()||r&&this._parent._childrenTransformDirty)&&(this._deformVertices.verticesDirty=!1,this._updateMesh()),i||r)return}if(this._transformDirty){if(this._transformDirty=!1,this._cachedFrameIndex<0){var n=t>=0;this._updateGlobalTransformMatrix(n),n&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._isFromCache=!0,this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);this._updateTransform()}}},i.prototype.updateTransformAndMatrix=function(){this._transformDirty&&(this._transformDirty=!1,this._updateGlobalTransformMatrix(!1))},i.prototype.replaceDisplayData=function(t,e){if(void 0===e&&(e=-1),e<0&&(e=this._displayIndex<0?0:this._displayIndex),this._displayDatas.length<=e){this._displayDatas.length=e+1;for(var i=0,r=this._displayDatas.length;i<r;++i)this._displayDatas[i]||(this._displayDatas[i]=null)}this._displayDatas[e]=t},i.prototype.containsPoint=function(t,e){return null!==this._boundingBoxData&&(this.updateTransformAndMatrix(),i._helpMatrix.copyFrom(this.globalTransformMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(t,e,i._helpPoint),this._boundingBoxData.containsPoint(i._helpPoint.x,i._helpPoint.y))},i.prototype.intersectsSegment=function(t,e,r,n,s,a,o){if(void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null),null===this._boundingBoxData)return 0;this.updateTransformAndMatrix(),i._helpMatrix.copyFrom(this.globalTransformMatrix),i._helpMatrix.invert(),i._helpMatrix.transformPoint(t,e,i._helpPoint),t=i._helpPoint.x,e=i._helpPoint.y,i._helpMatrix.transformPoint(r,n,i._helpPoint),r=i._helpPoint.x,n=i._helpPoint.y;var l=this._boundingBoxData.intersectsSegment(t,e,r,n,s,a,o);return l>0&&(1===l||2===l?null!==s?(this.globalTransformMatrix.transformPoint(s.x,s.y,s),null!==a&&(a.x=s.x,a.y=s.y)):null!==a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a):(null!==s&&this.globalTransformMatrix.transformPoint(s.x,s.y,s),null!==a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a)),null!==o&&(this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,!0),o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,!0),o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x))),l},i.prototype.invalidUpdate=function(){this._displayDirty=!0,this._transformDirty=!0},Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible!==t&&(this._visible=t,this._updateVisible())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){this._setDisplayIndex(t)&&this.update(-1)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._slotData.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat(),r=new Array;this._setDisplayList(e)&&this.update(-1);for(var n=0,s=i;n<s.length;n++)null!==(l=s[n])&&l!==this._rawDisplay&&l!==this._meshDisplay&&this._displayList.indexOf(l)<0&&r.indexOf(l)<0&&r.push(l);for(var a=0,o=r;a<o.length;a++){var l;(l=o[a])instanceof t.Armature||this._disposeDisplay(l,!0)}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"slotData",{get:function(){return this._slotData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rawDisplayDatas",{get:function(){return this._rawDisplayDatas},set:function(t){if(this._rawDisplayDatas!==t)if(this._displayDirty=!0,this._rawDisplayDatas=t,null!==this._rawDisplayDatas){this._displayDatas.length=this._rawDisplayDatas.length;for(var e=0,i=this._displayDatas.length;e<i;++e){var r=this._rawDisplayDatas[e];null===r&&(r=this._getDefaultRawDisplayData(e)),this._displayDatas[e]=r}}else this._displayDatas.length=0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayData",{get:function(){return this._displayData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"boundingBoxData",{get:function(){return this._boundingBoxData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rawDisplay",{get:function(){return this._rawDisplay},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshDisplay",{get:function(){return this._meshDisplay},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"display",{get:function(){return this._display},set:function(t){if(this._display!==t){var e=this._displayList.length;if(this._displayIndex<0&&0===e&&(this._displayIndex=0),!(this._displayIndex<0)){var i=this.displayList;e<=this._displayIndex&&(i.length=this._displayIndex+1),i[this._displayIndex]=t,this.displayList=i}}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"childArmature",{get:function(){return this._childArmature},set:function(t){this._childArmature!==t&&(this.display=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),i.prototype.getDisplay=function(){return this._display},i.prototype.setDisplay=function(t){this.display=t},i}(t.TransformObject);t.Slot=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return gnt(i,e),i.prototype._onClear=function(){this._armature=null,this._target=null,this._root=null,this._bone=null},Object.defineProperty(i.prototype,"name",{get:function(){return this._constraintData.name},enumerable:!0,configurable:!0}),i._helpMatrix=new t.Matrix,i._helpTransform=new t.Transform,i._helpPoint=new t.Point,i}(t.BaseObject);t.Constraint=e;var i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return gnt(i,e),i.toString=function(){return"[class dragonBones.IKConstraint]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this._scaleEnabled=!1,this._bendPositive=!1,this._weight=1,this._constraintData=null},i.prototype._computeA=function(){var e=this._target.global,i=this._root.global,r=this._root.globalTransformMatrix,n=Math.atan2(e.y-i.y,e.x-i.x);i.scaleX<0&&(n+=Math.PI),i.rotation+=t.Transform.normalizeRadian(n-i.rotation)*this._weight,i.toMatrix(r)},i.prototype._computeB=function(){var e=this._bone._boneData.length,i=this._root,r=this._target.global,n=i.global,s=this._bone.global,a=this._bone.globalTransformMatrix,o=a.a*e,l=a.b*e,h=o*o+l*l,u=Math.sqrt(h),c=s.x-n.x,_=s.y-n.y,f=c*c+_*_,p=Math.sqrt(f),d=s.rotation,m=n.rotation,y=Math.atan2(_,c),g=(c=r.x-n.x)*c+(_=r.y-n.y)*_,v=Math.sqrt(g),b=0;if(u+p<=v||v+u<=p||v+p<=u)b=Math.atan2(r.y-n.y,r.x-n.x),u+p<=v||p<u&&(b+=Math.PI);else{var S=(f-h+g)/(2*g),A=Math.sqrt(f-S*S*g)/v,C=n.x+c*S,x=n.y+_*S,T=-_*A,w=c*A,E=!1,B=i.parent;if(null!==B){var D=B.globalTransformMatrix;E=D.a*D.d-D.b*D.c<0}E!==this._bendPositive?(s.x=C-T,s.y=x-w):(s.x=C+T,s.y=x+w),b=Math.atan2(s.y-n.y,s.x-n.x)}var M=t.Transform.normalizeRadian(b-y);n.rotation=m+M*this._weight,n.toMatrix(i.globalTransformMatrix);var P=y+M*this._weight;s.x=n.x+Math.cos(P)*p,s.y=n.y+Math.sin(P)*p;var R=Math.atan2(r.y-s.y,r.x-s.x);s.scaleX<0&&(R+=Math.PI),s.rotation=n.rotation+d-m+t.Transform.normalizeRadian(R-M-d)*this._weight,s.toMatrix(a)},i.prototype.init=function(t,e){if(null===this._constraintData){this._constraintData=t,this._armature=e,this._target=this._armature.getBone(this._constraintData.target.name),this._root=this._armature.getBone(this._constraintData.root.name),this._bone=null!==this._constraintData.bone?this._armature.getBone(this._constraintData.bone.name):null;var i=this._constraintData;this._scaleEnabled=i.scaleEnabled,this._bendPositive=i.bendPositive,this._weight=i.weight,this._root._hasConstraint=!0}},i.prototype.update=function(){this._root.updateByConstraint(),null!==this._bone?(this._bone.updateByConstraint(),this._computeB()):this._computeA()},i.prototype.invalidUpdate=function(){this._root.invalidUpdate(),null!==this._bone&&this._bone.invalidUpdate()},i}(e);t.IKConstraint=i;var r=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._bones=[],t._spaces=[],t._positions=[],t._curves=[],t._boneLengths=[],t._pathGlobalVertices=[],t._segments=[10],t}return gnt(i,e),i.toString=function(){return"[class dragonBones.PathConstraint]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.dirty=!1,this.pathOffset=0,this.position=0,this.spacing=0,this.rotateOffset=0,this.rotateMix=1,this.translateMix=1,this._pathSlot=null,this._bones.length=0,this._spaces.length=0,this._positions.length=0,this._curves.length=0,this._boneLengths.length=0,this._pathGlobalVertices.length=0},i.prototype._updatePathVertices=function(t){var e=this._armature,i=e.armatureData.parent,r=e.armatureData.scale,n=i.intArray,s=i.floatArray,a=t.offset,o=n[a+0],l=n[a+2];this._pathGlobalVertices.length=2*o;var h=t.weight;if(null!==h)for(var u=this._pathSlot._deformVertices.bones,c=h.bones.length,_=h.offset,f=n[_+1],p=_+2+c,d=(x=0,0);x<o;x++){for(var m=0,y=0,g=0,v=n[p++];g<v;g++){var b=u[n[p++]];if(null!==b){b.updateByConstraint(),C=b.globalTransformMatrix;var S=s[f++];w=s[f++]*r,E=s[f++]*r,m+=(C.a*w+C.c*E+C.tx)*S,y+=(C.b*w+C.d*E+C.ty)*S}}this._pathGlobalVertices[d++]=m,this._pathGlobalVertices[d++]=y}else{var A=this._pathSlot.parent;A.updateByConstraint();for(var C=A.globalTransformMatrix,x=0,T=l;x<o;x+=2){var w=s[T++]*r,E=s[T++]*r,B=C.a*w+C.c*E+C.tx,D=C.b*w+C.d*E+C.ty;this._pathGlobalVertices[x]=B,this._pathGlobalVertices[x+1]=D}}},i.prototype._computeVertices=function(t,e,i,r){for(var n=i,s=t;n<e;n+=2)r[n]=this._pathGlobalVertices[s++],r[n+1]=this._pathGlobalVertices[s++]},i.prototype._computeBezierCurve=function(t,e,i,r,n){var s=this._armature.armatureData.parent.intArray[t.vertices.offset+0],a=this._positions,o=this._spaces,l=t.closed,h=Array(),u=2*s,c=u/6,_=-1,f=this.position;a.length=3*e+2;var p=0;if(t.constantSpeed){l?(u+=2,h.length=s,this._computeVertices(2,u-4,0,h),this._computeVertices(0,2,u-4,h),h[u-2]=h[0],h[u-1]=h[1]):(c--,u-=4,h.length=u,this._computeVertices(2,u,0,h));var d=new Array(c);p=0;for(var m,y,g,v,b,S,A,C,x=h[0],T=h[1],w=0,E=0,B=0,D=0,M=0,P=0,R=(U=0,2);U<c;U++,R+=6)w=h[R],E=h[R+1],B=h[R+2],D=h[R+3],b=2*(m=.1875*(x-2*w+B))+(g=.09375*(3*(w-B)-x+(M=h[R+4]))),S=2*(y=.1875*(T-2*E+D))+(v=.09375*(3*(E-D)-T+(P=h[R+5]))),A=.75*(w-x)+m+.16666667*g,C=.75*(E-T)+y+.16666667*v,p+=Math.sqrt(A*A+C*C),A+=b,C+=S,b+=g,S+=v,p+=Math.sqrt(A*A+C*C),A+=b,C+=S,p+=Math.sqrt(A*A+C*C),A+=b+g,C+=S+v,p+=Math.sqrt(A*A+C*C),d[U]=p,x=M,T=P;if(r&&(f*=p),n)for(U=0;U<e;U++)o[U]*=p;for(var I=this._segments,O=0,F=(U=0,H=0,j=0,0);U<e;U++,H+=3){var L=f+=o[U];if(l)(L%=p)<0&&(L+=p),j=0;else{if(L<0)continue;if(L>p)continue}for(;;j++){var V=d[j];if(!(L>V)){0===j?L/=V:L=(L-(G=d[j-1]))/(V-G);break}}if(j!==_){_=j;var k=6*j;for(x=h[k],T=h[k+1],w=h[k+2],E=h[k+3],B=h[k+4],D=h[k+5],b=2*(m=.03*(x-2*w+B))+(g=.006*(3*(w-B)-x+(M=h[k+6]))),S=2*(y=.03*(T-2*E+D))+(v=.006*(3*(E-D)-T+(P=h[k+7]))),A=.3*(w-x)+m+.16666667*g,C=.3*(E-T)+y+.16666667*v,O=Math.sqrt(A*A+C*C),I[0]=O,k=1;k<8;k++)A+=b,C+=S,b+=g,S+=v,O+=Math.sqrt(A*A+C*C),I[k]=O;A+=b,C+=S,O+=Math.sqrt(A*A+C*C),I[8]=O,A+=b+g,C+=S+v,O+=Math.sqrt(A*A+C*C),I[9]=O,F=0}for(L*=O;;F++){var N=I[F];if(!(L>N)){var G;0===F?L/=N:L=F+(L-(G=I[F-1]))/(N-G);break}}this.addCurvePosition(.1*L,x,T,w,E,B,D,M,P,a,H,i)}}else{var z=t.curveLengths;if(p=z[c-=l?1:2],r&&(f*=p),n)for(var U=0;U<e;U++)o[U]*=p;h.length=8;U=0;for(var H=0,j=0;U<e;U++,H+=3){if(f+=o[U],l)(f%=p)<0&&(f+=p),j=0;else{if(f<0)continue;if(f>p)continue}for(var W=0;;j++){var X=z[j];if(!(f>X)){if(0===j)W=f/X;else{var Y=z[j-1];W=(f-Y)/(X-Y)}break}}j!==_&&(_=j,l&&j===c?(this._computeVertices(u-4,4,0,h),this._computeVertices(0,4,4,h)):this._computeVertices(6*j+2,8,0,h)),this.addCurvePosition(W,h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],a,H,i)}}},i.prototype.addCurvePosition=function(t,e,i,r,n,s,a,o,l,h,u,c){if(0===t)return h[u]=e,h[u+1]=i,void(h[u+2]=0);if(1===t)return h[u]=o,h[u+1]=l,void(h[u+2]=0);var _=1-t,f=_*_,p=t*t,d=f*_,m=f*t*3,y=_*p*3,g=t*p,v=d*e+m*r+y*s+g*o,b=d*i+m*n+y*a+g*l;h[u]=v,h[u+1]=b,h[u+2]=c?Math.atan2(b-(d*i+m*n+y*a),v-(d*e+m*r+y*s)):0},i.prototype.init=function(t,e){this._constraintData=t,this._armature=e;var i=t;this.pathOffset=i.pathDisplayData.vertices.offset,this.position=i.position,this.spacing=i.spacing,this.rotateOffset=i.rotateOffset,this.rotateMix=i.rotateMix,this.translateMix=i.translateMix,this._root=this._armature.getBone(i.root.name),this._target=this._armature.getBone(i.target.name),this._pathSlot=this._armature.getSlot(i.pathSlot.name);for(var r=0,n=i.bones.length;r<n;r++){var s=this._armature.getBone(i.bones[r].name);null!==s&&this._bones.push(s)}2===i.rotateMode&&(this._boneLengths.length=this._bones.length),this._root._hasConstraint=!0},i.prototype.update=function(){var e=this._pathSlot;if(null!==e._deformVertices&&null!==e._deformVertices.verticesData&&e._deformVertices.verticesData.offset===this.pathOffset){var i=this._constraintData,r=e._displayData,n=!1,s=e._deformVertices;if(this._root._childrenTransformDirty?(this._updatePathVertices(r.vertices),n=!0):null!==s&&(s.verticesDirty||s.isBonesUpdate())&&(this._updatePathVertices(r.vertices),s.verticesDirty=!1,n=!0),n||this.dirty){var a=i.positionMode,o=i.spacingMode,l=i.rotateMode,h=this._bones,u=0===o,c=2===l,_=0===l,f=h.length,p=_?f:f+1,d=this.spacing,m=this._spaces;if(m.length=p,c||u){m[0]=0;for(var y=0,g=p-1;y<g;y++){(P=h[y]).updateByConstraint();var v=P._boneData.length,b=v*(R=P.globalTransformMatrix).a,S=v*R.b,A=Math.sqrt(b*b+S*S);c&&(this._boneLengths[y]=A),m[y+1]=(v+d)*A/v}}else for(y=0;y<p;y++)m[y]=d;this._computeBezierCurve(r,p,_,1===a,2===o);var C,x=this._positions,T=this.rotateOffset,w=x[0],E=x[1];0===T?C=1===l:(C=!1,null!==(P=e.parent)&&(T*=(R=P.globalTransformMatrix).a*R.d-R.b*R.c>0?t.Transform.DEG_RAD:-t.Transform.DEG_RAD));for(var B=this.rotateMix,D=this.translateMix,M=(y=0,3);y<f;y++,M+=3){var P,R;(P=h[y]).updateByConstraint(),(R=P.globalTransformMatrix).tx+=(w-R.tx)*D,R.ty+=(E-R.ty)*D;var I=(b=x[M])-w,O=(S=x[M+1])-E;if(c){var F=this._boneLengths[y],L=(Math.sqrt(I*I+O*O)/F-1)*B+1;R.a*=L,R.b*=L}if(w=b,E=S,B>0){var V=R.a,k=R.b,N=R.c,G=R.d,z=void 0,U=void 0,H=void 0;if(z=_?x[M-1]:Math.atan2(O,I),z-=Math.atan2(k,V),C){U=Math.cos(z),H=Math.sin(z);var j=P._boneData.length;w+=(j*(U*V-H*k)-I)*B,E+=(j*(H*V+U*k)-O)*B}else z+=T;z>t.Transform.PI?z-=t.Transform.PI_D:z<-t.Transform.PI&&(z+=t.Transform.PI_D),z*=B,U=Math.cos(z),H=Math.sin(z),R.a=U*V-H*k,R.b=H*V+U*k,R.c=U*N-H*G,R.d=H*N+U*G}P.global.fromMatrix(R)}this.dirty=!1}}},i.prototype.invalidUpdate=function(){},i}(e);t.PathConstraint=r}(vnt||(vnt={})),function(t){var e=function(){function t(t){void 0===t&&(t=0),this.time=0,this.timeScale=1,this._systemTime=0,this._animatebles=[],this._clock=null,this.time=t,this._systemTime=.001*(new Date).getTime()}return t.prototype.advanceTime=function(t){t!=t&&(t=0);var e=.001*Date.now();if(t<0&&(t=e-this._systemTime),this._systemTime=e,1!==this.timeScale&&(t*=this.timeScale),0!==t){t<0?this.time-=t:this.time+=t;for(var i=0,r=0,n=this._animatebles.length;i<n;++i){var s=this._animatebles[i];null!==s?(r>0&&(this._animatebles[i-r]=s,this._animatebles[i]=null),s.advanceTime(t)):r++}if(r>0){for(n=this._animatebles.length;i<n;++i){var a=this._animatebles[i];null!==a?this._animatebles[i-r]=a:r++}this._animatebles.length-=r}}},t.prototype.contains=function(t){if(t===this)return!1;for(var e=t;e!==this&&null!==e;)e=e.clock;return e===this},t.prototype.add=function(t){this._animatebles.indexOf(t)<0&&(this._animatebles.push(t),t.clock=this)},t.prototype.remove=function(t){var e=this._animatebles.indexOf(t);e>=0&&(this._animatebles[e]=null,t.clock=null)},t.prototype.clear=function(){for(var t=0,e=this._animatebles;t<e.length;t++){var i=e[t];null!==i&&(i.clock=null)}},Object.defineProperty(t.prototype,"clock",{get:function(){return this._clock},set:function(t){this._clock!==t&&(null!==this._clock&&this._clock.remove(this),this._clock=t,null!==this._clock&&this._clock.add(this))},enumerable:!0,configurable:!0}),t.clock=new t,t}();t.WorldClock=e}(vnt||(vnt={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._animationNames=[],t._animationStates=[],t._animations={},t._animationConfig=null,t}return gnt(i,e),i.toString=function(){return"[class dragonBones.Animation]"},i.prototype._onClear=function(){for(var t=0,e=this._animationStates;t<e.length;t++)e[t].returnToPool();for(var i in this._animations)delete this._animations[i];null!==this._animationConfig&&this._animationConfig.returnToPool(),this.timeScale=1,this._lockUpdate=!1,this._animationDirty=!1,this._inheritTimeScale=1,this._animationNames.length=0,this._animationStates.length=0,this._armature=null,this._animationConfig=null,this._lastAnimationState=null},i.prototype._fadeOut=function(t){switch(t.fadeOutMode){case 1:for(var e=0,i=this._animationStates;e<i.length;e++)null===(h=i[e])._parent&&h.layer===t.layer&&h.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case 2:for(var r=0,n=this._animationStates;r<n.length;r++)null===(h=n[r])._parent&&h.group===t.group&&h.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case 3:for(var s=0,a=this._animationStates;s<a.length;s++)null===(h=a[s])._parent&&h.layer===t.layer&&h.group===t.group&&h.fadeOut(t.fadeOutTime,t.pauseFadeOut);break;case 4:for(var o=0,l=this._animationStates;o<l.length;o++){var h;null===(h=l[o])._parent&&h.fadeOut(t.fadeOutTime,t.pauseFadeOut)}}},i.prototype.init=function(e){null===this._armature&&(this._armature=e,this._animationConfig=t.BaseObject.borrowObject(t.AnimationConfig))},i.prototype.advanceTime=function(t){t<0&&(t=-t),this._armature.inheritAnimation&&null!==this._armature._parent?this._inheritTimeScale=this._armature._parent._armature.animation._inheritTimeScale*this.timeScale:this._inheritTimeScale=this.timeScale,1!==this._inheritTimeScale&&(t*=this._inheritTimeScale);var e=this._animationStates.length;if(1===e)if((p=this._animationStates[0])._fadeState>0&&p._subFadeState>0)this._armature._dragonBones.bufferObject(p),this._animationStates.length=0,this._lastAnimationState=null;else{var i=p._animationData,r=i.cacheFrameRate;if(this._animationDirty&&r>0){this._animationDirty=!1;for(var n=0,s=this._armature.getBones();n<s.length;n++){var a=s[n];a._cachedFrameIndices=i.getBoneCachedFrameIndices(a.name)}for(var o=0,l=this._armature.getSlots();o<l.length;o++){var h=l[o],u=h.rawDisplayDatas;if(null!==u&&u.length>0){var c=u[0];if(null!==c&&c.parent===this._armature.armatureData.defaultSkin){h._cachedFrameIndices=i.getSlotCachedFrameIndices(h.name);continue}}h._cachedFrameIndices=null}}p.advanceTime(t,r)}else if(e>1){for(var _=0,f=0;_<e;++_){var p;(p=this._animationStates[_])._fadeState>0&&p._subFadeState>0?(f++,this._armature._dragonBones.bufferObject(p),this._animationDirty=!0,this._lastAnimationState===p&&(this._lastAnimationState=null)):(f>0&&(this._animationStates[_-f]=p),p.advanceTime(t,0)),_===e-1&&f>0&&(this._animationStates.length-=f,null===this._lastAnimationState&&this._animationStates.length>0&&(this._lastAnimationState=this._animationStates[this._animationStates.length-1]))}this._armature._cacheFrameIndex=-1}else this._armature._cacheFrameIndex=-1},i.prototype.reset=function(){for(var t=0,e=this._animationStates;t<e.length;t++)e[t].returnToPool();this._animationDirty=!1,this._animationConfig.clear(),this._animationStates.length=0,this._lastAnimationState=null},i.prototype.stop=function(t){if(void 0===t&&(t=null),null!==t)null!==(r=this.getState(t))&&r.stop();else for(var e=0,i=this._animationStates;e<i.length;e++){var r;(r=i[e]).stop()}},i.prototype.playConfig=function(e){var i=e.animation;if(!(i in this._animations))return console.warn("Non-existent animation.\n","DragonBones name: "+this._armature.armatureData.parent.name,"Armature name: "+this._armature.name,"Animation name: "+i),null;var r=this._animations[i];if(5===e.fadeOutMode)for(var n=0,s=this._animationStates;n<s.length;n++){var a=s[n];if(a._animationData===r)return a}0===this._animationStates.length?e.fadeInTime=0:e.fadeInTime<0&&(e.fadeInTime=r.fadeInTime),e.fadeOutTime<0&&(e.fadeOutTime=e.fadeInTime),e.timeScale<=-100&&(e.timeScale=1/r.scale),r.frameCount>1?(e.position<0?(e.position%=r.duration,e.position=r.duration-e.position):e.position===r.duration?e.position-=1e-6:e.position>r.duration&&(e.position%=r.duration),e.duration>0&&e.position+e.duration>r.duration&&(e.duration=r.duration-e.position),e.playTimes<0&&(e.playTimes=r.playTimes)):(e.playTimes=1,e.position=0,e.duration>0&&(e.duration=0)),0===e.duration&&(e.duration=-1),this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);if(o.init(this._armature,r,e),this._animationDirty=!0,this._armature._cacheFrameIndex=-1,this._animationStates.length>0){for(var l=!1,h=0,u=this._animationStates.length;h<u;++h){if(o.layer>this._animationStates[h].layer){l=!0,this._animationStates.splice(h,0,o);break}if(h!==u-1&&o.layer>this._animationStates[h+1].layer){l=!0,this._animationStates.splice(h+1,0,o);break}}l||this._animationStates.push(o)}else this._animationStates.push(o);for(var c=0,_=this._armature.getSlots();c<_.length;c++){var f=_[c].childArmature;null!==f&&f.inheritAnimation&&f.animation.hasAnimation(i)&&null===f.animation.getState(i)&&f.animation.fadeIn(i)}var p=!1;for(var d in r.animationTimelines){this._lockUpdate||(p=!0,this._lockUpdate=!0);var m=this.fadeIn(d,e.fadeInTime,1,o.layer,null,0);null!==m&&(m.resetToPose=!1,m._parent=o,m.stop())}return p&&(this._lockUpdate=!1),this._lockUpdate||(e.fadeInTime<=0&&this._armature.advanceTime(0),this._lastAnimationState=o),o},i.prototype.play=function(t,e){if(void 0===t&&(t=null),void 0===e&&(e=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=e,this._animationConfig.fadeInTime=0,this._animationConfig.animation=null!==t?t:"",null!==t&&t.length>0)this.playConfig(this._animationConfig);else if(null===this._lastAnimationState){var i=this._armature.armatureData.defaultAnimation;null!==i&&(this._animationConfig.animation=i.name,this.playConfig(this._animationConfig))}else this._lastAnimationState.isPlaying||this._lastAnimationState.isCompleted?(this._animationConfig.animation=this._lastAnimationState.name,this.playConfig(this._animationConfig)):this._lastAnimationState.play();return this._lastAnimationState},i.prototype.fadeIn=function(t,e,i,r,n,s){return void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===r&&(r=0),void 0===n&&(n=null),void 0===s&&(s=3),this._animationConfig.clear(),this._animationConfig.fadeOutMode=s,this._animationConfig.playTimes=i,this._animationConfig.layer=r,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=null!==n?n:"",this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByTime=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.position=e,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t,this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByFrame=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;return null!==r&&(this._animationConfig.position=r.duration*e/r.frameCount),this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByProgress=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;return null!==r&&(this._animationConfig.position=r.duration*(e>0?e:0)),this.playConfig(this._animationConfig)},i.prototype.gotoAndStopByTime=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByTime(t,e,1);return null!==i&&i.stop(),i},i.prototype.gotoAndStopByFrame=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByFrame(t,e,1);return null!==i&&i.stop(),i},i.prototype.gotoAndStopByProgress=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByProgress(t,e,1);return null!==i&&i.stop(),i},i.prototype.getState=function(t){for(var e=this._animationStates.length;e--;){var i=this._animationStates[e];if(i.name===t)return i}return null},i.prototype.hasAnimation=function(t){return t in this._animations},i.prototype.getStates=function(){return this._animationStates},Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t<e.length;t++)if(e[t].isPlaying)return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isCompleted",{get:function(){for(var t=0,e=this._animationStates;t<e.length;t++)if(!e[t].isCompleted)return!1;return this._animationStates.length>0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return null!==this._lastAnimationState?this._lastAnimationState.name:""},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations!==t){for(var e in this._animationNames.length=0,this._animations)delete this._animations[e];for(var e in t)this._animationNames.push(e),this._animations[e]=t[e]}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationConfig",{get:function(){return this._animationConfig.clear(),this._animationConfig},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:!0,configurable:!0}),i.prototype.gotoAndPlay=function(t,e,i,r,n,s,a){void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===r&&(r=-1),void 0===n&&(n=0),void 0===s&&(s=null),void 0===a&&(a=3),console.warn("Deprecated."),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.fadeOutMode=a,this._animationConfig.playTimes=r,this._animationConfig.layer=n,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=null!==s?s:"";var o=this._animations[t];return o&&i>0&&(this._animationConfig.timeScale=o.duration/i),this.playConfig(this._animationConfig)},i.prototype.gotoAndStop=function(t,e){return void 0===e&&(e=0),console.warn("Deprecated."),this.gotoAndStopByTime(t,e)},Object.defineProperty(i.prototype,"animationList",{get:function(){return console.warn("Deprecated."),this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationDataList",{get:function(){console.warn("Deprecated.");for(var t=[],e=0,i=this._animationNames.length;e<i;++e)t.push(this._animations[this._animationNames[e]]);return t},enumerable:!0,configurable:!0}),i}(t.BaseObject);t.Animation=e}(vnt||(vnt={})),function(t){var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._blendState=new r,t._boneMask=[],t._boneTimelines=[],t._surfaceTimelines=[],t._slotTimelines=[],t._constraintTimelines=[],t._animationTimelines=[],t._poseTimelines=[],t._bonePoses={},t._actionTimeline=null,t._zOrderTimeline=null,t._parent=null,t}return gnt(n,e),n.toString=function(){return"[class dragonBones.AnimationState]"},n.prototype._onClear=function(){for(var t=0,e=this._boneTimelines;t<e.length;t++)e[t].returnToPool();for(var i=0,r=this._surfaceTimelines;i<r.length;i++)r[i].returnToPool();for(var n=0,s=this._slotTimelines;n<s.length;n++)s[n].returnToPool();for(var a=0,o=this._constraintTimelines;a<o.length;a++)o[a].returnToPool();for(var l=0,h=this._animationTimelines;l<h.length;l++)h[l].returnToPool();for(var u in this._bonePoses)this._bonePoses[u].returnToPool(),delete this._bonePoses[u];null!==this._actionTimeline&&this._actionTimeline.returnToPool(),null!==this._zOrderTimeline&&this._zOrderTimeline.returnToPool(),this.actionEnabled=!1,this.additiveBlending=!1,this.displayControl=!1,this.resetToPose=!1,this.playTimes=1,this.layer=0,this.timeScale=1,this.weight=1,this.autoFadeOutTime=0,this.fadeTotalTime=0,this.name="",this.group="",this._timelineDirty=2,this._playheadState=0,this._fadeState=-1,this._subFadeState=-1,this._position=0,this._duration=0,this._fadeTime=0,this._time=0,this._fadeProgress=0,this._weightResult=0,this._blendState.clear(),this._boneMask.length=0,this._boneTimelines.length=0,this._surfaceTimelines.length=0,this._slotTimelines.length=0,this._constraintTimelines.length=0,this._animationTimelines.length=0,this._poseTimelines.length=0,this._animationData=null,this._armature=null,this._actionTimeline=null,this._zOrderTimeline=null,this._parent=null},n.prototype._updateTimelines=function(){for(var e=0,i=this._armature._constraints;e<i.length;e++){var r=i[e];if(null!==(l=this._animationData.getConstraintTimelines(r.name)))for(var n=0,s=l;n<s.length;n++)switch((_=s[n]).type){case 30:(f=t.BaseObject.borrowObject(t.IKConstraintTimelineState)).constraint=r,f.init(this._armature,this,_),this._constraintTimelines.push(f)}else this.resetToPose&&((f=t.BaseObject.borrowObject(t.IKConstraintTimelineState)).constraint=r,f.init(this._armature,this,null),this._constraintTimelines.push(f),this._poseTimelines.push(f))}for(var a=0,o=this._armature.animation.getStates();a<o.length;a++){var l,h=o[a];if(h._parent===this&&null!==(l=this._animationData.getAnimationTimelines(h.name)))for(var u=0,c=l;u<c.length;u++){var _;switch((_=c[u]).type){case 40:var f;(f=t.BaseObject.borrowObject(t.AnimationTimelineState)).animationState=h,f.init(this._armature,this,_),this._animationTimelines.push(f)}}}},n.prototype._updateBoneAndSlotTimelines=function(){for(var e={},r=0,n=this._boneTimelines;r<n.length;r++)(l=(g=n[r]).bone.name)in e||(e[l]=[]),e[l].push(g);for(var s=0,a=this._armature.getBones();s<a.length;s++){var o=a[s],l=o.name;if(this.containsBoneMask(l))if(l in e)delete e[l];else if(0===o._boneData.type){var h=this._animationData.getBoneTimelines(l),u=l in this._bonePoses?this._bonePoses[l]:this._bonePoses[l]=t.BaseObject.borrowObject(i);if(null!==h)for(var c=0,_=h;c<_.length;c++)switch((P=_[c]).type){case 10:(g=t.BaseObject.borrowObject(t.BoneAllTimelineState)).bone=o,g.bonePose=u,g.init(this._armature,this,P),this._boneTimelines.push(g);break;case 11:(g=t.BaseObject.borrowObject(t.BoneTranslateTimelineState)).bone=o,g.bonePose=u,g.init(this._armature,this,P),this._boneTimelines.push(g);break;case 12:(g=t.BaseObject.borrowObject(t.BoneRotateTimelineState)).bone=o,g.bonePose=u,g.init(this._armature,this,P),this._boneTimelines.push(g);break;case 13:(g=t.BaseObject.borrowObject(t.BoneScaleTimelineState)).bone=o,g.bonePose=u,g.init(this._armature,this,P),this._boneTimelines.push(g)}else this.resetToPose&&((g=t.BaseObject.borrowObject(t.BoneAllTimelineState)).bone=o,g.bonePose=u,g.init(this._armature,this,null),this._boneTimelines.push(g),this._poseTimelines.push(g))}else if(1===o._boneData.type)if(null!==(h=this._animationData.getSurfaceTimelines(l)))for(var f=0,p=h;f<p.length;f++)switch((P=p[f]).type){case 50:(g=t.BaseObject.borrowObject(t.SurfaceTimelineState)).surface=o,g.init(this._armature,this,P),this._surfaceTimelines.push(g)}else this.resetToPose&&((g=t.BaseObject.borrowObject(t.SurfaceTimelineState)).surface=o,g.init(this._armature,this,null),this._surfaceTimelines.push(g),this._poseTimelines.push(g))}for(var d in e)for(var m=0,y=e[d];m<y.length;m++){var g=y[m];this._boneTimelines.splice(this._boneTimelines.indexOf(g),1),g.returnToPool()}for(var v={},b=[],S=0,A=this._slotTimelines;S<A.length;S++)(l=(g=A[S]).slot.name)in v||(v[l]=[]),v[l].push(g);for(var C=0,x=this._armature.getSlots();C<x.length;C++){var T=x[C],w=T.parent.name;if(this.containsBoneMask(w))if(l=T.name,h=this._animationData.getSlotTimelines(l),l in v)delete v[l];else{var E=!1,B=!1;if(b.length=0,null!==h)for(var D=0,M=h;D<M.length;D++){var P;switch((P=M[D]).type){case 20:(g=t.BaseObject.borrowObject(t.SlotDislayTimelineState)).slot=T,g.init(this._armature,this,P),this._slotTimelines.push(g),E=!0;break;case 21:(g=t.BaseObject.borrowObject(t.SlotColorTimelineState)).slot=T,g.init(this._armature,this,P),this._slotTimelines.push(g),B=!0;break;case 22:(g=t.BaseObject.borrowObject(t.DeformTimelineState)).slot=T,g.init(this._armature,this,P),this._slotTimelines.push(g),b.push(g.vertexOffset)}}if(this.resetToPose&&(E||((g=t.BaseObject.borrowObject(t.SlotDislayTimelineState)).slot=T,g.init(this._armature,this,null),this._slotTimelines.push(g),this._poseTimelines.push(g)),B||((g=t.BaseObject.borrowObject(t.SlotColorTimelineState)).slot=T,g.init(this._armature,this,null),this._slotTimelines.push(g),this._poseTimelines.push(g)),null!==T.rawDisplayDatas))for(var R=0,I=T.rawDisplayDatas;R<I.length;R++){var O=I[R];if(null!==O&&2===O.type){var F=O.vertices.offset;b.indexOf(F)<0&&((g=t.BaseObject.borrowObject(t.DeformTimelineState)).vertexOffset=F,g.slot=T,g.init(this._armature,this,null),this._slotTimelines.push(g),this._poseTimelines.push(g))}}}}for(var d in v)for(var L=0,V=v[d];L<V.length;L++)g=V[L],this._slotTimelines.splice(this._slotTimelines.indexOf(g),1),g.returnToPool()},n.prototype._advanceFadeTime=function(e){var i,r=this._fadeState>0;if(this._subFadeState<0){this._subFadeState=0;var n=r?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;this._armature.eventDispatcher.hasDBEventListener(n)&&((i=t.BaseObject.borrowObject(t.EventObject)).type=n,i.armature=this._armature,i.animationState=this,this._armature._dragonBones.bufferEvent(i))}(e<0&&(e=-e),this._fadeTime+=e,this._fadeTime>=this.fadeTotalTime?(this._subFadeState=1,this._fadeProgress=r?0:1):this._fadeTime>0?this._fadeProgress=r?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeProgress=r?1:0,this._subFadeState>0)&&(r||(this._playheadState|=1,this._fadeState=0),n=r?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE,this._armature.eventDispatcher.hasDBEventListener(n)&&((i=t.BaseObject.borrowObject(t.EventObject)).type=n,i.armature=this._armature,i.animationState=this,this._armature._dragonBones.bufferEvent(i)))},n.prototype.init=function(e,i,r){if(null===this._armature){if(this._armature=e,this._animationData=i,this.resetToPose=r.resetToPose,this.additiveBlending=r.additiveBlending,this.displayControl=r.displayControl,this.actionEnabled=r.actionEnabled,this.layer=r.layer,this.playTimes=r.playTimes,this.timeScale=r.timeScale,this.fadeTotalTime=r.fadeInTime,this.autoFadeOutTime=r.autoFadeOutTime,this.weight=r.weight,this.name=r.name.length>0?r.name:r.animation,this.group=r.group,r.pauseFadeIn?this._playheadState=2:this._playheadState=3,r.duration<0?(this._position=0,this._duration=this._animationData.duration,0!==r.position?this.timeScale>=0?this._time=r.position:this._time=r.position-this._duration:this._time=0):(this._position=r.position,this._duration=r.duration,this._time=0),this.timeScale<0&&0===this._time&&(this._time=-1e-6),this.fadeTotalTime<=0&&(this._fadeProgress=.999999),r.boneMask.length>0){this._boneMask.length=r.boneMask.length;for(var n=0,s=this._boneMask.length;n<s;++n)this._boneMask[n]=r.boneMask[n]}this._actionTimeline=t.BaseObject.borrowObject(t.ActionTimelineState),this._actionTimeline.init(this._armature,this,this._animationData.actionTimeline),this._actionTimeline.currentTime=this._time,this._actionTimeline.currentTime<0&&(this._actionTimeline.currentTime=this._duration-this._actionTimeline.currentTime),null!==this._animationData.zOrderTimeline&&(this._zOrderTimeline=t.BaseObject.borrowObject(t.ZOrderTimelineState),this._zOrderTimeline.init(this._armature,this,this._animationData.zOrderTimeline))}},n.prototype.advanceTime=function(e,i){if(this._blendState.dirty=!1,0===this._fadeState&&0===this._subFadeState||this._advanceFadeTime(e),3===this._playheadState&&(1!==this.timeScale&&(e*=this.timeScale),this._time+=e),0!==this._timelineDirty&&(2===this._timelineDirty&&this._updateTimelines(),this._timelineDirty=0,this._updateBoneAndSlotTimelines()),0!==this.weight){var r=0===this._fadeState&&i>0,n=!0,s=!0,a=this._time;if(this._weightResult=this.weight*this._fadeProgress,null!==this._parent&&(this._weightResult*=this._parent._weightResult/this._parent._fadeProgress),this._actionTimeline.playState<=0&&this._actionTimeline.update(a),r){var o=2*i;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(null!==this._zOrderTimeline&&this._zOrderTimeline.playState<=0&&this._zOrderTimeline.update(a),r){var l=Math.floor(this._actionTimeline.currentTime*i);this._armature._cacheFrameIndex===l?(n=!1,s=!1):(this._armature._cacheFrameIndex=l,this._animationData.cachedFrames[l]?s=!1:this._animationData.cachedFrames[l]=!0)}if(n){if(s)for(var h=0,u=this._boneTimelines.length;h<u;++h)(d=this._boneTimelines[h]).playState<=0&&d.update(a),(h===u-1||d.bone!==this._boneTimelines[h+1].bone)&&0!==(c=d.bone._blendState.update(this._weightResult,this.layer))&&d.blend(c);for(h=0,u=this._surfaceTimelines.length;h<u;++h){var c=(d=this._surfaceTimelines[h]).surface._blendState.update(this._weightResult,this.layer);d.playState<=0&&d.update(a),0!==c&&d.blend(c)}if(this.displayControl)for(h=0,u=this._slotTimelines.length;h<u;++h){var _=(d=this._slotTimelines[h]).slot.displayController;null!==_&&_!==this.name&&_!==this.group||d.playState<=0&&d.update(a)}for(h=0,u=this._constraintTimelines.length;h<u;++h)(d=this._constraintTimelines[h]).playState<=0&&d.update(a);for(h=0,u=this._animationTimelines.length;h<u;++h)c=(d=this._animationTimelines[h]).animationState._blendState.update(this._weightResult,this.layer),d.playState<=0&&d.update(a),0!==c&&d.blend(c)}if(0===this._fadeState){if(this._subFadeState>0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(var f=0,p=this._poseTimelines;f<p.length;f++){var d;(d=p[f])instanceof t.BoneTimelineState?this._boneTimelines.splice(this._boneTimelines.indexOf(d),1):d instanceof t.SurfaceTimelineState?this._surfaceTimelines.splice(this._surfaceTimelines.indexOf(d),1):d instanceof t.SlotTimelineState?this._slotTimelines.splice(this._slotTimelines.indexOf(d),1):d instanceof t.ConstraintTimelineState&&this._constraintTimelines.splice(this._constraintTimelines.indexOf(d),1),d.returnToPool()}this._poseTimelines.length=0}this._actionTimeline.playState>0&&this.autoFadeOutTime>=0&&this.fadeOut(this.autoFadeOutTime)}}},n.prototype.play=function(){this._playheadState=3},n.prototype.stop=function(){this._playheadState&=1},n.prototype.fadeOut=function(t,e){if(void 0===e&&(e=!0),t<0&&(t=0),e&&(this._playheadState&=2),this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime)return}else{this._fadeState=1,this._subFadeState=-1,(t<=0||this._fadeProgress<=0)&&(this._fadeProgress=1e-6);for(var i=0,r=this._boneTimelines;i<r.length;i++)(_=r[i]).fadeOut();for(var n=0,s=this._surfaceTimelines;n<s.length;n++)(_=s[n]).fadeOut();for(var a=0,o=this._slotTimelines;a<o.length;a++)(_=o[a]).fadeOut();for(var l=0,h=this._constraintTimelines;l<h.length;l++)(_=h[l]).fadeOut();for(var u=0,c=this._animationTimelines;u<c.length;u++){var _;(_=c[u]).animationState.fadeOut(t,e),_.fadeOut()}}this.displayControl=!1,this.fadeTotalTime=this._fadeProgress>1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)},n.prototype.containsBoneMask=function(t){return 0===this._boneMask.length||this._boneMask.indexOf(t)>=0},n.prototype.addBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._armature.getBone(t);if(null!==i){if(this._boneMask.indexOf(t)<0&&this._boneMask.push(t),e)for(var r=0,n=this._armature.getBones();r<n.length;r++){var s=n[r];this._boneMask.indexOf(s.name)<0&&i.contains(s)&&this._boneMask.push(s.name)}this._timelineDirty=1}},n.prototype.removeBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._boneMask.indexOf(t);if(i>=0&&this._boneMask.splice(i,1),e){var r=this._armature.getBone(t);if(null!==r){var n=this._armature.getBones();if(this._boneMask.length>0)for(var s=0,a=n;s<a.length;s++){var o=a[s],l=this._boneMask.indexOf(o.name);l>=0&&r.contains(o)&&this._boneMask.splice(l,1)}else for(var h=0,u=n;h<u.length;h++)(o=u[h])!==r&&(r.contains(o)||this._boneMask.push(o.name))}}this._timelineDirty=1},n.prototype.removeAllBoneMask=function(){this._boneMask.length=0,this._timelineDirty=1},Object.defineProperty(n.prototype,"isFadeIn",{get:function(){return this._fadeState<0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isFadeOut",{get:function(){return this._fadeState>0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isFadeComplete",{get:function(){return 0===this._fadeState},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isPlaying",{get:function(){return 0!=(2&this._playheadState)&&this._actionTimeline.playState<=0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"totalTime",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if((t<0||this._duration<t)&&(t=t%this._duration+e*this._duration)<0&&(t+=this._duration),this.playTimes>0&&e===this.playTimes-1&&t===this._duration&&(t=this._duration-1e-6),this._time!==t){this._time=t,this._actionTimeline.setCurrentTime(this._time),null!==this._zOrderTimeline&&(this._zOrderTimeline.playState=-1);for(var i=0,r=this._boneTimelines;i<r.length;i++)r[i].playState=-1;for(var n=0,s=this._slotTimelines;n<s.length;n++)s[n].playState=-1}},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"animationData",{get:function(){return this._animationData},enumerable:!0,configurable:!0}),n}(t.BaseObject);t.AnimationState=e;var i=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.current=new t.Transform,i.delta=new t.Transform,i.result=new t.Transform,i}return gnt(i,e),i.toString=function(){return"[class dragonBones.BonePose]"},i.prototype._onClear=function(){this.current.identity(),this.delta.identity(),this.result.identity()},i}(t.BaseObject);t.BonePose=i;var r=function(){function t(){}return t.prototype.update=function(t,e){if(this.dirty){if(!(this.leftWeight>0))return 0;if(this.layer!==e){if(this.layerWeight>=this.leftWeight)return this.leftWeight=0,0;this.layer=e,this.leftWeight-=this.layerWeight,this.layerWeight=0}return t*=this.leftWeight,this.layerWeight+=t,this.blendWeight=t,2}return this.dirty=!0,this.layer=e,this.layerWeight=t,this.leftWeight=1,this.blendWeight=t,1},t.prototype.clear=function(){this.dirty=!1,this.layer=0,this.leftWeight=0,this.layerWeight=0,this.blendWeight=0},t}();t.BlendState=r}(vnt||(vnt={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.prototype._onClear=function(){this.playState=-1,this.currentPlayTimes=-1,this.currentTime=-1,this._tweenState=0,this._frameRate=0,this._frameValueOffset=0,this._frameCount=0,this._frameOffset=0,this._frameIndex=-1,this._frameRateR=0,this._position=0,this._duration=0,this._timeScale=1,this._timeOffset=0,this._dragonBonesData=null,this._animationData=null,this._timelineData=null,this._armature=null,this._animationState=null,this._actionTimeline=null,this._frameArray=null,this._frameIntArray=null,this._frameFloatArray=null,this._timelineArray=null,this._frameIndices=null},e.prototype._setCurrentTime=function(t){var e=this.playState,i=this.currentPlayTimes,r=this.currentTime;if(null!==this._actionTimeline&&this._frameCount<=1)this.playState=this._actionTimeline.playState>=0?1:-1,this.currentPlayTimes=1,this.currentTime=this._actionTimeline.currentTime;else if(null===this._actionTimeline||1!==this._timeScale||0!==this._timeOffset){var n=this._animationState.playTimes,s=n*this._duration;t*=this._timeScale,0!==this._timeOffset&&(t+=this._timeOffset*this._animationData.duration),n>0&&(t>=s||t<=-s)?(this.playState<=0&&3===this._animationState._playheadState&&(this.playState=1),this.currentPlayTimes=n,this.currentTime=t<0?0:this._duration+1e-6):(0!==this.playState&&3===this._animationState._playheadState&&(this.playState=0),t<0?(t=-t,this.currentPlayTimes=Math.floor(t/this._duration),this.currentTime=this._duration-t%this._duration):(this.currentPlayTimes=Math.floor(t/this._duration),this.currentTime=t%this._duration)),this.currentTime+=this._position}else this.playState=this._actionTimeline.playState,this.currentPlayTimes=this._actionTimeline.currentPlayTimes,this.currentTime=this._actionTimeline.currentTime;return(this.currentPlayTimes!==i||this.currentTime!==r)&&((e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i)&&(this._frameIndex=-1),!0)},e.prototype.init=function(t,e,i){this._armature=t,this._animationState=e,this._timelineData=i,this._actionTimeline=this._animationState._actionTimeline,this===this._actionTimeline&&(this._actionTimeline=null),this._animationData=this._animationState._animationData,this._frameRate=this._animationData.parent.frameRate,this._frameRateR=1/this._frameRate,this._position=this._animationState._position,this._duration=this._animationState._duration,this._dragonBonesData=this._animationData.parent.parent,null!==this._timelineData&&(this._frameIntArray=this._dragonBonesData.frameIntArray,this._frameFloatArray=this._dragonBonesData.frameFloatArray,this._frameArray=this._dragonBonesData.frameArray,this._timelineArray=this._dragonBonesData.timelineArray,this._frameIndices=this._dragonBonesData.frameIndices,this._frameCount=this._timelineArray[this._timelineData.offset+2],this._frameValueOffset=this._timelineArray[this._timelineData.offset+4],this._timeScale=100/this._timelineArray[this._timelineData.offset+0],this._timeOffset=.01*this._timelineArray[this._timelineData.offset+1])},e.prototype.fadeOut=function(){},e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate),i=this._frameIndices[this._timelineData.frameIndicesOffset+e];this._frameIndex!==i&&(this._frameIndex=i,this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex],this._onArriveAtFrame())}else this._frameIndex<0&&(this._frameIndex=0,null!==this._timelineData&&(this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]),this._onArriveAtFrame());0!==this._tweenState&&this._onUpdateFrame()}},e}(t.BaseObject);t.TimelineState=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e._getEasingValue=function(t,e,i){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI))}return(r-e)*i+e},e._getEasingCurveValue=function(t,e,i,r){if(t<=0)return 0;if(t>=1)return 1;var n=i+1,s=Math.floor(t*n),a=0===s?0:e[r+s-1];return 1e-4*(a+((s===n-1?1e4:e[r+s])-a)*(t*n-s))},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._tweenType=0,this._curveCount=0,this._framePosition=0,this._frameDurationR=0,this._tweenProgress=0,this._tweenEasing=0},e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||0===this._animationState.playTimes||this._animationState.currentPlayTimes<this._animationState.playTimes-1))if(this._tweenType=this._frameArray[this._frameOffset+1],this._tweenState=0===this._tweenType?1:2,2===this._tweenType?this._curveCount=this._frameArray[this._frameOffset+2]:0!==this._tweenType&&1!==this._tweenType&&(this._tweenEasing=.01*this._frameArray[this._frameOffset+2]),this._framePosition=this._frameArray[this._frameOffset]*this._frameRateR,this._frameIndex===this._frameCount-1)this._frameDurationR=1/(this._animationData.duration-this._framePosition);else{var t=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex+1],e=this._frameArray[t]*this._frameRateR-this._framePosition;this._frameDurationR=e>0?1/e:0}else this._tweenState=1},e.prototype._onUpdateFrame=function(){2===this._tweenState?(this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR,2===this._tweenType?this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3):1!==this._tweenType&&(this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing))):this._tweenProgress=0},e}(e);t.TweenTimelineState=i;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.bone=null,this.bonePose=null},e.prototype.blend=function(t){var e=this.bone._blendState.blendWeight,i=this.bone.animationPose,r=this.bonePose.result;2===t?(i.x+=r.x*e,i.y+=r.y*e,i.rotation+=r.rotation*e,i.skew+=r.skew*e,i.scaleX+=(r.scaleX-1)*e,i.scaleY+=(r.scaleY-1)*e):1!==e?(i.x=r.x*e,i.y=r.y*e,i.rotation=r.rotation*e,i.skew=r.skew*e,i.scaleX=(r.scaleX-1)*e+1,i.scaleY=(r.scaleY-1)*e+1):(i.x=r.x,i.y=r.y,i.rotation=r.rotation,i.skew=r.skew,i.scaleX=r.scaleX,i.scaleY=r.scaleY),0===this._animationState._fadeState&&0===this._animationState._subFadeState||(this.bone._transformDirty=!0)},e}(i);t.BoneTimelineState=r;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.slot=null},e}(i);t.SlotTimelineState=n;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.constraint=null},e}(i);t.ConstraintTimelineState=s}(vnt||(vnt={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return gnt(i,e),i.toString=function(){return"[class dragonBones.ActionTimelineState]"},i.prototype._onCrossFrame=function(e){var i=this._armature.eventDispatcher;if(this._animationState.actionEnabled)for(var r=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+e],n=this._frameArray[r+1],s=this._animationData.parent.actions,a=0;a<n;++a){var o=s[this._frameArray[r+2+a]];if(0===o.type)(l=t.BaseObject.borrowObject(t.EventObject)).time=this._frameArray[r]/this._frameRate,l.animationState=this._animationState,t.EventObject.actionDataToInstance(o,l,this._armature),this._armature._bufferAction(l,!0);else{var l,h=10===o.type?t.EventObject.FRAME_EVENT:t.EventObject.SOUND_EVENT;(11===o.type||i.hasDBEventListener(h))&&((l=t.BaseObject.borrowObject(t.EventObject)).time=this._frameArray[r]/this._frameRate,l.animationState=this._animationState,t.EventObject.actionDataToInstance(o,l,this._armature),this._armature._dragonBones.bufferEvent(l))}}},i.prototype._onArriveAtFrame=function(){},i.prototype._onUpdateFrame=function(){},i.prototype.update=function(e){var i=this.playState,r=this.currentPlayTimes,n=this.currentTime;if(this._setCurrentTime(e)){var s=this._armature.eventDispatcher;if(i<0){if(this.playState===i)return;if(this._animationState.displayControl&&this._animationState.resetToPose&&this._armature._sortZOrder(null,0),r=this.currentPlayTimes,s.hasDBEventListener(t.EventObject.START)){var a=t.BaseObject.borrowObject(t.EventObject);a.type=t.EventObject.START,a.armature=this._armature,a.animationState=this._animationState,this._armature._dragonBones.bufferEvent(a)}}var o=this._animationState.timeScale<0,l=null,h=null;if(this.currentPlayTimes!==r&&(s.hasDBEventListener(t.EventObject.LOOP_COMPLETE)&&((l=t.BaseObject.borrowObject(t.EventObject)).type=t.EventObject.LOOP_COMPLETE,l.armature=this._armature,l.animationState=this._animationState),this.playState>0&&s.hasDBEventListener(t.EventObject.COMPLETE)&&((h=t.BaseObject.borrowObject(t.EventObject)).type=t.EventObject.COMPLETE,h.armature=this._armature,h.animationState=this._animationState)),this._frameCount>1){var u=this._timelineData,c=Math.floor(this.currentTime*this._frameRate),_=this._frameIndices[u.frameIndicesOffset+c];if(this._frameIndex!==_){var f=this._frameIndex;if(this._frameIndex=_,null!==this._timelineArray)if(this._frameOffset=this._animationData.frameOffset+this._timelineArray[u.offset+5+this._frameIndex],o){if(f<0){var p=Math.floor(n*this._frameRate);f=this._frameIndices[u.frameIndicesOffset+p],this.currentPlayTimes===r&&f===_&&(f=-1)}for(;f>=0;){var d=this._animationData.frameOffset+this._timelineArray[u.offset+5+f],m=this._frameArray[d]/this._frameRate;if(this._position<=m&&m<=this._position+this._duration&&this._onCrossFrame(f),null!==l&&0===f&&(this._armature._dragonBones.bufferEvent(l),l=null),f>0?f--:f=this._frameCount-1,f===_)break}}else for(f<0&&(p=Math.floor(n*this._frameRate),f=this._frameIndices[u.frameIndicesOffset+p],d=this._animationData.frameOffset+this._timelineArray[u.offset+5+f],m=this._frameArray[d]/this._frameRate,this.currentPlayTimes===r&&(n<=m?f>0?f--:f=this._frameCount-1:f===_&&(f=-1)));f>=0&&(f<this._frameCount-1?f++:f=0,d=this._animationData.frameOffset+this._timelineArray[u.offset+5+f],m=this._frameArray[d]/this._frameRate,this._position<=m&&m<=this._position+this._duration&&this._onCrossFrame(f),null!==l&&0===f&&(this._armature._dragonBones.bufferEvent(l),l=null),f!==_););}}else this._frameIndex<0&&(this._frameIndex=0,null!==this._timelineData)&&(this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5],m=this._frameArray[this._frameOffset]/this._frameRate,this.currentPlayTimes===r?n<=m&&this._onCrossFrame(this._frameIndex):this._position<=m&&(o||null===l||(this._armature._dragonBones.bufferEvent(l),l=null),this._onCrossFrame(this._frameIndex)));null!==l&&this._armature._dragonBones.bufferEvent(l),null!==h&&this._armature._dragonBones.bufferEvent(h)}},i.prototype.setCurrentTime=function(t){this._setCurrentTime(t),this._frameIndex=-1},i}(t.TimelineState);t.ActionTimelineState=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.ZOrderTimelineState]"},e.prototype._onArriveAtFrame=function(){this.playState>=0&&(this._frameArray[this._frameOffset+1]>0?this._armature._sortZOrder(this._frameArray,this._frameOffset+2):this._armature._sortZOrder(null,0))},e.prototype._onUpdateFrame=function(){},e}(t.TimelineState);t.ZOrderTimelineState=i;var r=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return gnt(i,e),i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"},i.prototype._onArriveAtFrame=function(){if(e.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var t=this._animationData.frameFloatOffset+this._frameValueOffset+6*this._frameIndex,i=this._armature._armatureData.scale,r=this._frameFloatArray,n=this.bonePose.current,s=this.bonePose.delta;n.x=r[t++]*i,n.y=r[t++]*i,n.rotation=r[t++],n.skew=r[t++],n.scaleX=r[t++],n.scaleY=r[t++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(t=this._animationData.frameFloatOffset+this._frameValueOffset),s.x=r[t++]*i-n.x,s.y=r[t++]*i-n.y,s.rotation=r[t++]-n.rotation,s.skew=r[t++]-n.skew,s.scaleX=r[t++]-n.scaleX,s.scaleY=r[t++]-n.scaleY):(s.x=0,s.y=0,s.rotation=0,s.skew=0,s.scaleX=0,s.scaleY=0)}else n=this.bonePose.current,s=this.bonePose.delta,n.x=0,n.y=0,n.rotation=0,n.skew=0,n.scaleX=1,n.scaleY=1,s.x=0,s.y=0,s.rotation=0,s.skew=0,s.scaleX=0,s.scaleY=0},i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current,i=this.bonePose.delta,r=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),r.x=t.x+i.x*this._tweenProgress,r.y=t.y+i.y*this._tweenProgress,r.rotation=t.rotation+i.rotation*this._tweenProgress,r.skew=t.skew+i.skew*this._tweenProgress,r.scaleX=t.scaleX+i.scaleX*this._tweenProgress,r.scaleY=t.scaleY+i.scaleY*this._tweenProgress},i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation),e.skew=t.Transform.normalizeRadian(e.skew)},i}(t.BoneTimelineState);t.BoneAllTimelineState=r;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._armature._armatureData.scale,r=this._frameFloatArray,n=this.bonePose.current,s=this.bonePose.delta;n.x=r[e++]*i,n.y=r[e++]*i,2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameFloatOffset+this._frameValueOffset),s.x=r[e++]*i-n.x,s.y=r[e++]*i-n.y):(s.x=0,s.y=0)}else n=this.bonePose.current,s=this.bonePose.delta,n.x=0,n.y=0,s.x=0,s.y=0},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current,i=this.bonePose.delta,r=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),r.x=e.x+i.x*this._tweenProgress,r.y=e.y+i.y*this._tweenProgress},e}(t.BoneTimelineState);t.BoneTranslateTimelineState=n;var s=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return gnt(i,e),i.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"},i.prototype._onArriveAtFrame=function(){if(e.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var i=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,r=this._frameFloatArray,n=this.bonePose.current,s=this.bonePose.delta;n.rotation=r[i++],n.skew=r[i++],2===this._tweenState?(this._frameIndex===this._frameCount-1?(i=this._animationData.frameFloatOffset+this._frameValueOffset,s.rotation=t.Transform.normalizeRadian(r[i++]-n.rotation)):s.rotation=r[i++]-n.rotation,s.skew=r[i++]-n.skew):(s.rotation=0,s.skew=0)}else n=this.bonePose.current,s=this.bonePose.delta,n.rotation=0,n.skew=0,s.rotation=0,s.skew=0},i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current,i=this.bonePose.delta,r=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),r.rotation=t.rotation+i.rotation*this._tweenProgress,r.skew=t.skew+i.skew*this._tweenProgress},i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation),e.skew=t.Transform.normalizeRadian(e.skew)},i}(t.BoneTimelineState);t.BoneRotateTimelineState=s;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._frameFloatArray,r=this.bonePose.current,n=this.bonePose.delta;r.scaleX=i[e++],r.scaleY=i[e++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameFloatOffset+this._frameValueOffset),n.scaleX=i[e++]-r.scaleX,n.scaleY=i[e++]-r.scaleY):(n.scaleX=0,n.scaleY=0)}else r=this.bonePose.current,n=this.bonePose.delta,r.scaleX=1,r.scaleY=1,n.scaleX=0,n.scaleY=0},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current,i=this.bonePose.delta,r=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),r.scaleX=e.scaleX+i.scaleX*this._tweenProgress,r.scaleY=e.scaleY+i.scaleY*this._tweenProgress},e}(t.BoneTimelineState);t.BoneScaleTimelineState=a;var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[],e._delta=[],e._result=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.SurfaceTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.surface=null,this._frameFloatOffset=0,this._valueCount=0,this._deformCount=0,this._valueOffset=0,this._current.length=0,this._delta.length=0,this._result.length=0},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount,i=this._armature._armatureData.scale,r=this._frameFloatArray;if(2===this._tweenState){var n=e+this._valueCount;this._frameIndex===this._frameCount-1&&(n=this._animationData.frameFloatOffset+this._frameValueOffset);for(var s=0;s<this._valueCount;++s)this._delta[s]=r[n+s]*i-(this._current[s]=r[e+s]*i)}else for(s=0;s<this._valueCount;++s)this._current[s]=r[e+s]*i}else for(s=0;s<this._valueCount;++s)this._current[s]=0},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),this.surface._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0);for(var e=0;e<this._valueCount;++e)this._result[e]=this._current[e]+this._delta[e]*this._tweenProgress},e.prototype.init=function(e,i,r){if(t.prototype.init.call(this,e,i,r),null!==this._timelineData){var n=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];this._deformCount=this._frameIntArray[n+1],this._valueCount=this._frameIntArray[n+2],this._valueOffset=this._frameIntArray[n+3],this._frameFloatOffset=this._frameIntArray[n+4]+this._animationData.frameFloatOffset}else this._deformCount=this.surface._deformVertices.length,this._valueCount=this._deformCount,this._valueOffset=0,this._frameFloatOffset=0;this._current.length=this._valueCount,this._delta.length=this._valueCount,this._result.length=this._valueCount;for(var s=0;s<this._valueCount;++s)this._delta[s]=0},e.prototype.blend=function(t){for(var e=this.surface._blendState.blendWeight,i=this.surface._deformVertices,r=0;r<this._deformCount;++r){var n;n=r<this._valueOffset?this._frameFloatArray[this._frameFloatOffset+r]:r<this._valueOffset+this._valueCount?this._result[r-this._valueOffset]:this._frameFloatArray[this._frameFloatOffset+r-this._valueCount],2===t?i[r]+=n*e:i[r]=1!==e?n*e:n}0===this._animationState._fadeState&&0===this._animationState._subFadeState||(this.surface._transformDirty=!0)},e}(t.TweenTimelineState);t.SurfaceTimelineState=o;var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.SlotDislayTimelineState]"},e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=null!==this._timelineData?this._frameArray[this._frameOffset+1]:this.slot._slotData.displayIndex;this.slot.displayIndex!==t&&this.slot._setDisplayIndex(t,!0)}},e}(t.SlotTimelineState);t.SlotDislayTimelineState=l;var h=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[0,0,0,0,0,0,0,0],e._delta=[0,0,0,0,0,0,0,0],e._result=[0,0,0,0,0,0,0,0],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._dirty=!1},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._dragonBonesData.intArray,i=this._frameIntArray,r=this._animationData.frameIntOffset+this._frameValueOffset+1*this._frameIndex,n=i[r];n<0&&(n+=65536),this._current[0]=e[n++],this._current[1]=e[n++],this._current[2]=e[n++],this._current[3]=e[n++],this._current[4]=e[n++],this._current[5]=e[n++],this._current[6]=e[n++],this._current[7]=e[n++],2===this._tweenState&&((n=this._frameIndex===this._frameCount-1?i[this._animationData.frameIntOffset+this._frameValueOffset]:i[r+1])<0&&(n+=65536),this._delta[0]=e[n++]-this._current[0],this._delta[1]=e[n++]-this._current[1],this._delta[2]=e[n++]-this._current[2],this._delta[3]=e[n++]-this._current[3],this._delta[4]=e[n++]-this._current[4],this._delta[5]=e[n++]-this._current[5],this._delta[6]=e[n++]-this._current[6],this._delta[7]=e[n++]-this._current[7])}else{var s=this.slot._slotData.color;this._current[0]=100*s.alphaMultiplier,this._current[1]=100*s.redMultiplier,this._current[2]=100*s.greenMultiplier,this._current[3]=100*s.blueMultiplier,this._current[4]=s.alphaOffset,this._current[5]=s.redOffset,this._current[6]=s.greenOffset,this._current[7]=s.blueOffset}},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),this._dirty=!0,2!==this._tweenState&&(this._tweenState=0),this._result[0]=.01*(this._current[0]+this._delta[0]*this._tweenProgress),this._result[1]=.01*(this._current[1]+this._delta[1]*this._tweenProgress),this._result[2]=.01*(this._current[2]+this._delta[2]*this._tweenProgress),this._result[3]=.01*(this._current[3]+this._delta[3]*this._tweenProgress),this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress,this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress,this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress,this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress},e.prototype.fadeOut=function(){this._tweenState=0,this._dirty=!1},e.prototype.update=function(e){if(t.prototype.update.call(this,e),0!==this._tweenState||this._dirty){var i=this.slot._colorTransform;if(0!==this._animationState._fadeState||0!==this._animationState._subFadeState){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*r,i.redMultiplier+=(this._result[1]-i.redMultiplier)*r,i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*r,i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*r,i.alphaOffset+=(this._result[4]-i.alphaOffset)*r,i.redOffset+=(this._result[5]-i.redOffset)*r,i.greenOffset+=(this._result[6]-i.greenOffset)*r,i.blueOffset+=(this._result[7]-i.blueOffset)*r,this.slot._colorDirty=!0}}else this._dirty&&(this._dirty=!1,i.alphaMultiplier===this._result[0]&&i.redMultiplier===this._result[1]&&i.greenMultiplier===this._result[2]&&i.blueMultiplier===this._result[3]&&i.alphaOffset===this._result[4]&&i.redOffset===this._result[5]&&i.greenOffset===this._result[6]&&i.blueOffset===this._result[7]||(i.alphaMultiplier=this._result[0],i.redMultiplier=this._result[1],i.greenMultiplier=this._result[2],i.blueMultiplier=this._result[3],i.alphaOffset=this._result[4],i.redOffset=this._result[5],i.greenOffset=this._result[6],i.blueOffset=this._result[7],this.slot._colorDirty=!0))}},e}(t.SlotTimelineState);t.SlotColorTimelineState=h;var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[],e._delta=[],e._result=[],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.DeformTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.vertexOffset=0,this._dirty=!1,this._frameFloatOffset=0,this._valueCount=0,this._deformCount=0,this._valueOffset=0,this._current.length=0,this._delta.length=0,this._result.length=0},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount,i=this._armature._armatureData.scale,r=this._frameFloatArray;if(2===this._tweenState){var n=e+this._valueCount;this._frameIndex===this._frameCount-1&&(n=this._animationData.frameFloatOffset+this._frameValueOffset);for(var s=0;s<this._valueCount;++s)this._delta[s]=r[n+s]*i-(this._current[s]=r[e+s]*i)}else for(s=0;s<this._valueCount;++s)this._current[s]=r[e+s]*i}else for(s=0;s<this._valueCount;++s)this._current[s]=0},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),this._dirty=!0,2!==this._tweenState&&(this._tweenState=0);for(var e=0;e<this._valueCount;++e)this._result[e]=this._current[e]+this._delta[e]*this._tweenProgress},e.prototype.init=function(e,i,r){if(t.prototype.init.call(this,e,i,r),null!==this._timelineData){var n=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];this.vertexOffset=this._frameIntArray[n+0],this.vertexOffset<0&&(this.vertexOffset+=65536),this._deformCount=this._frameIntArray[n+1],this._valueCount=this._frameIntArray[n+2],this._valueOffset=this._frameIntArray[n+3],this._frameFloatOffset=this._frameIntArray[n+4]+this._animationData.frameFloatOffset}else{var s=this.slot._deformVertices;this._deformCount=null!==s?s.vertices.length:0,this._valueCount=this._deformCount,this._valueOffset=0,this._frameFloatOffset=0}this._current.length=this._valueCount,this._delta.length=this._valueCount,this._result.length=this._valueCount;for(var a=0;a<this._valueCount;++a)this._delta[a]=0},e.prototype.fadeOut=function(){this._tweenState=0,this._dirty=!1},e.prototype.update=function(e){var i=this.slot._deformVertices;if(null!==i&&null!==i.verticesData&&i.verticesData.offset===this.vertexOffset&&(t.prototype.update.call(this,e),0!==this._tweenState||this._dirty)){var r=i.vertices;if(0!==this._animationState._fadeState||0!==this._animationState._subFadeState){for(var n=Math.pow(this._animationState._fadeProgress,2),s=0;s<this._deformCount;++s)s<this._valueOffset?r[s]+=(this._frameFloatArray[this._frameFloatOffset+s]-r[s])*n:s<this._valueOffset+this._valueCount?r[s]+=(this._result[s-this._valueOffset]-r[s])*n:r[s]+=(this._frameFloatArray[this._frameFloatOffset+s-this._valueCount]-r[s])*n;i.verticesDirty=!0}else if(this._dirty){for(this._dirty=!1,s=0;s<this._deformCount;++s)s<this._valueOffset?r[s]=this._frameFloatArray[this._frameFloatOffset+s]:s<this._valueOffset+this._valueCount?r[s]=this._result[s-this._valueOffset]:r[s]=this._frameFloatArray[this._frameFloatOffset+s-this._valueCount];i.verticesDirty=!0}}},e}(t.SlotTimelineState);t.DeformTimelineState=u;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.toString=function(){return"[class dragonBones.IKConstraintTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._current=0,this._delta=0},e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);var e=this.constraint;if(null!==this._timelineData){var i=this._animationData.frameIntOffset+this._frameValueOffset+2*this._frameIndex,r=this._frameIntArray,n=0!==r[i++];this._current=.01*r[i++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(i=this._animationData.frameIntOffset+this._frameValueOffset),this._delta=.01*r[i+1]-this._current):this._delta=0,e._bendPositive=n}else{var s=e._constraintData;this._current=s.weight,this._delta=0,e._bendPositive=s.bendPositive}e.invalidUpdate()},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),2!==this._tweenState&&(this._tweenState=0);var e=this.constraint;e._weight=this._current+this._delta*this._tweenProgress,e.invalidUpdate()},e}(t.ConstraintTimelineState);t.IKConstraintTimelineState=c;var _=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._floats=[0,0,0,0,0,0],e}return gnt(e,t),e.toString=function(){return"[class dragonBones.AnimationTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.animationState=null},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameIntOffset+this._frameValueOffset+2*this._frameIndex,i=1/this.animationState._animationData.parent.frameRate,r=this._frameIntArray;this._floats[0]=r[e++]*i,this._floats[3]=.01*r[e++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameIntOffset+this._frameValueOffset),this._floats[1]=r[e++]*i-this._floats[0],this._floats[4]=.01*r[e++]-this._floats[3]):(this._floats[1]=0,this._floats[4]=0)}},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),2!==this._tweenState&&(this._tweenState=0),this._floats[0]>=0&&(this._floats[2]=this._floats[0]+this._floats[1]*this._tweenProgress),this._floats[5]=this._floats[3]+this._floats[4]*this._tweenProgress},e.prototype.blend=function(t){var e=this.animationState,i=e._blendState.blendWeight;2===t?(e.weight+=this._floats[5]*i,e.currentTime+=this._floats[2]*i):(e.weight=this._floats[5]*i,e.currentTime=this._floats[2]*i)},e}(t.TweenTimelineState);t.AnimationTimelineState=_}(vnt||(vnt={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return gnt(e,t),e.actionDataToInstance=function(t,i,r){0===t.type?i.type=e.FRAME_EVENT:i.type=10===t.type?e.FRAME_EVENT:e.SOUND_EVENT,i.name=t.name,i.armature=r,i.actionData=t,i.data=t.data,null!==t.bone&&(i.bone=r.getBone(t.bone.name)),null!==t.slot&&(i.slot=r.getSlot(t.slot.name))},e.toString=function(){return"[class dragonBones.EventObject]"},e.prototype._onClear=function(){this.time=0,this.type="",this.name="",this.armature=null,this.bone=null,this.slot=null,this.animationState=null,this.actionData=null,this.data=null},e.START="start",e.LOOP_COMPLETE="loopComplete",e.COMPLETE="complete",e.FADE_IN="fadeIn",e.FADE_IN_COMPLETE="fadeInComplete",e.FADE_OUT="fadeOut",e.FADE_OUT_COMPLETE="fadeOutComplete",e.FRAME_EVENT="frameEvent",e.SOUND_EVENT="soundEvent",e}(t.BaseObject);t.EventObject=e}(vnt||(vnt={})),function(t){var e=function(){function e(){}return e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}},e._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}},e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}},e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}},e._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}},e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}},e._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}},e._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}},e._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}},e.parseDragonBonesData=function(e){return console.warn("Deprecated."),e instanceof ArrayBuffer?t.BinaryDataParser.getInstance().parseDragonBonesData(e):t.ObjectDataParser.getInstance().parseDragonBonesData(e)},e.parseTextureAtlasData=function(i,r){void 0===r&&(r=1),console.warn("已废弃");for(var n={},s=i[e.SUB_TEXTURE],a=0,o=s.length;a<o;a++){var l=s[a],h=l[e.NAME],u=new t.Rectangle,c=null;u.x=l[e.X]/r,u.y=l[e.Y]/r,u.width=l[e.WIDTH]/r,u.height=l[e.HEIGHT]/r,e.FRAME_WIDTH in l&&((c=new t.Rectangle).x=l[e.FRAME_X]/r,c.y=l[e.FRAME_Y]/r,c.width=l[e.FRAME_WIDTH]/r,c.height=l[e.FRAME_HEIGHT]/r),n[h]={region:u,frame:c,rotated:!1}}return n},e.DATA_VERSION_2_3="2.3",e.DATA_VERSION_3_0="3.0",e.DATA_VERSION_4_0="4.0",e.DATA_VERSION_4_5="4.5",e.DATA_VERSION_5_0="5.0",e.DATA_VERSION_5_5="5.5",e.DATA_VERSION=e.DATA_VERSION_5_5,e.DATA_VERSIONS=[e.DATA_VERSION_4_0,e.DATA_VERSION_4_5,e.DATA_VERSION_5_0,e.DATA_VERSION_5_5],e.TEXTURE_ATLAS="textureAtlas",e.SUB_TEXTURE="SubTexture",e.FORMAT="format",e.IMAGE_PATH="imagePath",e.WIDTH="width",e.HEIGHT="height",e.ROTATED="rotated",e.FRAME_X="frameX",e.FRAME_Y="frameY",e.FRAME_WIDTH="frameWidth",e.FRAME_HEIGHT="frameHeight",e.DRADON_BONES="dragonBones",e.USER_DATA="userData",e.ARMATURE="armature",e.BONE="bone",e.SURFACE="surface",e.SLOT="slot",e.CONSTRAINT="constraint",e.IK="ik",e.PATH_CONSTRAINT="path",e.SKIN="skin",e.DISPLAY="display",e.ANIMATION="animation",e.Z_ORDER="zOrder",e.FFD="ffd",e.FRAME="frame",e.TRANSLATE_FRAME="translateFrame",e.ROTATE_FRAME="rotateFrame",e.SCALE_FRAME="scaleFrame",e.DISPLAY_FRAME="displayFrame",e.COLOR_FRAME="colorFrame",e.DEFAULT_ACTIONS="defaultActions",e.ACTIONS="actions",e.EVENTS="events",e.INTS="ints",e.FLOATS="floats",e.STRINGS="strings",e.CANVAS="canvas",e.TRANSFORM="transform",e.PIVOT="pivot",e.AABB="aabb",e.COLOR="color",e.VERSION="version",e.COMPATIBLE_VERSION="compatibleVersion",e.FRAME_RATE="frameRate",e.TYPE="type",e.SUB_TYPE="subType",e.NAME="name",e.PARENT="parent",e.TARGET="target",e.STAGE="stage",e.SHARE="share",e.PATH="path",e.LENGTH="length",e.DISPLAY_INDEX="displayIndex",e.BLEND_MODE="blendMode",e.INHERIT_TRANSLATION="inheritTranslation",e.INHERIT_ROTATION="inheritRotation",e.INHERIT_SCALE="inheritScale",e.INHERIT_REFLECTION="inheritReflection",e.INHERIT_ANIMATION="inheritAnimation",e.INHERIT_DEFORM="inheritDeform",e.SEGMENT_X="segmentX",e.SEGMENT_Y="segmentY",e.BEND_POSITIVE="bendPositive",e.CHAIN="chain",e.WEIGHT="weight",e.FADE_IN_TIME="fadeInTime",e.PLAY_TIMES="playTimes",e.SCALE="scale",e.OFFSET="offset",e.POSITION="position",e.DURATION="duration",e.TWEEN_EASING="tweenEasing",e.TWEEN_ROTATE="tweenRotate",e.TWEEN_SCALE="tweenScale",e.CLOCK_WISE="clockwise",e.CURVE="curve",e.SOUND="sound",e.EVENT="event",e.ACTION="action",e.X="x",e.Y="y",e.SKEW_X="skX",e.SKEW_Y="skY",e.SCALE_X="scX",e.SCALE_Y="scY",e.VALUE="value",e.ROTATE="rotate",e.SKEW="skew",e.ALPHA_OFFSET="aO",e.RED_OFFSET="rO",e.GREEN_OFFSET="gO",e.BLUE_OFFSET="bO",e.ALPHA_MULTIPLIER="aM",e.RED_MULTIPLIER="rM",e.GREEN_MULTIPLIER="gM",e.BLUE_MULTIPLIER="bM",e.UVS="uvs",e.VERTICES="vertices",e.TRIANGLES="triangles",e.WEIGHTS="weights",e.SLOT_POSE="slotPose",e.BONE_POSE="bonePose",e.GLUE_WEIGHTS="glueWeights",e.GLUE_MESHES="glueMeshes",e.BONES="bones",e.POSITION_MODE="positionMode",e.SPACING_MODE="spacingMode",e.ROTATE_MODE="rotateMode",e.SPACING="spacing",e.ROTATE_OFFSET="rotateOffset",e.ROTATE_MIX="rotateMix",e.TRANSLATE_MIX="translateMix",e.TARGET_DISPLAY="targetDisplay",e.CLOSED="closed",e.CONSTANT_SPEED="constantSpeed",e.VERTEX_COUNT="vertexCount",e.LENGTHS="lengths",e.GOTO_AND_PLAY="gotoAndPlay",e.DEFAULT_NAME="default",e}();t.DataParser=e}(vnt||(vnt={})),function(t){var e=function(e){function r(){var i=null!==e&&e.apply(this,arguments)||this;return i._rawTextureAtlasIndex=0,i._rawBones=[],i._data=null,i._armature=null,i._bone=null,i._surface=null,i._slot=null,i._skin=null,i._mesh=null,i._animation=null,i._timeline=null,i._rawTextureAtlases=null,i._defaultColorOffset=-1,i._prevClockwise=0,i._prevRotation=0,i._helpMatrixA=new t.Matrix,i._helpMatrixB=new t.Matrix,i._helpTransform=new t.Transform,i._helpColorTransform=new t.ColorTransform,i._helpPoint=new t.Point,i._helpArray=[],i._intArray=[],i._floatArray=[],i._frameIntArray=[],i._frameFloatArray=[],i._frameArray=[],i._timelineArray=[],i._cacheRawMeshes=[],i._cacheMeshes=[],i._actionFrames=[],i._weightSlotPose={},i._weightBonePoses={},i._cacheBones={},i._slotChildActions={},i}return gnt(r,e),r._getBoolean=function(t,e,i){if(e in t){var r=t[e],n=typeof r;if("boolean"===n)return r;if("string"!==n)return!!r;switch(r){case"0":case"NaN":case"":case"false":case"null":case"undefined":return!1;default:return!0}}return i},r._getNumber=function(t,e,i){if(e in t){var r=t[e];return null===r||"NaN"===r?i:+r||0}return i},r._getString=function(e,i,r){if(i in e){var n=e[i];if("string"==typeof n){if(t.DragonBones.webAssembly)for(var s=0,a=n.length;s<a;++s)if(n.charCodeAt(s)>255)return encodeURI(n);return n}return String(n)}return r},r.prototype._getCurvePoint=function(t,e,i,r,n,s,a,o,l,h){var u=1-l,c=u*u,_=l*l,f=u*c,p=3*l*c,d=3*u*_,m=l*_;h.x=f*t+p*i+d*n+m*a,h.y=f*e+p*r+d*s+m*o},r.prototype._samplingEasingCurve=function(t,e){for(var i=t.length,r=-2,n=0,s=e.length;n<s;++n){for(var a=(n+1)/(s+1);(r+6<i?t[r+6]:1)<a;)r+=6;for(var o=r>=0&&r+6<i,l=o?t[r]:0,h=o?t[r+1]:0,u=t[r+2],c=t[r+3],_=t[r+4],f=t[r+5],p=o?t[r+6]:1,d=o?t[r+7]:1,m=0,y=1;y-m>1e-4;){var g=.5*(y+m);this._getCurvePoint(l,h,u,c,_,f,p,d,g,this._helpPoint),a-this._helpPoint.x>0?m=g:y=g}e[n]=this._helpPoint.y}},r.prototype._parseActionDataInFrame=function(e,i,r,n){t.DataParser.EVENT in e&&this._mergeActionFrame(e[t.DataParser.EVENT],i,10,r,n),t.DataParser.SOUND in e&&this._mergeActionFrame(e[t.DataParser.SOUND],i,11,r,n),t.DataParser.ACTION in e&&this._mergeActionFrame(e[t.DataParser.ACTION],i,0,r,n),t.DataParser.EVENTS in e&&this._mergeActionFrame(e[t.DataParser.EVENTS],i,10,r,n),t.DataParser.ACTIONS in e&&this._mergeActionFrame(e[t.DataParser.ACTIONS],i,0,r,n)},r.prototype._mergeActionFrame=function(e,r,n,s,a){for(var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length,l=this._parseActionData(e,n,s,a),h=0,u=null,c=0,_=l;c<_.length;c++){var f=_[c];this._armature.addAction(f,!1)}0===this._actionFrames.length&&((u=new i).frameStart=0,this._actionFrames.push(u),u=null);for(var p=0,d=this._actionFrames;p<d.length;p++){var m=d[p];if(m.frameStart===r){u=m;break}if(m.frameStart>r)break;h++}null===u&&((u=new i).frameStart=r,this._actionFrames.splice(h+1,0,u));for(var y=0;y<l.length;++y)u.actions.push(o+y)},r.prototype._parseArmature=function(e,i){var n=t.BaseObject.borrowObject(t.ArmatureData);if(n.name=r._getString(e,t.DataParser.NAME,""),n.frameRate=r._getNumber(e,t.DataParser.FRAME_RATE,this._data.frameRate),n.scale=i,t.DataParser.TYPE in e&&"string"==typeof e[t.DataParser.TYPE]?n.type=t.DataParser._getArmatureType(e[t.DataParser.TYPE]):n.type=r._getNumber(e,t.DataParser.TYPE,0),0===n.frameRate&&(n.frameRate=24),this._armature=n,t.DataParser.CANVAS in e){var s=e[t.DataParser.CANVAS],a=t.BaseObject.borrowObject(t.CanvasData);t.DataParser.COLOR in s?a.hasBackground=!0:a.hasBackground=!1,a.color=r._getNumber(s,t.DataParser.COLOR,0),a.x=r._getNumber(s,t.DataParser.X,0)*n.scale,a.y=r._getNumber(s,t.DataParser.Y,0)*n.scale,a.width=r._getNumber(s,t.DataParser.WIDTH,0)*n.scale,a.height=r._getNumber(s,t.DataParser.HEIGHT,0)*n.scale,n.canvas=a}if(t.DataParser.AABB in e){var o=e[t.DataParser.AABB];n.aabb.x=r._getNumber(o,t.DataParser.X,0)*n.scale,n.aabb.y=r._getNumber(o,t.DataParser.Y,0)*n.scale,n.aabb.width=r._getNumber(o,t.DataParser.WIDTH,0)*n.scale,n.aabb.height=r._getNumber(o,t.DataParser.HEIGHT,0)*n.scale}if(t.DataParser.BONE in e)for(var l=0,h=e[t.DataParser.BONE];l<h.length;l++){var u=h[l],c=r._getString(u,t.DataParser.PARENT,""),_=this._parseBone(u);if(c.length>0){var f=n.getBone(c);null!==f?_.parent=f:(c in this._cacheBones||(this._cacheBones[c]=[]),this._cacheBones[c].push(_))}if(_.name in this._cacheBones){for(var p=0,d=this._cacheBones[_.name];p<d.length;p++)d[p].parent=_;delete this._cacheBones[_.name]}n.addBone(_),this._rawBones.push(_)}if(t.DataParser.IK in e)for(var m=0,y=e[t.DataParser.IK];m<y.length;m++){var g=y[m];(B=this._parseIKConstraint(g))&&n.addConstraint(B)}if(n.sortBones(),t.DataParser.SLOT in e)for(var v=0,b=0,S=e[t.DataParser.SLOT];b<S.length;b++){var A=S[b];n.addSlot(this._parseSlot(A,v++))}if(t.DataParser.SKIN in e)for(var C=0,x=e[t.DataParser.SKIN];C<x.length;C++){var T=x[C];n.addSkin(this._parseSkin(T))}if(t.DataParser.PATH_CONSTRAINT in e)for(var w=0,E=e[t.DataParser.PATH_CONSTRAINT];w<E.length;w++){var B,D=E[w];(B=this._parsePathConstraint(D))&&n.addConstraint(B)}for(var M=0,P=this._cacheRawMeshes.length;M<P;++M){var R=this._cacheRawMeshes[M];t.DataParser.GLUE_WEIGHTS in R&&t.DataParser.GLUE_MESHES in R&&this._parseMeshGlue(R,this._cacheMeshes[M])}for(M=0,P=this._cacheRawMeshes.length;M<P;++M){var I=this._cacheRawMeshes[M],O=r._getString(I,t.DataParser.SHARE,"");if(0!==O.length){var F=r._getString(I,t.DataParser.SKIN,t.DataParser.DEFAULT_NAME);0===F.length&&(F=t.DataParser.DEFAULT_NAME);var L=n.getMesh(F,"",O);null!==L&&this._cacheMeshes[M].vertices.shareFrom(L.vertices)}}if(t.DataParser.ANIMATION in e)for(var V=0,k=e[t.DataParser.ANIMATION];V<k.length;V++){var N=k[V],G=this._parseAnimation(N);n.addAnimation(G)}if(t.DataParser.DEFAULT_ACTIONS in e)for(var z=0,U=this._parseActionData(e[t.DataParser.DEFAULT_ACTIONS],0,null,null);z<U.length;z++){var H=U[z];n.addAction(H,!0),0===H.type&&null!==(G=n.getAnimation(H.name))&&(n.defaultAnimation=G)}if(t.DataParser.ACTIONS in e)for(var j=0,W=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);j<W.length;j++)H=W[j],n.addAction(H,!1);for(var X in this._rawBones.length=0,this._cacheRawMeshes.length=0,this._cacheMeshes.length=0,this._armature=null,this._weightSlotPose)delete this._weightSlotPose[X];for(var X in this._weightBonePoses)delete this._weightBonePoses[X];for(var X in this._cacheBones)delete this._cacheBones[X];for(var X in this._slotChildActions)delete this._slotChildActions[X];return n},r.prototype._parseBone=function(e){var i=this._armature.scale;if(0===(t.DataParser.TYPE in e&&"string"==typeof e[t.DataParser.TYPE]?t.DataParser._getBoneType(e[t.DataParser.TYPE]):r._getNumber(e,t.DataParser.TYPE,0))){var n=t.BaseObject.borrowObject(t.BoneData);return n.inheritTranslation=r._getBoolean(e,t.DataParser.INHERIT_TRANSLATION,!0),n.inheritRotation=r._getBoolean(e,t.DataParser.INHERIT_ROTATION,!0),n.inheritScale=r._getBoolean(e,t.DataParser.INHERIT_SCALE,!0),n.inheritReflection=r._getBoolean(e,t.DataParser.INHERIT_REFLECTION,!0),n.length=r._getNumber(e,t.DataParser.LENGTH,0)*i,n.name=r._getString(e,t.DataParser.NAME,""),t.DataParser.TRANSFORM in e&&this._parseTransform(e[t.DataParser.TRANSFORM],n.transform,i),n}var s=t.BaseObject.borrowObject(t.SurfaceData);if(s.name=r._getString(e,t.DataParser.NAME,""),s.segmentX=r._getNumber(e,t.DataParser.SEGMENT_X,0),s.segmentY=r._getNumber(e,t.DataParser.SEGMENT_Y,0),s.vertices.length=(s.segmentX+1)*(s.segmentY+1)*2,t.DataParser.VERTICES in e)for(var a=e[t.DataParser.VERTICES],o=0,l=s.vertices.length;o<l;++o)o<a.length?s.vertices[o]=a[o]*i:s.vertices[o]=0;return s},r.prototype._parseIKConstraint=function(e){var i=this._armature.getBone(r._getString(e,t.DataParser.BONE,""));if(null===i)return null;var n=this._armature.getBone(r._getString(e,t.DataParser.TARGET,""));if(null===n)return null;var s=t.BaseObject.borrowObject(t.IKConstraintData);return s.scaleEnabled=r._getBoolean(e,t.DataParser.SCALE,!1),s.bendPositive=r._getBoolean(e,t.DataParser.BEND_POSITIVE,!0),s.weight=r._getNumber(e,t.DataParser.WEIGHT,1),s.name=r._getString(e,t.DataParser.NAME,""),s.type=0,s.target=n,r._getNumber(e,t.DataParser.CHAIN,0)>0&&null!==i.parent?(s.root=i.parent,s.bone=i):(s.root=i,s.bone=null),s},r.prototype._parsePathConstraint=function(e){var i=this._armature.getSlot(r._getString(e,t.DataParser.TARGET,""));if(null===i)return null;var n=this._armature.defaultSkin;if(null===n)return null;var s=n.getDisplay(i.name,r._getString(e,t.DataParser.TARGET_DISPLAY,i.name));if(null===s||!(s instanceof t.PathDisplayData))return null;var a=e[t.DataParser.BONES];if(null===a||0===a.length)return null;var o=t.BaseObject.borrowObject(t.PathConstraintData);o.name=r._getString(e,t.DataParser.NAME,""),o.type=1,o.pathSlot=i,o.pathDisplayData=s,o.target=i.parent,o.positionMode=t.DataParser._getPositionMode(r._getString(e,t.DataParser.POSITION_MODE,"")),o.spacingMode=t.DataParser._getSpacingMode(r._getString(e,t.DataParser.SPACING_MODE,"")),o.rotateMode=t.DataParser._getRotateMode(r._getString(e,t.DataParser.ROTATE_MODE,"")),o.position=r._getNumber(e,t.DataParser.POSITION,0),o.spacing=r._getNumber(e,t.DataParser.SPACING,0),o.rotateOffset=r._getNumber(e,t.DataParser.ROTATE_OFFSET,0),o.rotateMix=r._getNumber(e,t.DataParser.ROTATE_MIX,1),o.translateMix=r._getNumber(e,t.DataParser.TRANSLATE_MIX,1);for(var l=0,h=a;l<h.length;l++){var u=h[l],c=this._armature.getBone(u);null!==c&&(o.AddBone(c),null===o.root&&(o.root=c))}return o},r.prototype._parseSlot=function(e,i){var n=t.BaseObject.borrowObject(t.SlotData);return n.displayIndex=r._getNumber(e,t.DataParser.DISPLAY_INDEX,0),n.zOrder=i,n.name=r._getString(e,t.DataParser.NAME,""),n.parent=this._armature.getBone(r._getString(e,t.DataParser.PARENT,"")),t.DataParser.BLEND_MODE in e&&"string"==typeof e[t.DataParser.BLEND_MODE]?n.blendMode=t.DataParser._getBlendMode(e[t.DataParser.BLEND_MODE]):n.blendMode=r._getNumber(e,t.DataParser.BLEND_MODE,0),t.DataParser.COLOR in e?(n.color=t.SlotData.createColor(),this._parseColorTransform(e[t.DataParser.COLOR],n.color)):n.color=t.SlotData.DEFAULT_COLOR,t.DataParser.ACTIONS in e&&(this._slotChildActions[n.name]=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null)),n},r.prototype._parseSkin=function(e){var i=t.BaseObject.borrowObject(t.SkinData);if(i.name=r._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME),0===i.name.length&&(i.name=t.DataParser.DEFAULT_NAME),t.DataParser.SLOT in e){var n=e[t.DataParser.SLOT];this._skin=i;for(var s=0,a=n;s<a.length;s++){var o=a[s],l=r._getString(o,t.DataParser.NAME,""),h=this._armature.getSlot(l);if(null!==h){if(this._slot=h,t.DataParser.DISPLAY in o)for(var u=0,c=o[t.DataParser.DISPLAY];u<c.length;u++){var _=c[u];_?i.addDisplay(l,this._parseDisplay(_)):i.addDisplay(l,null)}this._slot=null}}this._skin=null}return i},r.prototype._parseDisplay=function(e){var i=r._getString(e,t.DataParser.NAME,""),n=r._getString(e,t.DataParser.PATH,""),s=0,a=null;switch(s=t.DataParser.TYPE in e&&"string"==typeof e[t.DataParser.TYPE]?t.DataParser._getDisplayType(e[t.DataParser.TYPE]):r._getNumber(e,t.DataParser.TYPE,s)){case 0:var o=a=t.BaseObject.borrowObject(t.ImageDisplayData);o.name=i,o.path=n.length>0?n:i,this._parsePivot(e,o);break;case 1:var l=a=t.BaseObject.borrowObject(t.ArmatureDisplayData);if(l.name=i,l.path=n.length>0?n:i,l.inheritAnimation=!0,t.DataParser.ACTIONS in e)for(var h=0,u=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);h<u.length;h++){var c=u[h];l.addAction(c)}else if(this._slot.name in this._slotChildActions){var _=this._skin.getDisplays(this._slot.name);if(null===_?0===this._slot.displayIndex:this._slot.displayIndex===_.length){for(var f=0,p=this._slotChildActions[this._slot.name];f<p.length;f++)c=p[f],l.addAction(c);delete this._slotChildActions[this._slot.name]}}break;case 2:var d=a=t.BaseObject.borrowObject(t.MeshDisplayData);d.vertices.inheritDeform=r._getBoolean(e,t.DataParser.INHERIT_DEFORM,!0),d.name=i,d.path=n.length>0?n:i,d.vertices.data=this._data,t.DataParser.SHARE in e?(this._cacheRawMeshes.push(e),this._cacheMeshes.push(d)):this._parseMesh(e,d),t.DataParser.GLUE_WEIGHTS in e&&t.DataParser.GLUE_MESHES in e&&(this._cacheRawMeshes.push(e),this._cacheMeshes.push(d));break;case 3:var m=this._parseBoundingBox(e);if(null!==m){var y=a=t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=i,y.path=n.length>0?n:i,y.boundingBox=m}break;case 4:var g=e[t.DataParser.LENGTHS],v=a=t.BaseObject.borrowObject(t.PathDisplayData);v.closed=r._getBoolean(e,t.DataParser.CLOSED,!1),v.constantSpeed=r._getBoolean(e,t.DataParser.CONSTANT_SPEED,!1),v.name=i,v.path=n.length>0?n:i,v.vertices.data=this._data,v.curveLengths.length=g.length;for(var b=0,S=g.length;b<S;++b)v.curveLengths[b]=g[b];this._parsePath(e,v)}return null!==a&&t.DataParser.TRANSFORM in e&&this._parseTransform(e[t.DataParser.TRANSFORM],a.transform,this._armature.scale),a},r.prototype._parsePath=function(e,i){var n=e[t.DataParser.VERTICES],s=r._getNumber(e,t.DataParser.VERTEX_COUNT,0),a=this._floatArray.length,o=this._intArray.length;if(i.vertices.offset=o,this._intArray.length+=2,this._intArray[o+0]=s,this._intArray[o+2]=a,t.DataParser.WEIGHTS in e){var l=e[t.DataParser.WEIGHTS],h=e[t.DataParser.BONES],u=h.length,c=Math.floor(l.length-s)/2,_=this._intArray.length,f=this._floatArray.length,p=this._armature.sortedBones,d=t.BaseObject.borrowObject(t.WeightData);for(d.count=c,d.offset=_,this._intArray.length+=2+u+s+c,this._intArray[_+0]=u,this._intArray[_+1]=f,B=0;B<u;B++){var m=h[B],y=this._rawBones[m];d.addBone(y),this._intArray[_+2+B]=p.indexOf(y)}this._floatArray.length+=3*c,B=0;for(var g=0,v=0,b=_+2+u,S=f;B<c;B++){var A=l[g++];this._intArray[b++]=A;for(var C=0;C<A;C++){var x=l[g++],T=l[g++],w=n[v++],E=n[v++];this._intArray[b++]=h.indexOf(x),this._floatArray[S++]=T,this._floatArray[S++]=w,this._floatArray[S++]=E}}i.vertices.weight=d}else{this._floatArray.length+=n.length;for(var B=0,D=n.length;B<D;++B)this._floatArray[a+B]=n[B]}},r.prototype._parsePivot=function(e,i){if(t.DataParser.PIVOT in e){var n=e[t.DataParser.PIVOT];i.pivot.x=r._getNumber(n,t.DataParser.X,0),i.pivot.y=r._getNumber(n,t.DataParser.Y,0)}else i.pivot.x=.5,i.pivot.y=.5},r.prototype._parseMesh=function(e,i){var r=e[t.DataParser.VERTICES],n=e[t.DataParser.UVS],s=e[t.DataParser.TRIANGLES],a=Math.floor(r.length/2),o=Math.floor(s.length/3),l=this._floatArray.length,h=l+2*a,u=this._intArray.length,c=this._skin.name+"_"+this._slot.name+"_"+i.name;i.vertices.offset=u,this._intArray.length+=4+3*o,this._intArray[u+0]=a,this._intArray[u+1]=o,this._intArray[u+2]=l;for(var _=0,f=3*o;_<f;++_)this._intArray[u+4+_]=s[_];for(this._floatArray.length+=2*a+2*a,_=0,f=2*a;_<f;++_)this._floatArray[l+_]=r[_],this._floatArray[h+_]=n[_];if(t.DataParser.WEIGHTS in e){var p=e[t.DataParser.WEIGHTS],d=e[t.DataParser.SLOT_POSE],m=e[t.DataParser.BONE_POSE],y=this._armature.sortedBones,g=new Array,v=Math.floor(m.length/7),b=this._floatArray.length,S=Math.floor(p.length-a)/2,A=this._intArray.length,C=t.BaseObject.borrowObject(t.WeightData);for(C.count=S,C.offset=A,g.length=v,this._intArray.length+=2+v+a+S,this._intArray[A+1]=b,_=0;_<v;++_){var x=m[7*_],T=this._rawBones[x];C.addBone(T),g[_]=x,this._intArray[A+2+_]=y.indexOf(T)}this._floatArray.length+=3*S,this._helpMatrixA.copyFromArray(d,0),_=0;for(var w=0,E=A+2+v,B=b;_<a;++_){var D=2*_,M=this._intArray[E++]=p[w++],P=this._floatArray[l+D],R=this._floatArray[l+D+1];this._helpMatrixA.transformPoint(P,R,this._helpPoint),P=this._helpPoint.x,R=this._helpPoint.y;for(var I=0;I<M;++I){x=p[w++];var O=g.indexOf(x);this._helpMatrixB.copyFromArray(m,7*O+1),this._helpMatrixB.invert(),this._helpMatrixB.transformPoint(P,R,this._helpPoint),this._intArray[E++]=O,this._floatArray[B++]=p[w++],this._floatArray[B++]=this._helpPoint.x,this._floatArray[B++]=this._helpPoint.y}}i.vertices.weight=C,this._weightSlotPose[c]=d,this._weightBonePoses[c]=m}},r.prototype._parseMeshGlue=function(){},r.prototype._parseBoundingBox=function(e){var i=null,n=0;switch(n=t.DataParser.SUB_TYPE in e&&"string"==typeof e[t.DataParser.SUB_TYPE]?t.DataParser._getBoundingBoxType(e[t.DataParser.SUB_TYPE]):r._getNumber(e,t.DataParser.SUB_TYPE,n)){case 0:i=t.BaseObject.borrowObject(t.RectangleBoundingBoxData);break;case 1:i=t.BaseObject.borrowObject(t.EllipseBoundingBoxData);break;case 2:i=this._parsePolygonBoundingBox(e)}return null!==i&&(i.color=r._getNumber(e,t.DataParser.COLOR,0),0!==i.type&&1!==i.type||(i.width=r._getNumber(e,t.DataParser.WIDTH,0),i.height=r._getNumber(e,t.DataParser.HEIGHT,0))),i},r.prototype._parsePolygonBoundingBox=function(e){var i=t.BaseObject.borrowObject(t.PolygonBoundingBoxData);if(t.DataParser.VERTICES in e){var r=this._armature.scale,n=e[t.DataParser.VERTICES],s=i.vertices;t.DragonBones.webAssembly?s.resize(n.length,0):s.length=n.length;for(var a=0,o=n.length;a<o;a+=2){var l=n[a]*r,h=n[a+1]*r;t.DragonBones.webAssembly?(s.set(a,l),s.set(a+1,h)):(s[a]=l,s[a+1]=h),0===a?(i.x=l,i.y=h,i.width=l,i.height=h):(l<i.x?i.x=l:l>i.width&&(i.width=l),h<i.y?i.y=h:h>i.height&&(i.height=h))}i.width-=i.x,i.height-=i.y}else console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.");return i},r.prototype._parseAnimation=function(e){var i=t.BaseObject.borrowObject(t.AnimationData);if(i.frameCount=Math.max(r._getNumber(e,t.DataParser.DURATION,1),1),i.playTimes=r._getNumber(e,t.DataParser.PLAY_TIMES,1),i.duration=i.frameCount/this._armature.frameRate,i.fadeInTime=r._getNumber(e,t.DataParser.FADE_IN_TIME,0),i.scale=r._getNumber(e,t.DataParser.SCALE,1),i.name=r._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME),0===i.name.length&&(i.name=t.DataParser.DEFAULT_NAME),i.frameIntOffset=this._frameIntArray.length,i.frameFloatOffset=this._frameFloatArray.length,i.frameOffset=this._frameArray.length,this._animation=i,t.DataParser.FRAME in e){var n=e[t.DataParser.FRAME],s=n.length;if(s>0)for(var a=0,o=0;a<s;++a){var l=n[a];this._parseActionDataInFrame(l,o,null,null),o+=r._getNumber(l,t.DataParser.DURATION,1)}}if(t.DataParser.Z_ORDER in e&&(this._animation.zOrderTimeline=this._parseTimeline(e[t.DataParser.Z_ORDER],null,t.DataParser.FRAME,1,!1,!1,0,this._parseZOrderFrame)),t.DataParser.BONE in e)for(var h=0,u=e[t.DataParser.BONE];h<u.length;h++){var c=u[h];this._parseBoneTimeline(c)}if(t.DataParser.SURFACE in e)for(var _=0,f=e[t.DataParser.SURFACE];_<f.length;_++){c=f[_];var p=r._getString(c,t.DataParser.NAME,"");this._surface=this._armature.getBone(p),null!==this._surface&&(null!==(B=this._parseTimeline(c,null,t.DataParser.FRAME,50,!1,!0,0,this._parseSurfaceFrame))&&this._animation.addSurfaceTimeline(this._surface,B),this._surface=null)}if(t.DataParser.SLOT in e)for(var d=0,m=e[t.DataParser.SLOT];d<m.length;d++)c=m[d],this._parseSlotTimeline(c);if(t.DataParser.FFD in e)for(var y=0,g=e[t.DataParser.FFD];y<g.length;y++){c=g[y];var v=r._getString(c,t.DataParser.SKIN,t.DataParser.DEFAULT_NAME),b=r._getString(c,t.DataParser.SLOT,""),S=r._getString(c,t.DataParser.NAME,"");0===v.length&&(v=t.DataParser.DEFAULT_NAME),this._slot=this._armature.getSlot(b),this._mesh=this._armature.getMesh(v,b,S),null!==this._slot&&null!==this._mesh&&(null!==(B=this._parseTimeline(c,null,t.DataParser.FRAME,22,!1,!0,0,this._parseSlotFFDFrame))&&this._animation.addSlotTimeline(this._slot,B),this._slot=null,this._mesh=null)}if(t.DataParser.IK in e)for(var A=0,C=e[t.DataParser.IK];A<C.length;A++){c=C[A];var x=r._getString(c,t.DataParser.NAME,""),T=this._armature.getConstraint(x);null!==T&&null!==(B=this._parseTimeline(c,null,t.DataParser.FRAME,30,!0,!1,2,this._parseIKConstraintFrame))&&this._animation.addConstraintTimeline(T,B)}if(t.DataParser.ANIMATION in e)for(var w=0,E=e[t.DataParser.ANIMATION];w<E.length;w++){c=E[w];var B,D=r._getString(c,t.DataParser.NAME,"");null!==(B=this._parseTimeline(c,null,t.DataParser.FRAME,40,!0,!1,2,this._parseAnimationFrame))&&this._animation.addAnimationTimeline(D,B)}return this._actionFrames.length>0&&(this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,!1,!1,0,this._parseActionFrame),this._actionFrames.length=0),this._animation=null,i},r.prototype._parseTimeline=function(e,n,s,a,o,l,h,u){if(null!==e&&s.length>0&&s in e&&(n=e[s]),null===n)return null;var c=n.length;if(0===c)return null;var _=this._frameIntArray.length,f=this._frameFloatArray.length,p=t.BaseObject.borrowObject(t.TimelineData),d=this._timelineArray.length;if(this._timelineArray.length+=5+c,null!==e?(this._timelineArray[d+0]=Math.round(100*r._getNumber(e,t.DataParser.SCALE,1)),this._timelineArray[d+1]=Math.round(100*r._getNumber(e,t.DataParser.OFFSET,0))):(this._timelineArray[d+0]=100,this._timelineArray[d+1]=0),this._timelineArray[d+2]=c,this._timelineArray[d+3]=h,this._timelineArray[d+4]=o?_-this._animation.frameIntOffset:l?f-this._animation.frameFloatOffset:0,this._timeline=p,p.type=a,p.offset=d,1===c)p.frameIndicesOffset=-1,this._timelineArray[d+5+0]=u.call(this,n[0],0,0)-this._animation.frameOffset;else{var m=this._animation.frameCount+1,y=this._data.frameIndices,g=0;t.DragonBones.webAssembly?(g=y.size(),y.resize(g+m,0)):(g=y.length,y.length+=m),p.frameIndicesOffset=g;for(var v=0,b=0,S=0,A=0;v<m;++v){if(S+A<=v&&b<c){var C=n[b];S=v,A=b===c-1?this._animation.frameCount-S:C instanceof i?this._actionFrames[b+1].frameStart-S:r._getNumber(C,t.DataParser.DURATION,1),this._timelineArray[d+5+b]=u.call(this,C,S,A)-this._animation.frameOffset,b++}t.DragonBones.webAssembly?y.set(g+v,b-1):y[g+v]=b-1}}return this._timeline=null,p},r.prototype._parseBoneTimeline=function(e){var i,n=this._armature.getBone(r._getString(e,t.DataParser.NAME,""));null!==n&&(this._bone=n,this._slot=this._armature.getSlot(this._bone.name),t.DataParser.TRANSLATE_FRAME in e&&null!==(i=this._parseTimeline(e,null,t.DataParser.TRANSLATE_FRAME,11,!1,!0,2,this._parseBoneTranslateFrame))&&this._animation.addBoneTimeline(n,i),t.DataParser.ROTATE_FRAME in e&&null!==(i=this._parseTimeline(e,null,t.DataParser.ROTATE_FRAME,12,!1,!0,2,this._parseBoneRotateFrame))&&this._animation.addBoneTimeline(n,i),t.DataParser.SCALE_FRAME in e&&null!==(i=this._parseTimeline(e,null,t.DataParser.SCALE_FRAME,13,!1,!0,2,this._parseBoneScaleFrame))&&this._animation.addBoneTimeline(n,i),t.DataParser.FRAME in e&&null!==(i=this._parseTimeline(e,null,t.DataParser.FRAME,10,!1,!0,6,this._parseBoneAllFrame))&&this._animation.addBoneTimeline(n,i),this._bone=null,this._slot=null)},r.prototype._parseSlotTimeline=function(e){var i=this._armature.getSlot(r._getString(e,t.DataParser.NAME,""));if(null!==i){this._slot=i;var n;null!==(n=t.DataParser.DISPLAY_FRAME in e?this._parseTimeline(e,null,t.DataParser.DISPLAY_FRAME,20,!1,!1,0,this._parseSlotDisplayFrame):this._parseTimeline(e,null,t.DataParser.FRAME,20,!1,!1,0,this._parseSlotDisplayFrame))&&this._animation.addSlotTimeline(i,n);var s;null!==(s=t.DataParser.COLOR_FRAME in e?this._parseTimeline(e,null,t.DataParser.COLOR_FRAME,21,!0,!1,1,this._parseSlotColorFrame):this._parseTimeline(e,null,t.DataParser.FRAME,21,!0,!1,1,this._parseSlotColorFrame))&&this._animation.addSlotTimeline(i,s),this._slot=null}},r.prototype._parseFrame=function(t,e){var i=this._frameArray.length;return this._frameArray.length+=1,this._frameArray[i+0]=e,i},r.prototype._parseTweenFrame=function(e,i,n){var s=this._parseFrame(e,i,n);if(n>0)if(t.DataParser.CURVE in e){var a=n+1;this._helpArray.length=a,this._samplingEasingCurve(e[t.DataParser.CURVE],this._helpArray),this._frameArray.length+=2+this._helpArray.length,this._frameArray[s+1]=2,this._frameArray[s+2]=a;for(var o=0;o<a;++o)this._frameArray[s+3+o]=Math.round(1e4*this._helpArray[o])}else{var l=-2;t.DataParser.TWEEN_EASING in e&&(l=r._getNumber(e,t.DataParser.TWEEN_EASING,-2)),-2===l?(this._frameArray.length+=1,this._frameArray[s+1]=0):0===l?(this._frameArray.length+=1,this._frameArray[s+1]=1):l<0?(this._frameArray.length+=2,this._frameArray[s+1]=3,this._frameArray[s+2]=Math.round(100*-l)):l<=1?(this._frameArray.length+=2,this._frameArray[s+1]=4,this._frameArray[s+2]=Math.round(100*l)):(this._frameArray.length+=2,this._frameArray[s+1]=5,this._frameArray[s+2]=Math.round(100*l-100))}else this._frameArray.length+=1,this._frameArray[s+1]=0;return s},r.prototype._parseActionFrame=function(t,e){var i=this._frameArray.length,r=t.actions.length;this._frameArray.length+=2+r,this._frameArray[i+0]=e,this._frameArray[i+0+1]=r;for(var n=0;n<r;++n)this._frameArray[i+0+2+n]=t.actions[n];return i},r.prototype._parseZOrderFrame=function(e,i,r){var n=this._parseFrame(e,i,r);if(t.DataParser.Z_ORDER in e){var s=e[t.DataParser.Z_ORDER];if(s.length>0){for(var a=this._armature.sortedSlots.length,o=new Array(a-s.length/2),l=new Array(a),h=0;h<o.length;++h)o[h]=0;for(var u=0;u<a;++u)l[u]=-1;for(var c=0,_=0,f=0,p=s.length;f<p;f+=2){for(var d=s[f],m=s[f+1];c!==d;)o[_++]=c++;l[c+m]=c++}for(;c<a;)o[_++]=c++;this._frameArray.length+=1+a,this._frameArray[n+1]=a;for(var y=a;y--;)-1===l[y]?this._frameArray[n+2+y]=o[--_]||0:this._frameArray[n+2+y]=l[y]||0;return n}}return this._frameArray.length+=1,this._frameArray[n+1]=0,n},r.prototype._parseBoneAllFrame=function(e,i,n){this._helpTransform.identity(),t.DataParser.TRANSFORM in e&&this._parseTransform(e[t.DataParser.TRANSFORM],this._helpTransform,1);var s=this._helpTransform.rotation;0!==i&&(0===this._prevClockwise?s=this._prevRotation+t.Transform.normalizeRadian(s-this._prevRotation):((this._prevClockwise>0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+t.Transform.PI_D*this._prevClockwise)),this._prevClockwise=r._getNumber(e,t.DataParser.TWEEN_ROTATE,0),this._prevRotation=s;var a=this._parseTweenFrame(e,i,n),o=this._frameFloatArray.length;return this._frameFloatArray.length+=6,this._frameFloatArray[o++]=this._helpTransform.x,this._frameFloatArray[o++]=this._helpTransform.y,this._frameFloatArray[o++]=s,this._frameFloatArray[o++]=this._helpTransform.skew,this._frameFloatArray[o++]=this._helpTransform.scaleX,this._frameFloatArray[o++]=this._helpTransform.scaleY,this._parseActionDataInFrame(e,i,this._bone,this._slot),a},r.prototype._parseBoneTranslateFrame=function(e,i,n){var s=this._parseTweenFrame(e,i,n),a=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[a++]=r._getNumber(e,t.DataParser.X,0),this._frameFloatArray[a++]=r._getNumber(e,t.DataParser.Y,0),s},r.prototype._parseBoneRotateFrame=function(e,i,n){var s=r._getNumber(e,t.DataParser.ROTATE,0)*t.Transform.DEG_RAD;0!==i&&(0===this._prevClockwise?s=this._prevRotation+t.Transform.normalizeRadian(s-this._prevRotation):((this._prevClockwise>0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+t.Transform.PI_D*this._prevClockwise)),this._prevClockwise=r._getNumber(e,t.DataParser.CLOCK_WISE,0),this._prevRotation=s;var a=this._parseTweenFrame(e,i,n),o=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[o++]=s,this._frameFloatArray[o++]=r._getNumber(e,t.DataParser.SKEW,0)*t.Transform.DEG_RAD,a},r.prototype._parseBoneScaleFrame=function(e,i,n){var s=this._parseTweenFrame(e,i,n),a=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[a++]=r._getNumber(e,t.DataParser.X,1),this._frameFloatArray[a++]=r._getNumber(e,t.DataParser.Y,1),s},r.prototype._parseSurfaceFrame=function(e,i,n){var s=this._frameFloatArray.length,a=this._parseTweenFrame(e,i,n),o=e[t.DataParser.VERTICES],l=r._getNumber(e,t.DataParser.OFFSET,0),h=this._surface.vertices.length/2,u=0,c=0;this._frameFloatArray.length+=2*h;for(var _=0;_<2*h;_+=2)u=_<l||_-l>=o.length?0:o[_-l],c=_+1<l||_+1-l>=o.length?0:o[_+1-l],this._frameFloatArray[s+_]=u,this._frameFloatArray[s+_+1]=c;if(0===i){var f=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[f+0]=0,this._frameIntArray[f+1]=this._frameFloatArray.length-s,this._frameIntArray[f+2]=this._frameFloatArray.length-s,this._frameIntArray[f+3]=0,this._frameIntArray[f+4]=s-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=f-this._animation.frameIntOffset}return a},r.prototype._parseSlotDisplayFrame=function(e,i,n){var s=this._parseFrame(e,i,n);return this._frameArray.length+=1,t.DataParser.VALUE in e?this._frameArray[s+1]=r._getNumber(e,t.DataParser.VALUE,0):this._frameArray[s+1]=r._getNumber(e,t.DataParser.DISPLAY_INDEX,0),this._parseActionDataInFrame(e,i,this._slot.parent,this._slot),s},r.prototype._parseSlotColorFrame=function(e,i,r){var n=this._parseTweenFrame(e,i,r),s=-1;if(t.DataParser.VALUE in e||t.DataParser.COLOR in e){var a=t.DataParser.VALUE in e?e[t.DataParser.VALUE]:e[t.DataParser.COLOR];for(var o in a){this._parseColorTransform(a,this._helpColorTransform),s=this._intArray.length,this._intArray.length+=8,this._intArray[s++]=Math.round(100*this._helpColorTransform.alphaMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.redMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.greenMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.blueMultiplier),this._intArray[s++]=Math.round(this._helpColorTransform.alphaOffset),this._intArray[s++]=Math.round(this._helpColorTransform.redOffset),this._intArray[s++]=Math.round(this._helpColorTransform.greenOffset),this._intArray[s++]=Math.round(this._helpColorTransform.blueOffset),s-=8;break}}s<0&&(this._defaultColorOffset<0&&(this._defaultColorOffset=s=this._intArray.length,this._intArray.length+=8,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=0,this._intArray[s++]=0,this._intArray[s++]=0,this._intArray[s++]=0),s=this._defaultColorOffset);var l=this._frameIntArray.length;return this._frameIntArray.length+=1,this._frameIntArray[l]=s,n},r.prototype._parseSlotFFDFrame=function(e,i,n){var s=this._frameFloatArray.length,a=this._parseTweenFrame(e,i,n),o=t.DataParser.VERTICES in e?e[t.DataParser.VERTICES]:null,l=r._getNumber(e,t.DataParser.OFFSET,0),h=this._intArray[this._mesh.vertices.offset+0],u=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name,c=this._mesh.vertices.weight,_=0,f=0,p=0,d=0;if(null!==c){var m=this._weightSlotPose[u];this._helpMatrixA.copyFromArray(m,0),this._frameFloatArray.length+=2*c.count,p=c.offset+2+c.bones.length}else this._frameFloatArray.length+=2*h;for(var y=0;y<2*h;y+=2)if(null===o?(_=0,f=0):(_=y<l||y-l>=o.length?0:o[y-l],f=y+1<l||y+1-l>=o.length?0:o[y+1-l]),null!==c){var g=this._weightBonePoses[u],v=this._intArray[p++];this._helpMatrixA.transformPoint(_,f,this._helpPoint,!0),_=this._helpPoint.x,f=this._helpPoint.y;for(var b=0;b<v;++b){var S=this._intArray[p++];this._helpMatrixB.copyFromArray(g,7*S+1),this._helpMatrixB.invert(),this._helpMatrixB.transformPoint(_,f,this._helpPoint,!0),this._frameFloatArray[s+d++]=this._helpPoint.x,this._frameFloatArray[s+d++]=this._helpPoint.y}}else this._frameFloatArray[s+y]=_,this._frameFloatArray[s+y+1]=f;if(0===i){var A=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[A+0]=this._mesh.vertices.offset,this._frameIntArray[A+1]=this._frameFloatArray.length-s,this._frameIntArray[A+2]=this._frameFloatArray.length-s,this._frameIntArray[A+3]=0,this._frameIntArray[A+4]=s-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=A-this._animation.frameIntOffset}return a},r.prototype._parseIKConstraintFrame=function(e,i,n){var s=this._parseTweenFrame(e,i,n),a=this._frameIntArray.length;return this._frameIntArray.length+=2,this._frameIntArray[a++]=r._getBoolean(e,t.DataParser.BEND_POSITIVE,!0)?1:0,this._frameIntArray[a++]=Math.round(100*r._getNumber(e,t.DataParser.WEIGHT,1)),s},r.prototype._parseAnimationFrame=function(e,i,n){var s=this._parseTweenFrame(e,i,n),a=this._frameIntArray.length;return this._frameIntArray.length+=2,this._frameIntArray[a++]=r._getNumber(e,t.DataParser.VALUE,0),this._frameIntArray[a++]=Math.round(100*r._getNumber(e,t.DataParser.WEIGHT,1)),s},r.prototype._parseActionData=function(e,i,n,s){var a=new Array;if("string"==typeof e)(u=t.BaseObject.borrowObject(t.ActionData)).type=i,u.name=e,u.bone=n,u.slot=s,a.push(u);else if(e instanceof Array)for(var o=0,l=e;o<l.length;o++){var h=l[o],u=t.BaseObject.borrowObject(t.ActionData);if(t.DataParser.GOTO_AND_PLAY in h?(u.type=0,u.name=r._getString(h,t.DataParser.GOTO_AND_PLAY,"")):(t.DataParser.TYPE in h&&"string"==typeof h[t.DataParser.TYPE]?u.type=t.DataParser._getActionType(h[t.DataParser.TYPE]):u.type=r._getNumber(h,t.DataParser.TYPE,i),u.name=r._getString(h,t.DataParser.NAME,"")),t.DataParser.BONE in h){var c=r._getString(h,t.DataParser.BONE,"");u.bone=this._armature.getBone(c)}else u.bone=n;if(t.DataParser.SLOT in h){var _=r._getString(h,t.DataParser.SLOT,"");u.slot=this._armature.getSlot(_)}else u.slot=s;var f=null;if(t.DataParser.INTS in h){null===f&&(f=t.BaseObject.borrowObject(t.UserData));for(var p=0,d=h[t.DataParser.INTS];p<d.length;p++){var m=d[p];f.addInt(m)}}if(t.DataParser.FLOATS in h){null===f&&(f=t.BaseObject.borrowObject(t.UserData));for(var y=0,g=h[t.DataParser.FLOATS];y<g.length;y++)m=g[y],f.addFloat(m)}if(t.DataParser.STRINGS in h){null===f&&(f=t.BaseObject.borrowObject(t.UserData));for(var v=0,b=h[t.DataParser.STRINGS];v<b.length;v++)m=b[v],f.addString(m)}u.data=f,a.push(u)}return a},r.prototype._parseTransform=function(e,i,n){i.x=r._getNumber(e,t.DataParser.X,0)*n,i.y=r._getNumber(e,t.DataParser.Y,0)*n,t.DataParser.ROTATE in e||t.DataParser.SKEW in e?(i.rotation=t.Transform.normalizeRadian(r._getNumber(e,t.DataParser.ROTATE,0)*t.Transform.DEG_RAD),i.skew=t.Transform.normalizeRadian(r._getNumber(e,t.DataParser.SKEW,0)*t.Transform.DEG_RAD)):(t.DataParser.SKEW_X in e||t.DataParser.SKEW_Y in e)&&(i.rotation=t.Transform.normalizeRadian(r._getNumber(e,t.DataParser.SKEW_Y,0)*t.Transform.DEG_RAD),i.skew=t.Transform.normalizeRadian(r._getNumber(e,t.DataParser.SKEW_X,0)*t.Transform.DEG_RAD)-i.rotation),i.scaleX=r._getNumber(e,t.DataParser.SCALE_X,1),i.scaleY=r._getNumber(e,t.DataParser.SCALE_Y,1)},r.prototype._parseColorTransform=function(e,i){i.alphaMultiplier=.01*r._getNumber(e,t.DataParser.ALPHA_MULTIPLIER,100),i.redMultiplier=.01*r._getNumber(e,t.DataParser.RED_MULTIPLIER,100),i.greenMultiplier=.01*r._getNumber(e,t.DataParser.GREEN_MULTIPLIER,100),i.blueMultiplier=.01*r._getNumber(e,t.DataParser.BLUE_MULTIPLIER,100),i.alphaOffset=r._getNumber(e,t.DataParser.ALPHA_OFFSET,0),i.redOffset=r._getNumber(e,t.DataParser.RED_OFFSET,0),i.greenOffset=r._getNumber(e,t.DataParser.GREEN_OFFSET,0),i.blueOffset=r._getNumber(e,t.DataParser.BLUE_OFFSET,0)},r.prototype._parseArray=function(){this._intArray.length=0,this._floatArray.length=0,this._frameIntArray.length=0,this._frameFloatArray.length=0,this._frameArray.length=0,this._timelineArray.length=0},r.prototype._modifyArray=function(){this._intArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._intArray.push(0),this._frameIntArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._frameIntArray.push(0),this._frameArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._frameArray.push(0),this._timelineArray.length%Uint16Array.BYTES_PER_ELEMENT!=0&&this._timelineArray.push(0);var e=this._intArray.length*Int16Array.BYTES_PER_ELEMENT,i=this._floatArray.length*Float32Array.BYTES_PER_ELEMENT,r=this._frameIntArray.length*Int16Array.BYTES_PER_ELEMENT,n=this._frameFloatArray.length*Float32Array.BYTES_PER_ELEMENT,s=this._frameArray.length*Int16Array.BYTES_PER_ELEMENT,a=this._timelineArray.length*Uint16Array.BYTES_PER_ELEMENT,o=e+i+r+n+s+a;if(t.DragonBones.webAssembly){for(var l=t.webAssemblyModule.HEAP16.buffer,h=t.webAssemblyModule._malloc(o),u=new Int16Array(l,h,this._intArray.length),c=new Float32Array(l,h+e,this._floatArray.length),_=new Int16Array(l,h+e+i,this._frameIntArray.length),f=new Float32Array(l,h+e+i+r,this._frameFloatArray.length),p=new Int16Array(l,h+e+i+r+n,this._frameArray.length),d=new Uint16Array(l,h+e+i+r+n+s,this._timelineArray.length),m=0,y=this._intArray.length;m<y;++m)u[m]=this._intArray[m];for(m=0,y=this._floatArray.length;m<y;++m)c[m]=this._floatArray[m];for(m=0,y=this._frameIntArray.length;m<y;++m)_[m]=this._frameIntArray[m];for(m=0,y=this._frameFloatArray.length;m<y;++m)f[m]=this._frameFloatArray[m];for(m=0,y=this._frameArray.length;m<y;++m)p[m]=this._frameArray[m];for(m=0,y=this._timelineArray.length;m<y;++m)d[m]=this._timelineArray[m];t.webAssemblyModule.setDataBinary(this._data,h,e,i,r,n,s,a)}else{var g=new ArrayBuffer(o);for(u=new Int16Array(g,0,this._intArray.length),c=new Float32Array(g,e,this._floatArray.length),_=new Int16Array(g,e+i,this._frameIntArray.length),f=new Float32Array(g,e+i+r,this._frameFloatArray.length),p=new Int16Array(g,e+i+r+n,this._frameArray.length),d=new Uint16Array(g,e+i+r+n+s,this._timelineArray.length),m=0,y=this._intArray.length;m<y;++m)u[m]=this._intArray[m];for(m=0,y=this._floatArray.length;m<y;++m)c[m]=this._floatArray[m];for(m=0,y=this._frameIntArray.length;m<y;++m)_[m]=this._frameIntArray[m];for(m=0,y=this._frameFloatArray.length;m<y;++m)f[m]=this._frameFloatArray[m];for(m=0,y=this._frameArray.length;m<y;++m)p[m]=this._frameArray[m];for(m=0,y=this._timelineArray.length;m<y;++m)d[m]=this._timelineArray[m];this._data.binary=g,this._data.intArray=u,this._data.floatArray=c,this._data.frameIntArray=_,this._data.frameFloatArray=f,this._data.frameArray=p,this._data.timelineArray=d}this._defaultColorOffset=-1},r.prototype.parseDragonBonesData=function(e,i){void 0===i&&(i=1),console.assert(null!=e,"Data error.");var n=r._getString(e,t.DataParser.VERSION,""),s=r._getString(e,t.DataParser.COMPATIBLE_VERSION,"");if(t.DataParser.DATA_VERSIONS.indexOf(n)>=0||t.DataParser.DATA_VERSIONS.indexOf(s)>=0){var a=t.BaseObject.borrowObject(t.DragonBonesData);if(a.version=n,a.name=r._getString(e,t.DataParser.NAME,""),a.frameRate=r._getNumber(e,t.DataParser.FRAME_RATE,24),0===a.frameRate&&(a.frameRate=24),t.DataParser.ARMATURE in e){this._data=a,this._parseArray(e);for(var o=0,l=e[t.DataParser.ARMATURE];o<l.length;o++){var h=l[o];a.addArmature(this._parseArmature(h,i))}this._data.binary||this._modifyArray(),t.DataParser.STAGE in e?a.stage=a.getArmature(r._getString(e,t.DataParser.STAGE,"")):a.armatureNames.length>0&&(a.stage=a.getArmature(a.armatureNames[0])),this._data=null}return t.DataParser.TEXTURE_ATLAS in e&&(this._rawTextureAtlases=e[t.DataParser.TEXTURE_ATLAS]),a}return console.assert(!1,"Nonsupport data version: "+n+"\nPlease convert DragonBones data to support version.\nRead more: https://github.com/DragonBones/Tools/"),null},r.prototype.parseTextureAtlasData=function(e,i,n){if(void 0===n&&(n=1),console.assert(void 0!==e),null===e){if(null===this._rawTextureAtlases||0===this._rawTextureAtlases.length)return!1;var s=this._rawTextureAtlases[this._rawTextureAtlasIndex++];return this.parseTextureAtlasData(s,i,n),this._rawTextureAtlasIndex>=this._rawTextureAtlases.length&&(this._rawTextureAtlasIndex=0,this._rawTextureAtlases=null),!0}if(i.width=r._getNumber(e,t.DataParser.WIDTH,0),i.height=r._getNumber(e,t.DataParser.HEIGHT,0),i.scale=1===n?1/r._getNumber(e,t.DataParser.SCALE,1):n,i.name=r._getString(e,t.DataParser.NAME,""),i.imagePath=r._getString(e,t.DataParser.IMAGE_PATH,""),t.DataParser.SUB_TEXTURE in e)for(var a=e[t.DataParser.SUB_TEXTURE],o=0,l=a.length;o<l;++o){var h=a[o],u=i.createTexture();u.rotated=r._getBoolean(h,t.DataParser.ROTATED,!1),u.name=r._getString(h,t.DataParser.NAME,""),u.region.x=r._getNumber(h,t.DataParser.X,0),u.region.y=r._getNumber(h,t.DataParser.Y,0),u.region.width=r._getNumber(h,t.DataParser.WIDTH,0),u.region.height=r._getNumber(h,t.DataParser.HEIGHT,0);var c=r._getNumber(h,t.DataParser.FRAME_WIDTH,-1),_=r._getNumber(h,t.DataParser.FRAME_HEIGHT,-1);c>0&&_>0&&(u.frame=t.TextureData.createRectangle(),u.frame.x=r._getNumber(h,t.DataParser.FRAME_X,0),u.frame.y=r._getNumber(h,t.DataParser.FRAME_Y,0),u.frame.width=c,u.frame.height=_),i.addTexture(u)}return!0},r.getInstance=function(){return null===r._objectDataParserInstance&&(r._objectDataParserInstance=new r),r._objectDataParserInstance},r._objectDataParserInstance=null,r}(t.DataParser);t.ObjectDataParser=e;var i=function(){this.frameStart=0,this.actions=[]};t.ActionFrame=i}(vnt||(vnt={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return gnt(i,e),i.prototype._inRange=function(t,e,i){return e<=t&&t<=i},i.prototype._decodeUTF8=function(t){for(var e,i=0,r="",n=0,s=0,a=0,o=0;t.length>i;){var l=t[i++];if(-1===l)e=0!==s?65533:-1;else if(0===s)this._inRange(l,0,127)?e=l:(this._inRange(l,194,223)?(s=1,o=128,n=l-192):this._inRange(l,224,239)?(s=2,o=2048,n=l-224):this._inRange(l,240,244)&&(s=3,o=65536,n=l-240),n*=Math.pow(64,s),e=null);else if(this._inRange(l,128,191))if(a+=1,n+=(l-128)*Math.pow(64,s-a),a!==s)e=null;else{var h=n,u=o;n=0,s=0,a=0,o=0,e=this._inRange(h,u,1114111)&&!this._inRange(h,55296,57343)?h:l}else n=0,s=0,a=0,o=0,i--,e=l;null!==e&&-1!==e&&(e<=65535?e>0&&(r+=String.fromCharCode(e)):(e-=65536,r+=String.fromCharCode(55296+(e>>10&1023)),r+=String.fromCharCode(56320+(1023&e))))}return r},i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e<i;++e)if(t.charCodeAt(e)>255)return encodeURI(t);return t},i.prototype._parseBinaryTimeline=function(e,i,r){void 0===r&&(r=null);var n=null!==r?r:t.BaseObject.borrowObject(t.TimelineData);n.type=e,n.offset=i,this._timeline=n;var s=this._timelineArrayBuffer[n.offset+2];if(1===s)n.frameIndicesOffset=-1;else{var a=0,o=this._animation.frameCount+1,l=this._data.frameIndices;t.DragonBones.webAssembly?(a=l.size(),l.resize(a+o,0)):(a=l.length,l.length+=o),n.frameIndicesOffset=a;for(var h=0,u=0,c=0,_=0;h<o;++h)c+_<=h&&u<s&&(c=this._frameArrayBuffer[this._animation.frameOffset+this._timelineArrayBuffer[n.offset+5+u]],_=u===s-1?this._animation.frameCount-c:this._frameArrayBuffer[this._animation.frameOffset+this._timelineArrayBuffer[n.offset+5+u+1]]-c,u++),t.DragonBones.webAssembly?l.set(a+h,u-1):l[a+h]=u-1}return this._timeline=null,n},i.prototype._parseVertices=function(e,i){i.offset=e[t.DataParser.OFFSET];var r=this._intArrayBuffer[i.offset+3];if(r>=0){var n=t.BaseObject.borrowObject(t.WeightData),s=this._intArrayBuffer[i.offset+0],a=this._intArrayBuffer[r+0];n.offset=r;for(var o=0;o<a;++o){var l=this._intArrayBuffer[r+2+o];n.addBone(this._rawBones[l])}for(var h=r+2+a,u=0,c=(o=0,s);o<c;++o){var _=this._intArrayBuffer[h++];u+=_,h+=_}n.count=u,i.weight=n}},i.prototype._parseMesh=function(t,e){this._parseVertices(t,e.vertices)},i.prototype._parsePath=function(t,e){this._parseVertices(t,e.vertices)},i.prototype._parseAnimation=function(e){var i=t.BaseObject.borrowObject(t.AnimationData);i.frameCount=Math.max(t.ObjectDataParser._getNumber(e,t.DataParser.DURATION,1),1),i.playTimes=t.ObjectDataParser._getNumber(e,t.DataParser.PLAY_TIMES,1),i.duration=i.frameCount/this._armature.frameRate,i.fadeInTime=t.ObjectDataParser._getNumber(e,t.DataParser.FADE_IN_TIME,0),i.scale=t.ObjectDataParser._getNumber(e,t.DataParser.SCALE,1),i.name=t.ObjectDataParser._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME),0===i.name.length&&(i.name=t.DataParser.DEFAULT_NAME);var r=e[t.DataParser.OFFSET];if(i.frameIntOffset=r[0],i.frameFloatOffset=r[1],i.frameOffset=r[2],this._animation=i,t.DataParser.ACTION in e&&(i.actionTimeline=this._parseBinaryTimeline(0,e[t.DataParser.ACTION])),t.DataParser.Z_ORDER in e&&(i.zOrderTimeline=this._parseBinaryTimeline(1,e[t.DataParser.Z_ORDER])),t.DataParser.BONE in e){var n=e[t.DataParser.BONE];for(var s in n){var a=n[s];t.DragonBones.webAssembly&&(s=this._getUTF16Key(s));var o=this._armature.getBone(s);if(null!==o)for(var l=0,h=a.length;l<h;l+=2){var u=a[l],c=a[l+1],_=this._parseBinaryTimeline(u,c);this._animation.addBoneTimeline(o,_)}}}if(t.DataParser.SURFACE in e)for(var s in n=e[t.DataParser.SURFACE]){a=n[s],t.DragonBones.webAssembly&&(s=this._getUTF16Key(s));var f=this._armature.getBone(s);if(null!==f)for(l=0,h=a.length;l<h;l+=2)u=a[l],c=a[l+1],_=this._parseBinaryTimeline(u,c),this._animation.addSurfaceTimeline(f,_)}if(t.DataParser.SLOT in e)for(var s in n=e[t.DataParser.SLOT]){a=n[s],t.DragonBones.webAssembly&&(s=this._getUTF16Key(s));var p=this._armature.getSlot(s);if(null!==p)for(l=0,h=a.length;l<h;l+=2)u=a[l],c=a[l+1],_=this._parseBinaryTimeline(u,c),this._animation.addSlotTimeline(p,_)}if(t.DataParser.CONSTRAINT in e)for(var s in n=e[t.DataParser.CONSTRAINT]){a=n[s],t.DragonBones.webAssembly&&(s=this._getUTF16Key(s));var d=this._armature.getConstraint(s);if(null!==d)for(l=0,h=a.length;l<h;l+=2)u=a[l],c=a[l+1],_=this._parseBinaryTimeline(u,c),this._animation.addConstraintTimeline(d,_)}if(t.DataParser.ANIMATION in e)for(var s in n=e[t.DataParser.ANIMATION])for(a=n[s],t.DragonBones.webAssembly&&(s=this._getUTF16Key(s)),l=0,h=a.length;l<h;l+=2)u=a[l],c=a[l+1],_=this._parseBinaryTimeline(u,c),this._animation.addAnimationTimeline(s,_);return this._animation=null,i},i.prototype._parseArray=function(e){var i=e[t.DataParser.OFFSET],r=i[1],n=i[3],s=i[5],a=i[7],o=i[9],l=i[11],h=new Int16Array(this._binary,this._binaryOffset+i[0],r/Int16Array.BYTES_PER_ELEMENT),u=new Float32Array(this._binary,this._binaryOffset+i[2],n/Float32Array.BYTES_PER_ELEMENT),c=new Int16Array(this._binary,this._binaryOffset+i[4],s/Int16Array.BYTES_PER_ELEMENT),_=new Float32Array(this._binary,this._binaryOffset+i[6],a/Float32Array.BYTES_PER_ELEMENT),f=new Int16Array(this._binary,this._binaryOffset+i[8],o/Int16Array.BYTES_PER_ELEMENT),p=new Uint16Array(this._binary,this._binaryOffset+i[10],l/Uint16Array.BYTES_PER_ELEMENT);if(t.DragonBones.webAssembly){for(var d=r+n+s+a+o+l,m=t.webAssemblyModule._malloc(d),y=new Uint8Array(this._binary,this._binaryOffset,d/Uint8Array.BYTES_PER_ELEMENT),g=new Uint8Array(t.webAssemblyModule.HEAP16.buffer,m,y.length),v=0,b=y.length;v<b;++v)g[v]=y[v];t.webAssemblyModule.setDataBinary(this._data,m,r,n,s,a,o,l),this._intArrayBuffer=h,this._floatArrayBuffer=u,this._frameIntArrayBuffer=c,this._frameFloatArrayBuffer=_,this._frameArrayBuffer=f,this._timelineArrayBuffer=p}else this._data.binary=this._binary,this._data.intArray=this._intArrayBuffer=h,this._data.floatArray=this._floatArrayBuffer=u,this._data.frameIntArray=this._frameIntArrayBuffer=c,this._data.frameFloatArray=this._frameFloatArrayBuffer=_,this._data.frameArray=this._frameArrayBuffer=f,this._data.timelineArray=this._timelineArrayBuffer=p},i.prototype.parseDragonBonesData=function(t,i){void 0===i&&(i=1),console.assert(null!=t&&t instanceof ArrayBuffer,"Data error.");var r=new Uint8Array(t,0,8);if(r[0]!=="D".charCodeAt(0)||r[1]!=="B".charCodeAt(0)||r[2]!=="D".charCodeAt(0)||r[3]!=="T".charCodeAt(0))return console.assert(!1,"Nonsupport data."),null;var n=new Uint32Array(t,8,1)[0],s=new Uint8Array(t,12,n),a=this._decodeUTF8(s),o=JSON.parse(a);return this._binaryOffset=12+n,this._binary=t,e.prototype.parseDragonBonesData.call(this,o,i)},i.getInstance=function(){return null===i._binaryDataParserInstance&&(i._binaryDataParserInstance=new i),i._binaryDataParserInstance},i._binaryDataParserInstance=null,i}(t.ObjectDataParser);t.BinaryDataParser=e}(vnt||(vnt={})),function(t){var e=function(){function e(i){void 0===i&&(i=null),this.autoSearch=!1,this._dragonBonesDataMap={},this._textureAtlasDataMap={},this._dragonBones=null,this._dataParser=null,null===e._objectParser&&(e._objectParser=new t.ObjectDataParser),null===e._binaryParser&&(e._binaryParser=new t.BinaryDataParser),this._dataParser=null!==i?i:e._objectParser}return e.prototype._isSupportMesh=function(){return!0},e.prototype._getTextureData=function(t,e){if(t in this._textureAtlasDataMap)for(var i=0,r=this._textureAtlasDataMap[t];i<r.length;i++)if(null!==(l=(o=r[i]).getTexture(e)))return l;if(this.autoSearch)for(var n in this._textureAtlasDataMap)for(var s=0,a=this._textureAtlasDataMap[n];s<a.length;s++){var o,l;if((o=a[s]).autoSearch&&null!==(l=o.getTexture(e)))return l}return null},e.prototype._fillBuildArmaturePackage=function(t,e,i,r,n){var s=null,a=null;if(e.length>0&&e in this._dragonBonesDataMap&&(a=(s=this._dragonBonesDataMap[e]).getArmature(i)),null===a&&(0===e.length||this.autoSearch))for(var o in this._dragonBonesDataMap)if(s=this._dragonBonesDataMap[o],(0===e.length||s.autoSearch)&&null!==(a=s.getArmature(i))){e=o;break}if(null!==a){if(t.dataName=e,t.textureAtlasName=n,t.data=s,t.armature=a,t.skin=null,r.length>0&&(t.skin=a.getSkin(r),null===t.skin&&this.autoSearch))for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o].getArmature(r);if(null!==l){t.skin=l.defaultSkin;break}}return null===t.skin&&(t.skin=a.defaultSkin),!0}return!1},e.prototype._buildBones=function(e,i){for(var r=0,n=e.armature.sortedBones;r<n.length;r++){var s=n[r];t.BaseObject.borrowObject(0===s.type?t.Bone:t.Surface).init(s,i)}},e.prototype._buildSlots=function(e,i){var r=e.skin,n=e.armature.defaultSkin;if(null!==r&&null!==n){var s={};for(var a in n.displays){var o=n.getDisplays(a);s[a]=o}if(r!==n)for(var a in r.displays)o=r.getDisplays(a),s[a]=o;for(var l=0,h=e.armature.sortedSlots;l<h.length;l++){var u=h[l],c=u.name in s?s[u.name]:null,_=this._buildSlot(e,u,i);if(_.rawDisplayDatas=c,null!==c){for(var f=new Array,p=0,d=t.DragonBones.webAssembly?c.size():c.length;p<d;++p){var m=t.DragonBones.webAssembly?c.get(p):c[p];null!==m?f.push(this._getSlotDisplay(e,m,null,_)):f.push(null)}_._setDisplayList(f)}_._setDisplayIndex(u.displayIndex,!0)}}},e.prototype._buildConstraints=function(e,i){var r=e.armature.constraints;for(var n in r){var s=r[n];switch(s.type){case 0:var a=t.BaseObject.borrowObject(t.IKConstraint);a.init(s,i),i._addConstraint(a);break;case 1:var o=t.BaseObject.borrowObject(t.PathConstraint);o.init(s,i),i._addConstraint(o);break;default:var l=t.BaseObject.borrowObject(t.IKConstraint);l.init(s,i),i._addConstraint(l)}}},e.prototype._buildChildArmature=function(t,e,i){return this.buildArmature(i.path,null!==t?t.dataName:"","",null!==t?t.textureAtlasName:"")},e.prototype._getSlotDisplay=function(e,i,r,n){var s=null!==e?e.dataName:i.parent.parent.parent.name,a=null;switch(i.type){case 0:var o=i;null!==e&&e.textureAtlasName.length>0&&(o.texture=this._getTextureData(e.textureAtlasName,i.path)),null===o.texture&&(o.texture=this._getTextureData(s,i.path)),a=null!==r&&2===r.type&&this._isSupportMesh()?n.meshDisplay:n.rawDisplay;break;case 2:var l=i;null!==e&&e.textureAtlasName.length>0&&(l.texture=this._getTextureData(e.textureAtlasName,l.path)),null===l.texture&&(l.texture=this._getTextureData(s,l.path)),a=this._isSupportMesh()?n.meshDisplay:n.rawDisplay;break;case 1:var h=i,u=this._buildChildArmature(e,n,i);if(null!==u){if(u.inheritAnimation=h.inheritAnimation,!u.inheritAnimation){var c=h.actions.length>0?h.actions:u.armatureData.defaultActions;if(c.length>0)for(var _=0,f=c;_<f.length;_++){var p=f[_],d=t.BaseObject.borrowObject(t.EventObject);t.EventObject.actionDataToInstance(p,d,n.armature),d.slot=n,n.armature._bufferAction(d,!1)}else u.animation.play()}h.armature=u.armatureData}a=u}return a},e.prototype.parseDragonBonesData=function(t,i,r){void 0===i&&(i=null),void 0===r&&(r=1);for(var n=t instanceof ArrayBuffer?e._binaryParser:this._dataParser,s=n.parseDragonBonesData(t,r);;){var a=this._buildTextureAtlasData(null,null);if(!n.parseTextureAtlasData(null,a,r)){a.returnToPool();break}this.addTextureAtlasData(a,i)}return null!==s&&this.addDragonBonesData(s,i),s},e.prototype.parseTextureAtlasData=function(t,e,i,r){void 0===i&&(i=null),void 0===r&&(r=1);var n=this._buildTextureAtlasData(null,null);return this._dataParser.parseTextureAtlasData(t,n,r),this._buildTextureAtlasData(n,e||null),this.addTextureAtlasData(n,i),n},e.prototype.updateTextureAtlasData=function(t,e){var i=this.getTextureAtlasData(t);if(null!==i)for(var r=0,n=i.length;r<n;++r)r<e.length&&this._buildTextureAtlasData(i[r],e[r])},e.prototype.getDragonBonesData=function(t){return t in this._dragonBonesDataMap?this._dragonBonesDataMap[t]:null},e.prototype.addDragonBonesData=function(t,e){if(void 0===e&&(e=null),(e=null!==e?e:t.name)in this._dragonBonesDataMap){if(this._dragonBonesDataMap[e]===t)return;console.warn("Can not add same name data: "+e)}else this._dragonBonesDataMap[e]=t},e.prototype.removeDragonBonesData=function(t,e){void 0===e&&(e=!0),t in this._dragonBonesDataMap&&(e&&this._dragonBones.bufferObject(this._dragonBonesDataMap[t]),delete this._dragonBonesDataMap[t])},e.prototype.getTextureAtlasData=function(t){return t in this._textureAtlasDataMap?this._textureAtlasDataMap[t]:null},e.prototype.addTextureAtlasData=function(t,e){void 0===e&&(e=null);var i=(e=null!==e?e:t.name)in this._textureAtlasDataMap?this._textureAtlasDataMap[e]:this._textureAtlasDataMap[e]=[];i.indexOf(t)<0&&i.push(t)},e.prototype.removeTextureAtlasData=function(t,e){if(void 0===e&&(e=!0),t in this._textureAtlasDataMap){var i=this._textureAtlasDataMap[t];if(e)for(var r=0,n=i;r<n.length;r++){var s=n[r];this._dragonBones.bufferObject(s)}delete this._textureAtlasDataMap[t]}},e.prototype.getArmatureData=function(t,e){void 0===e&&(e="");var r=new i;return this._fillBuildArmaturePackage(r,e,t,"","")?r.armature:null},e.prototype.clear=function(t){for(var e in void 0===t&&(t=!0),this._dragonBonesDataMap)t&&this._dragonBones.bufferObject(this._dragonBonesDataMap[e]),delete this._dragonBonesDataMap[e];for(var e in this._textureAtlasDataMap){if(t)for(var i=0,r=this._textureAtlasDataMap[e];i<r.length;i++){var n=r[i];this._dragonBones.bufferObject(n)}delete this._textureAtlasDataMap[e]}},e.prototype.buildArmature=function(t,e,r,n){void 0===e&&(e=""),void 0===r&&(r=""),void 0===n&&(n="");var s=new i;if(!this._fillBuildArmaturePackage(s,e||"",t,r||"",n||""))return console.warn("No armature data: "+t+", "+(null!==e?e:"")),null;var a=this._buildArmature(s);return this._buildBones(s,a),this._buildSlots(s,a),this._buildConstraints(s,a),a.invalidUpdate(null,!0),a.advanceTime(0),a},e.prototype.replaceDisplay=function(e,i,r){void 0===r&&(r=-1),r<0&&(r=e.displayIndex),r<0&&(r=0),e.replaceDisplayData(i,r);var n=e.displayList;if(n.length<=r){n.length=r+1;for(var s=0,a=n.length;s<a;++s)n[s]||(n[s]=null)}if(null!==i){var o=e.rawDisplayDatas,l=null;o&&(t.DragonBones.webAssembly?r<o.size()&&(l=o.get(r)):r<o.length&&(l=o[r])),n[r]=this._getSlotDisplay(null,i,l,e)}else n[r]=null;e.displayList=n},e.prototype.replaceSlotDisplay=function(t,e,i,r,n,s){void 0===s&&(s=-1);var a=this.getArmatureData(e,t||"");if(!a||!a.defaultSkin)return!1;var o=a.defaultSkin.getDisplay(i,r);return!!o&&(this.replaceDisplay(n,o,s),!0)},e.prototype.replaceSlotDisplayList=function(e,i,r,n){var s=this.getArmatureData(i,e||"");if(!s||!s.defaultSkin)return!1;var a=s.defaultSkin.getDisplays(r);if(!a)return!1;for(var o=0,l=0,h=t.DragonBones.webAssembly?a.size():a.length;l<h;++l){var u=t.DragonBones.webAssembly?a.get(l):a[l];this.replaceDisplay(n,u,o++)}return!0},e.prototype.replaceSkin=function(e,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null);for(var s=!1,a=i.parent.defaultSkin,o=0,l=e.getSlots();o<l.length;o++){var h=l[o];if(!(null!==n&&n.indexOf(h.name)>=0)){var u=i.getDisplays(h.name);if(u||(null!==a&&i!==a&&(u=a.getDisplays(h.name)),u)){var c=t.DragonBones.webAssembly?u.size():u.length,_=h.displayList;_.length=c;for(var f=0,p=c;f<p;++f){var d=t.DragonBones.webAssembly?u.get(f):u[f];_[f]=null!==d?this._getSlotDisplay(null,d,null,h):null}s=!0,h.rawDisplayDatas=u,h.displayList=_}else r&&(h.rawDisplayDatas=null,h.displayList=[])}}return s},e.prototype.replaceAnimation=function(e,i,r){void 0===r&&(r=!0);var n=i.defaultSkin;if(null===n)return!1;if(r)e.animation.animations=i.animations;else{var s=e.animation.animations,a={};for(var o in s)a[o]=s[o];for(var o in i.animations)a[o]=i.animations[o];e.animation.animations=a}for(var l=0,h=e.getSlots();l<h.length;l++)for(var u=h[l],c=0,_=0,f=u.displayList;_<f.length;_++){var p=f[_];if(p instanceof t.Armature){var d=n.getDisplays(u.name);if(null!==d&&c<(t.DragonBones.webAssembly?d.size():d.length)){var m=t.DragonBones.webAssembly?d.get(c):d[c];if(null!==m&&1===m.type){var y=this.getArmatureData(m.path,m.parent.parent.parent.name);y&&this.replaceAnimation(p,y,r)}}}c++}return!0},e.prototype.getAllDragonBonesData=function(){return this._dragonBonesDataMap},e.prototype.getAllTextureAtlasData=function(){return this._textureAtlasDataMap},Object.defineProperty(e.prototype,"clock",{get:function(){return this._dragonBones.clock},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dragonBones",{get:function(){return this._dragonBones},enumerable:!0,configurable:!0}),e.prototype.changeSkin=function(t,e,i){return void 0===i&&(i=null),this.replaceSkin(t,e,!1,i)},e.prototype.copyAnimationsToArmature=function(t,e,i,r,n){void 0===r&&(r=""),void 0===n&&(n=!0);var s=this.getArmatureData(e,r);return!!s&&this.replaceAnimation(t,s,n)},e._objectParser=null,e._binaryParser=null,e}();t.BaseFactory=e;var i=function(){this.dataName="",this.textureAtlasName="",this.skin=null};t.BuildArmaturePackage=i}(vnt||(vnt={})),function(t){t.BinaryOffset={WeigthBoneCount:0,WeigthFloatOffset:1,WeigthBoneIndices:2,MeshVertexCount:0,MeshTriangleCount:1,MeshFloatOffset:2,MeshWeightOffset:3,MeshVertexIndices:4,TimelineScale:0,TimelineOffset:1,TimelineKeyFrameCount:2,TimelineFrameValueCount:3,TimelineFrameValueOffset:4,TimelineFrameOffset:5,FramePosition:0,FrameTweenType:1,FrameTweenEasingOrCurveSampleCount:2,FrameCurveSamples:3,DeformMeshOffset:0,DeformCount:1,DeformValueCount:2,DeformValueOffset:3,DeformFloatOffset:4},t.ArmatureType={Armature:0,MovieClip:1,Stage:2},t.BoneType={Bone:0,Surface:1},t.DisplayType={Image:0,Armature:1,Mesh:2,BoundingBox:3},t.BoundingBoxType={Rectangle:0,Ellipse:1,Polygon:2},t.ActionType={Play:0,Stop:1,GotoAndPlay:2,GotoAndStop:3,FadeIn:4,FadeOut:5,Frame:10,Sound:11},t.BlendMode={Normal:0,Add:1,Alpha:2,Darken:3,Difference:4,Erase:5,HardLight:6,Invert:7,Layer:8,Lighten:9,Multiply:10,Overlay:11,Screen:12,Subtract:13},t.TweenType={None:0,Line:1,Curve:2,QuadIn:3,QuadOut:4,QuadInOut:5},t.TimelineType={Action:0,ZOrder:1,BoneAll:10,BoneTranslate:11,BoneRotate:12,BoneScale:13,Surface:50,SlotDisplay:20,SlotColor:21,SlotFFD:22,IKConstraint:30,AnimationTime:40,AnimationWeight:41}}(vnt||(vnt={}));var bnt,Snt,Ant,Cnt,xnt,Tnt,wnt,Ent,Bnt,Dnt,Mnt,Pnt,Rnt,Int=vnt.DragonBones,Ont=vnt.BaseObject,Fnt=vnt.Matrix,Lnt=vnt.Transform,Vnt=vnt.ColorTransform,knt=vnt.Point,Nnt=vnt.Rectangle,Gnt=vnt.UserData,znt=vnt.ActionData,Unt=vnt.DragonBonesData,Hnt=vnt.ArmatureData,jnt=vnt.BoneData,Wnt=vnt.SurfaceData,Xnt=vnt.SlotData,Ynt=vnt.ConstraintData,qnt=vnt.IKConstraintData,Jnt=vnt.PathConstraintData,Knt=vnt.CanvasData,Znt=vnt.SkinData,Qnt=vnt.VerticesData,$nt=vnt.DisplayData,tst=vnt.ImageDisplayData,est=vnt.ArmatureDisplayData,ist=vnt.MeshDisplayData,rst=vnt.BoundingBoxDisplayData,nst=vnt.PathDisplayData,sst=vnt.WeightData,ast=vnt.BoundingBoxData,ost=vnt.RectangleBoundingBoxData,lst=vnt.EllipseBoundingBoxData,hst=vnt.PolygonBoundingBoxData,ust=vnt.AnimationData,cst=vnt.TimelineData,_st=vnt.AnimationConfig,fst=vnt.TextureAtlasData,pst=vnt.TextureData,dst=vnt.DeformVertices,mst=vnt.Armature,yst=vnt.TransformObject,gst=vnt.Bone,vst=vnt.Surface,bst=vnt.Slot,Sst=vnt.Constraint,Ast=vnt.IKConstraint,Cst=vnt.PathConstraint,xst=vnt.WorldClock,Tst=vnt.Animation,wst=vnt.AnimationState,Est=vnt.BonePose,Bst=vnt.BlendState,Dst=vnt.TimelineState,Mst=vnt.TweenTimelineState,Pst=vnt.BoneTimelineState,Rst=vnt.SlotTimelineState,Ist=vnt.ConstraintTimelineState,Ost=vnt.ActionTimelineState,Fst=vnt.ZOrderTimelineState,Lst=vnt.BoneAllTimelineState,Vst=vnt.BoneTranslateTimelineState,kst=vnt.BoneRotateTimelineState,Nst=vnt.BoneScaleTimelineState,Gst=vnt.SurfaceTimelineState,zst=vnt.SlotDislayTimelineState,Ust=vnt.SlotColorTimelineState,Hst=vnt.DeformTimelineState,jst=vnt.IKConstraintTimelineState,Wst=vnt.AnimationTimelineState,Xst=vnt.EventObject,Yst=vnt.DataParser,qst=vnt.ObjectDataParser,Jst=vnt.ActionFrame,Kst=vnt.BinaryDataParser,Zst=vnt.BaseFactory,Qst=vnt.BuildArmaturePackage,$st=vnt.BinaryOffset,tat=vnt.ArmatureType,eat=vnt.BoneType,iat=vnt.DisplayType,rat=vnt.BoundingBoxType,nat=vnt.ActionType,sat=vnt.BlendMode,aat=vnt.TweenType,oat=vnt.TimelineType,lat=ri("dragonBones.CCTextureAtlasData")(bnt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this)._renderTexture=null,e}Me(e,t),e.toString=function(){return"[class dragonBones.CCTextureAtlasData]"};var i=e.prototype;return i.createTexture=function(){return Ont.borrowObject(hat)},i._onClear=function(){t.prototype._onClear.call(this),this.renderTexture=null},Pe(e,[{key:"renderTexture",get:function(){return this._renderTexture},set:function(t){if(this._renderTexture=t,t)for(var e in this.textures){var i=this.textures[e];if(!i.spriteFrame){var r=null;i.rotated?r=new gr(i.region.x,i.region.y,i.region.height,i.region.width):(r=new gr(i.region.x,i.region.y,i.region.width,i.region.height),i.spriteFrame=new xc,i.spriteFrame.texture=t,i.spriteFrame.rect=r)}}else for(var n in this.textures)this.textures[n].spriteFrame=null}}]),e}(fst))||bnt,hat=ri("dragonBones.CCTextureData")(Snt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return(e=t.call.apply(t,[this].concat(r))||this).spriteFrame=null,e}return Me(e,t),e.toString=function(){return"[class dragonBones.CCTextureData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.spriteFrame=null},e}(pst))||Snt,uat=ri("dragonBones.CCSlot")(Ant=function(t){function e(){var e;return(e=t.call(this)||this)._localVertices=void 0,e._indices=void 0,e._matrix=void 0,e._worldMatrix=void 0,e._worldMatrixDirty=void 0,e._color=void 0,e._localVertices=[],e._indices=[],e._matrix=new Ri,e._worldMatrix=new Ri,e._worldMatrixDirty=!0,e._visible=!1,e._color=new Ui,e}Me(e,t),e.toString=function(){return"[class dragonBones.CCSlot]"};var i=e.prototype;return i.getTexture=function(){if(this._textureData){var t=this._textureData.spriteFrame;return t.texture instanceof Ye?t.texture._texture:t.texture}return null},i.calculWorldMatrix=function(){var t=this._armature._parent;t?this._mulMat(this._worldMatrix,t._worldMatrix,this._matrix):Ri.copy(this._worldMatrix,this._matrix),this._worldMatrixDirty=!1},i._onClear=function(){t.prototype._onClear.call(this),this._localVertices.length=0,this._indices.length=0,Ri.identity(this._matrix),Ri.identity(this._worldMatrix),this._worldMatrixDirty=!0,this._color=new Ui,this._visible=!1},i._onUpdateDisplay=function(){},i._initDisplay=function(){},i._addDisplay=function(){this._visible=!0},i._replaceDisplay=function(){},i._removeDisplay=function(){this._visible=!1},i._disposeDisplay=function(){},i._updateVisible=function(){this._visible=this.parent.visible},i._updateGlueMesh=function(){},i._updateZOrder=function(){},i._updateBlendMode=function(){if(this._childArmature)for(var t=this._childArmature.getSlots(),e=0,i=t.length;e<i;e++){var r=t[e];r._blendMode=this._blendMode,r._updateBlendMode()}},i._updateColor=function(){var t=this._color;t.r=255*this._colorTransform.redMultiplier,t.g=255*this._colorTransform.greenMultiplier,t.b=255*this._colorTransform.blueMultiplier,t.a=255*this._colorTransform.alphaMultiplier},i._updateFrame=function(){this._indices.length=0;var t=this._indices,e=this._localVertices,i=0,r=0,n=this._textureData;if(this._display&&!(this._displayIndex<0)&&n&&n.spriteFrame){var s=n.spriteFrame.texture,a=s.width,o=s.height,l=n.region;if(0!==a&&0!==o){var h=null!==this._deformVertices&&this._display===this._meshDisplay?this._deformVertices.verticesData:null;if(h){var u=h.data,c=u.intArray,_=u.floatArray,f=c[h.offset+$st.MeshVertexCount],p=c[h.offset+$st.MeshTriangleCount],d=c[h.offset+$st.MeshFloatOffset];d<0&&(d+=65536);for(var m=d+2*f,y=this._armature._armatureData.scale,g=0,v=2*f;g<v;g+=2)e[r++]=_[d+g]*y,e[r++]=-_[d+g+1]*y,h.rotated?(e[r++]=(l.x+(1-_[m+g])*l.width)/a,e[r++]=(l.y+_[m+g+1]*l.height)/o):(e[r++]=(l.x+_[m+g]*l.width)/a,e[r++]=(l.y+_[m+g+1]*l.height)/o);for(var b=0;b<3*p;++b)t[i++]=c[h.offset+$st.MeshVertexIndices+b];e.length=r,t.length=i,h.weight&&this._identityTransform()}else{var S=l.x/a,A=(l.y+l.height)/o,C=(l.x+l.width)/a,x=l.y/o;e[r++]=0,e[r++]=0,e[r++]=S,e[r++]=A,e[r++]=l.width,e[r++]=0,e[r++]=C,e[r++]=A,e[r++]=0,e[r++]=l.height,e[r++]=S,e[r++]=x,e[r++]=l.width,e[r++]=l.height,e[r++]=C,e[r++]=x,t[0]=0,t[1]=1,t[2]=2,t[3]=1,t[4]=3,t[5]=2,e.length=r,t.length=6}this._visibleDirty=!0,this._blendModeDirty=!0,this._colorDirty=!0}else console.error("SpriteFrame "+n.spriteFrame.name+" incorrect size "+a+" x "+o)}},i._updateMesh=function(){var t=this._armature._armatureData.scale,e=this._deformVertices.vertices,i=this._deformVertices.bones,r=this._deformVertices.verticesData,n=r.weight,s=e.length>0&&r.inheritDeform,a=this._localVertices;if(n){var o=r.data,l=o.intArray,h=o.floatArray,u=l[r.offset+$st.MeshVertexCount],c=l[n.offset+$st.WeigthFloatOffset];c<0&&(c+=65536);for(var _=0,f=n.offset+$st.WeigthBoneIndices+i.length,p=c,d=0,m=0;_<u;_++,m+=4){for(var y=l[f++],g=0,v=0,b=0;b<y;++b){var S=i[l[f++]];if(null!==S){var A=S.globalTransformMatrix,C=h[p++],x=h[p++]*t,T=h[p++]*t;s&&(x+=e[d++],T+=e[d++]),g+=(A.a*x+A.c*T+A.tx)*C,v+=(A.b*x+A.d*T+A.ty)*C}}a[m]=g,a[m+1]=-v}}else if(s){var w=this._parent._boneData.type!==eat.Bone,E=r.data,B=E.intArray,D=E.floatArray,M=B[r.offset+$st.MeshVertexCount],P=B[r.offset+$st.MeshFloatOffset];P<0&&(P+=65536);for(var R=0,I=M,O=0;R<I;R++,O+=4){var F=D[P+2*R]*t+e[2*R],L=D[P+2*R+1]*t+e[2*R+1];if(w){var V=this._parent._getGlobalTransformMatrix(F,L);a[O]=V.a*F+V.c*L+V.tx,a[O+1]=-V.b*F+V.d*L+V.ty}else a[O]=F,a[O+1]=-L}}n&&this._identityTransform()},i._identityTransform=function(){var t=this._matrix;t.m00=1,t.m01=0,t.m04=-0,t.m05=-1,t.m12=0,t.m13=0,this._worldMatrixDirty=!0},i._updateTransform=function(){var t=this._matrix;t.m00=this.globalTransformMatrix.a,t.m01=this.globalTransformMatrix.b,t.m04=-this.globalTransformMatrix.c,t.m05=-this.globalTransformMatrix.d,this._childArmature?(t.m12=this.globalTransformMatrix.tx,t.m13=this.globalTransformMatrix.ty):(t.m12=this.globalTransformMatrix.tx-(this.globalTransformMatrix.a*this._pivotX-this.globalTransformMatrix.c*this._pivotY),t.m13=this.globalTransformMatrix.ty-(this.globalTransformMatrix.b*this._pivotX-this.globalTransformMatrix.d*this._pivotY)),this._worldMatrixDirty=!0},i.updateWorldMatrix=function(){if(this._armature){var t=this._armature._parent;if(t&&t.updateWorldMatrix(),this._worldMatrixDirty){this.calculWorldMatrix();var e=this.childArmature;if(!e)return;for(var i=e.getSlots(),r=0,n=i.length;r<n;r++){var s=i[r];s&&(s._worldMatrixDirty=!0)}}}},i._mulMat=function(t,e,i){var r=e.m00,n=e.m01,s=e.m04,a=e.m05,o=e.m12,l=e.m13,h=i.m00,u=i.m01,c=i.m04,_=i.m05,f=i.m12,p=i.m13;0!==n||0!==s?(t.m00=h*r+u*s,t.m01=h*n+u*a,t.m04=c*r+_*s,t.m05=c*n+_*a,t.m12=r*f+s*p+o,t.m13=n*f+a*p+l):(t.m00=h*r,t.m01=u*a,t.m04=c*r,t.m05=_*a,t.m12=r*f+o,t.m13=a*p+l)},e}(bst))||Ant,cat=ri("dragonBones.CCArmatureDisplay")(Cnt=function(t){function e(){var e;return(e=t.call(this)||this).shouldAdvanced=!1,e._ccNode=null,e._ccComponent=null,e._eventTarget=void 0,e._armature=null,e._eventTarget=new os,e}Me(e,t);var i=e.prototype;return i.hasEvent=function(){return console.warn("Method not implemented."),!1},i.addEvent=function(){console.warn("Method not implemented.")},i.removeEvent=function(){console.warn("Method not implemented.")},i.setEventTarget=function(t){this._eventTarget=t},i.getRootDisplay=function(){var t,e=this._armature._parent;if(!e)return this;for(;e;)t=e,e=e._armature._parent;return t._armature.display},i.convertToRootSpace=function(t){var e=this._armature._parent;if(!e)return t;e.updateWorldMatrix();var i=e._worldMatrix,r=new ii(0,0);return r.x=t.x*i.m00+t.y*i.m04+i.m12,r.y=t.x*i.m01+t.y*i.m05+i.m13,r},i.convertToWorldSpace=function(t){var e,i=this.convertToRootSpace(t),r=this.getRootNode();return null==r||null===(e=r._uiProps.uiTransformComp)||void 0===e?void 0:e.convertToWorldSpaceAR(i)},i.getRootNode=function(){var t=this.getRootDisplay();return t&&t._ccNode},i.dbInit=function(t){this._armature=t},i.dbClear=function(){this._armature=null},i.dbUpdate=function(){this._ccComponent&&this._ccComponent.markForUpdateRenderData()},i.advanceTimeBySelf=function(t){this.shouldAdvanced=!!t},i.hasDBEventListener=function(t){return this._eventTarget.hasEventListener(t)},i.addDBEventListener=function(t,e,i){this._eventTarget.on(t,e,i)},i.removeDBEventListener=function(t,e,i){this._eventTarget.off(t,e,i)},i.dispatchDBEvent=function(t,e){this._eventTarget.emit(t,e)},Pe(e,[{key:"node",get:function(){return this}}]),e}($nt))||Cnt,_at=ri("CCFactory")((wnt=Tnt=function(t){function e(){var e;(e=t.call(this)||this).id=void 0,e.uuid=void 0,e._slots=void 0;var i=new cat;return e._dragonBones=new Int(i),wr.getScheduler()&&(Wr.on(Nr.EVENT_RESTART,e.initUpdate,hi(e)),e.initUpdate()),e.id=e.uuid="CCFactory",e}Me(e,t),e.getInstance=function(){return e._factory||(e._factory=new e),e._factory};var i=e.prototype;return i.initUpdate=function(){vs.enableForTarget(this),wr.getScheduler().scheduleUpdate(this,vs.PRIORITY_SYSTEM,!1)},i.update=function(t){this._dragonBones.advanceTime(t)},i.getDragonBonesDataByRawData=function(t){return(t instanceof ArrayBuffer?Zst._binaryParser:this._dataParser).parseDragonBonesData(t,1)},i.buildArmatureDisplay=function(t,e,i,r){var n=this.buildArmature(t,e,i,r);return n?n._display:null},i.createArmatureNode=function(t,e,i){var r=(i=i||new ur).getComponent("dragonBones.ArmatureDisplay");return r||(r=i.addComponent("dragonBones.ArmatureDisplay")),i.name=e,r._armatureName=e,r._dragonAsset=t.dragonAsset,r._dragonAtlasAsset=t.dragonAtlasAsset,r._init(),r},i._buildTextureAtlasData=function(t,e){return t?t.renderTexture=e:t=Ont.borrowObject(lat),t},i._sortSlots=function(){for(var t=this._slots,e=[],i=0,r=t.length;i<r;i++){for(var n=t[i],s=n._zOrder,a=!1,o=e.length-1;o>=0;o--)if(s>=e[o]._zOrder){e.splice(o+1,0,n),a=!0;break}a||e.splice(0,0,n)}this._slots=e},i._buildArmature=function(t){var e=Ont.borrowObject(mst);e._skinData=t.skin,e._animation=Ont.borrowObject(Tst),e._animation._armature=e,e._animation.animations=t.armature.animations,e._isChildArmature=!1;var i=new cat;return e.init(t.armature,i,i,this._dragonBones),e},i._buildSlot=function(t,e,i){var r=Ont.borrowObject(uat),n=r;return r.init(e,i,n,n),r},i.getDragonBonesDataByUUID=function(t){for(var e in this._dragonBonesDataMap)if(-1!==e.indexOf(t))return this._dragonBonesDataMap[e];return null},i.removeDragonBonesDataByUUID=function(t,e){for(var i in void 0===e&&(e=!0),this._dragonBonesDataMap)-1!==i.indexOf(t)&&(e&&this._dragonBones.bufferObject(this._dragonBonesDataMap[i]),delete this._dragonBonesDataMap[i])},e}(Zst),Tnt._factory=null,xnt=wnt))||xnt,fat=1/60,pat=[],dat=[],mat=0,yat=0,gat=0,vat=null,bat=null,Sat=0,Aat=0,Cat=0,xat=0,Tat=0,wat=function(){function t(){this._privateMode=!1,this._inited=!1,this._invalid=!0,this._enableCacheAttachedInfo=!1,this.frames=[],this.totalTime=0,this.isCompleted=!1,this._frameIdx=-1,this._armatureInfo=null,this._animationName=null,this._tempSegments=null,this._tempColors=null,this._tempBoneInfos=null}var e=t.prototype;return e.init=function(t,e){this._inited=!0,this._armatureInfo=t,this._animationName=e},e.clear=function(){this._inited=!1;for(var t=0,e=this.frames.length;t<e;t++)this.frames[t].segments.length=0;this.invalidAllFrame()},e.begin=function(){if(this._invalid){var t=this._armatureInfo,e=t.curAnimationCache;e&&e!==this&&(this._privateMode?e.invalidAllFrame():e.updateToFrame()),t.armature.animation.play(this._animationName,1),t.curAnimationCache=this,this._invalid=!1,this._frameIdx=-1,this.totalTime=0,this.isCompleted=!1}},e.end=function(){this._needToUpdate()||(this._armatureInfo.curAnimationCache=null,this.frames.length=this._frameIdx+1,this.isCompleted=!0)},e._needToUpdate=function(t){return!this._armatureInfo.armature.animation.isCompleted&&this.totalTime<30&&(void 0===t||this._frameIdx<t)},e.updateToFrame=function(t){if(this._inited&&(this.begin(),this._needToUpdate(t))){var e=this._armatureInfo.armature;do{e.advanceTime(fat),this._frameIdx++,this._updateFrame(e,this._frameIdx),this.totalTime+=fat}while(this._needToUpdate(t));this.end()}},e.isInited=function(){return this._inited},e.isInvalid=function(){return this._invalid},e.invalidAllFrame=function(){this.isCompleted=!1,this._invalid=!0},e.updateAllFrame=function(){this.invalidAllFrame(),this.updateToFrame()},e.enableCacheAttachedInfo=function(){this._enableCacheAttachedInfo||(this._enableCacheAttachedInfo=!0,this.invalidAllFrame())},e._updateFrame=function(t,e){gat=0,mat=0,yat=0,vat=null,bat=null,Sat=0,Aat=0,Cat=0,xat=0,Tat=0,this.frames[e]=this.frames[e]||{segments:[],colors:[],boneInfos:[],vertices:null,uintVert:null,indices:null};var i=this.frames[e],r=this._tempSegments=i.segments,n=this._tempColors=i.colors,s=this._tempBoneInfos=i.boneInfos;this._traverseArmature(t,1),xat>0&&(n[xat-1].vfOffset=gat),n.length=xat,s.length=mat;var a=Cat-1;if(a>=0)if(Aat>0){var o=r[a];o.indexCount=Aat,o.vfCount=5*Sat,o.vertexCount=Sat,r.length=Cat}else r.length=Cat-1;if(0!==r.length){var l=i.vertices,h=i.uintVert;(!l||l.length<gat)&&(l=i.vertices=new Float32Array(gat),h=i.uintVert=new Uint32Array(l.buffer));for(var u=0,c=0;u<gat;)l[u++]=pat[c++],l[u++]=pat[c++],l[u++]=pat[c++],l[u++]=pat[c++],h[u++]=pat[c++];var _=i.indices;(!_||_.length<yat)&&(_=i.indices=new Uint16Array(yat));for(var f=0;f<yat;f++)_[f]=dat[f];i.vertices=l,i.uintVert=h,i.indices=_}},e._traverseArmature=function(t,e){var i,r,n,s,a,o,l,h,u,c=this._tempColors,_=this._tempSegments,f=this._tempBoneInfos,p=pat,d=dat,m=t._slots,y=t._bones;if(this._enableCacheAttachedInfo)for(var g=0,v=y.length;g<v;g++,mat++){var b=y[g],S=f[mat];S||(S=f[mat]={globalTransformMatrix:new Fnt});var A=b.globalTransformMatrix;S.globalTransformMatrix.copyFrom(A)}for(var C=0,x=m.length;C<x;C++)if((n=m[C])._visible&&n._displayData)if(n.updateWorldMatrix(),a=n._color,n.childArmature)this._traverseArmature(n.childArmature,e*a.a/255);else if(l=n.getTexture()){vat===l.nativeUrl&&bat===n._blendMode||(vat=l.nativeUrl,bat=n._blendMode,(h=Cat-1)>=0&&(Aat>0?((u=_[h]).indexCount=Aat,u.vertexCount=Sat,u.vfCount=5*Sat):Cat--),_[Cat]={tex:l,blendMode:n._blendMode,indexCount:0,vertexCount:0,vfCount:0},Cat++,Aat=0,Sat=0),o=(a.a*e<<24>>>0)+(a.b<<16)+(a.g<<8)+a.r,Tat!==o&&(Tat=o,xat>0&&(c[xat-1].vfOffset=gat),c[xat++]={r:a.r,g:a.g,b:a.b,a:a.a*e,vfOffset:0}),i=n._localVertices,r=n._indices,s=n._worldMatrix;for(var T=0,w=i.length;T<w;)Ent=i[T++],Bnt=i[T++],p[gat++]=Ent*s.m00+Bnt*s.m04+s.m12,p[gat++]=Ent*s.m01+Bnt*s.m05+s.m13,p[gat++]=i[T++],p[gat++]=i[T++],p[gat++]=o;for(var E=0,B=r.length;E<B;E++)d[yat++]=Sat+r[E];Aat+=r.length,Sat+=i.length/4}},t}(),Eat=function(){function t(){this._privateMode=!1,this._animationPool={},this._armatureCache={}}var e=t.prototype;return e.enablePrivateMode=function(){this._privateMode=!0},e.dispose=function(){for(var t in this._armatureCache){var e=this._armatureCache[t];if(e){var i=e.armature;i&&i.dispose()}}this._armatureCache={},this._animationPool={}},e._removeArmature=function(t){var e=this._armatureCache[t],i=e.animationsCache;for(var r in i){var n=i[r];n&&(this._animationPool[t+"#"+r]=n,n.clear())}var s=e.armature;s&&s.dispose(),delete this._armatureCache[t]},e.resetArmature=function(t){for(var e in this._armatureCache)-1!==e.indexOf(t)&&this._removeArmature(e)},e.getArmatureCache=function(e,i,r){var n,s=this._armatureCache[i];if(s)n=s.armature;else{var a=_at.getInstance().buildArmatureDisplay(e,i,"",r);if(!a||!a._armature)return null;if(n=a._armature,!t.canCache(n))return n.dispose(),null;this._armatureCache[i]={armature:n,animationsCache:{},curAnimationCache:null}}return n},e.getAnimationCache=function(t,e){var i=this._armatureCache[t];return i?i.animationsCache[e]:null},e.initAnimationCache=function(t,e){if(!e)return null;var i=this._armatureCache[t],r=i&&i.armature;if(!r)return null;if(!r.animation.hasAnimation(e))return null;var n=i.animationsCache,s=n[e];if(!s){var a=t+"#"+e;(s=this._animationPool[a])?delete this._animationPool[a]:(s=new wat)._privateMode=this._privateMode,s.init(i,e),n[e]=s}return s},e.invalidAnimationCache=function(t){var e=this._armatureCache[t];if(e&&e.armature){var i=e.animationsCache;for(var r in i)i[r].invalidAllFrame()}},e.updateAnimationCache=function(t,e){if(e){var i=this.initAnimationCache(t,e);if(!i)return;i.updateAllFrame()}else{var r=this._armatureCache[t];if(!r||!r.armature)return;var n=r.animationsCache;for(var s in n)n[s].updateAllFrame()}},t.canCache=function(t){for(var e=t._slots,i=0,r=e.length;i<r;i++)if(e[i].childArmature)return!1;return!0},t}();Eat.FrameTime=fat,Eat.sharedCache=new Eat;var Bat,Dat,Mat,Pat,Rat,Iat,Oat,Fat,Lat,Vat=ri("dragonBones.DragonBonesAsset")((Rnt=function(t){function e(){for(var e,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return e=t.call.apply(t,[this].concat(r))||this,li(e,"_dragonBonesJson",Pnt,hi(e)),e._factory=null,e._dragonBonesJsonData=void 0,e._armaturesEnum=null,e}Me(e,t);var i=e.prototype;return i.constructctor=function(){this.reset()},i.createNode=function(t){var e=new ur(this.name);return e.addComponent("dragonBones.ArmatureDisplay").dragonAsset=this,t(null,e)},i.reset=function(){this._clear()},i.init=function(t,e){this._factory=t,!this._dragonBonesJsonData&&this.dragonBonesJson&&(this._dragonBonesJsonData=JSON.parse(this.dragonBonesJson));var i;if(i=this._dragonBonesJsonData?this._dragonBonesJsonData:this._nativeAsset,!this._uuid){var r=this._factory.getDragonBonesDataByRawData(i);r?this._uuid=r.name:console.warn("dragonbones name is empty")}var n=this._uuid+"#"+e;return this._factory.getDragonBonesData(n)||this._factory.parseDragonBonesData(i instanceof ArrayBuffer?i:i.buffer instanceof ArrayBuffer?i.buffer:i,n),n},i.getArmatureEnum=function(){if(this._armaturesEnum)return this._armaturesEnum;this.init();var t=this._factory.getDragonBonesDataByUUID(this._uuid);if(t){for(var e=t.armatureNames,i={},r=0;r<e.length;r++)i[e[r]]=r;return this._armaturesEnum=yi(i)}return null},i.getAnimsEnum=function(t){this.init();var e=this._factory.getDragonBonesDataByUUID(this._uuid);if(e){var i=e.getArmature(t);if(!i)return null;var r={"<None>":0},n=i.animations,s=0;for(var a in n)n.hasOwnProperty(a)&&(r[a]=s+1,s++);return yi(r)}return null},i.destroy=function(){return this._clear(),t.prototype.destroy.call(this)},i._clear=function(){this._factory&&(Eat.sharedCache.resetArmature(this._uuid),this._factory.removeDragonBonesDataByUUID(this._uuid,!0))},Pe(e,[{key:"dragonBonesJson",get:function(){return this._dragonBonesJson},set:function(t){this._dragonBonesJson=t,this._dragonBonesJsonData=JSON.parse(t),this.reset()}}]),e}(ai),Pnt=oi((Mnt=Rnt).prototype,"_dragonBonesJson",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Dnt=Mnt))||Dnt;He.internal.DragonBonesAsset=Vat;var kat,Nat=(Bat=ri("dragonBones.DragonBonesAtlasAsset"),Dat=bi(qe),Bat((Lat=function(t){function e(){var e;return e=t.call(this)||this,li(e,"_atlasJson",Rat,hi(e)),li(e,"_texture",Iat,hi(e)),li(e,"_atlasJsonData",Oat,hi(e)),e._factory=null,li(e,"_textureAtlasData",Fat,hi(e)),e._clear(),e}Me(e,t);var i=e.prototype;return i.createNode=function(t){var e=new ur(this.name);return e.addComponent("dragonBones.ArmatureDisplay").dragonAtlasAsset=this,t(null,e)},i.init=function(t){this._factory=t,this._atlasJsonData||(this._atlasJsonData=JSON.parse(this.atlasJson));var e=this._atlasJsonData;this._uuid=this._uuid||e.name,this._textureAtlasData?t.addTextureAtlasData(this._textureAtlasData,this._uuid):this._textureAtlasData=t.parseTextureAtlasData(e,this.texture,this._uuid)},i.destroy=function(){return this._clear(),t.prototype.destroy.call(this)},i._clear=function(){this._factory&&(Eat.sharedCache.resetArmature(this._uuid),this._factory.removeTextureAtlasData(this._uuid,!0),this._factory.removeDragonBonesDataByUUID(this._uuid,!0)),this._textureAtlasData=null},Pe(e,[{key:"atlasJson",get:function(){return this._atlasJson},set:function(t){this._atlasJson=t,this._atlasJsonData=JSON.parse(this.atlasJson),this._clear()}},{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this._clear()}}]),e}(ai),Rat=oi((Pat=Lat).prototype,"_atlasJson",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Iat=oi(Pat.prototype,"_texture",[_i,Dat],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Oat=oi(Pat.prototype,"_atlasJsonData",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),Fat=oi(Pat.prototype,"_textureAtlasData",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Mat=Pat))||Mat);He.internal.DragonBonesAtlasAsset=Nat;var Gat,zat,Uat,Hat,jat,Wat,Xat,Yat,qat,Jat,Kat,Zat,Qat,$at,tot,eot,iot,rot,not,sot,aot,oot,lot,hot,uot,cot,_ot,fot,pot,dot,mot,yot,got,vot,bot,Sot,Aot,Cot,xot,Tot,wot,Eot,Bot,Dot,Mot,Pot,Rot,Iot,Oot,Fot,Lot,Vot=new Ri,kot=ri("dragonBones.AttachUtil")(kat=function(){function t(){this._inited=!1,this._armature=null,this._armatureNode=null,this._armatureDisplay=null}var e=t.prototype;return e.init=function(t){this._inited=!0,this._armature=t._armature,this._armatureNode=t.node,this._armatureDisplay=t},e.reset=function(){this._inited=!1,this._armature=null,this._armatureNode=null,this._armatureDisplay=null},e._syncAttachedNode=function(){if(this._inited){this._armatureNode.worldMatrix;var t=null,e=this._armatureDisplay.isAnimationCached();if(!e||!this._armatureDisplay||(t=this._armatureDisplay._curFrame&&this._armatureDisplay._curFrame.boneInfos))for(var i,r,n,s=this._armatureDisplay.sockets,a=this._armatureDisplay.socketNodes,o=new ii,l=this._armature.getBones(),h=s.length-1;h>=0;h--){var u=s[h],c=u.target;if(c)if(c.isValid){var _=e?t[u.boneIndex]:l[u.boneIndex];_&&(i=c,r=_.globalTransformMatrix,n=void 0,(n=Vot).m00=r.a,n.m01=r.b,n.m04=-r.c,n.m05=-r.d,n.m12=r.tx,n.m13=r.ty,i._oldScale||(i._oldScale=i.scale.clone()),o.set(i._oldScale),i.matrix=Vot,i.scale=o.multiply(this._armatureNode.scale))}else a.delete(u.path),s.splice(h,1)}}},t}())||kat;function Not(t,e,i){gs.Attr.setClassAttr(t,e,"type","Enum"),gs.Attr.setClassAttr(t,e,"enumList",yi.getList(i))}!function(t){t[t.default=-1]="default"}(Iot||(Iot={})),Pr(Iot),function(t){t[t["<None>"]=0]="<None>"}(Oot||(Oot={})),Pr(Oot),function(t){t[t.REALTIME=0]="REALTIME"}(Fot||(Fot={})),Pr(Oot),function(t){t[t.REALTIME=0]="REALTIME",t[t.SHARED_CACHE=1]="SHARED_CACHE",t[t.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(Lot||(Lot={})),Pr(Lot);var Got=(Gat=ri("dragonBones.ArmatureDisplay.DragonBoneSocket"),zat=bi(ur),Gat((jat=oi((Hat=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),li(this,"path",jat,this),li(this,"target",Wat,this),this.boneIndex=null,this.path=t,this.target=e}).prototype,"path",[_i,vi],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Wat=oi(Hat.prototype,"target",[zat,vi,_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Uat=Hat))||Uat);bs(Got,"dragonBones.ArmatureDisplay.DragonBoneSocket");var zot=(Xat=ri("dragonBones.ArmatureDisplay"),Yat=wi(),qat=Bi(),Jat=bi(Vat),Kat=Di(),Zat=bi(Nat),Qat=Di(),$at=Mi(),tot=Mi(),eot=Ir(),iot=bi(Iot),rot=Di(),not=bi(Oot),sot=Ir(),aot=Di(),oot=Ir(),lot=Di(),hot=Di(),uot=Di(),cot=Di(),_ot=Di(),fot=bi([Got]),pot=Di(),Xat(dot=Yat(dot=qat(dot=Si((Rot=Pot=function(t){function e(){var e;return e=t.call(this)||this,li(e,"playTimes",yot,hi(e)),li(e,"premultipliedAlpha",got,hi(e)),e._armature=null,e.attachUtil=void 0,li(e,"_defaultArmatureIndexValue",vot,hi(e)),li(e,"_dragonAsset",bot,hi(e)),li(e,"_dragonAtlasAsset",Sot,hi(e)),li(e,"_armatureName",Aot,hi(e)),li(e,"_animationName",Cot,hi(e)),li(e,"_animationIndexValue",xot,hi(e)),e._preCacheMode=-1,e._cacheMode=Lot.REALTIME,li(e,"_defaultCacheModeValue",Tot,hi(e)),li(e,"_timeScale",wot,hi(e)),li(e,"_playTimes",Eot,hi(e)),li(e,"_debugBones",Bot,hi(e)),e._debugDraw=null,li(e,"_enableBatch",Dot,hi(e)),e._armatureKey="",e._accTime=0,e._playCount=0,e._frameCache=null,e._curFrame=null,e._playing=!1,e._armatureCache=null,e._eventTarget=void 0,e._factory=null,e._displayProxy=null,e._meshRenderDataArray=[],e._materialCache={},e._enumArmatures=yi({}),e._enumAnimations=yi({}),e._socketNodes=new Map,e._cachedSockets=new Map,li(e,"_sockets",Mot,hi(e)),e._inited=void 0,e._meshRenderDataArrayIdx=0,e._cacheModeEnum=void 0,e._eventTarget=new os,e._inited=!1,e.attachUtil=new kot,e.initFactory(),Not(hi(e),"_animationIndex",e._enumAnimations),Not(hi(e),"_defaultArmatureIndex",e._enumArmatures),e}Me(e,t);var i=e.prototype;return i.initFactory=function(){this._factory=_at.getInstance()},i.onLoad=function(){for(var t=this.node.children,e=0,i=t.length;e<i;e++){var r=t[e];0===(r.name&&r.name.search("CHILD_ARMATURE-"))&&r.destroy()}},i.requestMeshRenderData=function(){var t=this._meshRenderDataArray;if(t.length>0&&0===t[t.length-1].renderData.vertexCount)return t[t.length-1];var e={renderData:new I_,texture:null};return t.push(e),e},i.destroyRenderData=function(){this._meshRenderDataArray&&(this._meshRenderDataArray.forEach((function(t){t.renderData.reset()})),this._meshRenderDataArray.length=0)},i.resetRenderData=function(){this._meshRenderDataArray&&this._meshRenderDataArray.forEach((function(t){t.renderData.reset()}))},i.getMaterialForBlend=function(t,e){var i=t+"/"+e,r=this._materialCache[i];if(r)return r;var n=this.getMaterial(0);return(r=new Vr({parent:n,subModelIdx:0,owner:this})).recompileShaders({USE_LOCAL:!1},0),this._materialCache[i]=r,r.overridePipelineStates({blendState:{targets:[{blendSrc:t,blendDst:e}]}}),r},i._render=function(t){if(this._meshRenderDataArray)for(var e=0;e<this._meshRenderDataArray.length;e++){var i=this.material;this._meshRenderDataArrayIdx=e;var r=this._meshRenderDataArray[e];this.material=r.renderData.material,r.texture&&t.commitComp(this,r.texture,this._assembler,null),this.material=i}},i._updateBatch=function(){this._materialCache={},this.destroyRenderData(),this.markForUpdateRenderData()},i._updateMaterial=function(){this.markForUpdateRenderData()},i.disableRender=function(){},i._validateRender=function(){var t=this.dragonAtlasAsset&&this.dragonAtlasAsset.texture;return!(!t||!t.loaded)||(this.disableRender(),!1)},i.__preload=function(){t.prototype.__preload.call(this),this._init()},i._init=function(){if(this._cacheMode=this._defaultCacheMode,!this._inited){this._inited=!0,this._parseDragonAtlasAsset(),this._refresh();for(var t=this.node.children,e=0,i=t.length;e<i;e++){var r=t[e];r&&"DEBUG_DRAW_NODE"===r.name&&r.destroy()}this._updateDebugDraw(),this._indexBoneSockets(),this._updateSocketBindings()}},i.getArmatureKey=function(){return this._armatureKey},i.setAnimationCacheMode=function(t){this._preCacheMode!==t&&(this._cacheMode=t,this._buildArmature(),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.add(this._armature),this._updateSocketBindings(),this.markForUpdateRenderData())},i.isAnimationCached=function(){return this._cacheMode!==Lot.REALTIME},i.onEnable=function(){t.prototype.onEnable.call(this),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.add(this._armature),this._flushAssembler()},i.onDisable=function(){t.prototype.onDisable.call(this),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.remove(this._armature)},i._emitCacheCompleteEvent=function(){this._eventTarget.emit(Xst.LOOP_COMPLETE),this._eventTarget.emit(Xst.COMPLETE)},i.update=function(t){if(this.isAnimationCached()&&this._frameCache){this.markForUpdateRenderData();var e=this._frameCache;if(e.isInited()){var i=e.frames;if(this._playing){var r=Eat.FrameTime;0===this._accTime&&0===this._playCount&&this._eventTarget.emit(Xst.START),this._accTime+=t*this.timeScale*1;var n=Math.floor(this._accTime/r);if(e.isCompleted||e.updateToFrame(n),e.isCompleted&&n>=i.length){if(this._playCount++,this.playTimes>0&&this._playCount>=this.playTimes)return this._curFrame=i[i.length-1],this._accTime=0,this._playing=!1,this._playCount=0,this._emitCacheCompleteEvent(),void this.attachUtil._syncAttachedNode();this._accTime=0,n=0,this._emitCacheCompleteEvent()}this._curFrame=i[n],this.attachUtil._syncAttachedNode()}else e.isInvalid()&&(e.updateToFrame(),this._curFrame=i[i.length-1])}}},i.onDestroy=function(){this._materialInstances=this._materialInstances.filter((function(t){return!!t})),t.prototype.onDestroy.call(this),this._inited=!1,this._cacheMode===Lot.PRIVATE_CACHE?(this._armatureCache.dispose(),this._armatureCache=null,this._armature=null):this._cacheMode===Lot.SHARED_CACHE?(this._armatureCache=null,this._armature=null):this._armature&&(this._armature.dispose(),this._armature=null),this.destroyRenderData()},i._updateDebugDraw=function(){if(this.debugBones){if(!this._debugDraw){var t=new ur("DEBUG_DRAW_NODE");t.hideFlags|=Lr.Flags.DontSave|Lr.Flags.HideInHierarchy;var e=t.addComponent(Hd);e.lineWidth=1,e.strokeColor=new Ui(255,0,0,255),this._debugDraw=e}this._debugDraw.node.parent=this.node}else this._debugDraw&&(this._debugDraw.node.parent=null);this.destroyRenderData(),this.markForUpdateRenderData()},i._buildArmature=function(){if(this.dragonAsset&&this.dragonAtlasAsset&&this.armatureName){this._armature&&(this._preCacheMode===Lot.PRIVATE_CACHE?this._armatureCache.dispose():this._preCacheMode===Lot.REALTIME&&this._armature.dispose(),this._armatureCache=null,this._armature=null,this._displayProxy=null,this._frameCache=null,this._curFrame=null,this._playing=!1,this._preCacheMode=-1),this._cacheMode===Lot.SHARED_CACHE?this._armatureCache=Eat.sharedCache:this._cacheMode===Lot.PRIVATE_CACHE&&(this._armatureCache=new Eat,this._armatureCache.enablePrivateMode());var t=this.dragonAtlasAsset._uuid;if(this._armatureKey=this.dragonAsset.init(this._factory,t),this.isAnimationCached()&&(this._armature=this._armatureCache.getArmatureCache(this.armatureName,this._armatureKey,t),this._armature||(this._cacheMode=Lot.REALTIME)),this._preCacheMode=this._cacheMode,this._cacheMode===Lot.REALTIME){if(this._displayProxy=this._factory.buildArmatureDisplay(this.armatureName,this._armatureKey,"",t),!this._displayProxy)return;this._displayProxy._ccNode=this.node,this._displayProxy._ccComponent=this,this._displayProxy.setEventTarget(this._eventTarget),this._armature=this._displayProxy._armature,this._armature.animation.timeScale=this.timeScale}if(this._cacheMode!==Lot.REALTIME&&this.debugBones&&console.warn("Debug bones is invalid in cached mode"),this._armature){var e=this._armature.armatureData.aabb;this.node._uiProps.uiTransformComp.setContentSize(e.width,e.height)}this._updateBatch(),this.attachUtil.init(this),this.animationName&&this.playAnimation(this.animationName,this.playTimes),this.destroyRenderData(),this.markForUpdateRenderData()}},i.querySockets=function(){return this._armature?(0===this._cachedSockets.size&&this._indexBoneSockets(),Array.from(this._cachedSockets.keys()).sort()):[]},i.setBlendHash=function(){-1!==this._blendHash&&(this._blendHash=-1)},i.querySocketPathByName=function(t){for(var e,i=[],r=Fe(this._cachedSockets.keys());!(e=r()).done;){var n=e.value;n.endsWith(t)&&i.push(n)}return i},i._parseDragonAtlasAsset=function(){this.dragonAtlasAsset&&this.dragonAtlasAsset.init(this._factory)},i._refresh=function(){this._buildArmature(),this.markForUpdateRenderData()},i._updateCacheModeEnum=function(){this._cacheModeEnum=yi({}),this._armature?Object.assign(this._cacheModeEnum,Lot):Object.assign(this._cacheModeEnum,Fot),Not(this,"_defaultCacheMode",this._cacheModeEnum)},i._updateAnimEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getAnimsEnum(this.armatureName):Oot,this._enumAnimations=yi({}),Object.assign(this._enumAnimations,t||Oot),yi.update(this._enumAnimations),Not(this,"_animationIndex",this._enumAnimations)},i._updateArmatureEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getArmatureEnum():Iot,this._enumArmatures=yi({}),Object.assign(this._enumArmatures,t||Iot),yi.update(this._enumArmatures),Not(this,"_defaultArmatureIndex",this._enumArmatures)},i._indexBoneSockets=function(){if(this._armature){this._cachedSockets.clear();var t=this._cachedSockets,e=function t(e,i,r){if(r.has(e))return r.get(e);var n=i[e];if(!n.parent)return r.set(e,n.name),n.path=n.name,n.name;var s=t(n.parent._boneIndex,i,r)+"/"+n.name;return r.set(e,s),n.path=s,s};!function i(r,n){for(var s=n.getBones(),a=new Map,o=0;o<s.length;o++)s[o]._boneIndex=o;for(var l=0;l<s.length;l++)e(l,s,a);for(var h,u=Fe(a.keys());!(h=u()).done;){var c=h.value;t.set(""+r+a.get(c),c)}for(var _=n.getSlots(),f=0;f<_.length;f++)_[f].childArmature&&i(_[f].name,_[f].childArmature)}("",this._armature)}},i.playAnimation=function(t,e){if(this.playTimes=void 0===e?-1:e,this.animationName=t,this.isAnimationCached()){var i=this._armatureCache.getAnimationCache(this._armatureKey,t);i||(i=this._armatureCache.initAnimationCache(this._armatureKey,t)),i&&(this._accTime=0,this._playCount=0,this._frameCache=i,this._sockets.length>0&&this._frameCache.enableCacheAttachedInfo(),this._frameCache.updateToFrame(0),this._playing=!0,this._curFrame=this._frameCache.frames[0])}else if(this._armature)return this._armature.animation.play(t,this.playTimes);return this.markForUpdateRenderData(),null},i.updateAnimationCache=function(t){this.isAnimationCached()&&this._armatureCache.updateAnimationCache(this._armatureKey,t)},i.invalidAnimationCache=function(){this.isAnimationCached()&&this._armatureCache.invalidAnimationCache(this._armatureKey)},i.getArmatureNames=function(){var t=this._factory.getDragonBonesData(this._armatureKey);return t&&t.armatureNames||[]},i.getAnimationNames=function(t){var e=[],i=this._factory.getDragonBonesData(this._armatureKey);if(i){var r=i.getArmature(t);if(r)for(var n in r.animations)r.animations.hasOwnProperty(n)&&e.push(n)}return e},i.on=function(t,e,i){this.addEventListener(t,e,i)},i.off=function(t,e,i){this.removeEventListener(t,e,i)},i.once=function(t,e,i){this._eventTarget.once(t,e,i)},i.addEventListener=function(t,e,i){this._eventTarget.on(t,e,i)},i.removeEventListener=function(t,e,i){this._eventTarget.off(t,e,i)},i.buildArmature=function(t,e){return this._factory.createArmatureNode(this,t,e)},i.armature=function(){return this._armature},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),0===this._meshRenderDataArray.length&&this._assembler&&this._assembler.createData&&(this._assembler.createData(this),this.markForUpdateRenderData(),this._updateColor())},i._updateSocketBindings=function(){if(this._armature){this._socketNodes.clear();for(var t=0,e=this._sockets.length;t<e;t++){var i=this._sockets[t];if(i.path&&i.target){var r=this._cachedSockets.get(i.path);if(!r){console.error("Skeleton data does not contain path "+i.path);continue}i.boneIndex=r,this._socketNodes.set(i.path,i.target)}}}},i._verifySockets=function(t){for(var e=0,i=t.length;e<i;e++){var r=t[e].target;!r||r.parent&&r.parent===this.node||console.error("Target node "+r.name+" is expected to be a direct child of "+this.node.name)}},Pe(e,[{key:"dragonAsset",get:function(){return this._dragonAsset},set:function(t){this._dragonAsset=t,this._refresh()}},{key:"dragonAtlasAsset",get:function(){return this._dragonAtlasAsset},set:function(t){this._dragonAtlasAsset=t,this._parseDragonAtlasAsset(),this._refresh()}},{key:"armatureName",get:function(){return this._armatureName},set:function(t){this._armatureName=t;var e=this.getAnimationNames(this._armatureName);(!this.animationName||e.indexOf(this.animationName)<0)&&(this.animationName=""),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.remove(this._armature),this._refresh(),this._armature&&!this.isAnimationCached()&&this._factory._dragonBones.clock.add(this._armature)}},{key:"animationName",get:function(){return this._animationName},set:function(t){this._animationName=t}},{key:"_defaultArmatureIndex",get:function(){return this._defaultArmatureIndexValue},set:function(t){this._defaultArmatureIndexValue=t;var e="";if(this.dragonAsset){var i;if(this.dragonAsset&&(i=this.dragonAsset.getArmatureEnum()),!i)return void Re(7400,this.name);e=i[this._defaultArmatureIndex]}void 0!==e?this.armatureName=e:Re(7401,this.name),this.resetRenderData(),this.markForUpdateRenderData()}},{key:"_animationIndex",get:function(){return this._animationIndexValue},set:function(t){var e;if(this._animationIndexValue=t,0!==this._animationIndex){if(this.dragonAsset&&(e=this.dragonAsset.getAnimsEnum(this.armatureName)),e){var i=e[this._animationIndex];void 0!==i?this.playAnimation(i,this.playTimes):Re(7402,this.name)}}else this.animationName=""}},{key:"_defaultCacheMode",get:function(){return this._defaultCacheModeValue},set:function(t){if(this._defaultCacheModeValue=t,this._defaultCacheMode!==Lot.REALTIME&&this._armature&&!Eat.canCache(this._armature))return this._defaultCacheMode=Lot.REALTIME,void console.warn("Animation cache mode doesn't support skeletal nesting");this.setAnimationCacheMode(this._defaultCacheMode)}},{key:"timeScale",get:function(){return this._timeScale},set:function(t){this._timeScale=t,this._armature&&!this.isAnimationCached()&&(this._armature.animation.timeScale=this.timeScale)}},{key:"debugBones",get:function(){return this._debugBones},set:function(t){this._debugBones=t,this._updateDebugDraw()}},{key:"sockets",get:function(){return this._sockets},set:function(t){this._verifySockets(t),this._sockets=t,this._updateSocketBindings(),t.length>0&&this._frameCache&&this._frameCache.enableCacheAttachedInfo()}},{key:"socketNodes",get:function(){return this._socketNodes}},{key:"meshRenderDataArray",get:function(){return this._meshRenderDataArray}}]),e}(Ap),Pot.AnimationCacheMode=Lot,oi((mot=Rot).prototype,"dragonAsset",[vi,Jat,Kat],Object.getOwnPropertyDescriptor(mot.prototype,"dragonAsset"),mot.prototype),oi(mot.prototype,"dragonAtlasAsset",[vi,Zat,Qat],Object.getOwnPropertyDescriptor(mot.prototype,"dragonAtlasAsset"),mot.prototype),oi(mot.prototype,"armatureName",[$at],Object.getOwnPropertyDescriptor(mot.prototype,"armatureName"),mot.prototype),oi(mot.prototype,"animationName",[tot],Object.getOwnPropertyDescriptor(mot.prototype,"animationName"),mot.prototype),oi(mot.prototype,"_defaultArmatureIndex",[eot,vi,iot,rot],Object.getOwnPropertyDescriptor(mot.prototype,"_defaultArmatureIndex"),mot.prototype),oi(mot.prototype,"_animationIndex",[vi,not,sot,aot],Object.getOwnPropertyDescriptor(mot.prototype,"_animationIndex"),mot.prototype),oi(mot.prototype,"_defaultCacheMode",[vi,oot,lot],Object.getOwnPropertyDescriptor(mot.prototype,"_defaultCacheMode"),mot.prototype),oi(mot.prototype,"timeScale",[vi,hot,_i],Object.getOwnPropertyDescriptor(mot.prototype,"timeScale"),mot.prototype),yot=oi(mot.prototype,"playTimes",[uot,vi,_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),got=oi(mot.prototype,"premultipliedAlpha",[_i,vi,cot],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),oi(mot.prototype,"debugBones",[_ot,vi],Object.getOwnPropertyDescriptor(mot.prototype,"debugBones"),mot.prototype),oi(mot.prototype,"sockets",[fot,pot],Object.getOwnPropertyDescriptor(mot.prototype,"sockets"),mot.prototype),vot=oi(mot.prototype,"_defaultArmatureIndexValue",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Iot.default}}),bot=oi(mot.prototype,"_dragonAsset",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Sot=oi(mot.prototype,"_dragonAtlasAsset",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Aot=oi(mot.prototype,"_armatureName",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Cot=oi(mot.prototype,"_animationName",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),xot=oi(mot.prototype,"_animationIndexValue",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Tot=oi(mot.prototype,"_defaultCacheModeValue",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Lot.REALTIME}}),wot=oi(mot.prototype,"_timeScale",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Eot=oi(mot.prototype,"_playTimes",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Bot=oi(mot.prototype,"_debugBones",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Dot=oi(mot.prototype,"_enableBatch",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Mot=oi(mot.prototype,"_sockets",[_i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),dot=mot))||dot)||dot)||dot)||dot);He.internal.ArmatureDisplay=zot;var Uot,Hot,jot,Wot,Xot,Yot,qot,Jot,Kot,Zot,Qot,$ot,tlt,elt,ilt,rlt,nlt,slt,alt,olt,llt,hlt,ult,clt=new Ui(255,0,0,255),_lt=new Ui(0,0,255,255),flt=new Ui(0,255,0,255),plt=new Float32Array(4),dlt=new ii;function mlt(t,e){if(!t)return null;var i,r;switch(e){case 1:i=Xot?E.ONE:E.SRC_ALPHA,r=E.ONE;break;case 10:i=E.DST_COLOR,r=E.ONE_MINUS_SRC_ALPHA;break;case 12:i=E.ONE,r=E.ONE_MINUS_SRC_COLOR;break;case 0:default:i=Xot?E.ONE:E.SRC_ALPHA,r=E.ONE_MINUS_SRC_ALPHA}return Kot.setBlendHash(),Kot.getMaterialForBlend(i,r)}function ylt(t,e){var i=t.a*e*Wot,r=Xot?i/255:1,n=t.r*Uot*r/255,s=t.g*Hot*r/255,a=t.b*jot*r/255;plt[0]=n,plt[1]=s,plt[2]=a,plt[3]=Xot?1:i/255}function glt(t){plt[0]=(255&t>>>24)/255,plt[1]=(255&t>>>16)/255,plt[2]=(255&t>>>8)/255,plt[3]=(255&t>>>0)/255}var vlt={createData:function(){},updateRenderData:function(t){Kot=t,function(t){var e=t._armature;if(e){t.markForUpdateRenderData(),t.destroyRenderData(),Yot=!0,Xot=t.premultipliedAlpha,Jot=t.node,qot=t.requestMeshRenderData(),Kot=t,nlt=0;var i,r=t.color;if(Uot=r.r/255,Hot=r.g/255,jot=r.b/255,Wot=r.a/255,4294967295!==r._val&&(nlt|=1),Kot._enableBatch&&(i=Jot.worldMatrix,Yot=!1,nlt|=16),t.isAnimationCached())!function(t,e){if(t){var i,r,n,s=t.segments;if(0!==s.length){var a=t.vertices,o=new Uint32Array(a.buffer),l=t.indices,h=0,u=0,c=0;e&&(slt=e.m00,llt=e.m01,alt=e.m04,hlt=e.m05,olt=e.m12,ult=e.m13);var _=16&nlt,f=_&&(1===slt&&0===llt&&0===alt&&1===hlt),p=0,d=t.colors,m=d[p++],y=m.vfOffset;ylt(m,1);for(var g=0,v=s.length;g<v;g++){var b=s[g];n=mlt(b.tex,b.blendMode),qot.renderData.material||(qot.renderData.material=n),qot.texture||(qot.texture=b.tex),(Yot||qot.renderData.material!==n||qot.texture!==b.tex)&&(Yot=!1,(qot=Kot.requestMeshRenderData()).renderData.material=n,qot.texture=b.tex),tlt=b.vertexCount,elt=b.indexCount;var S=qot.renderData;S.reserve(tlt,elt),Qot=S.indicesCount,Zot=S.vDataOffset,$ot=S.vertexCount,i=qot.renderData.vData,r=qot.renderData.iData;for(var A=Qot,C=Qot+elt;A<C;A++)r[A]=$ot+l[u++];c=b.vfCount;for(var x=h,T=Zot;x<h+c;)i[T]=a[x++],i[T+1]=a[x++],i[T+3]=a[x++],i[T+4]=a[x++],glt(o[x++]),i.set(plt,T+5),T+=9;if(h+=c,f)for(var w=Zot,E=Zot+c;w<E;w+=9)i[w]+=olt,i[w+1]+=ult;else if(_)for(var B=Zot,D=Zot+c;B<D;B+=9)ilt=i[B],rlt=i[B+1],i[B]=ilt*slt+rlt*alt+olt,i[B+1]=ilt*llt+rlt*hlt+ult;if(qot.renderData.advance(tlt,elt),1&nlt)for(var M=h-c,P=Zot+5,R=Zot+4+c;P<R;P+=9,M+=9)M>=y&&(ylt(m=d[p++],1),y=m.vfOffset),i.set(plt,P)}}}}(t._curFrame,i);else{blt(e,i,1);var n=t._debugDraw;if(t.debugBones&&n){n.clear(),n.lineWidth=5,n.strokeColor=clt,n.fillColor=_lt;for(var s=e.getBones(),a=0,o=s.length;a<o;a++){var l=s[a],h=Math.max(l.boneData.length,5),u=l.globalTransformMatrix.tx,c=l.globalTransformMatrix.ty,_=u+l.globalTransformMatrix.a*h,f=c+l.globalTransformMatrix.b*h;n.moveTo(u,c),n.lineTo(_,f),n.stroke(),n.circle(u,c,2*Math.PI),n.fill(),0===a&&(n.fillColor=flt)}}}t.attachUtil._syncAttachedNode(),Jot=void 0,qot=void 0,Kot=void 0}}(t)},updateColor:function(){},fillBuffers:function(t,e){if(t&&0!==t.meshRenderDataArray.length){var i=t.meshRenderDataArray,r=t.node,n=e.acquireBufferBatch(),s=n.byteOffset>>2,a=n.indicesOffset,o=n.vertexOffset,l=i[t._meshRenderDataArrayIdx].renderData;n.request(l.vertexCount,l.indicesCount)||(n=e.currBufferBatch,s=0,a=0,o=0);var h=n.vData,u=n.iData,c=r.worldMatrix,_=l.vData,f=l.vertexStart,p=l.iData;if(h.set(_.slice(f,f+9*l.vertexCount),s),!t._enableBatch)for(var d=0;d<l.vertexCount;d++){var m=s+9*d;dlt.set(h[m],h[m+1],h[m+2]),dlt.transformMat4(c),h[m]=dlt.x,h[m+1]=dlt.y,h[m+2]=dlt.z}for(var y=l.indicesStart,g=0;g<l.indicesCount;g+=1)u[g+a]=p[g+y]+o}}};function blt(t,e,i){for(var r,n,s,a,o,l,h,u=t._slots,c=new Ri,_=0,f=u.length;_<f;_++)if(l=(h=u[_])._color,h._visible&&h._displayData)if(e?h._mulMat(h._worldMatrix,e,h._matrix):Ri.copy(h._worldMatrix,h._matrix),h.childArmature)blt(h.childArmature,h._worldMatrix,i*l.a/255);else if(s=mlt(h.getTexture(),h._blendMode)){qot.renderData.material||(qot.renderData.material=s),qot.texture||(qot.texture=h.getTexture()),(Yot||s!==qot.renderData.material||qot.texture!==h.getTexture())&&(Yot=!1,(qot=Kot.requestMeshRenderData()).renderData.material=s,qot.texture=h.getTexture()),ylt(l,i),c.set(h._worldMatrix),a=h._localVertices,tlt=a.length>>2,o=h._indices,elt=o.length;var p=qot.renderData;p.reserve(tlt,elt),Qot=p.indicesCount,Zot=p.vDataOffset,$ot=p.vertexCount,r=qot.renderData.vData,n=qot.renderData.iData,slt=c.m00,alt=c.m04,olt=c.m12,llt=c.m01,hlt=c.m05,ult=c.m13;for(var d=0,m=a.length;d<m;)ilt=a[d++],rlt=a[d++],r[Zot]=ilt*slt+rlt*alt+olt,r[Zot+1]=ilt*llt+rlt*hlt+ult,r[Zot+3]=a[d++],r[Zot+4]=a[d++],r.set(plt,Zot+5),Zot+=9;for(var y=0,g=o.length;y<g;y++)n[Qot++]=$ot+o[y];qot.renderData.advance(tlt,elt)}}He.internal.DragonBonesAssembler=vlt;var Slt,Alt,Clt,xlt={getAssembler:function(){return vlt}};zot.Assembler=xlt,function(t){t[t.FFD=0]="FFD",t[t.AdjustColor=10]="AdjustColor",t[t.BevelFilter=11]="BevelFilter",t[t.BlurFilter=12]="BlurFilter",t[t.DropShadowFilter=13]="DropShadowFilter",t[t.GlowFilter=14]="GlowFilter",t[t.GradientBevelFilter=15]="GradientBevelFilter",t[t.GradientGlowFilter=16]="GradientGlowFilter"}(Slt||(Slt={})),function(t){t[t.Frame=0]="Frame",t[t.Sound=1]="Sound"}(Alt||(Alt={})),function(t){t[t.None=0]="None",t[t.SameLayer=1]="SameLayer",t[t.SameGroup=2]="SameGroup",t[t.SameLayerAndGroup=3]="SameLayerAndGroup",t[t.All=4]="All"}(Clt||(Clt={})),t("dragonBones",Object.freeze({__proto__:null,get ExtensionType(){return Slt},get EventType(){return Alt},get AnimationFadeOutMode(){return Clt},CCFactory:_at,CCSlot:uat,CCTextureAtlasData:lat,CCTextureData:hat,CCArmatureDisplay:cat,AnimationCache:wat,ArmatureCache:Eat,DragonBonesAsset:Vat,DragonBonesAtlasAsset:Nat,timeScale:1,get AnimationCacheMode(){return Lot},DragonBoneSocket:Got,ArmatureDisplay:zot,AttachUtil:kot,simpleDragonBoneAssembler:xlt,DragonBones:Int,BaseObject:Ont,Matrix:Fnt,Transform:Lnt,ColorTransform:Vnt,Point:knt,Rectangle:Nnt,UserData:Gnt,ActionData:znt,DragonBonesData:Unt,ArmatureData:Hnt,BoneData:jnt,SurfaceData:Wnt,SlotData:Xnt,ConstraintData:Ynt,IKConstraintData:qnt,PathConstraintData:Jnt,CanvasData:Knt,SkinData:Znt,VerticesData:Qnt,DisplayData:$nt,ImageDisplayData:tst,ArmatureDisplayData:est,MeshDisplayData:ist,BoundingBoxDisplayData:rst,PathDisplayData:nst,WeightData:sst,BoundingBoxData:ast,RectangleBoundingBoxData:ost,EllipseBoundingBoxData:lst,PolygonBoundingBoxData:hst,AnimationData:ust,TimelineData:cst,AnimationConfig:_st,TextureAtlasData:fst,TextureData:pst,DeformVertices:dst,Armature:mst,TransformObject:yst,Bone:gst,Surface:vst,Slot:bst,Constraint:Sst,IKConstraint:Ast,PathConstraint:Cst,WorldClock:xst,Animation:Tst,AnimationState:wst,BonePose:Est,BlendState:Bst,TimelineState:Dst,TweenTimelineState:Mst,BoneTimelineState:Pst,SlotTimelineState:Rst,ConstraintTimelineState:Ist,ActionTimelineState:Ost,ZOrderTimelineState:Fst,BoneAllTimelineState:Lst,BoneTranslateTimelineState:Vst,BoneRotateTimelineState:kst,BoneScaleTimelineState:Nst,SurfaceTimelineState:Gst,SlotDislayTimelineState:zst,SlotColorTimelineState:Ust,DeformTimelineState:Hst,IKConstraintTimelineState:jst,AnimationTimelineState:Wst,EventObject:Xst,DataParser:Yst,ObjectDataParser:qst,ActionFrame:Jst,BinaryDataParser:Kst,BaseFactory:Zst,BuildArmaturePackage:Qst,BinaryOffset:$st,ArmatureType:tat,BoneType:eat,DisplayType:iat,BoundingBoxType:rat,ActionType:nat,BlendMode:sat,TweenType:aat,TimelineType:oat}))}}}));
|